From: Anders Carlsson Date: Tue, 22 Sep 2009 20:33:31 +0000 (+0000) Subject: CXXMethodDecls should always be mangled, even if they are inside an extern "C" block... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=add28829c7a8d3c5da9ae140f18d3c9ad2d8b599;p=clang 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 5a994d2234..878f13d516 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -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(FD) && isInCLinkageSpecification(FD)) return false; } @@ -502,6 +502,9 @@ void CXXNameMangler::manglePrefix(const DeclContext *DC) { // ::= // FIXME: We only handle mangling of namespaces and classes at the moment. + while (isa(DC)) + DC = DC->getParent(); + if (DC->isTranslationUnit()) return; diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index dbcd0c9460..306188c8de 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -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 ;} +}