[cfe-commits] r73311 - /cfe/trunk/lib/CodeGen/Mangle.cpp

Chris Lattner sabre at nondot.org
Sat Jun 13 16:34:16 PDT 2009


Author: lattner
Date: Sat Jun 13 18:34:16 2009
New Revision: 73311

URL: http://llvm.org/viewvc/llvm-project?rev=73311&view=rev
Log:
Simplify mangleFunctionDecl by unnesting a crazy condition.  This fixes
the check for extern "c" system headers, which should prevent functiondecls
from being mangled.

Modified:
    cfe/trunk/lib/CodeGen/Mangle.cpp

Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=73311&r1=73310&r2=73311&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Sat Jun 13 18:34:16 2009
@@ -87,19 +87,20 @@
 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";





More information about the cfe-commits mailing list