[AST] namespace ns { extern "C" { int X; }} prints as "ns::X", not as "X"

llvm-svn: 324081
This commit is contained in:
Sam McCall 2018-02-02 13:34:47 +00:00
parent 492f1cc8c7
commit 34f9d3fe2a
2 changed files with 11 additions and 3 deletions

View File

@ -1497,8 +1497,9 @@ void NamedDecl::printQualifiedName(raw_ostream &OS,
using ContextsTy = SmallVector<const DeclContext *, 8>;
ContextsTy Contexts;
// Collect contexts.
while (Ctx && isa<NamedDecl>(Ctx)) {
// Collect named contexts.
while (Ctx) {
if (isa<NamedDecl>(Ctx))
Contexts.push_back(Ctx);
Ctx = Ctx->getParent();
}

View File

@ -173,3 +173,10 @@ TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) {
"A",
"X::Y::A"));
}
TEST(NamedDeclPrinter, TestLinkageInNamespace) {
ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
"namespace X { extern \"C\" { int A; } }",
"A",
"X::A"));
}