================
@@ -986,6 +987,54 @@ def test_binop(self):
c = get_cursor(tu, op)
assert c.binary_operator == typ
+ def test_unaryop(self):
+ tu = get_tu(
+ """
+ void func(void) {
+ int a = 0;
+ a++;
+ ++a;
+ a--;
+ --a;
+ *(&a);
+ +a;
+ -a;
+ !a;
+ ~a;
+ float _Complex b;
+ __real b;
+ __imag b;
+ __extension__ a;
+ }""",
+ lang="cpp",
+ )
+
+ operators = {
+ "&": UnaryOperator.AddrOf,
+ "*": UnaryOperator.Deref,
+ "+": UnaryOperator.Plus,
+ "-": UnaryOperator.Minus,
+ "~": UnaryOperator.Not,
+ "!": UnaryOperator.LNot,
+ "__real": UnaryOperator.Real,
+ "__imag": UnaryOperator.Imag,
+ "__extension__": UnaryOperator.Extension,
+ }
+
+ for op, typ in operators.items():
+ c = get_cursor(tu, op)
+ assert c.unary_operator == typ
+
+ shoulds = (
+ UnaryOperator.PostInc,
+ UnaryOperator.PreInc,
+ UnaryOperator.PostDec,
+ UnaryOperator.PreDec,
+ )
+ haves = list(next(tu.cursor.get_children()).get_children())[1:]
----------------
ItsRumo wrote:
Good point. I changed it to disambiguate the pre- and postfix operators using
separate functions in the TU.
https://github.com/llvm/llvm-project/pull/219983
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits