aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-06-30 18:27:47 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-06-30 18:27:47 +0000
commit2fe13882a846b4152abf0734be43b3e141843818 (patch)
treebeac4ac8aeebba817eb3728545f42a1bbbc60bb4
parent4680bf233caeebe89aa297eb5a25709dd15a4b11 (diff)
extern variable declared locally to objective-c++ method
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
-rw-r--r--lib/CodeGen/Mangle.cpp2
-rw-r--r--test/CodeGenObjCXX/method-local-extern-mangle.mm14
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index ac962247fd..4d755ce957 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -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
index 0000000000..794075da1a
--- /dev/null
+++ b/test/CodeGenObjCXX/method-local-extern-mangle.mm
@@ -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