summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-02-02 13:34:47 +0000
committerSam McCall <sam.mccall@gmail.com>2018-02-02 13:34:47 +0000
commit34f9d3fe2ac63a50a237809236880dd34953ecd6 (patch)
tree3bebb89aa46bc6bce3920a10bb2afbc9d7dc877d /clang
parent492f1cc8c78c9a5e0611fdd2ab26fa213f85e4bd (diff)
downloadbcm5719-llvm-34f9d3fe2ac63a50a237809236880dd34953ecd6.tar.gz
bcm5719-llvm-34f9d3fe2ac63a50a237809236880dd34953ecd6.zip
[AST] namespace ns { extern "C" { int X; }} prints as "ns::X", not as "X"
llvm-svn: 324081
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Decl.cpp7
-rw-r--r--clang/unittests/AST/NamedDeclPrinterTest.cpp7
2 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 9c73ee7ede3..30599ea7cfb 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1497,9 +1497,10 @@ void NamedDecl::printQualifiedName(raw_ostream &OS,
using ContextsTy = SmallVector<const DeclContext *, 8>;
ContextsTy Contexts;
- // Collect contexts.
- while (Ctx && isa<NamedDecl>(Ctx)) {
- Contexts.push_back(Ctx);
+ // Collect named contexts.
+ while (Ctx) {
+ if (isa<NamedDecl>(Ctx))
+ Contexts.push_back(Ctx);
Ctx = Ctx->getParent();
}
diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp
index 002bb28f374..5715a341d81 100644
--- a/clang/unittests/AST/NamedDeclPrinterTest.cpp
+++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp
@@ -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"));
+}
OpenPOWER on IntegriCloud