diff --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp --- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp @@ -2454,7 +2454,7 @@ )txt")); } -TEST_P(SyntaxTreeTest, Namespaces) { +TEST_P(SyntaxTreeTest, Namespace_Nested) { if (!GetParam().isCXX()) { return; } @@ -2462,9 +2462,6 @@ R"cpp( namespace a { namespace b {} } namespace a::b {} -namespace {} - -namespace foo = a; )cpp", R"txt( *: TranslationUnit @@ -2478,82 +2475,91 @@ | | |-{ | | `-} | `-} -|-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) {