diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2020-06-03 10:50:57 +0200 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2020-06-03 10:58:12 +0200 |
commit | b34b7691facd89022e7fee174debdbd2bf7920f3 (patch) | |
tree | a9f209dd34cd8f9203f1664f19dfc00cc639ea03 /clang/unittests/Tooling/Syntax/TreeTest.cpp | |
parent | 7c7941fb4bd884ee7dce96fdfdf657c0fdb608dd (diff) | |
download | llvm-b34b7691facd89022e7fee174debdbd2bf7920f3.zip llvm-b34b7691facd89022e7fee174debdbd2bf7920f3.tar.gz llvm-b34b7691facd89022e7fee174debdbd2bf7920f3.tar.bz2 |
Syntax tree: ignore implicit expressions at the top level of statements
Summary:
I changed `markStmtChild` to ignore implicit expressions the same way as
`markExprChild` does it already. The test that I modified crashes
without this change.
Reviewers: hlopko, eduucaldas
Reviewed By: hlopko, eduucaldas
Subscribers: gribozavr2, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D81019
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"); } |