Skip to content

Commit

Permalink
[find-all-symbol] Ignore inline namespace context.
Browse files Browse the repository at this point in the history
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270206
  • Loading branch information
hokein committed May 20, 2016
1 parent 8571aa3 commit a23ac3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Expand Up @@ -42,9 +42,9 @@ std::vector<SymbolInfo::Context> GetContexts(const NamedDecl *ND) {
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());
Expand Down
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit a23ac3d

Please sign in to comment.