This revision was automatically updated to reflect the committed changes. Closed by commit rL270206: [find-all-symbol] Ignore inline namespace context. (authored by hokein).
Changed prior to commit: http://reviews.llvm.org/D20465?vs=57918&id=57925#toc Repository: rL LLVM http://reviews.llvm.org/D20465 Files: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp =================================================================== --- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -42,9 +42,9 @@ assert(llvm::isa<NamedDecl>(Context) && "Expect Context to be a NamedDecl"); if (const auto *NSD = dyn_cast<NamespaceDecl>(Context)) { - Contexts.emplace_back(SymbolInfo::ContextType::Namespace, - NSD->isAnonymousNamespace() ? "" - : NSD->getName().str()); + if (!NSD->isInlineNamespace()) + Contexts.emplace_back(SymbolInfo::ContextType::Namespace, + NSD->getName().str()); } else if (const auto *ED = dyn_cast<EnumDecl>(Context)) { Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl, ED->getName().str()); Index: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp =================================================================== --- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp +++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp @@ -268,7 +268,8 @@ int X1; namespace { int X2; } namespace { namespace { int X3; } } - namespace { namespace nb { int X4;} } + namespace { namespace nb { int X4; } } + namespace na { inline namespace __1 { int X5; } } )"; runFindAllSymbols(Code); @@ -289,6 +290,10 @@ {{SymbolInfo::ContextType::Namespace, "nb"}, {SymbolInfo::ContextType::Namespace, ""}}); EXPECT_TRUE(hasSymbol(Symbol)); + + Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6, + {{SymbolInfo::ContextType::Namespace, "na"}}); + EXPECT_TRUE(hasSymbol(Symbol)); } TEST_F(FindAllSymbolsTest, DecayedTypeTest) {
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp =================================================================== --- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -42,9 +42,9 @@ assert(llvm::isa<NamedDecl>(Context) && "Expect Context to be a NamedDecl"); if (const auto *NSD = dyn_cast<NamespaceDecl>(Context)) { - Contexts.emplace_back(SymbolInfo::ContextType::Namespace, - NSD->isAnonymousNamespace() ? "" - : NSD->getName().str()); + if (!NSD->isInlineNamespace()) + Contexts.emplace_back(SymbolInfo::ContextType::Namespace, + NSD->getName().str()); } else if (const auto *ED = dyn_cast<EnumDecl>(Context)) { Contexts.emplace_back(SymbolInfo::ContextType::EnumDecl, ED->getName().str()); Index: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp =================================================================== --- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp +++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp @@ -268,7 +268,8 @@ int X1; namespace { int X2; } namespace { namespace { int X3; } } - namespace { namespace nb { int X4;} } + namespace { namespace nb { int X4; } } + namespace na { inline namespace __1 { int X5; } } )"; runFindAllSymbols(Code); @@ -289,6 +290,10 @@ {{SymbolInfo::ContextType::Namespace, "nb"}, {SymbolInfo::ContextType::Namespace, ""}}); EXPECT_TRUE(hasSymbol(Symbol)); + + Symbol = SymbolInfo("X5", SymbolInfo::SymbolKind::Variable, HeaderName, 6, + {{SymbolInfo::ContextType::Namespace, "na"}}); + EXPECT_TRUE(hasSymbol(Symbol)); } TEST_F(FindAllSymbolsTest, DecayedTypeTest) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits