hokein created this revision. hokein added a reviewer: kbobyrev. hokein requested review of this revision. Herald added a project: clang.
OpaqueValueExpr doesn't correspond to the concrete syntax, it has invalid source location, ignore them. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D96112 Files: clang/lib/Tooling/Syntax/BuildTree.cpp clang/unittests/Tooling/Syntax/BuildTreeTest.cpp Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp =================================================================== --- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp +++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp @@ -503,6 +503,25 @@ )txt")); } +TEST_P(BuildSyntaxTreeTest, ConditionalOperator) { + // FIXME: conditional expression is not modeled yet. + EXPECT_TRUE(treeDumpEqualOnAnnotations( + R"cpp( +void test() { + [[1?:2]]; +} +)cpp", + {R"txt( +UnknownExpression Expression +|-IntegerLiteralExpression +| `-'1' LiteralToken +|-'?' +|-':' +`-IntegerLiteralExpression + `-'2' LiteralToken +)txt"})); +} + TEST_P(BuildSyntaxTreeTest, UnqualifiedId_Identifier) { EXPECT_TRUE(treeDumpEqualOnAnnotations( R"cpp( Index: clang/lib/Tooling/Syntax/BuildTree.cpp =================================================================== --- clang/lib/Tooling/Syntax/BuildTree.cpp +++ clang/lib/Tooling/Syntax/BuildTree.cpp @@ -855,6 +855,11 @@ return RecursiveASTVisitor::TraverseStmt(S); } + bool TraverseOpaqueValueExpr(OpaqueValueExpr *VE) { + // OpaqueValue doesn't correspond to concrete syntax, ignore it. + return true; + } + // Some expressions are not yet handled by syntax trees. bool WalkUpFromExpr(Expr *E) { assert(!isImplicitExpr(E) && "should be handled by TraverseStmt");
Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp =================================================================== --- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp +++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp @@ -503,6 +503,25 @@ )txt")); } +TEST_P(BuildSyntaxTreeTest, ConditionalOperator) { + // FIXME: conditional expression is not modeled yet. + EXPECT_TRUE(treeDumpEqualOnAnnotations( + R"cpp( +void test() { + [[1?:2]]; +} +)cpp", + {R"txt( +UnknownExpression Expression +|-IntegerLiteralExpression +| `-'1' LiteralToken +|-'?' +|-':' +`-IntegerLiteralExpression + `-'2' LiteralToken +)txt"})); +} + TEST_P(BuildSyntaxTreeTest, UnqualifiedId_Identifier) { EXPECT_TRUE(treeDumpEqualOnAnnotations( R"cpp( Index: clang/lib/Tooling/Syntax/BuildTree.cpp =================================================================== --- clang/lib/Tooling/Syntax/BuildTree.cpp +++ clang/lib/Tooling/Syntax/BuildTree.cpp @@ -855,6 +855,11 @@ return RecursiveASTVisitor::TraverseStmt(S); } + bool TraverseOpaqueValueExpr(OpaqueValueExpr *VE) { + // OpaqueValue doesn't correspond to concrete syntax, ignore it. + return true; + } + // Some expressions are not yet handled by syntax trees. bool WalkUpFromExpr(Expr *E) { assert(!isImplicitExpr(E) && "should be handled by TraverseStmt");
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits