Author: Eduardo Caldas Date: 2020-08-20T15:14:56Z New Revision: e4e983e240430b3a0dc92402cc940292bd0d263f
URL: https://github.com/llvm/llvm-project/commit/e4e983e240430b3a0dc92402cc940292bd0d263f DIFF: https://github.com/llvm/llvm-project/commit/e4e983e240430b3a0dc92402cc940292bd0d263f.diff LOG: [SyntaxTree] Split tests related to Namespace Differential Revision: https://reviews.llvm.org/D86139 Added: Modified: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp Removed: ################################################################################ diff --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp index 2692c1f6ff58..a3e86dac50c5 100644 --- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp @@ -2454,7 +2454,7 @@ typedef decltype(sizeof(void *)) size_t; )txt")); } -TEST_P(SyntaxTreeTest, Namespaces) { +TEST_P(SyntaxTreeTest, Namespace_Nested) { if (!GetParam().isCXX()) { return; } @@ -2462,9 +2462,6 @@ TEST_P(SyntaxTreeTest, Namespaces) { R"cpp( namespace a { namespace b {} } namespace a::b {} -namespace {} - -namespace foo = a; )cpp", R"txt( *: TranslationUnit @@ -2478,82 +2475,91 @@ namespace foo = a; | | |-{ | | `-} | `-} -|-NamespaceDefinition -| |-namespace -| |-a -| |-:: -| |-b -| |-{ -| `-} -|-NamespaceDefinition -| |-namespace -| |-{ -| `-} -`-NamespaceAliasDefinition +`-NamespaceDefinition |-namespace - |-foo - |-= |-a - `-; + |-:: + |-b + |-{ + `-} )txt")); } -TEST_P(SyntaxTreeTest, UsingDirective) { +TEST_P(SyntaxTreeTest, Namespace_Unnamed) { if (!GetParam().isCXX()) { return; } EXPECT_TRUE(treeDumpEqual( R"cpp( -namespace ns {} -using namespace ::ns; +namespace {} )cpp", R"txt( *: TranslationUnit -|-NamespaceDefinition -| |-namespace -| |-ns -| |-{ -| `-} -`-UsingNamespaceDirective - |-using +`-NamespaceDefinition |-namespace - |-NestedNameSpecifier - | `-:: - |-ns - `-; + |-{ + `-} )txt")); } +TEST_P(SyntaxTreeTest, Namespace_Alias) { + if (!GetParam().isCXX()) { + return; + } + EXPECT_TRUE(treeDumpEqualOnAnnotations( + R"cpp( +namespace a {} +[[namespace foo = a;]] +)cpp", + {R"txt( +NamespaceAliasDefinition +|-namespace +|-foo +|-= +|-a +`-; +)txt"})); +} + +TEST_P(SyntaxTreeTest, UsingDirective) { + if (!GetParam().isCXX()) { + return; + } + EXPECT_TRUE(treeDumpEqualOnAnnotations( + R"cpp( +namespace ns {} +[[using namespace ::ns;]] +)cpp", + {R"txt( +UsingNamespaceDirective +|-using +|-namespace +|-NestedNameSpecifier +| `-:: +|-ns +`-; +)txt"})); +} + TEST_P(SyntaxTreeTest, UsingDeclaration) { if (!GetParam().isCXX()) { return; } - EXPECT_TRUE(treeDumpEqual( + EXPECT_TRUE(treeDumpEqualOnAnnotations( R"cpp( namespace ns { int a; } -using ns::a; +[[using ns::a;]] )cpp", - R"txt( -*: TranslationUnit -|-NamespaceDefinition -| |-namespace -| |-ns -| |-{ -| |-SimpleDeclaration -| | |-int -| | |-SimpleDeclarator -| | | `-a -| | `-; -| `-} -`-UsingDeclaration - |-using - |-NestedNameSpecifier - | |-IdentifierNameSpecifier - | | `-ns - | `-:: - |-a - `-; -)txt")); + {R"txt( +UsingDeclaration +|-using +|-NestedNameSpecifier +| |-IdentifierNameSpecifier +| | `-ns +| `-:: +|-a +`-; +)txt"})); } TEST_P(SyntaxTreeTest, FreeStandingClasses) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits