summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-01-07 20:11:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-01-07 20:11:22 +0000
commit475831bd6e3f6e96751e744951750f0d94220434 (patch)
tree4e743935e42326654d330bc3d4fa233758a408f5
parent0bcf08584558980c08773f3d01eac54c50fceae0 (diff)
downloadbcm5719-llvm-475831bd6e3f6e96751e744951750f0d94220434.tar.gz
bcm5719-llvm-475831bd6e3f6e96751e744951750f0d94220434.zip
Another nasty code gen. bug with trivial fix. Calling class
method on 'super' receiver in a category implementation. Other simpler cases were working by accident. llvm-svn: 61880
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp4
-rw-r--r--clang/test/CodeGenObjC/category-super-class-meth.m19
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index dd722458aaa..03f7b78ec8e 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1244,7 +1244,9 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {
// if know when we entered/exitted an implementation block.
// Check for an existing forward reference.
- if (llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name)) {
+ // Previously, metaclass with internal linkage may have been defined.
+ // pass 'true' as 2nd argument so it is returned.
+ if (llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true)) {
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
"Forward metaclass reference has incorrect type.");
return GV;
diff --git a/clang/test/CodeGenObjC/category-super-class-meth.m b/clang/test/CodeGenObjC/category-super-class-meth.m
new file mode 100644
index 00000000000..4385b56774e
--- /dev/null
+++ b/clang/test/CodeGenObjC/category-super-class-meth.m
@@ -0,0 +1,19 @@
+// RUN: clang -emit-llvm -o %t %s
+
+@interface BASE
++ (int) BaseMeth;
+@end
+
+@interface Child: BASE
+@end
+
+@interface Child (Categ)
++ (int) flushCache2;
+@end
+
+@implementation Child @end
+
+@implementation Child (Categ)
++ (int) flushCache2 { [super BaseMeth]; }
+@end
+
OpenPOWER on IntegriCloud