]> granicus.if.org Git - clang/commitdiff
Ignore extern "C++" { } when mangling.
authorAnders Carlsson <andersca@mac.com>
Thu, 17 Sep 2009 16:12:20 +0000 (16:12 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 17 Sep 2009 16:12:20 +0000 (16:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82146 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle.cpp

index 8241ad61d077c7fd6a6023fff6148e2103fad6ee..aaa771b21de2cef95076b899e3bb7e5013012576 100644 (file)
@@ -249,14 +249,20 @@ void CXXNameMangler::mangleName(const NamedDecl *ND) {
   //         ::= <unscoped-template-name> <template-args>
   //         ::= <local-name>
   //
-  if (ND->getDeclContext()->isTranslationUnit() ||
-      isStdNamespace(ND->getDeclContext())) {
+  const DeclContext *DC = ND->getDeclContext();
+  while (isa<LinkageSpecDecl>(DC)) {
+    assert(cast<LinkageSpecDecl>(DC)->getLanguage() == 
+           LinkageSpecDecl::lang_cxx && "Unexpected linkage decl!");
+    DC = DC->getParent();
+  }
+  
+  if (DC->isTranslationUnit() || isStdNamespace(DC)) {
     const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND);
     if (FD && FD->getPrimaryTemplate()) 
       mangleUnscopedTemplateName(FD);
     else
       mangleUnscopedName(ND);
-  } else if (isa<FunctionDecl>(ND->getDeclContext()))
+  } else if (isa<FunctionDecl>(DC))
     mangleLocalName(ND);
   else
     mangleNestedName(ND);
index 65ef0083e41f421e784ff30ea83e532ef795ce1c..98db0845c779117f411c16bd406528882bac8ffc 100644 (file)
@@ -99,3 +99,8 @@ void g() {
   // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
   ft2<char>(1, 0, 0);
 }
+
+extern "C++" {
+  // CHECK: @_Z1hv
+ void h() { } 
+}