Author: fjahanian
Date: Wed Jan  7 14:11:22 2009
New Revision: 61880

URL: http://llvm.org/viewvc/llvm-project?rev=61880&view=rev
Log:
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.

Added:
    cfe/trunk/test/CodeGenObjC/category-super-class-meth.m
Modified:
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=61880&r1=61879&r2=61880&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Jan  7 14:11:22 2009
@@ -1244,7 +1244,9 @@
   // 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;

Added: cfe/trunk/test/CodeGenObjC/category-super-class-meth.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/category-super-class-meth.m?rev=61880&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenObjC/category-super-class-meth.m (added)
+++ cfe/trunk/test/CodeGenObjC/category-super-class-meth.m Wed Jan  7 14:11:22 
2009
@@ -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
+


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to