[cfe-commits] r107303 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenObjCXX/method-local-extern-mangle.mm

Fariborz Jahanian fjahanian at apple.com
Wed Jun 30 11:27:47 PDT 2010


Author: fjahanian
Date: Wed Jun 30 13:27:47 2010
New Revision: 107303

URL: http://llvm.org/viewvc/llvm-project?rev=107303&view=rev
Log:
extern variable declared locally to objective-c++ method
should not be mangled either. Fixes radar 8016412.


Added:
    cfe/trunk/test/CodeGenObjCXX/method-local-extern-mangle.mm
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=107303&r1=107302&r2=107303&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Wed Jun 30 13:27:47 2010
@@ -294,7 +294,7 @@
   if (!FD) {
     const DeclContext *DC = D->getDeclContext();
     // Check for extern variable declared locally.
-    if (isa<FunctionDecl>(DC) && D->hasLinkage())
+    if ((isa<FunctionDecl>(DC) || isa<ObjCMethodDecl>(DC) ) && D->hasLinkage())
       while (!DC->isNamespace() && !DC->isTranslationUnit())
         DC = DC->getParent();
     if (DC->isTranslationUnit() && D->getLinkage() != InternalLinkage)

Added: cfe/trunk/test/CodeGenObjCXX/method-local-extern-mangle.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/method-local-extern-mangle.mm?rev=107303&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/method-local-extern-mangle.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/method-local-extern-mangle.mm Wed Jun 30 13:27:47 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @gGlobals = external global
+
+ at interface I
+- (int) Meth;
+ at end
+
+ at implementation I
+- (int) Meth {
+    extern int gGlobals;
+    return gGlobals;
+}
+ at end





More information about the cfe-commits mailing list