]> granicus.if.org Git - clang/commitdiff
CXXMethodDecls should always be mangled, even if they are inside an extern "C" block...
authorAnders Carlsson <andersca@mac.com>
Tue, 22 Sep 2009 20:33:31 +0000 (20:33 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 22 Sep 2009 20:33:31 +0000 (20:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82567 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 5a994d2234b272f9242b1f4dcbca28aaa8a7919f..878f13d516d93c3b489382e184e8aef0d8f57a07 100644 (file)
@@ -131,7 +131,7 @@ bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) {
       return false;
 
     // No name mangling in a C linkage specification.
-    if (isInCLinkageSpecification(FD))
+    if (!isa<CXXMethodDecl>(FD) && isInCLinkageSpecification(FD))
       return false;
   }
 
@@ -502,6 +502,9 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC) {
   //           ::= <substitution>
   // FIXME: We only handle mangling of namespaces and classes at the moment.
 
+  while (isa<LinkageSpecDecl>(DC))
+    DC = DC->getParent();
+  
   if (DC->isTranslationUnit())
     return;
   
index dbcd0c9460d72eb8f519b4640087e33d84b7eb57..306188c8de2f0841ec6dde7906bb837793263a1a 100644 (file)
@@ -137,3 +137,13 @@ extern "C" { struct a { int b; }; }
 int f(struct a *x) {
     return x->b;
 }
+
+// PR5017
+extern "C" {
+struct Debug {
+ const Debug& operator<< (unsigned a) const { }
+};
+Debug dbg;
+// CHECK: @_ZNK5DebuglsEj
+int main(void) {  dbg << 32 ;}
+}