[cfe-commits] r90995 - in /cfe/trunk: lib/AST/Expr.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenObjC/id-isa-codegen.m
Fariborz Jahanian
fjahanian at apple.com
Wed Dec 9 15:35:31 PST 2009
Author: fjahanian
Date: Wed Dec 9 17:35:29 2009
New Revision: 90995
URL: http://llvm.org/viewvc/llvm-project?rev=90995&view=rev
Log:
Code gen for ObjCIsaExpr AST used as lvalue.
(fixes radar 7457534).
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenObjC/id-isa-codegen.m
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=90995&r1=90994&r2=90995&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Dec 9 17:35:29 2009
@@ -983,6 +983,7 @@
// Check whether the expression can be sanely treated like an l-value
Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
switch (getStmtClass()) {
+ case ObjCIsaExprClass:
case StringLiteralClass: // C99 6.5.1p4
case ObjCEncodeExprClass: // @encode behaves like its string in every way.
return LV_Valid;
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=90995&r1=90994&r2=90995&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Dec 9 17:35:29 2009
@@ -245,6 +245,8 @@
switch (E->getStmtClass()) {
default: return EmitUnsupportedLValue(E, "l-value expression");
+ case Expr::ObjCIsaExprClass:
+ return EmitObjCIsaExpr(cast<ObjCIsaExpr>(E));
case Expr::BinaryOperatorClass:
return EmitBinaryOperatorLValue(cast<BinaryOperator>(E));
case Expr::CallExprClass:
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=90995&r1=90994&r2=90995&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Dec 9 17:35:29 2009
@@ -168,21 +168,8 @@
}
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();
+ LValue LV = CGF.EmitObjCIsaExpr(E);
+ Value *V = CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal();
return V;
}
@@ -1997,3 +1984,22 @@
return Vec;
}
+
+LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) {
+ llvm::Value *V;
+ // object->isa or (*object).isa
+ // Generate code as for: *(Class*)object
+ Expr *BaseExpr = E->getBase();
+ if (E->isArrow())
+ V = ScalarExprEmitter(*this).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, MakeQualifiers(E->getType()));
+ return LV;
+}
+
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=90995&r1=90994&r2=90995&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Dec 9 17:35:29 2009
@@ -971,6 +971,7 @@
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E);
LValue EmitMemberExpr(const MemberExpr *E);
+ LValue EmitObjCIsaExpr(const ObjCIsaExpr *E);
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E);
LValue EmitConditionalOperatorLValue(const ConditionalOperator *E);
LValue EmitCastLValue(const CastExpr *E);
Modified: cfe/trunk/test/CodeGenObjC/id-isa-codegen.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/id-isa-codegen.m?rev=90995&r1=90994&r2=90995&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/id-isa-codegen.m (original)
+++ cfe/trunk/test/CodeGenObjC/id-isa-codegen.m Wed Dec 9 17:35:29 2009
@@ -8,17 +8,20 @@
@interface I
+ (Class) class;
-- (void)meth : (id)object;
+- (void)meth : (id)object : (id)src_object;
+ (unsigned char) isSubclassOfClass:(Class)aClass ;
@end
@implementation I
+ (Class) class {return 0;}
+ (unsigned char) isSubclassOfClass:(Class)aClass {return 0;}
-- (void)meth : (id)object {
+- (void)meth : (id)object : (id)src_object {
[object->isa isSubclassOfClass:[I class]];
[(*object).isa isSubclassOfClass:[I class]];
+
+ object->isa = src_object->isa;
+ (*src_object).isa = (*object).isa;
}
@end
More information about the cfe-commits
mailing list