]> granicus.if.org Git - clang/commitdiff
Fix code gen bug generating code for
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 3 Mar 2010 22:09:47 +0000 (22:09 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 3 Mar 2010 22:09:47 +0000 (22:09 +0000)
((id)cat)->isa. Fixes radar 7709015.

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

lib/CodeGen/CGExprScalar.cpp
test/CodeGenObjC/id-isa-codegen.m

index db0998b4dedc5f2ce602ea551b9e0c4f26d5f669..7e26971414b40252273e214076518cf7ae2a6145 100644 (file)
@@ -1888,6 +1888,8 @@ LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) {
     V = CreateTempAlloca(ClassPtrTy, "resval");
     llvm::Value *Src = EmitScalarExpr(BaseExpr);
     Builder.CreateStore(Src, V);
+    LValue LV = LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+    V = ScalarExprEmitter(*this).EmitLoadOfLValue(LV, E->getType());
   }
   else {
       if (E->isArrow())
index 3179e11b7f399ef9bc5ee2c32d60971f1d87bb98..e893aaa4f3c2134b3db42abf0fafe949443d7dc8 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -emit-llvm -o - %s
 
 typedef struct objc_class *Class;
 
@@ -48,3 +48,19 @@ id Test2() {
       return (*[Foo method]).isa;
     return [Foo method]->isa;
 }
+
+// rdar 7709015
+@interface Cat   {}
+@end
+
+@interface SuperCat : Cat {}
++(void)geneticallyAlterCat:(Cat *)cat;
+@end
+
+@implementation SuperCat
++ (void)geneticallyAlterCat:(Cat *)cat {
+    Class dynamicSubclass;
+    ((id)cat)->isa = dynamicSubclass;
+}
+@end
+