]> granicus.if.org Git - clang/commitdiff
Fix a bug in the mangler where in 'namespace std { extern "C" {X;} }', X would not...
authorJames Molloy <james.molloy@arm.com>
Mon, 5 Mar 2012 09:59:43 +0000 (09:59 +0000)
committerJames Molloy <james.molloy@arm.com>
Mon, 5 Mar 2012 09:59:43 +0000 (09:59 +0000)
Migrate two other places where the same logic is used to use the helper function that already exists.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152022 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ItaniumMangle.cpp
test/CodeGenCXX/mangle-std-externc.cpp [new file with mode: 0644]

index 48e2a62c88776b31874fe214c83e310d0064ff02..b7b04434d8237a989e26f6105f3141afd7332c03 100644 (file)
@@ -553,8 +553,7 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) {
     return;
   }
 
-  while (isa<LinkageSpecDecl>(DC))
-    DC = getEffectiveParentContext(DC);
+  DC = IgnoreLinkageSpecDecls(DC);
 
   if (DC->isTranslationUnit() || isStdNamespace(DC)) {
     // Check if we have a template.
@@ -594,7 +593,8 @@ void CXXNameMangler::mangleName(const TemplateDecl *TD,
 void CXXNameMangler::mangleUnscopedName(const NamedDecl *ND) {
   //  <unscoped-name> ::= <unqualified-name>
   //                  ::= St <unqualified-name>   # ::std::
-  if (isStdNamespace(getEffectiveDeclContext(ND)))
+
+  if (isStdNamespace(IgnoreLinkageSpecDecls(getEffectiveDeclContext(ND))))
     Out << "St";
 
   mangleUnqualifiedName(ND);
@@ -1393,8 +1393,7 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC, bool NoFunction) {
   //           ::= # empty
   //           ::= <substitution>
 
-  while (isa<LinkageSpecDecl>(DC))
-    DC = getEffectiveParentContext(DC);
+  DC = IgnoreLinkageSpecDecls(DC);
 
   if (DC->isTranslationUnit())
     return;
diff --git a/test/CodeGenCXX/mangle-std-externc.cpp b/test/CodeGenCXX/mangle-std-externc.cpp
new file mode 100644 (file)
index 0000000..a478dee
--- /dev/null
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -DNS=std -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-STD
+// RUN: %clang_cc1 %s -DNS=n -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-N
+
+// _ZNSt1DISt1CE1iE = std::D<std::C>::i
+// CHECK-STD: @_ZNSt1DISt1CE1iE = 
+
+// _ZN1n1DINS_1CEE1iE == n::D<n::C>::i
+// CHECK-N: @_ZN1n1DINS_1CEE1iE = 
+
+namespace NS {
+  extern "C" {
+    class C {
+    };
+  }
+
+  template <class T>
+  class D {
+  public:
+    static int i;
+  };
+
+}
+
+
+int f() {
+  return NS::D<NS::C>::i;
+}