[cfe-commits] r66556 - in /cfe/trunk: include/clang/AST/ExprObjC.h lib/CodeGen/CGObjC.cpp test/CodeGenObjC/class-getter-dotsyntax.m
Fariborz Jahanian
fjahanian at apple.com
Tue Mar 10 11:03:11 PDT 2009
Author: fjahanian
Date: Tue Mar 10 13:03:11 2009
New Revision: 66556
URL: http://llvm.org/viewvc/llvm-project?rev=66556&view=rev
Log:
ir-gen support for class getter/setter call
using property dot-syntax.
Added:
cfe/trunk/test/CodeGenObjC/class-getter-dotsyntax.m
Modified:
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/CodeGen/CGObjC.cpp
Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=66556&r1=66555&r2=66556&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Tue Mar 10 13:03:11 2009
@@ -275,7 +275,11 @@
ObjCMethodDecl *getSetterMethod() const {
return Setter;
}
-
+
+ ObjCInterfaceDecl *getClassProp() const {
+ return ClassProp;
+ }
+
virtual SourceRange getSourceRange() const {
if (Base)
return SourceRange(getBase()->getLocStart(), Loc);
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=66556&r1=66555&r2=66556&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Mar 10 13:03:11 2009
@@ -327,10 +327,17 @@
else {
const ObjCKVCRefExpr *KE = cast<ObjCKVCRefExpr>(Exp);
Selector S = KE->getGetterMethod()->getSelector();
+ llvm::Value *Receiver;
+ if (KE->getClassProp()) {
+ const ObjCInterfaceDecl *OID = KE->getClassProp();
+ Receiver = CGM.getObjCRuntime().GetClass(Builder, OID);
+ }
+ else
+ Receiver = EmitScalarExpr(KE->getBase());
return CGM.getObjCRuntime().
GenerateMessageSend(*this, Exp->getType(), S,
- EmitScalarExpr(KE->getBase()),
- false, CallArgList());
+ Receiver,
+ KE->getClassProp() != 0, CallArgList());
}
}
@@ -348,10 +355,17 @@
else if (const ObjCKVCRefExpr *E = dyn_cast<ObjCKVCRefExpr>(Exp)) {
Selector S = E->getSetterMethod()->getSelector();
CallArgList Args;
+ llvm::Value *Receiver;
+ if (E->getClassProp()) {
+ const ObjCInterfaceDecl *OID = E->getClassProp();
+ Receiver = CGM.getObjCRuntime().GetClass(Builder, OID);
+ }
+ else
+ Receiver = EmitScalarExpr(E->getBase());
Args.push_back(std::make_pair(Src, E->getType()));
CGM.getObjCRuntime().GenerateMessageSend(*this, getContext().VoidTy, S,
- EmitScalarExpr(E->getBase()),
- false, Args);
+ Receiver,
+ E->getClassProp() != 0, Args);
}
else
assert (0 && "bad expression node in EmitObjCPropertySet");
Added: cfe/trunk/test/CodeGenObjC/class-getter-dotsyntax.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/class-getter-dotsyntax.m?rev=66556&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/class-getter-dotsyntax.m (added)
+++ cfe/trunk/test/CodeGenObjC/class-getter-dotsyntax.m Tue Mar 10 13:03:11 2009
@@ -0,0 +1,21 @@
+// RUN: clang -fnext-runtime -emit-llvm -o %t %s
+
+ at interface Test { }
++ (Test *)crash;
++ (void)setCrash: (int)value;
+ at end
+
+ at implementation Test
+static int _value;
+- (void)cachesPath
+{
+ static Test *cachesPath;
+
+ if (!cachesPath) {
+ Test *crash = Test.crash;
+ }
+}
++ (Test *)crash{ return 0; }
++ (void)setCrash: (int)value{ _value = value; }
+ at end
+
More information about the cfe-commits
mailing list