[cfe-commits] r90981 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp lib/Sema/SemaExpr.cpp test/CodeGenObjC/id-isa-codegen.m
Fariborz Jahanian
fjahanian at apple.com
Wed Dec 9 11:05:56 PST 2009
Author: fjahanian
Date: Wed Dec 9 13:05:56 2009
New Revision: 90981
URL: http://llvm.org/viewvc/llvm-project?rev=90981&view=rev
Log:
Codegen. support for ObjCIsaExpr AST which until now
was not needed (fixes radar 7453430).
Added:
cfe/trunk/test/CodeGenObjC/id-isa-codegen.m
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=90981&r1=90980&r2=90981&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Dec 9 13:05:56 2009
@@ -167,6 +167,25 @@
return CGF.EmitObjCMessageExpr(E).getScalarVal();
}
+ Value *VisitObjCIsaExpr(ObjCIsaExpr *E) {
+ Value *V;
+ // object->isa or (*object).isa
+ // Generate code as for: *(Class*)object
+ Expr *BaseExpr = E->getBase();
+ if (E->isArrow())
+ V = EmitLoadOfLValue(BaseExpr);
+ else
+ V = EmitLValue(BaseExpr).getAddress();
+
+ // build Class* type
+ const llvm::Type *ClassPtrTy = ConvertType(E->getType());
+ ClassPtrTy = ClassPtrTy->getPointerTo();
+ V = Builder.CreateBitCast(V, ClassPtrTy);
+ LValue LV = LValue::MakeAddr(V, CGF.MakeQualifiers(E->getType()));
+ V = CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal();
+ return V;
+ }
+
Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E);
Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E);
Value *VisitMemberExpr(MemberExpr *E);
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=90981&r1=90980&r2=90981&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec 9 13:05:56 2009
@@ -2528,8 +2528,8 @@
BaseType->getAs<ObjCObjectPointerType>()) {
if (OPT->getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) &&
MemberName.getAsIdentifierInfo()->isStr("isa"))
- return Owned(new (Context) ObjCIsaExpr(BaseExpr, false, MemberLoc,
- Context.getObjCIdType()));
+ return Owned(new (Context) ObjCIsaExpr(BaseExpr, true, MemberLoc,
+ Context.getObjCClassType()));
}
}
// We have an 'id' type. Rather than fall through, we check if this
@@ -2888,7 +2888,7 @@
BaseType->isSpecificBuiltinType(BuiltinType::ObjCId) &&
MemberName.getAsIdentifierInfo()->isStr("isa"))
return Owned(new (Context) ObjCIsaExpr(BaseExpr, false, MemberLoc,
- Context.getObjCIdType()));
+ Context.getObjCClassType()));
// Handle 'field access' to vectors, such as 'V.xx'.
if (BaseType->isExtVectorType()) {
Added: cfe/trunk/test/CodeGenObjC/id-isa-codegen.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/id-isa-codegen.m?rev=90981&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/id-isa-codegen.m (added)
+++ cfe/trunk/test/CodeGenObjC/id-isa-codegen.m Wed Dec 9 13:05:56 2009
@@ -0,0 +1,24 @@
+// RUN: clang-cc -emit-llvm -o %t %s
+
+typedef struct objc_class *Class;
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+ at interface I
++ (Class) class;
+- (void)meth : (id)object;
++ (unsigned char) isSubclassOfClass:(Class)aClass ;
+ at end
+
+ at implementation I
++ (Class) class {return 0;}
++ (unsigned char) isSubclassOfClass:(Class)aClass {return 0;}
+- (void)meth : (id)object {
+ [object->isa isSubclassOfClass:[I class]];
+
+ [(*object).isa isSubclassOfClass:[I class]];
+}
+ at end
+
More information about the cfe-commits
mailing list