diff options
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/Syntax/TreeTest.cpp | 72 |
1 files changed, 49 insertions, 23 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index a7de4b9..0592d8f 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -705,20 +705,16 @@ void test(int a) { } TEST_P(SyntaxTreeTest, PrefixUnaryOperator) { - if (!GetParam().isCXX()) { - // TODO: Split parts that depend on C++ into a separate test. - return; - } expectTreeDumpEqual( R"cpp( -void test(int a, int *ap, bool b) { +void test(int a, int *ap) { --a; ++a; - ~a; compl a; + ~a; -a; +a; &a; *ap; - !b; not b; + !a; __real a; __imag a; } )cpp", @@ -740,11 +736,6 @@ void test(int a, int *ap, bool b) { | | `-SimpleDeclarator | | |-* | | `-ap - | |-, - | |-SimpleDeclaration - | | |-bool - | | `-SimpleDeclarator - | | `-b | `-) `-CompoundStatement |-{ @@ -768,12 +759,6 @@ void test(int a, int *ap, bool b) { | `-; |-ExpressionStatement | |-PrefixUnaryOperatorExpression - | | |-compl - | | `-UnknownExpression - | | `-a - | `-; - |-ExpressionStatement - | |-PrefixUnaryOperatorExpression | | |-- | | `-UnknownExpression | | `-a @@ -800,26 +785,67 @@ void test(int a, int *ap, bool b) { | |-PrefixUnaryOperatorExpression | | |-! | | `-UnknownExpression - | | `-b + | | `-a | `-; |-ExpressionStatement | |-PrefixUnaryOperatorExpression - | | |-not + | | |-__real | | `-UnknownExpression - | | `-b + | | `-a | `-; |-ExpressionStatement | |-PrefixUnaryOperatorExpression - | | |-__real + | | |-__imag | | `-UnknownExpression | | `-a | `-; + `-} +)txt"); +} + +TEST_P(SyntaxTreeTest, PrefixUnaryOperatorCxx) { + if (!GetParam().isCXX()) { + return; + } + expectTreeDumpEqual( + R"cpp( +void test(int a, bool b) { + compl a; + not b; +} + )cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-int + | | `-SimpleDeclarator + | | `-a + | |-, + | |-SimpleDeclaration + | | |-bool + | | `-SimpleDeclarator + | | `-b + | `-) + `-CompoundStatement + |-{ |-ExpressionStatement | |-PrefixUnaryOperatorExpression - | | |-__imag + | | |-compl | | `-UnknownExpression | | `-a | `-; + |-ExpressionStatement + | |-PrefixUnaryOperatorExpression + | | |-not + | | `-UnknownExpression + | | `-b + | `-; `-} )txt"); } |