From: Anders Carlsson Date: Sat, 7 Nov 2009 07:15:03 +0000 (+0000) Subject: Always mangle functions with special names. Fixes PR5420. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1e1622d1549c470acc999c4399456863e58a011;p=clang Always mangle functions with special names. Fixes PR5420. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86350 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 081156cb6e..94abcbe390 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -129,8 +129,10 @@ static bool isInCLinkageSpecification(const Decl *D) { bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) { // Clang's "overloadable" attribute extension to C/C++ implies name mangling - // (always). - if (!FD->hasAttr()) { + // (always) as does passing a C++ member function and a function + // whose name is not a simple identifier. + if (!FD->hasAttr() && !isa(FD) && + FD->getDeclName().isIdentifier()) { // C functions are not mangled, and "main" is never mangled. if (!Context.getASTContext().getLangOptions().CPlusPlus || FD->isMain()) return false; @@ -142,7 +144,7 @@ bool CXXNameMangler::mangleFunctionDecl(const FunctionDecl *FD) { return false; // No name mangling in a C linkage specification. - if (!isa(FD) && isInCLinkageSpecification(FD)) + if (isInCLinkageSpecification(FD)) return false; } diff --git a/test/CodeGenCXX/mangle-system-header.cpp b/test/CodeGenCXX/mangle-system-header.cpp new file mode 100644 index 0000000000..8c642bd075 --- /dev/null +++ b/test/CodeGenCXX/mangle-system-header.cpp @@ -0,0 +1,7 @@ +// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s + +// PR5420 + +# 1 "fake_system_header.h" 1 3 4 +// CHECK: define void @_ZdlPvS_( +void operator delete (void*, void*) {}