CXXMethodDecls should always be mangled, even if they are inside an extern "C" block. Fixes PR5017.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82567 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index 5a994d2..878f13d 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -131,7 +131,7 @@
       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 @@
   //           ::= <substitution>
   // FIXME: We only handle mangling of namespaces and classes at the moment.
 
+  while (isa<LinkageSpecDecl>(DC))
+    DC = DC->getParent();
+  
   if (DC->isTranslationUnit())
     return;