ExprObjC.h revision bebbe0d9b7568ce43a464286bee49429489ef483
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
1712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall#include "clang/AST/DeclObjC.h"
18f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff#include "clang/AST/Expr.h"
19c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbar#include "clang/Basic/IdentifierTable.h"
20f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
21f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffnamespace clang {
22f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  class IdentifierInfo;
23f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  class ASTContext;
241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
25f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// ObjCStringLiteral, used for Objective-C string literals
26f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// i.e. @"foo".
27f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCStringLiteral : public Expr {
28c6c16af963eddc3e9b75b5d2614d069e1162fe27Chris Lattner  Stmt *String;
29f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation AtLoc;
30f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic:
31f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
32bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : Expr(ObjCStringLiteralClass, T, VK_RValue, OK_Ordinary, false, false,
33bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false),
34f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall      String(SL), AtLoc(L) {}
353a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  explicit ObjCStringLiteral(EmptyShell Empty)
363a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner    : Expr(ObjCStringLiteralClass, Empty) {}
373a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner
383a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  StringLiteral *getString() { return cast<StringLiteral>(String); }
393a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  const StringLiteral *getString() const { return cast<StringLiteral>(String); }
403a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setString(StringLiteral *S) { String = S; }
41f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
42f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getAtLoc() const { return AtLoc; }
433a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setAtLoc(SourceLocation L) { AtLoc = L; }
44f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual SourceRange getSourceRange() const {
46f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return SourceRange(AtLoc, String->getLocEnd());
47f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == ObjCStringLiteralClass;
51f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const ObjCStringLiteral *) { return true; }
531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
54f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  // Iterators
55f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_begin();
56f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_end();
57f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff};
581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
59eaf2bb89eb2aad3b80673de30febe52df43c10ecChris Lattner/// ObjCEncodeExpr, used for @encode in Objective-C.  @encode has the same type
60eaf2bb89eb2aad3b80673de30febe52df43c10ecChris Lattner/// and behavior as StringLiteral except that the string initializer is obtained
61eaf2bb89eb2aad3b80673de30febe52df43c10ecChris Lattner/// from ASTContext with the encoding type as an argument.
62f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCEncodeExpr : public Expr {
6381d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor  TypeSourceInfo *EncodedType;
64f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation AtLoc, RParenLoc;
65f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic:
6681d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor  ObjCEncodeExpr(QualType T, TypeSourceInfo *EncodedType,
67f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff                 SourceLocation at, SourceLocation rp)
68f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(ObjCEncodeExprClass, T, VK_LValue, OK_Ordinary,
69f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall           EncodedType->getType()->isDependentType(),
70bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           EncodedType->getType()->isDependentType(),
71bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           EncodedType->getType()->containsUnexpandedParameterPack()),
7281d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor      EncodedType(EncodedType), AtLoc(at), RParenLoc(rp) {}
731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
744dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner  explicit ObjCEncodeExpr(EmptyShell Empty) : Expr(ObjCEncodeExprClass, Empty){}
754dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner
761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
77f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getAtLoc() const { return AtLoc; }
784dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner  void setAtLoc(SourceLocation L) { AtLoc = L; }
79f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getRParenLoc() const { return RParenLoc; }
804dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
8281d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor  QualType getEncodedType() const { return EncodedType->getType(); }
834dcf151a555ff51e4d643e8e6eeb80f121d11d1bChris Lattner
8481d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor  TypeSourceInfo *getEncodedTypeSourceInfo() const { return EncodedType; }
8581d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor  void setEncodedTypeSourceInfo(TypeSourceInfo *EncType) {
8681d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor    EncodedType = EncType;
8781d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor  }
881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
89f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual SourceRange getSourceRange() const {
90f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return SourceRange(AtLoc, RParenLoc);
91f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
93f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const Stmt *T) {
94f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return T->getStmtClass() == ObjCEncodeExprClass;
95f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
96f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const ObjCEncodeExpr *) { return true; }
971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
98f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  // Iterators
99f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_begin();
100f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_end();
101f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff};
102f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
103f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// ObjCSelectorExpr used for @selector in Objective-C.
104f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCSelectorExpr : public Expr {
105f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  Selector SelName;
106f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation AtLoc, RParenLoc;
107f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic:
108f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  ObjCSelectorExpr(QualType T, Selector selInfo,
109f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff                   SourceLocation at, SourceLocation rp)
110bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : Expr(ObjCSelectorExprClass, T, VK_RValue, OK_Ordinary, false, false,
111bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false),
112f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    SelName(selInfo), AtLoc(at), RParenLoc(rp){}
1133a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  explicit ObjCSelectorExpr(EmptyShell Empty)
1143a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner   : Expr(ObjCSelectorExprClass, Empty) {}
1153a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner
116f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  Selector getSelector() const { return SelName; }
1173a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setSelector(Selector S) { SelName = S; }
1181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
119f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getAtLoc() const { return AtLoc; }
120f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getRParenLoc() const { return RParenLoc; }
1213a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setAtLoc(SourceLocation L) { AtLoc = L; }
1223a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
123f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
124f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual SourceRange getSourceRange() const {
125f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return SourceRange(AtLoc, RParenLoc);
126f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
1271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
128f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  /// getNumArgs - Return the number of actual arguments to this call.
129f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
131f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const Stmt *T) {
132f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return T->getStmtClass() == ObjCSelectorExprClass;
133f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
134f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const ObjCSelectorExpr *) { return true; }
1351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
136f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  // Iterators
137f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_begin();
138f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_end();
139f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff};
1401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1413a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// ObjCProtocolExpr used for protocol expression in Objective-C.  This is used
1423a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// as: @protocol(foo), as in:
1433a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner///   obj conformsToProtocol:@protocol(foo)]
1443a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner/// The return type is "Protocol*".
1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumpclass ObjCProtocolExpr : public Expr {
1461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCProtocolDecl *TheProtocol;
147f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation AtLoc, RParenLoc;
148f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic:
149f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  ObjCProtocolExpr(QualType T, ObjCProtocolDecl *protocol,
150f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff                   SourceLocation at, SourceLocation rp)
151bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : Expr(ObjCProtocolExprClass, T, VK_RValue, OK_Ordinary, false, false,
152bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           false),
153bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor      TheProtocol(protocol), AtLoc(at), RParenLoc(rp) {}
1543a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  explicit ObjCProtocolExpr(EmptyShell Empty)
1553a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner    : Expr(ObjCProtocolExprClass, Empty) {}
1563a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner
157262f9cf85294a1a0713420abc79d40f64aef7240Fariborz Jahanian  ObjCProtocolDecl *getProtocol() const { return TheProtocol; }
158262f9cf85294a1a0713420abc79d40f64aef7240Fariborz Jahanian  void setProtocol(ObjCProtocolDecl *P) { TheProtocol = P; }
1591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
160f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getAtLoc() const { return AtLoc; }
161f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getRParenLoc() const { return RParenLoc; }
1623a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setAtLoc(SourceLocation L) { AtLoc = L; }
1633a57a3765b6192a94ff4e5997ae0489a1471b308Chris Lattner  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
164f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
165f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual SourceRange getSourceRange() const {
166f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return SourceRange(AtLoc, RParenLoc);
167f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
1681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
169f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const Stmt *T) {
170f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return T->getStmtClass() == ObjCProtocolExprClass;
171f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
172f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const ObjCProtocolExpr *) { return true; }
1731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
174f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  // Iterators
175f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_begin();
176f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_end();
177f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff};
178f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
179f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff/// ObjCIvarRefExpr - A reference to an ObjC instance variable.
180f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCIvarRefExpr : public Expr {
181aaa63a761c6671a08e3f4f463435b72739fa194bFariborz Jahanian  class ObjCIvarDecl *D;
182f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation Loc;
1835549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Stmt *Base;
184f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  bool IsArrow:1;      // True if this is "X->F", false if this is "X.F".
185f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  bool IsFreeIvar:1;   // True if ivar reference has no base (self assumed).
1861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
187f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffpublic:
188f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ObjCIvarRefExpr(ObjCIvarDecl *d, QualType t,
189f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                  SourceLocation l, Expr *base,
1901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump                  bool arrow = false, bool freeIvar = false) :
191f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    Expr(ObjCIvarRefExprClass, t, VK_LValue, OK_Ordinary,
192bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor         /*TypeDependent=*/false, base->isValueDependent(),
193bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor         base->containsUnexpandedParameterPack()),
194bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    D(d), Loc(l), Base(base), IsArrow(arrow), IsFreeIvar(freeIvar) {}
1951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1960389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  explicit ObjCIvarRefExpr(EmptyShell Empty)
1970389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner    : Expr(ObjCIvarRefExprClass, Empty) {}
1980389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner
199f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  ObjCIvarDecl *getDecl() { return D; }
200f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  const ObjCIvarDecl *getDecl() const { return D; }
2010389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  void setDecl(ObjCIvarDecl *d) { D = d; }
2021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2035549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  const Expr *getBase() const { return cast<Expr>(Base); }
2045549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  Expr *getBase() { return cast<Expr>(Base); }
205f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  void setBase(Expr * base) { Base = base; }
2061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
207f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  bool isArrow() const { return IsArrow; }
208f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  bool isFreeIvar() const { return IsFreeIvar; }
2090389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  void setIsArrow(bool A) { IsArrow = A; }
2100389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  void setIsFreeIvar(bool A) { IsFreeIvar = A; }
2111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
212f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  SourceLocation getLocation() const { return Loc; }
2130389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  void setLocation(SourceLocation L) { Loc = L; }
2140389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner
2151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual SourceRange getSourceRange() const {
2160389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner    return isFreeIvar() ? SourceRange(Loc)
2171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    : SourceRange(getBase()->getLocStart(), Loc);
2180389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  }
2191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
2211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == ObjCIvarRefExprClass;
222f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
223f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const ObjCIvarRefExpr *) { return true; }
2241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
225f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  // Iterators
226f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_begin();
227f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_end();
228f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff};
229f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
230e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar/// ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC
2315daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian/// property.
232e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar///
233ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroffclass ObjCPropertyRefExpr : public Expr {
234e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbarprivate:
23512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  /// If the bool is true, this is an implicit property reference; the
23612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  /// pointer is an (optional) ObjCMethodDecl and Setter may be set.
23712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  /// if the bool is false, this is an explicit property reference;
23812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  /// the pointer is an ObjCPropertyDecl and Setter is always null.
23912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  llvm::PointerIntPair<NamedDecl*, 1, bool> PropertyOrGetter;
24012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCMethodDecl *Setter;
24112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
242c77a636688e188af7e7a9a05829e542adb48e880Steve Naroff  SourceLocation IdLoc;
2438ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian
2448ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  /// \brief When the receiver in property access is 'super', this is
24512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  /// the location of the 'super' keyword.  When it's an interface,
24612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  /// this is that interface.
24712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  SourceLocation ReceiverLoc;
24812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  llvm::PointerUnion3<Stmt*, Type*, ObjCInterfaceDecl*> Receiver;
2498ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian
250ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroffpublic:
2511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
252f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                      ExprValueKind VK, ExprObjectKind OK,
253e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar                      SourceLocation l, Expr *base)
254f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(ObjCPropertyRefExprClass, t, VK, OK,
255bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           /*TypeDependent=*/false, base->isValueDependent(),
256bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           base->containsUnexpandedParameterPack()),
25712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      PropertyOrGetter(PD, false), Setter(0),
25812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      IdLoc(l), ReceiverLoc(), Receiver(base) {
2598ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  }
2608ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian
2618ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
262f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                      ExprValueKind VK, ExprObjectKind OK,
2638ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian                      SourceLocation l, SourceLocation sl, QualType st)
26412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    : Expr(ObjCPropertyRefExprClass, t, VK, OK,
265bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           /*TypeDependent=*/false, false,
266bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           st->containsUnexpandedParameterPack()),
26712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      PropertyOrGetter(PD, false), Setter(0),
26812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      IdLoc(l), ReceiverLoc(sl), Receiver(st.getTypePtr()) {
26912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
27012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
27112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
27212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      QualType T, ExprValueKind VK, ExprObjectKind OK,
27312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      SourceLocation IdLoc, Expr *Base)
27412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    : Expr(ObjCPropertyRefExprClass, T, VK, OK, false,
275bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Base->isValueDependent(),
276bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           Base->containsUnexpandedParameterPack()),
27712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      PropertyOrGetter(Getter, true), Setter(Setter),
27812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      IdLoc(IdLoc), ReceiverLoc(), Receiver(Base) {
27912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
28012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
28112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
28212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      QualType T, ExprValueKind VK, ExprObjectKind OK,
28312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      SourceLocation IdLoc,
28412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      SourceLocation SuperLoc, QualType SuperTy)
285bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false),
28612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      PropertyOrGetter(Getter, true), Setter(Setter),
28712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      IdLoc(IdLoc), ReceiverLoc(SuperLoc), Receiver(SuperTy.getTypePtr()) {
28812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
28912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
29012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCPropertyRefExpr(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter,
29112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      QualType T, ExprValueKind VK, ExprObjectKind OK,
29212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      SourceLocation IdLoc,
29312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                      SourceLocation ReceiverLoc, ObjCInterfaceDecl *Receiver)
294bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor    : Expr(ObjCPropertyRefExprClass, T, VK, OK, false, false, false),
29512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      PropertyOrGetter(Getter, true), Setter(Setter),
29612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      IdLoc(IdLoc), ReceiverLoc(ReceiverLoc), Receiver(Receiver) {
297e66f4e3e3ae9d7d11b0c302211066fad69228abaDaniel Dunbar  }
2981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2990389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  explicit ObjCPropertyRefExpr(EmptyShell Empty)
3000389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner    : Expr(ObjCPropertyRefExprClass, Empty) {}
3010389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner
30212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  bool isImplicitProperty() const { return PropertyOrGetter.getInt(); }
30312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  bool isExplicitProperty() const { return !PropertyOrGetter.getInt(); }
30412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
30512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCPropertyDecl *getExplicitProperty() const {
30612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    assert(!isImplicitProperty());
30712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return cast<ObjCPropertyDecl>(PropertyOrGetter.getPointer());
30812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
30912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
31012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCMethodDecl *getImplicitPropertyGetter() const {
31112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    assert(isImplicitProperty());
31212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return cast_or_null<ObjCMethodDecl>(PropertyOrGetter.getPointer());
31312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
31412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
31512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCMethodDecl *getImplicitPropertySetter() const {
31612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    assert(isImplicitProperty());
31712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return Setter;
31812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
31912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
32012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  Selector getGetterSelector() const {
32112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    if (isImplicitProperty())
32212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      return getImplicitPropertyGetter()->getSelector();
32312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return getExplicitProperty()->getGetterName();
32412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
32512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall
32612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  Selector getSetterSelector() const {
32712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    if (isImplicitProperty())
32812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall      return getImplicitPropertySetter()->getSelector();
32912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return getExplicitProperty()->getSetterName();
33012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
3311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3328ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  const Expr *getBase() const {
33312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return cast<Expr>(Receiver.get<Stmt*>());
3348ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  }
3358ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  Expr *getBase() {
33612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return cast<Expr>(Receiver.get<Stmt*>());
3378ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  }
3381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
339c77a636688e188af7e7a9a05829e542adb48e880Steve Naroff  SourceLocation getLocation() const { return IdLoc; }
3408ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian
34112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  SourceLocation getReceiverLocation() const { return ReceiverLoc; }
34212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  QualType getSuperReceiverType() const {
34312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return QualType(Receiver.get<Type*>(), 0);
3448ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  }
34512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  ObjCInterfaceDecl *getClassReceiver() const {
34612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return Receiver.get<ObjCInterfaceDecl*>();
34712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  }
34812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
34912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  bool isSuperReceiver() const { return Receiver.is<Type*>(); }
35012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
351ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff
3520389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  virtual SourceRange getSourceRange() const {
35312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    return SourceRange((isObjectReceiver() ? getBase()->getLocStart()
35412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                                           : getReceiverLocation()),
35512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall                       IdLoc);
3560389e6bd0159bfdd08f7c50a37543b6e3adf0c33Chris Lattner  }
3571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
3591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == ObjCPropertyRefExprClass;
360ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff  }
361ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff  static bool classof(const ObjCPropertyRefExpr *) { return true; }
3621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
363ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff  // Iterators
364ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff  virtual child_iterator child_begin();
365ae7840776d6cd31b4d7a4a345b61bcbb3744df6cSteve Naroff  virtual child_iterator child_end();
366f8730d7c313c421d5d7a2b9d97541fc89d5a52d4Ted Kremenekprivate:
367f8730d7c313c421d5d7a2b9d97541fc89d5a52d4Ted Kremenek  friend class ASTStmtReader;
36812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setExplicitProperty(ObjCPropertyDecl *D) {
36912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    PropertyOrGetter.setPointer(D);
37012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    PropertyOrGetter.setInt(false);
37112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    Setter = 0;
3728ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian  }
37312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setImplicitProperty(ObjCMethodDecl *Getter, ObjCMethodDecl *Setter) {
37412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    PropertyOrGetter.setPointer(Getter);
37512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    PropertyOrGetter.setInt(true);
37612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall    this->Setter = Setter;
3775daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian  }
37812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setBase(Expr *Base) { Receiver = Base; }
37912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setSuperReceiver(QualType T) { Receiver = T.getTypePtr(); }
38012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setClassReceiver(ObjCInterfaceDecl *D) { Receiver = D; }
3811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
38212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setLocation(SourceLocation L) { IdLoc = L; }
38312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall  void setReceiverLocation(SourceLocation Loc) { ReceiverLoc = Loc; }
3845daf570d0ce027e18ed5f9d66e6b2a14a40b720dFariborz Jahanian};
3851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3862725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// \brief An expression that sends a message to the given Objective-C
3872725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// object or class.
3882725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///
3892725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// The following contains two message send expressions:
3902725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///
3912725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// \code
3922725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///   [[NSString alloc] initWithString:@"Hello"]
3932725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// \endcode
3942725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///
3952725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// The innermost message send invokes the "alloc" class method on the
3962725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// NSString class, while the outermost message send invokes the
3972725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// "initWithString" instance method on the object returned from
3982725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// NSString's "alloc". In all, an Objective-C message send can take
3992725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// on four different (although related) forms:
4002725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///
4012725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///   1. Send to an object instance.
4022725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///   2. Send to a class.
4032725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///   3. Send to the superclass instance of the current class.
4042725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///   4. Send to the superclass of the current class.
4052725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///
4062725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// All four kinds of message sends are modeled by the ObjCMessageExpr
4072725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor/// class, and can be distinguished via \c getReceiverKind(). Example:
4082725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor///
409f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroffclass ObjCMessageExpr : public Expr {
41004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief The number of arguments in the message send, not
41104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// including the receiver.
41204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  unsigned NumArgs : 16;
41304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
41404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief The kind of message send this is, which is one of the
41504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// ReceiverKind values.
41604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
41704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// We pad this out to a byte to avoid excessive masking and shifting.
41804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  unsigned Kind : 8;
41904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
42004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Whether we have an actual method prototype in \c
42104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// SelectorOrMethod.
42204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
42304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// When non-zero, we have a method declaration; otherwise, we just
42404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// have a selector.
42504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  unsigned HasMethod : 8;
42604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
42704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief When the message expression is a send to 'super', this is
42804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// the location of the 'super' keyword.
42904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  SourceLocation SuperLoc;
43004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
43104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Stores either the selector that this message is sending
43204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// to (when \c HasMethod is zero) or an \c ObjCMethodDecl pointer
43304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// referring to the method that we type-checked against.
43404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  uintptr_t SelectorOrMethod;
43504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
436f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis  /// \brief Location of the selector.
437f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis  SourceLocation SelectorLoc;
438f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis
43904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief The source locations of the open and close square
44004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// brackets ('[' and ']', respectively).
44104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  SourceLocation LBracLoc, RBracLoc;
44204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
44304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ObjCMessageExpr(EmptyShell Empty, unsigned NumArgs)
44404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    : Expr(ObjCMessageExprClass, Empty), NumArgs(NumArgs), Kind(0),
44504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      HasMethod(0), SelectorOrMethod(0) { }
44604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
447f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ObjCMessageExpr(QualType T, ExprValueKind VK,
44804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation LBracLoc,
44904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation SuperLoc,
45004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  bool IsInstanceSuper,
45104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  QualType SuperType,
45204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Selector Sel,
453f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis                  SourceLocation SelLoc,
45404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  ObjCMethodDecl *Method,
45504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Expr **Args, unsigned NumArgs,
45604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation RBracLoc);
457f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ObjCMessageExpr(QualType T, ExprValueKind VK,
45804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation LBracLoc,
45904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  TypeSourceInfo *Receiver,
46004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Selector Sel,
461f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis                  SourceLocation SelLoc,
46204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  ObjCMethodDecl *Method,
46304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Expr **Args, unsigned NumArgs,
46404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation RBracLoc);
465f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ObjCMessageExpr(QualType T, ExprValueKind VK,
46604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation LBracLoc,
46704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Expr *Receiver,
46804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Selector Sel,
469f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis                  SourceLocation SelLoc,
47004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  ObjCMethodDecl *Method,
47104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  Expr **Args, unsigned NumArgs,
47204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                  SourceLocation RBracLoc);
47304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
4742725ca8eb3354975ca77ed4b88ede7b60b216b9aDouglas Gregor  /// \brief Retrieve the pointer value of the message receiver.
47504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void *getReceiverPointer() const {
47604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return *const_cast<void **>(
47704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                             reinterpret_cast<const void * const*>(this + 1));
47804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
4791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
48004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Set the pointer value of the message receiver.
48104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void setReceiverPointer(void *Value) {
48204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    *reinterpret_cast<void **>(this + 1) = Value;
48304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
4841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
48504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregorpublic:
48604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief The kind of receiver this message is sending to.
48704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  enum ReceiverKind {
48804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    /// \brief The receiver is a class.
48904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    Class = 0,
49004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    /// \brief The receiver is an object instance.
49104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    Instance,
49204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    /// \brief The receiver is a superclass.
49304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    SuperClass,
49404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    /// \brief The receiver is the instance of the superclass object.
49504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    SuperInstance
49604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  };
497c2350e553b853ad00914faf23fa731e5fc4a8a5cDouglas Gregor
49804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Create a message send to super.
49904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
50004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Context The ASTContext in which this expression will be created.
50104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
50204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param T The result type of this message.
50304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
504f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// \param VK The value kind of this message.  A message returning
505f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// a l-value or r-value reference will be an l-value or x-value,
506f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// respectively.
507f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ///
50804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param LBrac The location of the open square bracket '['.
50904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
51004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param SuperLoc The location of the "super" keyword.
51104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
51204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param IsInstanceSuper Whether this is an instance "super"
51304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// message (otherwise, it's a class "super" message).
51404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
51504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Sel The selector used to determine which method gets called.
51604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
51704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Method The Objective-C method against which this message
51804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// send was type-checked. May be NULL.
51904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
52004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Args The message send arguments.
52104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
52204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param NumArgs The number of arguments.
52304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
52404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param RBracLoc The location of the closing square bracket ']'.
525f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  static ObjCMessageExpr *Create(ASTContext &Context, QualType T,
526f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                 ExprValueKind VK,
52704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation LBracLoc,
52804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation SuperLoc,
52904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 bool IsInstanceSuper,
53004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 QualType SuperType,
53104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Selector Sel,
532f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis                                 SourceLocation SelLoc,
53304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 ObjCMethodDecl *Method,
53404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Expr **Args, unsigned NumArgs,
53504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation RBracLoc);
53604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
53704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Create a class message send.
53804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
53904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Context The ASTContext in which this expression will be created.
54004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
54104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param T The result type of this message.
54204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
543f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// \param VK The value kind of this message.  A message returning
544f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// a l-value or r-value reference will be an l-value or x-value,
545f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// respectively.
546f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ///
54704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param LBrac The location of the open square bracket '['.
54804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
54904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Receiver The type of the receiver, including
55004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// source-location information.
55104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
55204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Sel The selector used to determine which method gets called.
55304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
55404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Method The Objective-C method against which this message
55504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// send was type-checked. May be NULL.
55604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
55704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Args The message send arguments.
55804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
55904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param NumArgs The number of arguments.
56004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
56104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param RBracLoc The location of the closing square bracket ']'.
56204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  static ObjCMessageExpr *Create(ASTContext &Context, QualType T,
563f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                 ExprValueKind VK,
56404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation LBracLoc,
56504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 TypeSourceInfo *Receiver,
56604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Selector Sel,
567f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis                                 SourceLocation SelLoc,
56804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 ObjCMethodDecl *Method,
56904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Expr **Args, unsigned NumArgs,
57004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation RBracLoc);
57104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
57204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Create an instance message send.
57304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
57404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Context The ASTContext in which this expression will be created.
57504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
57604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param T The result type of this message.
57704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
578f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// \param VK The value kind of this message.  A message returning
579f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// a l-value or r-value reference will be an l-value or x-value,
580f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  /// respectively.
581f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall  ///
58204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param LBrac The location of the open square bracket '['.
58304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
58404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Receiver The expression used to produce the object that
58504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// will receive this message.
58604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
58704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Sel The selector used to determine which method gets called.
58804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
58904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Method The Objective-C method against which this message
59004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// send was type-checked. May be NULL.
59104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
59204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Args The message send arguments.
59304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
59404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param NumArgs The number of arguments.
59504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
59604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param RBracLoc The location of the closing square bracket ']'.
59704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  static ObjCMessageExpr *Create(ASTContext &Context, QualType T,
598f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall                                 ExprValueKind VK,
59904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation LBracLoc,
60004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Expr *Receiver,
60104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Selector Sel,
602f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis                                 SourceLocation SelLoc,
60304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 ObjCMethodDecl *Method,
60404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 Expr **Args, unsigned NumArgs,
60504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor                                 SourceLocation RBracLoc);
60604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
60704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Create an empty Objective-C message expression, to be
60804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// filled in by subsequent calls.
60904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
61004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param Context The context in which the message send will be created.
61104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
61204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \param NumArgs The number of message arguments, not including
61304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// the receiver.
61404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  static ObjCMessageExpr *CreateEmpty(ASTContext &Context, unsigned NumArgs);
61504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
61604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Determine the kind of receiver that this message is being
61704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// sent to.
61804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ReceiverKind getReceiverKind() const { return (ReceiverKind)Kind; }
61904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
620e005d19456e6fb73ace33f25e02ac10e22dd063fArgyrios Kyrtzidis  /// \brief Source range of the receiver.
621e005d19456e6fb73ace33f25e02ac10e22dd063fArgyrios Kyrtzidis  SourceRange getReceiverRange() const;
622e005d19456e6fb73ace33f25e02ac10e22dd063fArgyrios Kyrtzidis
62304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Determine whether this is an instance message to either a
62404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// computed object or to super.
62504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  bool isInstanceMessage() const {
62604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return getReceiverKind() == Instance || getReceiverKind() == SuperInstance;
62704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
6281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
62904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Determine whether this is an class message to either a
63004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// specified class or to super.
63104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  bool isClassMessage() const {
63204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return getReceiverKind() == Class || getReceiverKind() == SuperClass;
63304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
634f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
63504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Returns the receiver of an instance message.
63604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
63704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Returns the object expression for an instance message, or
63804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// NULL for a message that is not an instance message.
63904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  Expr *getInstanceReceiver() {
64004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (getReceiverKind() == Instance)
64104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return static_cast<Expr *>(getReceiverPointer());
642be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek
64304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return 0;
64404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
64504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  const Expr *getInstanceReceiver() const {
64604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return const_cast<ObjCMessageExpr*>(this)->getInstanceReceiver();
64704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
648be78424edfbc6095c4acb83c7ae7f53a42f0c870Ted Kremenek
64904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Turn this message send into an instance message that
65004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// computes the receiver object with the given expression.
65104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void setInstanceReceiver(Expr *rec) {
65204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    Kind = Instance;
65304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    setReceiverPointer(rec);
65404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
65504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
65604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Returns the type of a class message send, or NULL if the
65704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// message is not a class message.
65804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  QualType getClassReceiver() const {
65904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (TypeSourceInfo *TSInfo = getClassReceiverTypeInfo())
66004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return TSInfo->getType();
66104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
66204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return QualType();
66304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
6641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
66504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Returns a type-source information of a class message
66604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// send, or NULL if the message is not a class message.
66704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  TypeSourceInfo *getClassReceiverTypeInfo() const {
66804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (getReceiverKind() == Class)
66904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return reinterpret_cast<TypeSourceInfo *>(getReceiverPointer());
67004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return 0;
67104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
6721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
67304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void setClassReceiver(TypeSourceInfo *TSInfo) {
67404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    Kind = Class;
67504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    setReceiverPointer(TSInfo);
67604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
67704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
67804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Retrieve the location of the 'super' keyword for a class
67904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// or instance message to 'super', otherwise an invalid source location.
68004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  SourceLocation getSuperLoc() const {
68104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
68204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return SuperLoc;
6831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
68404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return SourceLocation();
68504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
686c2350e553b853ad00914faf23fa731e5fc4a8a5cDouglas Gregor
68704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Retrieve the Objective-C interface to which this message
68804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// is being directed, if known.
68904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
69004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// This routine cross-cuts all of the different kinds of message
69104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// sends to determine what the underlying (statically known) type
69204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// of the receiver will be; use \c getReceiverKind() to determine
69304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// whether the message is a class or an instance method, whether it
69404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// is a send to super or not, etc.
69504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
69604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \returns The Objective-C interface if known, otherwise NULL.
69704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ObjCInterfaceDecl *getReceiverInterface() const;
69804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
69904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Retrieve the type referred to by 'super'.
70004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ///
70104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// The returned type will either be an ObjCInterfaceType (for an
70204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// class message to super) or an ObjCObjectPointerType that refers
70304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// to a class (for an instance message to super);
70404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  QualType getSuperType() const {
70504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (getReceiverKind() == SuperInstance || getReceiverKind() == SuperClass)
70604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return QualType::getFromOpaquePtr(getReceiverPointer());
70704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
70804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return QualType();
70904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
710c2350e553b853ad00914faf23fa731e5fc4a8a5cDouglas Gregor
71104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void setSuper(SourceLocation Loc, QualType T, bool IsInstanceSuper) {
71204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    Kind = IsInstanceSuper? SuperInstance : SuperClass;
71304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    SuperLoc = Loc;
71404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    setReceiverPointer(T.getAsOpaquePtr());
71504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
716c2350e553b853ad00914faf23fa731e5fc4a8a5cDouglas Gregor
71704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  Selector getSelector() const;
718c2350e553b853ad00914faf23fa731e5fc4a8a5cDouglas Gregor
71904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void setSelector(Selector S) {
72004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    HasMethod = false;
72104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    SelectorOrMethod = reinterpret_cast<uintptr_t>(S.getAsOpaquePtr());
72204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
7231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
72404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  const ObjCMethodDecl *getMethodDecl() const {
72504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (HasMethod)
72604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return reinterpret_cast<const ObjCMethodDecl *>(SelectorOrMethod);
7271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
72804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return 0;
729f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
7301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
73104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  ObjCMethodDecl *getMethodDecl() {
73204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    if (HasMethod)
73304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor      return reinterpret_cast<ObjCMethodDecl *>(SelectorOrMethod);
73404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
73504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return 0;
73604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
73704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
73804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  void setMethodDecl(ObjCMethodDecl *MD) {
73904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    HasMethod = true;
74004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    SelectorOrMethod = reinterpret_cast<uintptr_t>(MD);
74104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
74204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
74304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Return the number of actual arguments in this message,
74404badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// not counting the receiver.
745f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  unsigned getNumArgs() const { return NumArgs; }
74604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor
74704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// \brief Retrieve the arguments to this message, not including the
74804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  /// receiver.
74904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  Stmt **getArgs() {
75004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return reinterpret_cast<Stmt **>(this + 1) + 1;
75104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  }
75204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  const Stmt * const *getArgs() const {
75304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return reinterpret_cast<const Stmt * const *>(this + 1) + 1;
754405bad07391494d2eb025f8222c256c66b56e5f8Douglas Gregor  }
7551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
756f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  /// getArg - Return the specified argument.
757f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  Expr *getArg(unsigned Arg) {
758f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    assert(Arg < NumArgs && "Arg access out of range!");
75904badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return cast<Expr>(getArgs()[Arg]);
760f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
761f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  const Expr *getArg(unsigned Arg) const {
762f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    assert(Arg < NumArgs && "Arg access out of range!");
76304badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return cast<Expr>(getArgs()[Arg]);
764f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
765f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  /// setArg - Set the specified argument.
766f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  void setArg(unsigned Arg, Expr *ArgExpr) {
767f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    assert(Arg < NumArgs && "Arg access out of range!");
76804badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    getArgs()[Arg] = ArgExpr;
769f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
7701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
77104badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  SourceLocation getLeftLoc() const { return LBracLoc; }
77204badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  SourceLocation getRightLoc() const { return RBracLoc; }
773f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis  SourceLocation getSelectorLoc() const { return SelectorLoc; }
7741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
775c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff  void setSourceRange(SourceRange R) {
77604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    LBracLoc = R.getBegin();
77704badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    RBracLoc = R.getEnd();
778c4f0bbdb166fbc31ab2cf0f6ff573fde9fa307b3Steve Naroff  }
779f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual SourceRange getSourceRange() const {
78004badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor    return SourceRange(LBracLoc, RBracLoc);
781f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
782f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
783f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const Stmt *T) {
784f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff    return T->getStmtClass() == ObjCMessageExprClass;
785f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  }
786f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  static bool classof(const ObjCMessageExpr *) { return true; }
7871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
788f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  // Iterators
789f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_begin();
790f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff  virtual child_iterator child_end();
7911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
7925549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  typedef ExprIterator arg_iterator;
7935549976193e34417d4474a5f4a514268ef6666c7Ted Kremenek  typedef ConstExprIterator const_arg_iterator;
7941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
79504badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  arg_iterator arg_begin() { return getArgs(); }
79604badcf84c8d504d8491c7c7e29b58f52cb16640Douglas Gregor  arg_iterator arg_end()   { return getArgs() + NumArgs; }
7971705fe9ec0efb65f77a46e669e48302923204fe8Benjamin Kramer  const_arg_iterator arg_begin() const { return getArgs(); }
7981705fe9ec0efb65f77a46e669e48302923204fe8Benjamin Kramer  const_arg_iterator arg_end() const { return getArgs() + NumArgs; }
799f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis
800f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis  friend class ASTStmtReader;
801f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis  friend class ASTStmtWriter;
802f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff};
803f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
80499b10be143e3148b9499af4c0e9ebaf46757cfe6Steve Naroff/// ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
80599b10be143e3148b9499af4c0e9ebaf46757cfe6Steve Naroff/// (similiar in spirit to MemberExpr).
806f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroffclass ObjCIsaExpr : public Expr {
807f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  /// Base - the expression for the base object pointer.
808f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  Stmt *Base;
8091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
810f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  /// IsaMemberLoc - This is the location of the 'isa'.
811f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  SourceLocation IsaMemberLoc;
8121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
813f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  /// IsArrow - True if this is "X->F", false if this is "X.F".
814f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  bool IsArrow;
815f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroffpublic:
8161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  ObjCIsaExpr(Expr *base, bool isarrow, SourceLocation l, QualType ty)
817f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall    : Expr(ObjCIsaExprClass, ty, VK_LValue, OK_Ordinary,
818bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           /*TypeDependent=*/false, base->isValueDependent(),
819bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor           /*ContainsUnexpandedParameterPack=*/false),
820f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff      Base(base), IsaMemberLoc(l), IsArrow(isarrow) {}
8211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
822f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  /// \brief Build an empty expression.
823f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  explicit ObjCIsaExpr(EmptyShell Empty) : Expr(ObjCIsaExprClass, Empty) { }
8241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
825f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  void setBase(Expr *E) { Base = E; }
826f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  Expr *getBase() const { return cast<Expr>(Base); }
8271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
828f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  bool isArrow() const { return IsArrow; }
829f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  void setArrow(bool A) { IsArrow = A; }
830f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff
831f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  /// getMemberLoc - Return the location of the "member", in X->F, it is the
832f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  /// location of 'F'.
833f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
834f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
835f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff
836f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  virtual SourceRange getSourceRange() const {
837f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff    return SourceRange(getBase()->getLocStart(), IsaMemberLoc);
838f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  }
8391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
840f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  virtual SourceLocation getExprLoc() const { return IsaMemberLoc; }
841f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff
8421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  static bool classof(const Stmt *T) {
8431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    return T->getStmtClass() == ObjCIsaExprClass;
844f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  }
845f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  static bool classof(const ObjCIsaExpr *) { return true; }
8461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
847f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  // Iterators
848f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  virtual child_iterator child_begin();
849f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff  virtual child_iterator child_end();
850f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff};
851f242b1b0c4e998911cb96b2ba7e27ab4a5abaed3Steve Naroff
852f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff}  // end namespace clang
853f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff
854f494b579b22f9950f5af021f0bf9879a91bb8b41Steve Naroff#endif
855