[PATCH] D81168: Add support for id-expression in SyntaxTree
gribozavr2 added inline comments. Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:815 +| | `-UnknownExpression +| | `-s +| `-; This part does not seem to appear in the source. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81168/new/ https://reviews.llvm.org/D81168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D81168: Add support for id-expression in SyntaxTree
eduucaldas added inline comments. Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829 +| | | | | `-:: +| | | | `-TypeSpecifier +| | | | |-S eduucaldas wrote: > Perhaps we shouldn't differ between specifiers as that is semantical > information Followed the [[ https://eel.is/c++draft/expr.prim.id.qual | grammar ]], but added specifier in the end as we also hold the `::` and not only the names Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81168/new/ https://reviews.llvm.org/D81168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D81168: Add support for id-expression in SyntaxTree
eduucaldas updated this revision to Diff 268503. eduucaldas marked an inline comment as done. eduucaldas added a comment. . Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81168/new/ https://reviews.llvm.org/D81168 Files: clang/unittests/Tooling/Syntax/TreeTest.cpp Index: clang/unittests/Tooling/Syntax/TreeTest.cpp === --- clang/unittests/Tooling/Syntax/TreeTest.cpp +++ clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -692,6 +692,152 @@ )txt")); } +TEST_P(SyntaxTreeTest, UnqualifiedId) { + if (!GetParam().isCXX()) { +return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +void test(int b) { + int a; + a = b; +} +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-int + | | `-SimpleDeclarator + | | `-b + | `-) + `-CompoundStatement +|-{ +|-DeclarationStatement +| |-SimpleDeclaration +| | |-int +| | `-SimpleDeclarator +| | `-a +| `-; +|-ExpressionStatement +| |-BinaryOperatorExpression +| | |-IdExpression +| | | `-UnqualifiedId +| | | `-a +| | |-= +| | `-IdExpression +| | `-UnqualifiedId +| | `-b +| `-; +`-} +)txt")); +} + +TEST_P(SyntaxTreeTest, QualifiedId) { + if (!GetParam().isCXX()) { +return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +namespace a { + namespace b { +struct S { + int i; + static void f(){} +}; + } +} +void test(int b) { + ::a::b::S::f(); +} +)cpp", + R"txt( +*: TranslationUnit +|-NamespaceDefinition +| |-namespace +| |-a +| |-{ +| |-NamespaceDefinition +| | |-namespace +| | |-b +| | |-{ +| | |-SimpleDeclaration +| | | |-struct +| | | |-S +| | | |-{ +| | | |-SimpleDeclaration +| | | | |-int +| | | | |-SimpleDeclarator +| | | | | `-i +| | | | `-; +| | | |-SimpleDeclaration +| | | | |-static +| | | | |-void +| | | | |-SimpleDeclarator +| | | | | |-f +| | | | | `-ParametersAndQualifiers +| | | | | |-( +| | | | | `-) +| | | | `-CompoundStatement +| | | | |-{ +| | | | `-} +| | | |-} +| | | `-; +| | `-} +| `-} +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-int + | | `-SimpleDeclarator + | | `-b + | `-) + `-CompoundStatement +|-{ +|-DeclarationStatement +| |-SimpleDeclaration +| | |-a +| | |-:: +| | |-b +| | |-:: +| | |-S +| | `-SimpleDeclarator +| | `-UnknownExpression +| | `-s +| `-; +|-ExpressionStatement +| |-UnknownExpression +| | |-IdExpression +| | | |-NestedNameSpecifier +| | | | |-GlobalNamespaceSpecifier +| | | | | `:: +| | | | |-NamespaceNameSpecifier +| | | | | |-a +| | | | | `-:: +| | | | |-NamespaceNameSpecifier +| | | | | |-b +| | | | | `-:: +| | | | `-TypeNameSpecifier +| | | | |-S +| | | | `-:: +| | | `-UnqualifiedId +| | | `-f +| | |-( +| | `-) +| `-; +`-} +)txt")); +} + TEST_P(SyntaxTreeTest, CxxNullPtrLiteral) { if (!GetParam().isCXX11OrLater()) { return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D81168: Add support for id-expression in SyntaxTree
eduucaldas added a subscriber: gribozavr2. eduucaldas marked an inline comment as done. eduucaldas added inline comments. Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829 +| | | | | `-:: +| | | | `-TypeSpecifier +| | | | |-S Perhaps we shouldn't differ between specifiers as that is semantical information Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81168/new/ https://reviews.llvm.org/D81168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D81168: Add support for id-expression in SyntaxTree
eduucaldas created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. eduucaldas added a subscriber: gribozavr2. eduucaldas marked an inline comment as done. eduucaldas added inline comments. eduucaldas marked an inline comment as not done. Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:829 +| | | | | `-:: +| | | | `-TypeSpecifier +| | | | |-S Perhaps we shouldn't differ between specifiers as that is semantical information Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D81168 Files: clang/unittests/Tooling/Syntax/TreeTest.cpp Index: clang/unittests/Tooling/Syntax/TreeTest.cpp === --- clang/unittests/Tooling/Syntax/TreeTest.cpp +++ clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -692,6 +692,152 @@ )txt")); } +TEST_P(SyntaxTreeTest, UnqualifiedId) { + if (!GetParam().isCXX()) { +return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +void test(int b) { + int a; + a = b; +} +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-int + | | `-SimpleDeclarator + | | `-b + | `-) + `-CompoundStatement +|-{ +|-DeclarationStatement +| |-SimpleDeclaration +| | |-int +| | `-SimpleDeclarator +| | `-a +| `-; +|-ExpressionStatement +| |-BinaryOperatorExpression +| | |-IdExpression +| | | `-UnqualifiedId +| | | `-a +| | |-= +| | `-IdExpression +| | `-UnqualifiedId +| | `-b +| `-; +`-} +)txt")); +} + +TEST_P(SyntaxTreeTest, QualifiedId) { + if (!GetParam().isCXX()) { +return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +namespace a { + namespace b { +struct S { + int i; + static void f(){} +}; + } +} +void test(int b) { + ::a::b::S::f(); +} +)cpp", + R"txt( +*: TranslationUnit +|-NamespaceDefinition +| |-namespace +| |-a +| |-{ +| |-NamespaceDefinition +| | |-namespace +| | |-b +| | |-{ +| | |-SimpleDeclaration +| | | |-struct +| | | |-S +| | | |-{ +| | | |-SimpleDeclaration +| | | | |-int +| | | | |-SimpleDeclarator +| | | | | `-i +| | | | `-; +| | | |-SimpleDeclaration +| | | | |-static +| | | | |-void +| | | | |-SimpleDeclarator +| | | | | |-f +| | | | | `-ParametersAndQualifiers +| | | | | |-( +| | | | | `-) +| | | | `-CompoundStatement +| | | | |-{ +| | | | `-} +| | | |-} +| | | `-; +| | `-} +| `-} +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | |-SimpleDeclaration + | | |-int + | | `-SimpleDeclarator + | | `-b + | `-) + `-CompoundStatement +|-{ +|-DeclarationStatement +| |-SimpleDeclaration +| | |-a +| | |-:: +| | |-b +| | |-:: +| | |-S +| | `-SimpleDeclarator +| | `-UnknownExpression +| | `-s +| `-; +|-ExpressionStatement +| |-UnknownExpression +| | |-IdExpression +| | | |-NameSpecifiers +| | | | |-GlobalNamespaceSpecifier +| | | | | `:: +| | | | |-NamespaceSpecifier +| | | | | |-a +| | | | | `-:: +| | | | |-NamespaceSpecifier +| | | | | |-b +| | | | | `-:: +| | | | `-TypeSpecifier +| | | | |-S +| | | | `-:: +| | | `-UnqualifiedId +| | | `-f +| | |-( +| | `-) +| `-; +`-} +)txt")); +} + TEST_P(SyntaxTreeTest, CxxNullPtrLiteral) { if (!GetParam().isCXX11OrLater()) { return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits