]> granicus.if.org Git - clang/commitdiff
extern variable declared locally to objective-c++ method
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 30 Jun 2010 18:27:47 +0000 (18:27 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 30 Jun 2010 18:27:47 +0000 (18:27 +0000)
should not be mangled either. Fixes radar 8016412.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107303 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/Mangle.cpp
test/CodeGenObjCXX/method-local-extern-mangle.mm [new file with mode: 0644]

index ac962247fd0ac5054f9d5803edd93ea1836de67b..4d755ce957547ec325e0dcbc667ba5c9183af654 100644 (file)
@@ -294,7 +294,7 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
   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)
diff --git a/test/CodeGenObjCXX/method-local-extern-mangle.mm b/test/CodeGenObjCXX/method-local-extern-mangle.mm
new file mode 100644 (file)
index 0000000..794075d
--- /dev/null
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @gGlobals = external global
+
+@interface I
+- (int) Meth;
+@end
+
+@implementation I
+- (int) Meth {
+    extern int gGlobals;
+    return gGlobals;
+}
+@end