diff options
author | Steve Naroff <snaroff@apple.com> | 2009-03-09 21:12:44 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-03-09 21:12:44 +0000 |
commit | 61f72cbd037e58f12cfe90cd442373f44092f030 (patch) | |
tree | 77292f6d4c23460429428e75f3309d662856586f /include/clang | |
parent | 35bd763b9438b53f7920521ed19c1ef74c7a6795 (diff) |
Implement property '.' notation on Factory/Class objects. Parser changes aren't very pretty:-(
This fixes <rdar://problem/6496506> Implement class setter/getter for properties.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66465 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/AST/ExprObjC.h | 19 | ||||
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 14 | ||||
-rw-r--r-- | include/clang/Parse/Action.h | 8 |
3 files changed, 36 insertions, 5 deletions
diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index f74e2ab2f9..d312d539a8 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -205,7 +205,6 @@ private: ObjCPropertyDecl *AsProperty; SourceLocation IdLoc; Stmt *Base; - public: ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, SourceLocation l, Expr *base) @@ -249,7 +248,10 @@ private: ObjCMethodDecl *Setter; ObjCMethodDecl *Getter; SourceLocation Loc; + // FIXME: Swizzle these into a single pointer. Stmt *Base; + ObjCInterfaceDecl *ClassProp; + SourceLocation ClassLoc; public: ObjCKVCRefExpr(ObjCMethodDecl *getter, @@ -257,7 +259,14 @@ public: ObjCMethodDecl *setter, SourceLocation l, Expr *base) : Expr(ObjCKVCRefExprClass, t), Setter(setter), - Getter(getter), Loc(l), Base(base) { + Getter(getter), Loc(l), Base(base), ClassProp(0), ClassLoc(SourceLocation()) { + } + ObjCKVCRefExpr(ObjCMethodDecl *getter, + QualType t, + ObjCMethodDecl *setter, + SourceLocation l, ObjCInterfaceDecl *C, SourceLocation CL) + : Expr(ObjCKVCRefExprClass, t), Setter(setter), + Getter(getter), Loc(l), Base(0), ClassProp(C), ClassLoc(CL) { } ObjCMethodDecl *getGetterMethod() const { @@ -267,8 +276,10 @@ public: return Setter; } - virtual SourceRange getSourceRange() const { - return SourceRange(getBase()->getLocStart(), Loc); + virtual SourceRange getSourceRange() const { + if (Base) + return SourceRange(getBase()->getLocStart(), Loc); + return SourceRange(ClassLoc, Loc); } const Expr *getBase() const { return cast<Expr>(Base); } Expr *getBase() { return cast<Expr>(Base); } diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 32818a9137..7630811f21 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -428,7 +428,19 @@ public: Selector getNullarySelector(IdentifierInfo *ID) { return Selector(ID, 0); } - + + /// constructSetterName - Return the setter name for the given + /// identifier, i.e. "set" + Name where the initial character of Name + /// has been capitalized. + static IdentifierInfo *constructSetterName(IdentifierTable &Idents, + const IdentifierInfo *Name) { + llvm::SmallString<100> SelectorName; + SelectorName = "set"; + SelectorName.append(Name->getName(), Name->getName()+Name->getLength()); + SelectorName[3] = toupper(SelectorName[3]); + return &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]); + } + // Emit - Emit a SelectorTable to bitcode. void Emit(llvm::Serializer& S) const; diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 87faf4cf9e..906e50e439 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -1362,6 +1362,14 @@ public: return 0; } + virtual OwningExprResult ActOnClassPropertyRefExpr( + IdentifierInfo &receiverName, + IdentifierInfo &propertyName, + SourceLocation &receiverNameLoc, + SourceLocation &propertyNameLoc) { + return ExprEmpty(); + } + // ActOnClassMessage - used for both unary and keyword messages. // ArgExprs is optional - if it is present, the number of expressions // is obtained from NumArgs. |