[clang-tools-extra] r270206 - [find-all-symbol] Ignore inline namespace context.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 05:04:57 PDT 2016


Author: hokein
Date: Fri May 20 07:04:56 2016
New Revision: 270206

URL: http://llvm.org/viewvc/llvm-project?rev=270206&view=rev
Log:
[find-all-symbol] Ignore inline namespace context.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20465

Modified:
    clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
    clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=270206&r1=270205&r2=270206&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp Fri May 20 07:04:56 2016
@@ -42,9 +42,9 @@ std::vector<SymbolInfo::Context> GetCont
     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());

Modified: clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp?rev=270206&r1=270205&r2=270206&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp Fri May 20 07:04:56 2016
@@ -268,7 +268,8 @@ TEST_F(FindAllSymbolsTest, NamespaceTest
       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 @@ TEST_F(FindAllSymbolsTest, NamespaceTest
                       {{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) {




More information about the cfe-commits mailing list