Simplify mangleFunctionDecl by unnesting a crazy condition. This fixes

the check for extern "c" system headers, which should prevent functiondecls
from being mangled.

llvm-svn: 73311
This commit is contained in:
Chris Lattner 2009-06-13 23:34:16 +00:00
parent a744527773
commit d50fea52af
1 changed files with 14 additions and 13 deletions

View File

@ -87,19 +87,20 @@ 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>()) {
; // fall into mangling code unconditionally.
} else if (// C functions are not mangled
!Context.getLangOptions().CPlusPlus ||
// "main" is not mangled in C++
FD->isMain() ||
// No mangling in an "implicit extern C" header.
(FD->getLocation().isValid() &&
Context.getSourceManager().getFileCharacteristic(FD->getLocation()))
== SrcMgr::C_ExternCSystem ||
// No name mangling in a C linkage specification.
isInCLinkageSpecification(FD))
return false;
if (!FD->hasAttr<OverloadableAttr>()) {
// C functions are not mangled, and "main" is never mangled.
if (!Context.getLangOptions().CPlusPlus || FD->isMain())
return false;
// No mangling in an "implicit extern C" header.
if (FD->getLocation().isValid() &&
Context.getSourceManager().isInExternCSystemHeader(FD->getLocation()))
return false;
// No name mangling in a C linkage specification.
if (isInCLinkageSpecification(FD))
return false;
}
// If we get here, mangle the decl name!
Out << "_Z";