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 @@ -2081,7 +2081,7 @@ )txt")); } -TEST_P(SyntaxTreeTest, Namespaces) { +TEST_P(SyntaxTreeTest, Namespace_Nested) { if (!GetParam().isCXX()) { return; } @@ -2089,9 +2089,6 @@ R"cpp( namespace a { namespace b {} } namespace a::b {} -namespace {} - -namespace foo = a; )cpp", R"txt( *: TranslationUnit @@ -2105,82 +2102,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, UsingDeclaration) { +TEST_P(SyntaxTreeTest, Namespace_Alias) { if (!GetParam().isCXX()) { return; } - EXPECT_TRUE(treeDumpEqual( + EXPECT_TRUE(treeDumpEqualOnAnnotations( + R"cpp( +namespace a {} +[[namespace foo = a;]] +)cpp", + {R"txt( +NamespaceAliasDefinition +|-namespace +|-foo +|-= +|-a +`-; +)txt"})); +} + +TEST_P(SyntaxTreeTest, Namepace_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, Namespace_UsingDeclaration) { + if (!GetParam().isCXX()) { + return; + } + 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) {