Expr.h revision 9971c9ace70624987cd74645a75f4bfbc05afdf2
1//===--- Expr.h - Classes for representing expressions ----------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines the Expr interface and subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_EXPR_H
15#define LLVM_CLANG_AST_EXPR_H
16
17#include "clang/AST/Stmt.h"
18#include "clang/AST/Type.h"
19#include "clang/AST/Decl.h"
20#include "clang/Basic/IdentifierTable.h"
21#include "llvm/ADT/APSInt.h"
22#include "llvm/ADT/APFloat.h"
23
24namespace clang {
25  class IdentifierInfo;
26  class Selector;
27  class Decl;
28  class ASTContext;
29
30/// Expr - This represents one expression.  Note that Expr's are subclasses of
31/// Stmt.  This allows an expression to be transparently used any place a Stmt
32/// is required.
33///
34class Expr : public Stmt {
35  QualType TR;
36protected:
37  Expr(StmtClass SC, QualType T) : Stmt(SC), TR(T) {}
38public:
39  QualType getType() const { return TR; }
40  void setType(QualType t) { TR = t; }
41
42  /// SourceLocation tokens are not useful in isolation - they are low level
43  /// value objects created/interpreted by SourceManager. We assume AST
44  /// clients will have a pointer to the respective SourceManager.
45  virtual SourceRange getSourceRange() const = 0;
46
47  /// getExprLoc - Return the preferred location for the arrow when diagnosing
48  /// a problem with a generic expression.
49  virtual SourceLocation getExprLoc() const { return getLocStart(); }
50
51  /// hasLocalSideEffect - Return true if this immediate expression has side
52  /// effects, not counting any sub-expressions.
53  bool hasLocalSideEffect() const;
54
55  /// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or
56  /// incomplete type other than void. Nonarray expressions that can be lvalues:
57  ///  - name, where name must be a variable
58  ///  - e[i]
59  ///  - (e), where e must be an lvalue
60  ///  - e.name, where e must be an lvalue
61  ///  - e->name
62  ///  - *e, the type of e cannot be a function type
63  ///  - string-constant
64  ///  - reference type [C++ [expr]]
65  ///
66  enum isLvalueResult {
67    LV_Valid,
68    LV_NotObjectType,
69    LV_IncompleteVoidType,
70    LV_DuplicateVectorComponents,
71    LV_InvalidExpression
72  };
73  isLvalueResult isLvalue() const;
74
75  /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type,
76  /// does not have an incomplete type, does not have a const-qualified type,
77  /// and if it is a structure or union, does not have any member (including,
78  /// recursively, any member or element of all contained aggregates or unions)
79  /// with a const-qualified type.
80  enum isModifiableLvalueResult {
81    MLV_Valid,
82    MLV_NotObjectType,
83    MLV_IncompleteVoidType,
84    MLV_DuplicateVectorComponents,
85    MLV_InvalidExpression,
86    MLV_IncompleteType,
87    MLV_ConstQualified,
88    MLV_ArrayType
89  };
90  isModifiableLvalueResult isModifiableLvalue() const;
91
92  bool isNullPointerConstant(ASTContext &Ctx) const;
93
94  /// isIntegerConstantExpr - Return true if this expression is a valid integer
95  /// constant expression, and, if so, return its value in Result.  If not a
96  /// valid i-c-e, return false and fill in Loc (if specified) with the location
97  /// of the invalid expression.
98  bool isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
99                             SourceLocation *Loc = 0,
100                             bool isEvaluated = true) const;
101  bool isIntegerConstantExpr(ASTContext &Ctx, SourceLocation *Loc = 0) const {
102    llvm::APSInt X(32);
103    return isIntegerConstantExpr(X, Ctx, Loc);
104  }
105  /// isConstantExpr - Return true if this expression is a valid constant expr.
106  bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const;
107
108  static bool classof(const Stmt *T) {
109    return T->getStmtClass() >= firstExprConstant &&
110           T->getStmtClass() <= lastExprConstant;
111  }
112  static bool classof(const Expr *) { return true; }
113
114  static inline Expr* Materialize(llvm::Deserializer& D) {
115    return cast<Expr>(Stmt::Materialize(D));
116  }
117};
118
119//===----------------------------------------------------------------------===//
120// Primary Expressions.
121//===----------------------------------------------------------------------===//
122
123/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function,
124/// enum, etc.
125class DeclRefExpr : public Expr {
126  ValueDecl *D;
127  SourceLocation Loc;
128public:
129  DeclRefExpr(ValueDecl *d, QualType t, SourceLocation l) :
130    Expr(DeclRefExprClass, t), D(d), Loc(l) {}
131
132  ValueDecl *getDecl() { return D; }
133  const ValueDecl *getDecl() const { return D; }
134  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
135
136
137  static bool classof(const Stmt *T) {
138    return T->getStmtClass() == DeclRefExprClass;
139  }
140  static bool classof(const DeclRefExpr *) { return true; }
141
142  // Iterators
143  virtual child_iterator child_begin();
144  virtual child_iterator child_end();
145
146  virtual void directEmit(llvm::Serializer& S) const;
147  static DeclRefExpr* directMaterialize(llvm::Deserializer& D);
148};
149
150/// PreDefinedExpr - [C99 6.4.2.2] - A pre-defined identifier such as __func__.
151class PreDefinedExpr : public Expr {
152public:
153  enum IdentType {
154    Func,
155    Function,
156    PrettyFunction
157  };
158
159private:
160  SourceLocation Loc;
161  IdentType Type;
162public:
163  PreDefinedExpr(SourceLocation l, QualType type, IdentType IT)
164    : Expr(PreDefinedExprClass, type), Loc(l), Type(IT) {}
165
166  IdentType getIdentType() const { return Type; }
167
168  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
169
170  static bool classof(const Stmt *T) {
171    return T->getStmtClass() == PreDefinedExprClass;
172  }
173  static bool classof(const PreDefinedExpr *) { return true; }
174
175  // Iterators
176  virtual child_iterator child_begin();
177  virtual child_iterator child_end();
178
179  virtual void directEmit(llvm::Serializer& S) const;
180  static PreDefinedExpr* directMaterialize(llvm::Deserializer& D);
181};
182
183class IntegerLiteral : public Expr {
184  llvm::APInt Value;
185  SourceLocation Loc;
186public:
187  // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy,
188  // or UnsignedLongLongTy
189  IntegerLiteral(const llvm::APInt &V, QualType type, SourceLocation l)
190    : Expr(IntegerLiteralClass, type), Value(V), Loc(l) {
191    assert(type->isIntegerType() && "Illegal type in IntegerLiteral");
192  }
193  const llvm::APInt &getValue() const { return Value; }
194  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
195
196  static bool classof(const Stmt *T) {
197    return T->getStmtClass() == IntegerLiteralClass;
198  }
199  static bool classof(const IntegerLiteral *) { return true; }
200
201  // Iterators
202  virtual child_iterator child_begin();
203  virtual child_iterator child_end();
204
205  virtual void directEmit(llvm::Serializer& S) const;
206  static IntegerLiteral* directMaterialize(llvm::Deserializer& D);
207};
208
209class CharacterLiteral : public Expr {
210  unsigned Value;
211  SourceLocation Loc;
212public:
213  // type should be IntTy
214  CharacterLiteral(unsigned value, QualType type, SourceLocation l)
215    : Expr(CharacterLiteralClass, type), Value(value), Loc(l) {
216  }
217  SourceLocation getLoc() const { return Loc; }
218
219  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
220
221  unsigned getValue() const { return Value; }
222
223  static bool classof(const Stmt *T) {
224    return T->getStmtClass() == CharacterLiteralClass;
225  }
226  static bool classof(const CharacterLiteral *) { return true; }
227
228  // Iterators
229  virtual child_iterator child_begin();
230  virtual child_iterator child_end();
231
232  virtual void directEmit(llvm::Serializer& S) const;
233  static CharacterLiteral* directMaterialize(llvm::Deserializer& D);
234};
235
236class FloatingLiteral : public Expr {
237  llvm::APFloat Value;
238  SourceLocation Loc;
239public:
240  FloatingLiteral(const llvm::APFloat &V, QualType Type, SourceLocation L)
241    : Expr(FloatingLiteralClass, Type), Value(V), Loc(L) {}
242
243  const llvm::APFloat &getValue() const { return Value; }
244
245  /// getValueAsDouble - This returns the value as an inaccurate double.  Note
246  /// that this may cause loss of precision, but is useful for debugging dumps
247  /// etc.
248  double getValueAsDouble() const {
249    // FIXME: We need something for long double here.
250    if (cast<BuiltinType>(getType())->getKind() == BuiltinType::Float)
251      return Value.convertToFloat();
252    else
253      return Value.convertToDouble();
254  }
255
256  virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
257
258  static bool classof(const Stmt *T) {
259    return T->getStmtClass() == FloatingLiteralClass;
260  }
261  static bool classof(const FloatingLiteral *) { return true; }
262
263  // Iterators
264  virtual child_iterator child_begin();
265  virtual child_iterator child_end();
266
267  virtual void directEmit(llvm::Serializer& S) const;
268  static FloatingLiteral* directMaterialize(llvm::Deserializer& D);
269};
270
271/// ImaginaryLiteral - We support imaginary integer and floating point literals,
272/// like "1.0i".  We represent these as a wrapper around FloatingLiteral and
273/// IntegerLiteral classes.  Instances of this class always have a Complex type
274/// whose element type matches the subexpression.
275///
276class ImaginaryLiteral : public Expr {
277  Expr *Val;
278public:
279  ImaginaryLiteral(Expr *val, QualType Ty)
280    : Expr(ImaginaryLiteralClass, Ty), Val(val) {}
281
282  const Expr *getSubExpr() const { return Val; }
283  Expr *getSubExpr() { return Val; }
284
285  virtual SourceRange getSourceRange() const { return Val->getSourceRange(); }
286  static bool classof(const Stmt *T) {
287    return T->getStmtClass() == ImaginaryLiteralClass;
288  }
289  static bool classof(const ImaginaryLiteral *) { return true; }
290
291  // Iterators
292  virtual child_iterator child_begin();
293  virtual child_iterator child_end();
294
295  virtual void directEmit(llvm::Serializer& S) const;
296  static ImaginaryLiteral* directMaterialize(llvm::Deserializer& D);
297};
298
299/// StringLiteral - This represents a string literal expression, e.g. "foo"
300/// or L"bar" (wide strings).  The actual string is returned by getStrData()
301/// is NOT null-terminated, and the length of the string is determined by
302/// calling getByteLength().
303class StringLiteral : public Expr {
304  const char *StrData;
305  unsigned ByteLength;
306  bool IsWide;
307  // if the StringLiteral was composed using token pasting, both locations
308  // are needed. If not (the common case), firstTokLoc == lastTokLoc.
309  // FIXME: if space becomes an issue, we should create a sub-class.
310  SourceLocation firstTokLoc, lastTokLoc;
311public:
312  StringLiteral(const char *strData, unsigned byteLength, bool Wide,
313                QualType t, SourceLocation b, SourceLocation e);
314  virtual ~StringLiteral();
315
316  const char *getStrData() const { return StrData; }
317  unsigned getByteLength() const { return ByteLength; }
318  bool isWide() const { return IsWide; }
319
320  virtual SourceRange getSourceRange() const {
321    return SourceRange(firstTokLoc,lastTokLoc);
322  }
323  static bool classof(const Stmt *T) {
324    return T->getStmtClass() == StringLiteralClass;
325  }
326  static bool classof(const StringLiteral *) { return true; }
327
328  // Iterators
329  virtual child_iterator child_begin();
330  virtual child_iterator child_end();
331
332  virtual void directEmit(llvm::Serializer& S) const;
333  static StringLiteral* directMaterialize(llvm::Deserializer& D);
334};
335
336/// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This
337/// AST node is only formed if full location information is requested.
338class ParenExpr : public Expr {
339  SourceLocation L, R;
340  Expr *Val;
341public:
342  ParenExpr(SourceLocation l, SourceLocation r, Expr *val)
343    : Expr(ParenExprClass, val->getType()), L(l), R(r), Val(val) {}
344
345  const Expr *getSubExpr() const { return Val; }
346  Expr *getSubExpr() { return Val; }
347  SourceRange getSourceRange() const { return SourceRange(L, R); }
348
349  static bool classof(const Stmt *T) {
350    return T->getStmtClass() == ParenExprClass;
351  }
352  static bool classof(const ParenExpr *) { return true; }
353
354  // Iterators
355  virtual child_iterator child_begin();
356  virtual child_iterator child_end();
357
358  virtual void directEmit(llvm::Serializer& S) const;
359  static ParenExpr* directMaterialize(llvm::Deserializer& D);
360};
361
362
363/// UnaryOperator - This represents the unary-expression's (except sizeof of
364/// types), the postinc/postdec operators from postfix-expression, and various
365/// extensions.
366///
367/// Notes on various nodes:
368///
369/// Real/Imag - These return the real/imag part of a complex operand.  If
370///   applied to a non-complex value, the former returns its operand and the
371///   later returns zero in the type of the operand.
372///
373/// __builtin_offsetof(type, a.b[10]) is represented as a unary operator whose
374///   subexpression is a compound literal with the various MemberExpr and
375///   ArraySubscriptExpr's applied to it.
376///
377class UnaryOperator : public Expr {
378public:
379  // Note that additions to this should also update the StmtVisitor class.
380  enum Opcode {
381    PostInc, PostDec, // [C99 6.5.2.4] Postfix increment and decrement operators
382    PreInc, PreDec,   // [C99 6.5.3.1] Prefix increment and decrement operators.
383    AddrOf, Deref,    // [C99 6.5.3.2] Address and indirection operators.
384    Plus, Minus,      // [C99 6.5.3.3] Unary arithmetic operators.
385    Not, LNot,        // [C99 6.5.3.3] Unary arithmetic operators.
386    SizeOf, AlignOf,  // [C99 6.5.3.4] Sizeof (expr, not type) operator.
387    Real, Imag,       // "__real expr"/"__imag expr" Extension.
388    Extension,        // __extension__ marker.
389    OffsetOf          // __builtin_offsetof
390  };
391private:
392  Expr *Val;
393  Opcode Opc;
394  SourceLocation Loc;
395public:
396
397  UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l)
398    : Expr(UnaryOperatorClass, type), Val(input), Opc(opc), Loc(l) {}
399
400  Opcode getOpcode() const { return Opc; }
401  Expr *getSubExpr() const { return Val; }
402
403  /// getOperatorLoc - Return the location of the operator.
404  SourceLocation getOperatorLoc() const { return Loc; }
405
406  /// isPostfix - Return true if this is a postfix operation, like x++.
407  static bool isPostfix(Opcode Op);
408
409  bool isPostfix() const { return isPostfix(Opc); }
410  bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; }
411  bool isSizeOfAlignOfOp() const { return Opc == SizeOf || Opc == AlignOf; }
412  static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; }
413
414  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
415  /// corresponds to, e.g. "sizeof" or "[pre]++"
416  static const char *getOpcodeStr(Opcode Op);
417
418  virtual SourceRange getSourceRange() const {
419    if (isPostfix())
420      return SourceRange(Val->getLocStart(), Loc);
421    else
422      return SourceRange(Loc, Val->getLocEnd());
423  }
424  virtual SourceLocation getExprLoc() const { return Loc; }
425
426  static bool classof(const Stmt *T) {
427    return T->getStmtClass() == UnaryOperatorClass;
428  }
429  static bool classof(const UnaryOperator *) { return true; }
430
431  // Iterators
432  virtual child_iterator child_begin();
433  virtual child_iterator child_end();
434};
435
436/// SizeOfAlignOfTypeExpr - [C99 6.5.3.4] - This is only for sizeof/alignof of
437/// *types*.  sizeof(expr) is handled by UnaryOperator.
438class SizeOfAlignOfTypeExpr : public Expr {
439  bool isSizeof;  // true if sizeof, false if alignof.
440  QualType Ty;
441  SourceLocation OpLoc, RParenLoc;
442public:
443  SizeOfAlignOfTypeExpr(bool issizeof, QualType argType, QualType resultType,
444                        SourceLocation op, SourceLocation rp) :
445    Expr(SizeOfAlignOfTypeExprClass, resultType),
446    isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {}
447
448  bool isSizeOf() const { return isSizeof; }
449  QualType getArgumentType() const { return Ty; }
450
451  SourceLocation getOperatorLoc() const { return OpLoc; }
452  SourceRange getSourceRange() const { return SourceRange(OpLoc, RParenLoc); }
453
454  static bool classof(const Stmt *T) {
455    return T->getStmtClass() == SizeOfAlignOfTypeExprClass;
456  }
457  static bool classof(const SizeOfAlignOfTypeExpr *) { return true; }
458
459  // Iterators
460  virtual child_iterator child_begin();
461  virtual child_iterator child_end();
462};
463
464//===----------------------------------------------------------------------===//
465// Postfix Operators.
466//===----------------------------------------------------------------------===//
467
468/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
469class ArraySubscriptExpr : public Expr {
470  enum { LHS, RHS, END_EXPR=2 };
471  Expr* SubExprs[END_EXPR];
472  SourceLocation RBracketLoc;
473public:
474  ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t,
475                     SourceLocation rbracketloc)
476  : Expr(ArraySubscriptExprClass, t), RBracketLoc(rbracketloc) {
477    SubExprs[LHS] = lhs;
478    SubExprs[RHS] = rhs;
479  }
480
481  /// An array access can be written A[4] or 4[A] (both are equivalent).
482  /// - getBase() and getIdx() always present the normalized view: A[4].
483  ///    In this case getBase() returns "A" and getIdx() returns "4".
484  /// - getLHS() and getRHS() present the syntactic view. e.g. for
485  ///    4[A] getLHS() returns "4".
486
487  Expr *getLHS() { return SubExprs[LHS]; }
488  const Expr *getLHS() const { return SubExprs[LHS]; }
489
490  Expr *getRHS() { return SubExprs[RHS]; }
491  const Expr *getRHS() const { return SubExprs[RHS]; }
492
493  Expr *getBase() {
494    return (getLHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
495  }
496
497  const Expr *getBase() const {
498    return (getLHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
499  }
500
501  Expr *getIdx() {
502    return (getLHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
503  }
504
505  const Expr *getIdx() const {
506    return (getLHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
507  }
508
509
510  SourceRange getSourceRange() const {
511    return SourceRange(getLHS()->getLocStart(), RBracketLoc);
512  }
513  virtual SourceLocation getExprLoc() const { return RBracketLoc; }
514
515  static bool classof(const Stmt *T) {
516    return T->getStmtClass() == ArraySubscriptExprClass;
517  }
518  static bool classof(const ArraySubscriptExpr *) { return true; }
519
520  // Iterators
521  virtual child_iterator child_begin();
522  virtual child_iterator child_end();
523};
524
525
526/// CallExpr - [C99 6.5.2.2] Function Calls.
527///
528class CallExpr : public Expr {
529  enum { FN=0, ARGS_START=1 };
530  Expr **SubExprs;
531  unsigned NumArgs;
532  SourceLocation RParenLoc;
533public:
534  CallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
535           SourceLocation rparenloc);
536  ~CallExpr() {
537    delete [] SubExprs;
538  }
539
540  const Expr *getCallee() const { return SubExprs[FN]; }
541  Expr *getCallee() { return SubExprs[FN]; }
542
543  /// getNumArgs - Return the number of actual arguments to this call.
544  ///
545  unsigned getNumArgs() const { return NumArgs; }
546
547  /// getArg - Return the specified argument.
548  Expr *getArg(unsigned Arg) {
549    assert(Arg < NumArgs && "Arg access out of range!");
550    return SubExprs[Arg+ARGS_START];
551  }
552  const Expr *getArg(unsigned Arg) const {
553    assert(Arg < NumArgs && "Arg access out of range!");
554    return SubExprs[Arg+ARGS_START];
555  }
556  /// setArg - Set the specified argument.
557  void setArg(unsigned Arg, Expr *ArgExpr) {
558    assert(Arg < NumArgs && "Arg access out of range!");
559    SubExprs[Arg+ARGS_START] = ArgExpr;
560  }
561  /// getNumCommas - Return the number of commas that must have been present in
562  /// this function call.
563  unsigned getNumCommas() const { return NumArgs ? NumArgs - 1 : 0; }
564
565  bool isBuiltinClassifyType(llvm::APSInt &Result) const;
566
567  SourceRange getSourceRange() const {
568    return SourceRange(getCallee()->getLocStart(), RParenLoc);
569  }
570
571  static bool classof(const Stmt *T) {
572    return T->getStmtClass() == CallExprClass;
573  }
574  static bool classof(const CallExpr *) { return true; }
575
576  // Iterators
577  virtual child_iterator child_begin();
578  virtual child_iterator child_end();
579};
580
581/// MemberExpr - [C99 6.5.2.3] Structure and Union Members.
582///
583class MemberExpr : public Expr {
584  Expr *Base;
585  FieldDecl *MemberDecl;
586  SourceLocation MemberLoc;
587  bool IsArrow;      // True if this is "X->F", false if this is "X.F".
588public:
589  MemberExpr(Expr *base, bool isarrow, FieldDecl *memberdecl, SourceLocation l)
590    : Expr(MemberExprClass, memberdecl->getType()),
591      Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow) {}
592
593  Expr *getBase() const { return Base; }
594  FieldDecl *getMemberDecl() const { return MemberDecl; }
595  bool isArrow() const { return IsArrow; }
596
597  virtual SourceRange getSourceRange() const {
598    return SourceRange(getBase()->getLocStart(), MemberLoc);
599  }
600  virtual SourceLocation getExprLoc() const { return MemberLoc; }
601
602  static bool classof(const Stmt *T) {
603    return T->getStmtClass() == MemberExprClass;
604  }
605  static bool classof(const MemberExpr *) { return true; }
606
607  // Iterators
608  virtual child_iterator child_begin();
609  virtual child_iterator child_end();
610};
611
612/// OCUVectorElementExpr - This represents access to specific elements of a
613/// vector, and may occur on the left hand side or right hand side.  For example
614/// the following is legal:  "V.xy = V.zw" if V is a 4 element ocu vector.
615///
616class OCUVectorElementExpr : public Expr {
617  Expr *Base;
618  IdentifierInfo &Accessor;
619  SourceLocation AccessorLoc;
620public:
621  enum ElementType {
622    Point,   // xywz
623    Color,   // rgba
624    Texture  // stpq
625  };
626  OCUVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor,
627                       SourceLocation loc)
628    : Expr(OCUVectorElementExprClass, ty),
629      Base(base), Accessor(accessor), AccessorLoc(loc) {}
630
631  const Expr *getBase() const { return Base; }
632  Expr *getBase() { return Base; }
633
634  IdentifierInfo &getAccessor() const { return Accessor; }
635
636  /// getNumElements - Get the number of components being selected.
637  unsigned getNumElements() const;
638
639  /// getElementType - Determine whether the components of this access are
640  /// "point" "color" or "texture" elements.
641  ElementType getElementType() const;
642
643  /// containsDuplicateElements - Return true if any element access is
644  /// repeated.
645  bool containsDuplicateElements() const;
646
647  /// getEncodedElementAccess - Encode the elements accessed into a bit vector.
648  /// The encoding currently uses 2-bit bitfields, but clients should use the
649  /// accessors below to access them.
650  ///
651  unsigned getEncodedElementAccess() const;
652
653  /// getAccessedFieldNo - Given an encoded value and a result number, return
654  /// the input field number being accessed.
655  static unsigned getAccessedFieldNo(unsigned Idx, unsigned EncodedVal) {
656    return (EncodedVal >> (Idx*2)) & 3;
657  }
658
659  virtual SourceRange getSourceRange() const {
660    return SourceRange(getBase()->getLocStart(), AccessorLoc);
661  }
662  static bool classof(const Stmt *T) {
663    return T->getStmtClass() == OCUVectorElementExprClass;
664  }
665  static bool classof(const OCUVectorElementExpr *) { return true; }
666
667  // Iterators
668  virtual child_iterator child_begin();
669  virtual child_iterator child_end();
670};
671
672/// CompoundLiteralExpr - [C99 6.5.2.5]
673///
674class CompoundLiteralExpr : public Expr {
675  Expr *Init;
676public:
677  CompoundLiteralExpr(QualType ty, Expr *init) :
678    Expr(CompoundLiteralExprClass, ty), Init(init) {}
679
680  const Expr *getInitializer() const { return Init; }
681  Expr *getInitializer() { return Init; }
682
683  virtual SourceRange getSourceRange() const {
684    if (Init)
685      return Init->getSourceRange();
686    return SourceRange();
687  }
688
689  static bool classof(const Stmt *T) {
690    return T->getStmtClass() == CompoundLiteralExprClass;
691  }
692  static bool classof(const CompoundLiteralExpr *) { return true; }
693
694  // Iterators
695  virtual child_iterator child_begin();
696  virtual child_iterator child_end();
697};
698
699/// ImplicitCastExpr - Allows us to explicitly represent implicit type
700/// conversions. For example: converting T[]->T*, void f()->void (*f)(),
701/// float->double, short->int, etc.
702///
703class ImplicitCastExpr : public Expr {
704  Expr *Op;
705public:
706  ImplicitCastExpr(QualType ty, Expr *op) :
707    Expr(ImplicitCastExprClass, ty), Op(op) {}
708
709  Expr *getSubExpr() { return Op; }
710  const Expr *getSubExpr() const { return Op; }
711
712  virtual SourceRange getSourceRange() const { return Op->getSourceRange(); }
713
714  static bool classof(const Stmt *T) {
715    return T->getStmtClass() == ImplicitCastExprClass;
716  }
717  static bool classof(const ImplicitCastExpr *) { return true; }
718
719  // Iterators
720  virtual child_iterator child_begin();
721  virtual child_iterator child_end();
722
723  virtual void directEmit(llvm::Serializer& S) const;
724  static ImplicitCastExpr* directMaterialize(llvm::Deserializer& D);
725};
726
727/// CastExpr - [C99 6.5.4] Cast Operators.
728///
729class CastExpr : public Expr {
730  Expr *Op;
731  SourceLocation Loc; // the location of the left paren
732public:
733  CastExpr(QualType ty, Expr *op, SourceLocation l) :
734    Expr(CastExprClass, ty), Op(op), Loc(l) {}
735
736  SourceLocation getLParenLoc() const { return Loc; }
737
738  Expr *getSubExpr() const { return Op; }
739
740  virtual SourceRange getSourceRange() const {
741    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
742  }
743  static bool classof(const Stmt *T) {
744    return T->getStmtClass() == CastExprClass;
745  }
746  static bool classof(const CastExpr *) { return true; }
747
748  // Iterators
749  virtual child_iterator child_begin();
750  virtual child_iterator child_end();
751
752  virtual void directEmit(llvm::Serializer& S) const;
753  static CastExpr* directMaterialize(llvm::Deserializer& D);
754};
755
756class BinaryOperator : public Expr {
757public:
758  enum Opcode {
759    // Operators listed in order of precedence.
760    // Note that additions to this should also update the StmtVisitor class.
761    Mul, Div, Rem,    // [C99 6.5.5] Multiplicative operators.
762    Add, Sub,         // [C99 6.5.6] Additive operators.
763    Shl, Shr,         // [C99 6.5.7] Bitwise shift operators.
764    LT, GT, LE, GE,   // [C99 6.5.8] Relational operators.
765    EQ, NE,           // [C99 6.5.9] Equality operators.
766    And,              // [C99 6.5.10] Bitwise AND operator.
767    Xor,              // [C99 6.5.11] Bitwise XOR operator.
768    Or,               // [C99 6.5.12] Bitwise OR operator.
769    LAnd,             // [C99 6.5.13] Logical AND operator.
770    LOr,              // [C99 6.5.14] Logical OR operator.
771    Assign, MulAssign,// [C99 6.5.16] Assignment operators.
772    DivAssign, RemAssign,
773    AddAssign, SubAssign,
774    ShlAssign, ShrAssign,
775    AndAssign, XorAssign,
776    OrAssign,
777    Comma             // [C99 6.5.17] Comma operator.
778  };
779private:
780  enum { LHS, RHS, END_EXPR };
781  Expr* SubExprs[END_EXPR];
782  Opcode Opc;
783  SourceLocation OpLoc;
784public:
785
786  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
787                 SourceLocation opLoc)
788    : Expr(BinaryOperatorClass, ResTy), Opc(opc), OpLoc(opLoc) {
789    SubExprs[LHS] = lhs;
790    SubExprs[RHS] = rhs;
791    assert(!isCompoundAssignmentOp() &&
792           "Use ArithAssignBinaryOperator for compound assignments");
793  }
794
795  SourceLocation getOperatorLoc() const { return OpLoc; }
796  Opcode getOpcode() const { return Opc; }
797  Expr *getLHS() const { return SubExprs[LHS]; }
798  Expr *getRHS() const { return SubExprs[RHS]; }
799  virtual SourceRange getSourceRange() const {
800    return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
801  }
802
803  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
804  /// corresponds to, e.g. "<<=".
805  static const char *getOpcodeStr(Opcode Op);
806
807  /// predicates to categorize the respective opcodes.
808  bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; }
809  bool isAdditiveOp() const { return Opc == Add || Opc == Sub; }
810  bool isShiftOp() const { return Opc == Shl || Opc == Shr; }
811  bool isBitwiseOp() const { return Opc >= And && Opc <= Or; }
812  bool isRelationalOp() const { return Opc >= LT && Opc <= GE; }
813  bool isEqualityOp() const { return Opc == EQ || Opc == NE; }
814  bool isLogicalOp() const { return Opc == LAnd || Opc == LOr; }
815  bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; }
816  bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;}
817  bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
818
819  static bool classof(const Stmt *S) {
820    return S->getStmtClass() == BinaryOperatorClass ||
821           S->getStmtClass() == CompoundAssignOperatorClass;
822  }
823  static bool classof(const BinaryOperator *) { return true; }
824
825  // Iterators
826  virtual child_iterator child_begin();
827  virtual child_iterator child_end();
828
829  virtual void directEmit(llvm::Serializer& S) const;
830  static BinaryOperator* directMaterialize(llvm::Deserializer& D);
831
832protected:
833  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
834                 SourceLocation oploc, bool dead)
835    : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc), OpLoc(oploc) {
836    SubExprs[LHS] = lhs;
837    SubExprs[RHS] = rhs;
838  }
839};
840
841/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
842/// track of the type the operation is performed in.  Due to the semantics of
843/// these operators, the operands are promoted, the aritmetic performed, an
844/// implicit conversion back to the result type done, then the assignment takes
845/// place.  This captures the intermediate type which the computation is done
846/// in.
847class CompoundAssignOperator : public BinaryOperator {
848  QualType ComputationType;
849public:
850  CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc,
851                         QualType ResType, QualType CompType,
852                         SourceLocation OpLoc)
853    : BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true),
854      ComputationType(CompType) {
855    assert(isCompoundAssignmentOp() &&
856           "Only should be used for compound assignments");
857  }
858
859  QualType getComputationType() const { return ComputationType; }
860
861  static bool classof(const CompoundAssignOperator *) { return true; }
862  static bool classof(const Stmt *S) {
863    return S->getStmtClass() == CompoundAssignOperatorClass;
864  }
865};
866
867/// ConditionalOperator - The ?: operator.  Note that LHS may be null when the
868/// GNU "missing LHS" extension is in use.
869///
870class ConditionalOperator : public Expr {
871  enum { COND, LHS, RHS, END_EXPR };
872  Expr* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
873public:
874  ConditionalOperator(Expr *cond, Expr *lhs, Expr *rhs, QualType t)
875    : Expr(ConditionalOperatorClass, t) {
876    SubExprs[COND] = cond;
877    SubExprs[LHS] = lhs;
878    SubExprs[RHS] = rhs;
879  }
880
881  Expr *getCond() const { return SubExprs[COND]; }
882  Expr *getLHS() const { return SubExprs[LHS]; }
883  Expr *getRHS() const { return SubExprs[RHS]; }
884
885  virtual SourceRange getSourceRange() const {
886    return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
887  }
888  static bool classof(const Stmt *T) {
889    return T->getStmtClass() == ConditionalOperatorClass;
890  }
891  static bool classof(const ConditionalOperator *) { return true; }
892
893  // Iterators
894  virtual child_iterator child_begin();
895  virtual child_iterator child_end();
896};
897
898/// AddrLabelExpr - The GNU address of label extension, representing &&label.
899class AddrLabelExpr : public Expr {
900  SourceLocation AmpAmpLoc, LabelLoc;
901  LabelStmt *Label;
902public:
903  AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
904                QualType t)
905    : Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
906
907  virtual SourceRange getSourceRange() const {
908    return SourceRange(AmpAmpLoc, LabelLoc);
909  }
910
911  LabelStmt *getLabel() const { return Label; }
912
913  static bool classof(const Stmt *T) {
914    return T->getStmtClass() == AddrLabelExprClass;
915  }
916  static bool classof(const AddrLabelExpr *) { return true; }
917
918  // Iterators
919  virtual child_iterator child_begin();
920  virtual child_iterator child_end();
921};
922
923/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
924/// The StmtExpr contains a single CompoundStmt node, which it evaluates and
925/// takes the value of the last subexpression.
926class StmtExpr : public Expr {
927  CompoundStmt *SubStmt;
928  SourceLocation LParenLoc, RParenLoc;
929public:
930  StmtExpr(CompoundStmt *substmt, QualType T,
931           SourceLocation lp, SourceLocation rp) :
932    Expr(StmtExprClass, T), SubStmt(substmt),  LParenLoc(lp), RParenLoc(rp) { }
933
934  CompoundStmt *getSubStmt() { return SubStmt; }
935  const CompoundStmt *getSubStmt() const { return SubStmt; }
936
937  virtual SourceRange getSourceRange() const {
938    return SourceRange(LParenLoc, RParenLoc);
939  }
940
941  static bool classof(const Stmt *T) {
942    return T->getStmtClass() == StmtExprClass;
943  }
944  static bool classof(const StmtExpr *) { return true; }
945
946  // Iterators
947  virtual child_iterator child_begin();
948  virtual child_iterator child_end();
949};
950
951/// TypesCompatibleExpr - GNU builtin-in function __builtin_type_compatible_p.
952/// This AST node represents a function that returns 1 if two *types* (not
953/// expressions) are compatible. The result of this built-in function can be
954/// used in integer constant expressions.
955class TypesCompatibleExpr : public Expr {
956  QualType Type1;
957  QualType Type2;
958  SourceLocation BuiltinLoc, RParenLoc;
959public:
960  TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
961                      QualType t1, QualType t2, SourceLocation RP) :
962    Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2),
963    BuiltinLoc(BLoc), RParenLoc(RP) {}
964
965  QualType getArgType1() const { return Type1; }
966  QualType getArgType2() const { return Type2; }
967
968  virtual SourceRange getSourceRange() const {
969    return SourceRange(BuiltinLoc, RParenLoc);
970  }
971  static bool classof(const Stmt *T) {
972    return T->getStmtClass() == TypesCompatibleExprClass;
973  }
974  static bool classof(const TypesCompatibleExpr *) { return true; }
975
976  // Iterators
977  virtual child_iterator child_begin();
978  virtual child_iterator child_end();
979};
980
981/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
982/// This AST node is similar to the conditional operator (?:) in C, with
983/// the following exceptions:
984/// - the test expression much be a constant expression.
985/// - the expression returned has it's type unaltered by promotion rules.
986/// - does not evaluate the expression that was not chosen.
987class ChooseExpr : public Expr {
988  enum { COND, LHS, RHS, END_EXPR };
989  Expr* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
990  SourceLocation BuiltinLoc, RParenLoc;
991public:
992  ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t,
993             SourceLocation RP)
994    : Expr(ChooseExprClass, t),
995      BuiltinLoc(BLoc), RParenLoc(RP) {
996      SubExprs[COND] = cond;
997      SubExprs[LHS] = lhs;
998      SubExprs[RHS] = rhs;
999    }
1000
1001  /// isConditionTrue - Return true if the condition is true.  This is always
1002  /// statically knowable for a well-formed choosexpr.
1003  bool isConditionTrue(ASTContext &C) const;
1004
1005  Expr *getCond() const { return SubExprs[COND]; }
1006  Expr *getLHS() const { return SubExprs[LHS]; }
1007  Expr *getRHS() const { return SubExprs[RHS]; }
1008
1009  virtual SourceRange getSourceRange() const {
1010    return SourceRange(BuiltinLoc, RParenLoc);
1011  }
1012  static bool classof(const Stmt *T) {
1013    return T->getStmtClass() == ChooseExprClass;
1014  }
1015  static bool classof(const ChooseExpr *) { return true; }
1016
1017  // Iterators
1018  virtual child_iterator child_begin();
1019  virtual child_iterator child_end();
1020};
1021
1022/// VAArgExpr, used for the builtin function __builtin_va_start.
1023class VAArgExpr : public Expr {
1024  Expr *Val;
1025  SourceLocation BuiltinLoc, RParenLoc;
1026public:
1027  VAArgExpr(SourceLocation BLoc, Expr* e, QualType t, SourceLocation RPLoc)
1028    : Expr(VAArgExprClass, t),
1029      Val(e),
1030      BuiltinLoc(BLoc),
1031      RParenLoc(RPLoc) { }
1032
1033  const Expr *getSubExpr() const { return Val; }
1034  Expr *getSubExpr() { return Val; }
1035  virtual SourceRange getSourceRange() const {
1036    return SourceRange(BuiltinLoc, RParenLoc);
1037  }
1038  static bool classof(const Stmt *T) {
1039    return T->getStmtClass() == VAArgExprClass;
1040  }
1041  static bool classof(const VAArgExpr *) { return true; }
1042
1043  // Iterators
1044  virtual child_iterator child_begin();
1045  virtual child_iterator child_end();
1046};
1047
1048/// InitListExpr, used for struct and array initializers.
1049class InitListExpr : public Expr {
1050  Expr **InitExprs;
1051  unsigned NumInits;
1052  SourceLocation LBraceLoc, RBraceLoc;
1053public:
1054  InitListExpr(SourceLocation lbraceloc, Expr **initexprs, unsigned numinits,
1055               SourceLocation rbraceloc);
1056  ~InitListExpr() {
1057    delete [] InitExprs;
1058  }
1059
1060  unsigned getNumInits() const { return NumInits; }
1061
1062  const Expr* getInit(unsigned Init) const {
1063    assert(Init < NumInits && "Initializer access out of range!");
1064    return InitExprs[Init];
1065  }
1066
1067  Expr* getInit(unsigned Init) {
1068    assert(Init < NumInits && "Initializer access out of range!");
1069    return InitExprs[Init];
1070  }
1071
1072  void setInit(unsigned Init, Expr *expr) {
1073    assert(Init < NumInits && "Initializer access out of range!");
1074    InitExprs[Init] = expr;
1075  }
1076
1077  virtual SourceRange getSourceRange() const {
1078    return SourceRange(LBraceLoc, RBraceLoc);
1079  }
1080  static bool classof(const Stmt *T) {
1081    return T->getStmtClass() == InitListExprClass;
1082  }
1083  static bool classof(const InitListExpr *) { return true; }
1084
1085  // Iterators
1086  virtual child_iterator child_begin();
1087  virtual child_iterator child_end();
1088};
1089
1090/// ObjCStringLiteral, used for Objective-C string literals
1091/// i.e. @"foo".
1092class ObjCStringLiteral : public Expr {
1093  StringLiteral *String;
1094  SourceLocation AtLoc;
1095public:
1096  ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
1097    : Expr(ObjCStringLiteralClass, T), String(SL), AtLoc(L) {}
1098
1099  StringLiteral* getString() { return String; }
1100
1101  const StringLiteral* getString() const { return String; }
1102
1103  virtual SourceRange getSourceRange() const {
1104    return SourceRange(AtLoc, String->getLocEnd());
1105  }
1106
1107  static bool classof(const Stmt *T) {
1108    return T->getStmtClass() == ObjCStringLiteralClass;
1109  }
1110  static bool classof(const ObjCStringLiteral *) { return true; }
1111
1112  // Iterators
1113  virtual child_iterator child_begin();
1114  virtual child_iterator child_end();
1115};
1116
1117/// ObjCEncodeExpr, used for @encode in Objective-C.
1118class ObjCEncodeExpr : public Expr {
1119  QualType EncType;
1120  SourceLocation AtLoc, RParenLoc;
1121public:
1122  ObjCEncodeExpr(QualType T, QualType ET,
1123                 SourceLocation at, SourceLocation rp)
1124    : Expr(ObjCEncodeExprClass, T), EncType(ET), AtLoc(at), RParenLoc(rp) {}
1125
1126  SourceLocation getAtLoc() const { return AtLoc; }
1127  SourceLocation getRParenLoc() const { return RParenLoc; }
1128
1129  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1130
1131  QualType getEncodedType() const { return EncType; }
1132
1133  static bool classof(const Stmt *T) {
1134    return T->getStmtClass() == ObjCEncodeExprClass;
1135  }
1136  static bool classof(const ObjCEncodeExpr *) { return true; }
1137
1138  // Iterators
1139  virtual child_iterator child_begin();
1140  virtual child_iterator child_end();
1141};
1142
1143/// ObjCSelectorExpr used for @selector in Objective-C.
1144class ObjCSelectorExpr : public Expr {
1145
1146  Selector SelName;
1147
1148  SourceLocation AtLoc, RParenLoc;
1149public:
1150  ObjCSelectorExpr(QualType T, Selector selInfo,
1151                   SourceLocation at, SourceLocation rp)
1152  : Expr(ObjCSelectorExprClass, T), SelName(selInfo),
1153  AtLoc(at), RParenLoc(rp) {}
1154
1155  const Selector &getSelector() const { return SelName; }
1156  Selector &getSelector() { return SelName; }
1157
1158  SourceLocation getAtLoc() const { return AtLoc; }
1159  SourceLocation getRParenLoc() const { return RParenLoc; }
1160  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1161
1162  /// getNumArgs - Return the number of actual arguments to this call.
1163  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1164
1165  static bool classof(const Stmt *T) {
1166    return T->getStmtClass() == ObjCSelectorExprClass;
1167  }
1168  static bool classof(const ObjCSelectorExpr *) { return true; }
1169
1170  // Iterators
1171  virtual child_iterator child_begin();
1172  virtual child_iterator child_end();
1173
1174};
1175
1176/// ObjCProtocolExpr used for protocol in Objective-C.
1177class ObjCProtocolExpr : public Expr {
1178
1179  ObjcProtocolDecl *Protocol;
1180
1181  SourceLocation AtLoc, RParenLoc;
1182  public:
1183  ObjCProtocolExpr(QualType T, ObjcProtocolDecl *protocol,
1184                   SourceLocation at, SourceLocation rp)
1185  : Expr(ObjCProtocolExprClass, T), Protocol(protocol),
1186  AtLoc(at), RParenLoc(rp) {}
1187
1188  ObjcProtocolDecl *getProtocol() const { return Protocol; }
1189
1190  SourceLocation getAtLoc() const { return AtLoc; }
1191  SourceLocation getRParenLoc() const { return RParenLoc; }
1192  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1193
1194  static bool classof(const Stmt *T) {
1195    return T->getStmtClass() == ObjCProtocolExprClass;
1196  }
1197  static bool classof(const ObjCProtocolExpr *) { return true; }
1198
1199  // Iterators
1200  virtual child_iterator child_begin();
1201  virtual child_iterator child_end();
1202
1203};
1204
1205class ObjCMessageExpr : public Expr {
1206  enum { RECEIVER=0, ARGS_START=1 };
1207
1208  Expr **SubExprs;
1209
1210  // A unigue name for this message.
1211  Selector SelName;
1212
1213  // A method prototype for this message (optional).
1214  // FIXME: Since method decls contain the selector, and most messages have a
1215  // prototype, consider devising a scheme for unifying SelName/MethodProto.
1216  ObjcMethodDecl *MethodProto;
1217
1218  IdentifierInfo *ClassName; // optional - 0 for instance messages.
1219
1220  SourceLocation LBracloc, RBracloc;
1221public:
1222  // constructor for class messages.
1223  // FIXME: clsName should be typed to ObjCInterfaceType
1224  ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
1225                  QualType retType, ObjcMethodDecl *methDecl,
1226                  SourceLocation LBrac, SourceLocation RBrac,
1227                  Expr **ArgExprs);
1228  // constructor for instance messages.
1229  ObjCMessageExpr(Expr *receiver, Selector selInfo,
1230                  QualType retType, ObjcMethodDecl *methDecl,
1231                  SourceLocation LBrac, SourceLocation RBrac,
1232                  Expr **ArgExprs);
1233  ~ObjCMessageExpr() {
1234    delete [] SubExprs;
1235  }
1236
1237  const Expr *getReceiver() const { return SubExprs[RECEIVER]; }
1238  Expr *getReceiver() { return SubExprs[RECEIVER]; }
1239
1240  const Selector &getSelector() const { return SelName; }
1241  Selector &getSelector() { return SelName; }
1242
1243  const ObjcMethodDecl *getMethodDecl() const { return MethodProto; }
1244  ObjcMethodDecl *getMethodDecl() { return MethodProto; }
1245
1246  const IdentifierInfo *getClassName() const { return ClassName; }
1247  IdentifierInfo *getClassName() { return ClassName; }
1248
1249  /// getNumArgs - Return the number of actual arguments to this call.
1250  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1251
1252/// getArg - Return the specified argument.
1253  Expr *getArg(unsigned Arg) {
1254    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1255    return SubExprs[Arg+ARGS_START];
1256  }
1257  const Expr *getArg(unsigned Arg) const {
1258    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1259    return SubExprs[Arg+ARGS_START];
1260  }
1261  /// setArg - Set the specified argument.
1262  void setArg(unsigned Arg, Expr *ArgExpr) {
1263    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1264    SubExprs[Arg+ARGS_START] = ArgExpr;
1265  }
1266  SourceRange getSourceRange() const { return SourceRange(LBracloc, RBracloc); }
1267
1268  static bool classof(const Stmt *T) {
1269    return T->getStmtClass() == ObjCMessageExprClass;
1270  }
1271  static bool classof(const ObjCMessageExpr *) { return true; }
1272
1273  // Iterators
1274  virtual child_iterator child_begin();
1275  virtual child_iterator child_end();
1276};
1277
1278}  // end namespace clang
1279
1280#endif
1281