From 524ed953823ee605793c93452a2f86e4a7c4a2fe Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 20 Feb 2009 23:09:27 +0000 Subject: [PATCH] We must always mangle attribute overloadable functions; even if in a system header. - Prevents a codegen crash when anything used anything in tgmath! :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65200 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 10 +++++----- test/CodeGen/mangle.c | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 test/CodeGen/mangle.c diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index f007539714..f310e989b5 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -62,14 +62,14 @@ bool CXXNameMangler::mangle(const NamedDecl *D) { // FIXME: Actually use a visitor to decode these? if (const FunctionDecl *FD = dyn_cast(D)) { bool RequiresMangling = false; - // No mangled in an "implicit extern C" header. - if (Context.getSourceManager().getFileCharacteristic(FD->getLocation()) - == SrcMgr::C_ExternCSystem) - RequiresMangling = false; // Clang's "overloadable" attribute extension to C/C++ implies // name mangling (always). - else if (FD->getAttr()) + if (FD->getAttr()) RequiresMangling = true; + // No mangled in an "implicit extern C" header. + else if (Context.getSourceManager().getFileCharacteristic(FD->getLocation()) + == SrcMgr::C_ExternCSystem) + RequiresMangling = false; else if (Context.getLangOptions().CPlusPlus) { // C++ requires name mangling, unless we're in a C linkage // specification. diff --git a/test/CodeGen/mangle.c b/test/CodeGen/mangle.c new file mode 100644 index 0000000000..fbee4122d1 --- /dev/null +++ b/test/CodeGen/mangle.c @@ -0,0 +1,9 @@ +// RUN: clang -arch i386 -emit-llvm -o %t %s && +// RUN: grep '@_Z2f0i' %t && +// RUN: grep '@_Z2f0l' %t + +// Make sure we mangle overloadable, even in C system headers. + +# 1 "somesystemheader.h" 1 3 4 +void __attribute__((__overloadable__)) f0(int a) {} +void __attribute__((__overloadable__)) f0(long b) {} -- 2.40.0