aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-11-22 18:39:36 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-11-22 18:39:36 +0000
commit5daf570d0ce027e18ed5f9d66e6b2a14a40b720d (patch)
treee554d26d58de550daf74b397b4e2e894927080df /lib/CodeGen
parente4c452c4c7b9124fe94a96f559ff077d59cdf996 (diff)
New AST node to access "implicit" setter/getter using property dor syntax.
Issuing diagnostics when assigning to read-only properties. This is work in progress. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGExprAgg.cpp13
-rw-r--r--lib/CodeGen/CGObjC.cpp33
-rw-r--r--lib/CodeGen/CodeGenFunction.h2
3 files changed, 21 insertions, 27 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 28f93c00f1..66f3feb8cc 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -87,6 +87,7 @@ public:
EmitAggLoadOfLValue(E);
}
void VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E);
+ void VisitObjCKVCRefExpr(ObjCKVCRefExpr *E);
void VisitConditionalOperator(const ConditionalOperator *CO);
void VisitInitListExpr(InitListExpr *E);
@@ -170,6 +171,18 @@ void AggExprEmitter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
CGF.EmitAggregateCopy(DestPtr, RV.getAggregateAddr(), E->getType());
}
+void AggExprEmitter::VisitObjCKVCRefExpr(ObjCKVCRefExpr *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;
+
+ CGF.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()));
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 4739efa63d..226ec9917c 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -278,40 +278,21 @@ llvm::Value *CodeGenFunction::LoadObjCSelf() {
return Builder.CreateLoad(LocalDeclMap[OMD->getSelfDecl()], "self");
}
-RValue CodeGenFunction::EmitObjCPropertyGet(const ObjCPropertyRefExpr *E) {
- // Determine getter selector.
- Selector S;
- if (E->getKind() == ObjCPropertyRefExpr::MethodRef) {
- S = E->getGetterMethod()->getSelector();
- } else {
- S = E->getProperty()->getGetterName();
- }
+RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) {
+ if (const ObjCPropertyRefExpr *E = dyn_cast<ObjCPropertyRefExpr>(Exp)) {
+ Selector S = E->getProperty()->getGetterName();
- return CGM.getObjCRuntime().
+ return CGM.getObjCRuntime().
GenerateMessageSend(*this, E->getType(), S,
EmitScalarExpr(E->getBase()),
false, CallArgList());
+ }
+ assert (0);
}
void CodeGenFunction::EmitObjCPropertySet(const ObjCPropertyRefExpr *E,
RValue Src) {
- Selector S;
- if (E->getKind() == ObjCPropertyRefExpr::MethodRef) {
- ObjCMethodDecl *Setter = E->getSetterMethod();
-
- if (Setter) {
- S = Setter->getSelector();
- } else {
- // FIXME: This should be diagnosed by sema.
- CGM.getDiags().Report(getContext().getFullLoc(E->getLocStart()),
- diag::err_typecheck_assign_const)
- << E->getSourceRange();
- return;
- }
- } else {
- S = E->getProperty()->getSetterName();
- }
-
+ Selector S = E->getProperty()->getSetterName();
CallArgList Args;
Args.push_back(std::make_pair(Src, E->getType()));
CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 85c500b95e..56a6e16e9e 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -524,7 +524,7 @@ public:
llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E);
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E);
- RValue EmitObjCPropertyGet(const ObjCPropertyRefExpr *E);
+ RValue EmitObjCPropertyGet(const Expr *E);
void EmitObjCPropertySet(const ObjCPropertyRefExpr *E, RValue Src);