summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-12-09 23:35:29 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-12-09 23:35:29 +0000
commit531c16f9fb040950ff068d8237e656bf12e3d070 (patch)
tree6f5110da14a53d0c51eaedc093ed4d481337f36a /clang/lib
parent25b20fc2ae8c08ee391b8b6a7f7856c2c275ead1 (diff)
downloadbcm5719-llvm-531c16f9fb040950ff068d8237e656bf12e3d070.tar.gz
bcm5719-llvm-531c16f9fb040950ff068d8237e656bf12e3d070.zip
Code gen for ObjCIsaExpr AST used as lvalue.
(fixes radar 7457534). llvm-svn: 90995
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp1
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp2
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp36
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h1
4 files changed, 25 insertions, 15 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4144661f7b0..e8758d814de 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -983,6 +983,7 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
// 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;
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index fde944ffcd6..873c28cdef8 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -245,6 +245,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
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:
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index 9ac8b4d8b3c..1ce4c5aef4c 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -168,21 +168,8 @@ public:
}
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 @@ llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals,
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;
+}
+
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 70d598dc0e9..30cc5d9cbf2 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -971,6 +971,7 @@ public:
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);
OpenPOWER on IntegriCloud