[PATCH] D20465: [find-all-symbol] Ignore inline namespace context.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 02:38:48 PDT 2016


hokein created this revision.
hokein added a reviewer: bkramer.
hokein added subscribers: ioeric, cfe-commits.

http://reviews.llvm.org/D20465

Files:
  include-fixer/find-all-symbols/FindAllSymbols.cpp
  unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp

Index: unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
===================================================================
--- unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
+++ unittests/include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
@@ -260,7 +260,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);
 
@@ -281,6 +282,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: include-fixer/find-all-symbols/FindAllSymbols.cpp
===================================================================
--- include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ 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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20465.57918.patch
Type: text/x-patch
Size: 1958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160520/318bddf8/attachment.bin>


More information about the cfe-commits mailing list