]> granicus.if.org Git - clang/commitdiff
Always mangle functions with special names. Fixes PR5420.
authorAnders Carlsson <andersca@mac.com>
Sat, 7 Nov 2009 07:15:03 +0000 (07:15 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 7 Nov 2009 07:15:03 +0000 (07:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86350 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle-system-header.cpp [new file with mode: 0644]

index 081156cb6e3c99179aa3745e1f1c2ddabb72b733..94abcbe390744b2a74ec32ec145d0ba5ef41ee99 100644 (file)
@@ -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<OverloadableAttr>()) {
+  // (always) as does passing a C++ member function and a function
+  // whose name is not a simple identifier.
+  if (!FD->hasAttr<OverloadableAttr>() && !isa<CXXMethodDecl>(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<CXXMethodDecl>(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 (file)
index 0000000..8c642bd
--- /dev/null
@@ -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*) {}