aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-12-15 21:34:52 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-12-15 21:34:52 +0000
commita7fa7cd3eaa5459dfb2d1495384ece9786f8434c (patch)
treec29b290e601c75fc606b85f9920c24cb62da6fd0
parent0ece491d8f62ce67f047491a6703fac0d3bd4ff4 (diff)
Fixes a code gen bug related to accessing a now
non-existing 'isa' field of a non-existing struct type all related to legacy type definition for 'id' which we have dropped in clang in favor of a built-in type. (fixes radar 7470820). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91455 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGExpr.cpp1
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--test/CodeGenObjC/id-isa-codegen.m9
3 files changed, 13 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 8e1413386a..c5a89e032b 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1389,6 +1389,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
case CastExpr::CK_NoOp:
case CastExpr::CK_ConstructorConversion:
case CastExpr::CK_UserDefinedConversion:
+ case CastExpr::CK_AnyPointerToObjCPointerCast:
return EmitLValue(E->getSubExpr());
case CastExpr::CK_DerivedToBase: {
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index cda27cf687..65c95b36aa 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3584,7 +3584,9 @@ static CastExpr::CastKind getScalarCastKind(ASTContext &Context,
if (SrcTy->hasPointerRepresentation()) {
if (DestTy->hasPointerRepresentation())
- return CastExpr::CK_BitCast;
+ return DestTy->isObjCObjectPointerType() ?
+ CastExpr::CK_AnyPointerToObjCPointerCast :
+ CastExpr::CK_BitCast;
if (DestTy->isIntegerType())
return CastExpr::CK_PointerToIntegral;
}
diff --git a/test/CodeGenObjC/id-isa-codegen.m b/test/CodeGenObjC/id-isa-codegen.m
index dc0bac3000..89e9922090 100644
--- a/test/CodeGenObjC/id-isa-codegen.m
+++ b/test/CodeGenObjC/id-isa-codegen.m
@@ -25,3 +25,12 @@ typedef struct objc_object {
}
@end
+
+// rdar 7470820
+static Class MyClass;
+
+Class Test(const void *inObject1) {
+ if(((id)inObject1)->isa == MyClass)
+ return ((id)inObject1)->isa;
+ return (id)0;
+}