]> granicus.if.org Git - clang/commitdiff
Another nasty code gen. bug with trivial fix. Calling class
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 7 Jan 2009 20:11:22 +0000 (20:11 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 7 Jan 2009 20:11:22 +0000 (20:11 +0000)
method on 'super' receiver in a category implementation.
Other simpler cases were working by accident.

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

lib/CodeGen/CGObjCMac.cpp
test/CodeGenObjC/category-super-class-meth.m [new file with mode: 0644]

index dd722458aaa3568db12055ce3eea994cc791cbdf..03f7b78ec8e0f45d0b95ddcb11694764028e7cd9 100644 (file)
@@ -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/test/CodeGenObjC/category-super-class-meth.m b/test/CodeGenObjC/category-super-class-meth.m
new file mode 100644 (file)
index 0000000..4385b56
--- /dev/null
@@ -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
+