ExprObjC.h revision 99b10be143e3148b9499af4c0e9ebaf46757cfe6
1f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff//===--- ExprObjC.h - Classes for representing ObjC expressions -*- C++ -*-===// 2f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// 3f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// The LLVM Compiler Infrastructure 4f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// 5f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// This file is distributed under the University of Illinois Open Source 6f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// License. See LICENSE.TXT for details. 7f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// 8f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff//===----------------------------------------------------------------------===// 9f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// 10f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// This file defines the ExprObjC interface and subclasses. 11f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff// 12f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff//===----------------------------------------------------------------------===// 13f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 14f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff#ifndef LLVM_CLANG_AST_EXPROBJC_H 15f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff#define LLVM_CLANG_AST_EXPROBJC_H 16f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 17f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff#include "clang/AST/Expr.h" 18c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/Basic/IdentifierTable.h" 19f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 20f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffnamespace clang { 21f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff class IdentifierInfo; 22f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff class ASTContext; 23e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar class ObjCMethodDecl; 24e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar class ObjCPropertyDecl; 25f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 26f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// ObjCStringLiteral, used for Objective-C string literals 27f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// i.e. @"foo". 28f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCStringLiteral : public Expr { 29c6c16af963eddc3e9b75b5d2614d069e1162fe27Chris Lattner Stmt *String; 30f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation AtLoc; 31f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic: 32f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L) 33f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff : Expr(ObjCStringLiteralClass, T), String(SL), AtLoc(L) {} 343a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner explicit ObjCStringLiteral(EmptyShell Empty) 353a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner : Expr(ObjCStringLiteralClass, Empty) {} 363a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner 3702d95baf23cbb29ea4ca58b3e8f54f92f845b900Anders Carlsson ObjCStringLiteral* Clone(ASTContext &C) const; 3802d95baf23cbb29ea4ca58b3e8f54f92f845b900Anders Carlsson 393a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner StringLiteral *getString() { return cast<StringLiteral>(String); } 403a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner const StringLiteral *getString() const { return cast<StringLiteral>(String); } 413a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setString(StringLiteral *S) { String = S; } 42f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 43f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getAtLoc() const { return AtLoc; } 443a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setAtLoc(SourceLocation L) { AtLoc = L; } 45f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 46f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual SourceRange getSourceRange() const { 47f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return SourceRange(AtLoc, String->getLocEnd()); 48f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 49f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 50f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const Stmt *T) { 51f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return T->getStmtClass() == ObjCStringLiteralClass; 52f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 53f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const ObjCStringLiteral *) { return true; } 54f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 55f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // Iterators 56f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_begin(); 57f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_end(); 58f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}; 59f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 60eaf2bb89eb2aad3b80673de30febe52df43c10ecChris Lattner/// ObjCEncodeExpr, used for @encode in Objective-C. @encode has the same type 61eaf2bb89eb2aad3b80673de30febe52df43c10ecChris Lattner/// and behavior as StringLiteral except that the string initializer is obtained 62eaf2bb89eb2aad3b80673de30febe52df43c10ecChris Lattner/// from ASTContext with the encoding type as an argument. 63f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCEncodeExpr : public Expr { 64f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff QualType EncType; 65f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation AtLoc, RParenLoc; 66f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic: 67f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCEncodeExpr(QualType T, QualType ET, 68f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation at, SourceLocation rp) 69fc0f021b492cf28ee7b3a6bd4445ae569e6f15deAnders Carlsson : Expr(ObjCEncodeExprClass, T, ET->isDependentType(), 70fc0f021b492cf28ee7b3a6bd4445ae569e6f15deAnders Carlsson ET->isDependentType()), EncType(ET), AtLoc(at), RParenLoc(rp) {} 71f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 724dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){} 734dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner 744dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner 75f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getAtLoc() const { return AtLoc; } 764dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner void setAtLoc(SourceLocation L) { AtLoc = L; } 77f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getRParenLoc() const { return RParenLoc; } 784dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner void setRParenLoc(SourceLocation L) { RParenLoc = L; } 794dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner 804dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner QualType getEncodedType() const { return EncType; } 814dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner void setEncodedType(QualType T) { EncType = T; } 824dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner 83f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 84f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual SourceRange getSourceRange() const { 85f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return SourceRange(AtLoc, RParenLoc); 86f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 874dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner 88f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const Stmt *T) { 89f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return T->getStmtClass() == ObjCEncodeExprClass; 90f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 91f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const ObjCEncodeExpr *) { return true; } 92f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 93f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // Iterators 94f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_begin(); 95f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_end(); 96f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}; 97f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 98f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// ObjCSelectorExpr used for @selector in Objective-C. 99f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCSelectorExpr : public Expr { 100f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Selector SelName; 101f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation AtLoc, RParenLoc; 102f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic: 103f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCSelectorExpr(QualType T, Selector selInfo, 104f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation at, SourceLocation rp) 1053a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner : Expr(ObjCSelectorExprClass, T), SelName(selInfo), AtLoc(at), RParenLoc(rp){} 1063a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner explicit ObjCSelectorExpr(EmptyShell Empty) 1073a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner : Expr(ObjCSelectorExprClass, Empty) {} 1083a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner 10902d95baf23cbb29ea4ca58b3e8f54f92f845b900Anders Carlsson ObjCSelectorExpr *Clone(ASTContext &C) const; 11002d95baf23cbb29ea4ca58b3e8f54f92f845b900Anders Carlsson 111f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Selector getSelector() const { return SelName; } 1123a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setSelector(Selector S) { SelName = S; } 113f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 114f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getAtLoc() const { return AtLoc; } 115f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getRParenLoc() const { return RParenLoc; } 1163a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setAtLoc(SourceLocation L) { AtLoc = L; } 1173a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setRParenLoc(SourceLocation L) { RParenLoc = L; } 118f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 119f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual SourceRange getSourceRange() const { 120f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return SourceRange(AtLoc, RParenLoc); 121f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 122f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 123f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff /// getNumArgs - Return the number of actual arguments to this call. 124f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff unsigned getNumArgs() const { return SelName.getNumArgs(); } 125f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 126f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const Stmt *T) { 127f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return T->getStmtClass() == ObjCSelectorExprClass; 128f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 129f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const ObjCSelectorExpr *) { return true; } 130f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 131f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // Iterators 132f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_begin(); 133f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_end(); 134f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}; 135f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 1363a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// ObjCProtocolExpr used for protocol expression in Objective-C. This is used 1373a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// as: @protocol(foo), as in: 1383a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// obj conformsToProtocol:@protocol(foo)] 1393a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// The return type is "Protocol*". 140f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCProtocolExpr : public Expr { 141262f9cf85294a1a0713420abc79d40f64aef7240Fariborz Jahanian ObjCProtocolDecl *TheProtocol; 142f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation AtLoc, RParenLoc; 143f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic: 144f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol, 145f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation at, SourceLocation rp) 146262f9cf85294a1a0713420abc79d40f64aef7240Fariborz Jahanian : Expr(ObjCProtocolExprClass, T), TheProtocol(protocol), 1473a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner AtLoc(at), RParenLoc(rp) {} 1483a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner explicit ObjCProtocolExpr(EmptyShell Empty) 1493a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner : Expr(ObjCProtocolExprClass, Empty) {} 1503a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner 15102d95baf23cbb29ea4ca58b3e8f54f92f845b900Anders Carlsson ObjCProtocolExpr *Clone(ASTContext &C) const; 15202d95baf23cbb29ea4ca58b3e8f54f92f845b900Anders Carlsson 153262f9cf85294a1a0713420abc79d40f64aef7240Fariborz Jahanian ObjCProtocolDecl *getProtocol() const { return TheProtocol; } 154262f9cf85294a1a0713420abc79d40f64aef7240Fariborz Jahanian void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; } 155f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 156f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getAtLoc() const { return AtLoc; } 157f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getRParenLoc() const { return RParenLoc; } 1583a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setAtLoc(SourceLocation L) { AtLoc = L; } 1593a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner void setRParenLoc(SourceLocation L) { RParenLoc = L; } 160f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 161f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual SourceRange getSourceRange() const { 162f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return SourceRange(AtLoc, RParenLoc); 163f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 164f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 165f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const Stmt *T) { 166f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return T->getStmtClass() == ObjCProtocolExprClass; 167f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 168f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const ObjCProtocolExpr *) { return true; } 169f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 170f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // Iterators 171f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_begin(); 172f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_end(); 173f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}; 174f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 175f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// ObjCIvarRefExpr - A reference to an ObjC instance variable. 176f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCIvarRefExpr : public Expr { 177aaa63a761c6671a08e3f4f463435b72739fa194bFariborz Jahanian class ObjCIvarDecl *D; 178f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation Loc; 1795549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek Stmt *Base; 180f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff bool IsArrow:1; // True if this is "X->F", false if this is "X.F". 181f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff bool IsFreeIvar:1; // True if ivar reference has no base (self assumed). 182f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 183f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic: 184efc4c4bdbd8fee90b93deb3b5cfaeb044ae22557Fariborz Jahanian ObjCIvarRefExpr(ObjCIvarDecl *d, 185aaa63a761c6671a08e3f4f463435b72739fa194bFariborz Jahanian QualType t, SourceLocation l, Expr *base=0, 186f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff bool arrow = false, bool freeIvar = false) : 187efc4c4bdbd8fee90b93deb3b5cfaeb044ae22557Fariborz Jahanian Expr(ObjCIvarRefExprClass, t), D(d), 188aaa63a761c6671a08e3f4f463435b72739fa194bFariborz Jahanian Loc(l), Base(base), IsArrow(arrow), 189f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff IsFreeIvar(freeIvar) {} 190f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 1910389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner explicit ObjCIvarRefExpr(EmptyShell Empty) 1920389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner : Expr(ObjCIvarRefExprClass, Empty) {} 1930389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 194f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCIvarDecl *getDecl() { return D; } 195f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff const ObjCIvarDecl *getDecl() const { return D; } 1960389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setDecl(ObjCIvarDecl *d) { D = d; } 1970389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 1985549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek const Expr *getBase() const { return cast<Expr>(Base); } 1995549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek Expr *getBase() { return cast<Expr>(Base); } 200f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff void setBase(Expr * base) { Base = base; } 2010389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 202f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff bool isArrow() const { return IsArrow; } 203f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff bool isFreeIvar() const { return IsFreeIvar; } 2040389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setIsArrow(bool A) { IsArrow = A; } 2050389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setIsFreeIvar(bool A) { IsFreeIvar = A; } 206f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 207f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation getLocation() const { return Loc; } 2080389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 2090389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 2100389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner virtual SourceRange getSourceRange() const { 2110389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner return isFreeIvar() ? SourceRange(Loc) 2120389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner : SourceRange(getBase()->getLocStart(), Loc); 2130389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner } 214f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 215f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const Stmt *T) { 216f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return T->getStmtClass() == ObjCIvarRefExprClass; 217f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 218f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const ObjCIvarRefExpr *) { return true; } 219f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 220f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // Iterators 221f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_begin(); 222f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_end(); 223f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}; 224f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 225e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar/// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC 2265daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// property. 227e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar/// 228ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroffclass ObjCPropertyRefExpr : public Expr { 229e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbarprivate: 2305daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian ObjCPropertyDecl *AsProperty; 231c77a636688e188af7e7a9a05829e542adb48e880Steve Naroff SourceLocation IdLoc; 2325549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek Stmt *Base; 233ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroffpublic: 234e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t, 235e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar SourceLocation l, Expr *base) 236c77a636688e188af7e7a9a05829e542adb48e880Steve Naroff : Expr(ObjCPropertyRefExprClass, t), AsProperty(PD), IdLoc(l), Base(base) { 237e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar } 238ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff 2390389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner explicit ObjCPropertyRefExpr(EmptyShell Empty) 2400389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner : Expr(ObjCPropertyRefExprClass, Empty) {} 2410389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 2420389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner ObjCPropertyDecl *getProperty() const { return AsProperty; } 2430389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setProperty(ObjCPropertyDecl *D) { AsProperty = D; } 2440389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 2455549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek const Expr *getBase() const { return cast<Expr>(Base); } 2465549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek Expr *getBase() { return cast<Expr>(Base); } 2470389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setBase(Expr *base) { Base = base; } 248ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff 249c77a636688e188af7e7a9a05829e542adb48e880Steve Naroff SourceLocation getLocation() const { return IdLoc; } 2500389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setLocation(SourceLocation L) { IdLoc = L; } 251ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff 2520389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner virtual SourceRange getSourceRange() const { 2530389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner return SourceRange(getBase()->getLocStart(), IdLoc); 2540389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner } 2550389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 256ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff static bool classof(const Stmt *T) { 257ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff return T->getStmtClass() == ObjCPropertyRefExprClass; 258ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff } 259ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff static bool classof(const ObjCPropertyRefExpr *) { return true; } 260ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff 261ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff // Iterators 262ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff virtual child_iterator child_begin(); 263ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff virtual child_iterator child_end(); 264ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff}; 265ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff 2665daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// ObjCKVCRefExpr - A dot-syntax expression to access "implicit" properties 2675daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// (i.e. methods following the property naming convention). KVC stands for 2685daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// Key Value Encoding, a generic concept for accessing or setting a 'Key' 2695daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// value for an object. 2705daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// 2715daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanianclass ObjCKVCRefExpr : public Expr { 2725daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian ObjCMethodDecl *Setter; 2735daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian ObjCMethodDecl *Getter; 2745daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian SourceLocation Loc; 27561f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff // FIXME: Swizzle these into a single pointer. 2765daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian Stmt *Base; 27761f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff ObjCInterfaceDecl *ClassProp; 27861f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff SourceLocation ClassLoc; 2795daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian 2805daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanianpublic: 2815daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian ObjCKVCRefExpr(ObjCMethodDecl *getter, 2825daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian QualType t, 283ba8d2d684e74a20bef03828c21c991d222c7e9e5Fariborz Jahanian ObjCMethodDecl *setter, 2845daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian SourceLocation l, Expr *base) 285ba8d2d684e74a20bef03828c21c991d222c7e9e5Fariborz Jahanian : Expr(ObjCKVCRefExprClass, t), Setter(setter), 2860389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner Getter(getter), Loc(l), Base(base), ClassProp(0), 2870389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner ClassLoc(SourceLocation()) { 28861f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff } 28961f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff ObjCKVCRefExpr(ObjCMethodDecl *getter, 29061f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff QualType t, 29161f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff ObjCMethodDecl *setter, 29261f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff SourceLocation l, ObjCInterfaceDecl *C, SourceLocation CL) 29361f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff : Expr(ObjCKVCRefExprClass, t), Setter(setter), 29461f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff Getter(getter), Loc(l), Base(0), ClassProp(C), ClassLoc(CL) { 2955daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian } 2960389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner explicit ObjCKVCRefExpr(EmptyShell Empty) : Expr(ObjCKVCRefExprClass, Empty){} 2973523d4f59eb0aa1f200dcb943093ecfe75008735Fariborz Jahanian 2980389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner ObjCMethodDecl *getGetterMethod() const { return Getter; } 2990389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner ObjCMethodDecl *getSetterMethod() const { return Setter; } 3000389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner ObjCInterfaceDecl *getClassProp() const { return ClassProp; } 3010389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setGetterMethod(ObjCMethodDecl *D) { Getter = D; } 3020389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setSetterMethod(ObjCMethodDecl *D) { Setter = D; } 3030389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setClassProp(ObjCInterfaceDecl *D) { ClassProp = D; } 3043523d4f59eb0aa1f200dcb943093ecfe75008735Fariborz Jahanian 30561f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff virtual SourceRange getSourceRange() const { 30661f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff if (Base) 30761f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff return SourceRange(getBase()->getLocStart(), Loc); 30861f72cbd037e58f12cfe90cd442373f44092f030Steve Naroff return SourceRange(ClassLoc, Loc); 3095daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian } 310405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor const Expr *getBase() const { return cast_or_null<Expr>(Base); } 311405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor Expr *getBase() { return cast_or_null<Expr>(Base); } 3120389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setBase(Expr *base) { Base = base; } 3135daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian 3145daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian SourceLocation getLocation() const { return Loc; } 3150389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setLocation(SourceLocation L) { Loc = L; } 3160389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner SourceLocation getClassLoc() const { return ClassLoc; } 3170389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setClassLoc(SourceLocation L) { ClassLoc = L; } 3185daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian 3195daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian static bool classof(const Stmt *T) { 3205daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian return T->getStmtClass() == ObjCKVCRefExprClass; 3215daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian } 3225daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian static bool classof(const ObjCKVCRefExpr *) { return true; } 3235daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian 3245daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian // Iterators 3255daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian virtual child_iterator child_begin(); 3265daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian virtual child_iterator child_end(); 3275daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian}; 3285daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian 329f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCMessageExpr : public Expr { 330be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek // SubExprs - The receiver and arguments of the message expression. 3315549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek Stmt **SubExprs; 332f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 333be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek // NumArgs - The number of arguments (not including the receiver) to the 334be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek // message expression. 335f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff unsigned NumArgs; 336f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 337f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // A unigue name for this message. 338f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Selector SelName; 339f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 340f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // A method prototype for this message (optional). 341f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // FIXME: Since method decls contain the selector, and most messages have a 342f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // prototype, consider devising a scheme for unifying SelName/MethodProto. 343f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCMethodDecl *MethodProto; 344f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 345f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation LBracloc, RBracloc; 346be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek 347be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek // Constants for indexing into SubExprs. 348be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek enum { RECEIVER=0, ARGS_START=1 }; 349be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek 3500389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner // Bit-swizzling flags. 351be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek enum { IsInstMeth=0, IsClsMethDeclUnknown, IsClsMethDeclKnown, Flags=0x3 }; 352be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek unsigned getFlag() const { return (uintptr_t) SubExprs[RECEIVER] & Flags; } 353f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 354f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic: 3554df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// This constructor is used to represent class messages where the 3564df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// ObjCInterfaceDecl* of the receiver is not known. 357f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo, 358f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff QualType retType, ObjCMethodDecl *methDecl, 359f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation LBrac, SourceLocation RBrac, 360f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Expr **ArgExprs, unsigned NumArgs); 3614df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek 3624df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// This constructor is used to represent class messages where the 3634df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// ObjCInterfaceDecl* of the receiver is known. 3644df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek // FIXME: clsName should be typed to ObjCInterfaceType 3654df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek ObjCMessageExpr(ObjCInterfaceDecl *cls, Selector selInfo, 3664df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek QualType retType, ObjCMethodDecl *methDecl, 3674df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek SourceLocation LBrac, SourceLocation RBrac, 3684df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek Expr **ArgExprs, unsigned NumArgs); 3694df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek 370f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // constructor for instance messages. 371f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCMessageExpr(Expr *receiver, Selector selInfo, 372f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff QualType retType, ObjCMethodDecl *methDecl, 373f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SourceLocation LBrac, SourceLocation RBrac, 374f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Expr **ArgExprs, unsigned NumArgs); 375c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff 376c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff explicit ObjCMessageExpr(EmptyShell Empty) 377405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor : Expr(ObjCMessageExprClass, Empty), SubExprs(0), NumArgs(0) {} 378f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 379f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ~ObjCMessageExpr() { 380f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff delete [] SubExprs; 381f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 382f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 383f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff /// getReceiver - Returns the receiver of the message expression. 384a75a8ea5b72ebdda5f651b57ae2c3b4e84b69253Ted Kremenek /// This can be NULL if the message is for class methods. For 385a75a8ea5b72ebdda5f651b57ae2c3b4e84b69253Ted Kremenek /// class methods, use getClassName. 386fc93d52ada07d52de0ad4fd051b6a08e21d421ffSteve Naroff /// FIXME: need to handle/detect 'super' usage within a class method. 387f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Expr *getReceiver() { 388f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff uintptr_t x = (uintptr_t) SubExprs[RECEIVER]; 3894df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek return (x & Flags) == IsInstMeth ? (Expr*) x : 0; 390f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 391f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff const Expr *getReceiver() const { 392f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return const_cast<ObjCMessageExpr*>(this)->getReceiver(); 393f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 394c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff // FIXME: need setters for different receiver types. 395c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff void setReceiver(Expr *rec) { SubExprs[RECEIVER] = rec; } 396f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Selector getSelector() const { return SelName; } 397c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff void setSelector(Selector S) { SelName = S; } 398c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff 399f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff const ObjCMethodDecl *getMethodDecl() const { return MethodProto; } 400f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff ObjCMethodDecl *getMethodDecl() { return MethodProto; } 401c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff void setMethodDecl(ObjCMethodDecl *MD) { MethodProto = MD; } 402c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff 4034df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek typedef std::pair<ObjCInterfaceDecl*, IdentifierInfo*> ClassInfo; 4044df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek 4054df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// getClassInfo - For class methods, this returns both the ObjCInterfaceDecl* 4064df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// and IdentifierInfo* of the invoked class. Both can be NULL if this 4074df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// is an instance message, and the ObjCInterfaceDecl* can be NULL if none 4084df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek /// was available when this ObjCMessageExpr object was constructed. 4090389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner ClassInfo getClassInfo() const; 4100389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setClassInfo(const ClassInfo &C); 411f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 412a75a8ea5b72ebdda5f651b57ae2c3b4e84b69253Ted Kremenek /// getClassName - For class methods, this returns the invoked class, 413a75a8ea5b72ebdda5f651b57ae2c3b4e84b69253Ted Kremenek /// and returns NULL otherwise. For instance methods, use getReceiver. 4144df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek IdentifierInfo *getClassName() const { 4154df728e368fa1f65ffc57572fed613dcca5b4fe8Ted Kremenek return getClassInfo().second; 416f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 417f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 418f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff /// getNumArgs - Return the number of actual arguments to this call. 419f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff unsigned getNumArgs() const { return NumArgs; } 420405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor void setNumArgs(unsigned nArgs) { 421405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor NumArgs = nArgs; 422405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor // FIXME: should always allocate SubExprs via the ASTContext's 423405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor // allocator. 424405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor if (!SubExprs) 425405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor SubExprs = new Stmt* [NumArgs + 1]; 426405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor } 427c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff 428f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff /// getArg - Return the specified argument. 429f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff Expr *getArg(unsigned Arg) { 430f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff assert(Arg < NumArgs && "Arg access out of range!"); 4315549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek return cast<Expr>(SubExprs[Arg+ARGS_START]); 432f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 433f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff const Expr *getArg(unsigned Arg) const { 434f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff assert(Arg < NumArgs && "Arg access out of range!"); 4355549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek return cast<Expr>(SubExprs[Arg+ARGS_START]); 436f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 437f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff /// setArg - Set the specified argument. 438f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff void setArg(unsigned Arg, Expr *ArgExpr) { 439f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff assert(Arg < NumArgs && "Arg access out of range!"); 440f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff SubExprs[Arg+ARGS_START] = ArgExpr; 441f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 4420389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 4430389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner SourceLocation getLeftLoc() const { return LBracloc; } 4440389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner SourceLocation getRightLoc() const { return RBracloc; } 445f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 4460389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setLeftLoc(SourceLocation L) { LBracloc = L; } 4470389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setRightLoc(SourceLocation L) { RBracloc = L; } 4480389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 449c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff void setSourceRange(SourceRange R) { 450c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff LBracloc = R.getBegin(); 451c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff RBracloc = R.getEnd(); 452c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff } 453f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual SourceRange getSourceRange() const { 454f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return SourceRange(LBracloc, RBracloc); 455f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 456f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 457f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const Stmt *T) { 458f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff return T->getStmtClass() == ObjCMessageExprClass; 459f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff } 460f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff static bool classof(const ObjCMessageExpr *) { return true; } 461f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 462f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff // Iterators 463f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_begin(); 464f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff virtual child_iterator child_end(); 465f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 4665549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek typedef ExprIterator arg_iterator; 4675549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek typedef ConstExprIterator const_arg_iterator; 468f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 469f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff arg_iterator arg_begin() { return &SubExprs[ARGS_START]; } 4705549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek arg_iterator arg_end() { return &SubExprs[ARGS_START] + NumArgs; } 471f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff const_arg_iterator arg_begin() const { return &SubExprs[ARGS_START]; } 4725549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek const_arg_iterator arg_end() const { return &SubExprs[ARGS_START] + NumArgs; } 473f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}; 474f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 475cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor/// ObjCSuperExpr - Represents the "super" expression in Objective-C, 476cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor/// which refers to the object on which the current method is executing. 477cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregorclass ObjCSuperExpr : public Expr { 478cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor SourceLocation Loc; 479cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregorpublic: 480cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor ObjCSuperExpr(SourceLocation L, QualType Type) 481cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor : Expr(ObjCSuperExprClass, Type), Loc(L) { } 4820389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner explicit ObjCSuperExpr(EmptyShell Empty) : Expr(ObjCSuperExprClass, Empty) {} 483cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor 4840389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner SourceLocation getLoc() const { return Loc; } 4850389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner void setLoc(SourceLocation L) { Loc = L; } 4860389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner 487cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 488cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor 489cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor static bool classof(const Stmt *T) { 490cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor return T->getStmtClass() == ObjCSuperExprClass; 491cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor } 492cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor static bool classof(const ObjCSuperExpr *) { return true; } 493cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor 494cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor // Iterators 495cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor virtual child_iterator child_begin(); 496cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor virtual child_iterator child_end(); 497cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor}; 498cd9b46e5442a3ef17f83f75177d8545cb5b3e2b9Douglas Gregor 49999b10be143e3148b9499af4c0e9ebaf46757cfe6Steve Naroff/// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type. 50099b10be143e3148b9499af4c0e9ebaf46757cfe6Steve Naroff/// (similiar in spirit to MemberExpr). 501f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroffclass ObjCIsaExpr : public Expr { 502f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff /// Base - the expression for the base object pointer. 503f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff Stmt *Base; 504f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 505f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff /// IsaMemberLoc - This is the location of the 'isa'. 506f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff SourceLocation IsaMemberLoc; 507f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 508f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff /// IsArrow - True if this is "X->F", false if this is "X.F". 509f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff bool IsArrow; 510f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroffpublic: 511f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty) 512f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff : Expr(ObjCIsaExprClass, ty), 513f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff Base(base), IsaMemberLoc(l), IsArrow(isarrow) {} 514f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 515f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff /// \brief Build an empty expression. 516f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) { } 517f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 518f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff void setBase(Expr *E) { Base = E; } 519f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff Expr *getBase() const { return cast<Expr>(Base); } 520f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 521f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff bool isArrow() const { return IsArrow; } 522f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff void setArrow(bool A) { IsArrow = A; } 523f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 524f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff /// getMemberLoc - Return the location of the "member", in X->F, it is the 525f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff /// location of 'F'. 526f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } 527f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } 528f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 529f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff virtual SourceRange getSourceRange() const { 530f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff return SourceRange(getBase()->getLocStart(), IsaMemberLoc); 531f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff } 532f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 533f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff virtual SourceLocation getExprLoc() const { return IsaMemberLoc; } 534f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 535f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff static bool classof(const Stmt *T) { 536f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff return T->getStmtClass() == ObjCIsaExprClass; 537f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff } 538f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff static bool classof(const ObjCIsaExpr *) { return true; } 539f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 540f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff // Iterators 541f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff virtual child_iterator child_begin(); 542f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff virtual child_iterator child_end(); 543f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff}; 544f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff 545f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff} // end namespace clang 546f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff 547f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff#endif 548