[cfe-commits] r82146 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle.cpp

Anders Carlsson andersca at mac.com
Thu Sep 17 09:12:20 PDT 2009


Author: andersca
Date: Thu Sep 17 11:12:20 2009
New Revision: 82146

URL: http://llvm.org/viewvc/llvm-project?rev=82146&view=rev
Log:
Ignore extern "C++" { } when mangling.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp
    cfe/trunk/test/CodeGenCXX/mangle.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=82146&r1=82145&r2=82146&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Thu Sep 17 11:12:20 2009
@@ -249,14 +249,20 @@
   //         ::= <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);

Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=82146&r1=82145&r2=82146&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Sep 17 11:12:20 2009
@@ -99,3 +99,8 @@
   // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
   ft2<char>(1, 0, 0);
 }
+
+extern "C++" {
+  // CHECK: @_Z1hv
+ void h() { } 
+}





More information about the cfe-commits mailing list