diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-10 18:03:11 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-10 18:03:11 +0000 |
commit | 3523d4f59eb0aa1f200dcb943093ecfe75008735 (patch) | |
tree | d87fe28137732cfc503a472f3eec963e07faff85 | |
parent | 4a77edb3f0fabc8e214a3d5636c4d0aff031645c (diff) |
ir-gen support for class getter/setter call
using property dot-syntax.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66556 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/ExprObjC.h | 6 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 22 | ||||
-rw-r--r-- | test/CodeGenObjC/class-getter-dotsyntax.m | 21 |
3 files changed, 44 insertions, 5 deletions
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index d312d539a8..5775cab3ba 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -275,7 +275,11 @@ public: ObjCMethodDecl *getSetterMethod() const { return Setter; } - + + ObjCInterfaceDecl *getClassProp() const { + return ClassProp; + } + virtual SourceRange getSourceRange() const { if (Base) return SourceRange(getBase()->getLocStart(), Loc); diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 5798865077..aa1f4c2494 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -327,10 +327,17 @@ RValue CodeGenFunction::EmitObjCPropertyGet(const Expr *Exp) { 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 @@ void CodeGenFunction::EmitObjCPropertySet(const Expr *Exp, 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"); diff --git a/test/CodeGenObjC/class-getter-dotsyntax.m b/test/CodeGenObjC/class-getter-dotsyntax.m new file mode 100644 index 0000000000..54ed890cc4 --- /dev/null +++ b/test/CodeGenObjC/class-getter-dotsyntax.m @@ -0,0 +1,21 @@ +// RUN: clang -fnext-runtime -emit-llvm -o %t %s + +@interface Test { } ++ (Test *)crash; ++ (void)setCrash: (int)value; +@end + +@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; } +@end + |