aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-03-03 22:09:47 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-03-03 22:09:47 +0000
commit9f9efe6d58f49bce01b548bf81245f053b632a02 (patch)
treea8a966a7c376b71c65570a2441b016036d3bc16e
parenteeeb49a69a35aba5b09021ffb4550a840af54053 (diff)
Fix code gen bug generating code for
((id)cat)->isa. Fixes radar 7709015. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97672 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExprScalar.cpp2
-rw-r--r--test/CodeGenObjC/id-isa-codegen.m18
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index db0998b4de..7e26971414 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -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())
diff --git a/test/CodeGenObjC/id-isa-codegen.m b/test/CodeGenObjC/id-isa-codegen.m
index 3179e11b7f..e893aaa4f3 100644
--- a/test/CodeGenObjC/id-isa-codegen.m
+++ b/test/CodeGenObjC/id-isa-codegen.m
@@ -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
+