[cfe-commits] r55410 - in /cfe/trunk/lib/CodeGen: CGExprAgg.cpp CGExprScalar.cpp CGObjC.cpp CodeGenFunction.h
Daniel Dunbar
daniel at zuster.org
Tue Aug 26 23:57:25 PDT 2008
Author: ddunbar
Date: Wed Aug 27 01:57:25 2008
New Revision: 55410
URL: http://llvm.org/viewvc/llvm-project?rev=55410&view=rev
Log:
Initial support for Obj-C dot-syntax for getters.
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=55410&r1=55409&r2=55410&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Wed Aug 27 01:57:25 2008
@@ -91,10 +91,7 @@
void VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
EmitAggLoadOfLValue(E);
}
- void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
- // FIXME: Implement!
- CGF.ErrorUnsupported(E, "aggregate expression (Objective-C property reference)");
- }
+ void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
void VisitConditionalOperator(const ConditionalOperator *CO);
void VisitInitListExpr(InitListExpr *E);
@@ -219,6 +216,18 @@
EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
+void AggExprEmitter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
+ RValue RV = CGF.EmitObjCPropertyGet(E);
+ assert(RV.isAggregate() && "Return value must be aggregate value!");
+
+ // If the result is ignored, don't copy from the value.
+ if (DestPtr == 0)
+ // FIXME: If the source is volatile, we must read from it.
+ return;
+
+ EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
+}
+
void AggExprEmitter::VisitOverloadExpr(const OverloadExpr *E) {
RValue RV = CGF.EmitCallExpr(E->getFn(), E->arg_begin(),
E->arg_end(CGF.getContext()));
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=55410&r1=55409&r2=55410&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Wed Aug 27 01:57:25 2008
@@ -134,14 +134,20 @@
return llvm::ConstantInt::get(EC->getInitVal());
return EmitLoadOfLValue(E);
}
- Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E);
- Value *VisitObjCProtocolExpr(ObjCProtocolExpr *E);
- Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E);}
+ Value *VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
+ return CGF.EmitObjCSelectorExpr(E);
+ }
+ Value *VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
+ return CGF.EmitObjCProtocolExpr(E);
+ }
+ Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
+ return EmitLoadOfLValue(E);
+ }
Value *VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
- CGF.ErrorUnsupported(E, "scalar expression (Objective-C property reference)");
- if (E->getType()->isVoidType())
- return 0;
- return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
+ return CGF.EmitObjCPropertyGet(E).getScalarVal();
+ }
+ Value *VisitObjCMessageExpr(ObjCMessageExpr *E) {
+ return CGF.EmitObjCMessageExpr(E).getScalarVal();
}
Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E);
@@ -196,10 +202,6 @@
return CGF.EmitCallExpr(E).getScalarVal();
}
- Value *VisitObjCMessageExpr(ObjCMessageExpr *E) {
- return CGF.EmitObjCMessageExpr(E).getScalarVal();
- }
-
Value *VisitStmtExpr(const StmtExpr *E);
// Unary Operators.
@@ -481,14 +483,6 @@
return Builder.CreateShuffleVector(V1, V2, SV, "shuffle");
}
-Value *ScalarExprEmitter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
- return CGF.EmitObjCSelectorExpr(E);
-}
-
-Value *ScalarExprEmitter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
- return CGF.EmitObjCProtocolExpr(E);
-}
-
Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
// Emit subscript expressions in rvalue context's. For most cases, this just
// loads the lvalue formed by the subscript expr. However, we have to be
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=55410&r1=55409&r2=55410&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Aug 27 01:57:25 2008
@@ -218,4 +218,24 @@
return Builder.CreateLoad(LocalDeclMap[OMD->getSelfDecl()], "self");
}
+RValue CodeGenFunction::EmitObjCPropertyGet(const ObjCPropertyRefExpr *E) {
+ // Determine getter selector.
+ Selector S;
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(E->getDecl())) {
+ S = MD->getSelector();
+ } else {
+ S = cast<ObjCPropertyDecl>(E->getDecl())->getGetterName();
+ }
+
+ // FIXME: Improve location information.
+ SourceLocation Loc = E->getLocation();
+ // PropertyRefExprs are always instance messages.
+ // FIXME: Is there any reason to try and pass the method here?
+ ObjCMessageExpr GetExpr(const_cast<Expr*>(E->getBase()),
+ S, E->getType(), 0, Loc, Loc,
+ 0, 0);
+
+ return EmitObjCMessageExpr(&GetExpr);
+}
+
CGObjCRuntime::~CGObjCRuntime() {}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=55410&r1=55409&r2=55410&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Aug 27 01:57:25 2008
@@ -326,6 +326,7 @@
llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E);
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E);
+ RValue EmitObjCPropertyGet(const ObjCPropertyRefExpr *E);
//===--------------------------------------------------------------------===//
More information about the cfe-commits
mailing list