diff options
author | Anders Carlsson <andersca@mac.com> | 2009-09-22 20:33:31 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-09-22 20:33:31 +0000 |
commit | add28829c7a8d3c5da9ae140f18d3c9ad2d8b599 (patch) | |
tree | 15b9fd848d7557cd6c712da9c5b0bc6771cf02b5 | |
parent | 17c7a5d7ae8c818696e10a62bbcf19fa6cb90755 (diff) |
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
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 5 | ||||
-rw-r--r-- | test/CodeGenCXX/mangle.cpp | 10 |
2 files changed, 14 insertions, 1 deletions
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<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; 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 ;} +} |