Expr.h revision 612c9b9ca73593b3194866c9e1a51554db9752e7
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
296/// StringLiteral - This represents a string literal expression, e.g. "foo"
297/// or L"bar" (wide strings).  The actual string is returned by getStrData()
298/// is NOT null-terminated, and the length of the string is determined by
299/// calling getByteLength().
300class StringLiteral : public Expr {
301  const char *StrData;
302  unsigned ByteLength;
303  bool IsWide;
304  // if the StringLiteral was composed using token pasting, both locations
305  // are needed. If not (the common case), firstTokLoc == lastTokLoc.
306  // FIXME: if space becomes an issue, we should create a sub-class.
307  SourceLocation firstTokLoc, lastTokLoc;
308public:
309  StringLiteral(const char *strData, unsigned byteLength, bool Wide,
310                QualType t, SourceLocation b, SourceLocation e);
311  virtual ~StringLiteral();
312
313  const char *getStrData() const { return StrData; }
314  unsigned getByteLength() const { return ByteLength; }
315  bool isWide() const { return IsWide; }
316
317  virtual SourceRange getSourceRange() const {
318    return SourceRange(firstTokLoc,lastTokLoc);
319  }
320  static bool classof(const Stmt *T) {
321    return T->getStmtClass() == StringLiteralClass;
322  }
323  static bool classof(const StringLiteral *) { return true; }
324
325  // Iterators
326  virtual child_iterator child_begin();
327  virtual child_iterator child_end();
328};
329
330/// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This
331/// AST node is only formed if full location information is requested.
332class ParenExpr : public Expr {
333  SourceLocation L, R;
334  Expr *Val;
335public:
336  ParenExpr(SourceLocation l, SourceLocation r, Expr *val)
337    : Expr(ParenExprClass, val->getType()), L(l), R(r), Val(val) {}
338
339  const Expr *getSubExpr() const { return Val; }
340  Expr *getSubExpr() { return Val; }
341  SourceRange getSourceRange() const { return SourceRange(L, R); }
342
343  static bool classof(const Stmt *T) {
344    return T->getStmtClass() == ParenExprClass;
345  }
346  static bool classof(const ParenExpr *) { return true; }
347
348  // Iterators
349  virtual child_iterator child_begin();
350  virtual child_iterator child_end();
351
352  virtual void directEmit(llvm::Serializer& S) const;
353  static ParenExpr* directMaterialize(llvm::Deserializer& D);
354};
355
356
357/// UnaryOperator - This represents the unary-expression's (except sizeof of
358/// types), the postinc/postdec operators from postfix-expression, and various
359/// extensions.
360///
361/// Notes on various nodes:
362///
363/// Real/Imag - These return the real/imag part of a complex operand.  If
364///   applied to a non-complex value, the former returns its operand and the
365///   later returns zero in the type of the operand.
366///
367/// __builtin_offsetof(type, a.b[10]) is represented as a unary operator whose
368///   subexpression is a compound literal with the various MemberExpr and
369///   ArraySubscriptExpr's applied to it.
370///
371class UnaryOperator : public Expr {
372public:
373  // Note that additions to this should also update the StmtVisitor class.
374  enum Opcode {
375    PostInc, PostDec, // [C99 6.5.2.4] Postfix increment and decrement operators
376    PreInc, PreDec,   // [C99 6.5.3.1] Prefix increment and decrement operators.
377    AddrOf, Deref,    // [C99 6.5.3.2] Address and indirection operators.
378    Plus, Minus,      // [C99 6.5.3.3] Unary arithmetic operators.
379    Not, LNot,        // [C99 6.5.3.3] Unary arithmetic operators.
380    SizeOf, AlignOf,  // [C99 6.5.3.4] Sizeof (expr, not type) operator.
381    Real, Imag,       // "__real expr"/"__imag expr" Extension.
382    Extension,        // __extension__ marker.
383    OffsetOf          // __builtin_offsetof
384  };
385private:
386  Expr *Val;
387  Opcode Opc;
388  SourceLocation Loc;
389public:
390
391  UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l)
392    : Expr(UnaryOperatorClass, type), Val(input), Opc(opc), Loc(l) {}
393
394  Opcode getOpcode() const { return Opc; }
395  Expr *getSubExpr() const { return Val; }
396
397  /// getOperatorLoc - Return the location of the operator.
398  SourceLocation getOperatorLoc() const { return Loc; }
399
400  /// isPostfix - Return true if this is a postfix operation, like x++.
401  static bool isPostfix(Opcode Op);
402
403  bool isPostfix() const { return isPostfix(Opc); }
404  bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; }
405  bool isSizeOfAlignOfOp() const { return Opc == SizeOf || Opc == AlignOf; }
406  static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; }
407
408  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
409  /// corresponds to, e.g. "sizeof" or "[pre]++"
410  static const char *getOpcodeStr(Opcode Op);
411
412  virtual SourceRange getSourceRange() const {
413    if (isPostfix())
414      return SourceRange(Val->getLocStart(), Loc);
415    else
416      return SourceRange(Loc, Val->getLocEnd());
417  }
418  virtual SourceLocation getExprLoc() const { return Loc; }
419
420  static bool classof(const Stmt *T) {
421    return T->getStmtClass() == UnaryOperatorClass;
422  }
423  static bool classof(const UnaryOperator *) { return true; }
424
425  // Iterators
426  virtual child_iterator child_begin();
427  virtual child_iterator child_end();
428};
429
430/// SizeOfAlignOfTypeExpr - [C99 6.5.3.4] - This is only for sizeof/alignof of
431/// *types*.  sizeof(expr) is handled by UnaryOperator.
432class SizeOfAlignOfTypeExpr : public Expr {
433  bool isSizeof;  // true if sizeof, false if alignof.
434  QualType Ty;
435  SourceLocation OpLoc, RParenLoc;
436public:
437  SizeOfAlignOfTypeExpr(bool issizeof, QualType argType, QualType resultType,
438                        SourceLocation op, SourceLocation rp) :
439    Expr(SizeOfAlignOfTypeExprClass, resultType),
440    isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {}
441
442  bool isSizeOf() const { return isSizeof; }
443  QualType getArgumentType() const { return Ty; }
444
445  SourceLocation getOperatorLoc() const { return OpLoc; }
446  SourceRange getSourceRange() const { return SourceRange(OpLoc, RParenLoc); }
447
448  static bool classof(const Stmt *T) {
449    return T->getStmtClass() == SizeOfAlignOfTypeExprClass;
450  }
451  static bool classof(const SizeOfAlignOfTypeExpr *) { return true; }
452
453  // Iterators
454  virtual child_iterator child_begin();
455  virtual child_iterator child_end();
456};
457
458//===----------------------------------------------------------------------===//
459// Postfix Operators.
460//===----------------------------------------------------------------------===//
461
462/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
463class ArraySubscriptExpr : public Expr {
464  enum { LHS, RHS, END_EXPR=2 };
465  Expr* SubExprs[END_EXPR];
466  SourceLocation RBracketLoc;
467public:
468  ArraySubscriptExpr(Expr *lhs, Expr *rhs, QualType t,
469                     SourceLocation rbracketloc)
470  : Expr(ArraySubscriptExprClass, t), RBracketLoc(rbracketloc) {
471    SubExprs[LHS] = lhs;
472    SubExprs[RHS] = rhs;
473  }
474
475  /// An array access can be written A[4] or 4[A] (both are equivalent).
476  /// - getBase() and getIdx() always present the normalized view: A[4].
477  ///    In this case getBase() returns "A" and getIdx() returns "4".
478  /// - getLHS() and getRHS() present the syntactic view. e.g. for
479  ///    4[A] getLHS() returns "4".
480
481  Expr *getLHS() { return SubExprs[LHS]; }
482  const Expr *getLHS() const { return SubExprs[LHS]; }
483
484  Expr *getRHS() { return SubExprs[RHS]; }
485  const Expr *getRHS() const { return SubExprs[RHS]; }
486
487  Expr *getBase() {
488    return (getLHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
489  }
490
491  const Expr *getBase() const {
492    return (getLHS()->getType()->isIntegerType()) ? getRHS() : getLHS();
493  }
494
495  Expr *getIdx() {
496    return (getLHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
497  }
498
499  const Expr *getIdx() const {
500    return (getLHS()->getType()->isIntegerType()) ? getLHS() : getRHS();
501  }
502
503
504  SourceRange getSourceRange() const {
505    return SourceRange(getLHS()->getLocStart(), RBracketLoc);
506  }
507  virtual SourceLocation getExprLoc() const { return RBracketLoc; }
508
509  static bool classof(const Stmt *T) {
510    return T->getStmtClass() == ArraySubscriptExprClass;
511  }
512  static bool classof(const ArraySubscriptExpr *) { return true; }
513
514  // Iterators
515  virtual child_iterator child_begin();
516  virtual child_iterator child_end();
517};
518
519
520/// CallExpr - [C99 6.5.2.2] Function Calls.
521///
522class CallExpr : public Expr {
523  enum { FN=0, ARGS_START=1 };
524  Expr **SubExprs;
525  unsigned NumArgs;
526  SourceLocation RParenLoc;
527public:
528  CallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
529           SourceLocation rparenloc);
530  ~CallExpr() {
531    delete [] SubExprs;
532  }
533
534  const Expr *getCallee() const { return SubExprs[FN]; }
535  Expr *getCallee() { return SubExprs[FN]; }
536
537  /// getNumArgs - Return the number of actual arguments to this call.
538  ///
539  unsigned getNumArgs() const { return NumArgs; }
540
541  /// getArg - Return the specified argument.
542  Expr *getArg(unsigned Arg) {
543    assert(Arg < NumArgs && "Arg access out of range!");
544    return SubExprs[Arg+ARGS_START];
545  }
546  const Expr *getArg(unsigned Arg) const {
547    assert(Arg < NumArgs && "Arg access out of range!");
548    return SubExprs[Arg+ARGS_START];
549  }
550  /// setArg - Set the specified argument.
551  void setArg(unsigned Arg, Expr *ArgExpr) {
552    assert(Arg < NumArgs && "Arg access out of range!");
553    SubExprs[Arg+ARGS_START] = ArgExpr;
554  }
555  /// getNumCommas - Return the number of commas that must have been present in
556  /// this function call.
557  unsigned getNumCommas() const { return NumArgs ? NumArgs - 1 : 0; }
558
559  bool isBuiltinClassifyType(llvm::APSInt &Result) const;
560
561  SourceRange getSourceRange() const {
562    return SourceRange(getCallee()->getLocStart(), RParenLoc);
563  }
564
565  static bool classof(const Stmt *T) {
566    return T->getStmtClass() == CallExprClass;
567  }
568  static bool classof(const CallExpr *) { return true; }
569
570  // Iterators
571  virtual child_iterator child_begin();
572  virtual child_iterator child_end();
573};
574
575/// MemberExpr - [C99 6.5.2.3] Structure and Union Members.
576///
577class MemberExpr : public Expr {
578  Expr *Base;
579  FieldDecl *MemberDecl;
580  SourceLocation MemberLoc;
581  bool IsArrow;      // True if this is "X->F", false if this is "X.F".
582public:
583  MemberExpr(Expr *base, bool isarrow, FieldDecl *memberdecl, SourceLocation l)
584    : Expr(MemberExprClass, memberdecl->getType()),
585      Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow) {}
586
587  Expr *getBase() const { return Base; }
588  FieldDecl *getMemberDecl() const { return MemberDecl; }
589  bool isArrow() const { return IsArrow; }
590
591  virtual SourceRange getSourceRange() const {
592    return SourceRange(getBase()->getLocStart(), MemberLoc);
593  }
594  virtual SourceLocation getExprLoc() const { return MemberLoc; }
595
596  static bool classof(const Stmt *T) {
597    return T->getStmtClass() == MemberExprClass;
598  }
599  static bool classof(const MemberExpr *) { return true; }
600
601  // Iterators
602  virtual child_iterator child_begin();
603  virtual child_iterator child_end();
604};
605
606/// OCUVectorElementExpr - This represents access to specific elements of a
607/// vector, and may occur on the left hand side or right hand side.  For example
608/// the following is legal:  "V.xy = V.zw" if V is a 4 element ocu vector.
609///
610class OCUVectorElementExpr : public Expr {
611  Expr *Base;
612  IdentifierInfo &Accessor;
613  SourceLocation AccessorLoc;
614public:
615  enum ElementType {
616    Point,   // xywz
617    Color,   // rgba
618    Texture  // stpq
619  };
620  OCUVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor,
621                       SourceLocation loc)
622    : Expr(OCUVectorElementExprClass, ty),
623      Base(base), Accessor(accessor), AccessorLoc(loc) {}
624
625  const Expr *getBase() const { return Base; }
626  Expr *getBase() { return Base; }
627
628  IdentifierInfo &getAccessor() const { return Accessor; }
629
630  /// getNumElements - Get the number of components being selected.
631  unsigned getNumElements() const;
632
633  /// getElementType - Determine whether the components of this access are
634  /// "point" "color" or "texture" elements.
635  ElementType getElementType() const;
636
637  /// containsDuplicateElements - Return true if any element access is
638  /// repeated.
639  bool containsDuplicateElements() const;
640
641  /// getEncodedElementAccess - Encode the elements accessed into a bit vector.
642  /// The encoding currently uses 2-bit bitfields, but clients should use the
643  /// accessors below to access them.
644  ///
645  unsigned getEncodedElementAccess() const;
646
647  /// getAccessedFieldNo - Given an encoded value and a result number, return
648  /// the input field number being accessed.
649  static unsigned getAccessedFieldNo(unsigned Idx, unsigned EncodedVal) {
650    return (EncodedVal >> (Idx*2)) & 3;
651  }
652
653  virtual SourceRange getSourceRange() const {
654    return SourceRange(getBase()->getLocStart(), AccessorLoc);
655  }
656  static bool classof(const Stmt *T) {
657    return T->getStmtClass() == OCUVectorElementExprClass;
658  }
659  static bool classof(const OCUVectorElementExpr *) { return true; }
660
661  // Iterators
662  virtual child_iterator child_begin();
663  virtual child_iterator child_end();
664};
665
666/// CompoundLiteralExpr - [C99 6.5.2.5]
667///
668class CompoundLiteralExpr : public Expr {
669  Expr *Init;
670public:
671  CompoundLiteralExpr(QualType ty, Expr *init) :
672    Expr(CompoundLiteralExprClass, ty), Init(init) {}
673
674  const Expr *getInitializer() const { return Init; }
675  Expr *getInitializer() { return Init; }
676
677  virtual SourceRange getSourceRange() const {
678    if (Init)
679      return Init->getSourceRange();
680    return SourceRange();
681  }
682
683  static bool classof(const Stmt *T) {
684    return T->getStmtClass() == CompoundLiteralExprClass;
685  }
686  static bool classof(const CompoundLiteralExpr *) { return true; }
687
688  // Iterators
689  virtual child_iterator child_begin();
690  virtual child_iterator child_end();
691};
692
693/// ImplicitCastExpr - Allows us to explicitly represent implicit type
694/// conversions. For example: converting T[]->T*, void f()->void (*f)(),
695/// float->double, short->int, etc.
696///
697class ImplicitCastExpr : public Expr {
698  Expr *Op;
699public:
700  ImplicitCastExpr(QualType ty, Expr *op) :
701    Expr(ImplicitCastExprClass, ty), Op(op) {}
702
703  Expr *getSubExpr() { return Op; }
704  const Expr *getSubExpr() const { return Op; }
705
706  virtual SourceRange getSourceRange() const { return Op->getSourceRange(); }
707
708  static bool classof(const Stmt *T) {
709    return T->getStmtClass() == ImplicitCastExprClass;
710  }
711  static bool classof(const ImplicitCastExpr *) { return true; }
712
713  // Iterators
714  virtual child_iterator child_begin();
715  virtual child_iterator child_end();
716};
717
718/// CastExpr - [C99 6.5.4] Cast Operators.
719///
720class CastExpr : public Expr {
721  Expr *Op;
722  SourceLocation Loc; // the location of the left paren
723public:
724  CastExpr(QualType ty, Expr *op, SourceLocation l) :
725    Expr(CastExprClass, ty), Op(op), Loc(l) {}
726
727  SourceLocation getLParenLoc() const { return Loc; }
728
729  Expr *getSubExpr() const { return Op; }
730
731  virtual SourceRange getSourceRange() const {
732    return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd());
733  }
734  static bool classof(const Stmt *T) {
735    return T->getStmtClass() == CastExprClass;
736  }
737  static bool classof(const CastExpr *) { return true; }
738
739  // Iterators
740  virtual child_iterator child_begin();
741  virtual child_iterator child_end();
742};
743
744class BinaryOperator : public Expr {
745public:
746  enum Opcode {
747    // Operators listed in order of precedence.
748    // Note that additions to this should also update the StmtVisitor class.
749    Mul, Div, Rem,    // [C99 6.5.5] Multiplicative operators.
750    Add, Sub,         // [C99 6.5.6] Additive operators.
751    Shl, Shr,         // [C99 6.5.7] Bitwise shift operators.
752    LT, GT, LE, GE,   // [C99 6.5.8] Relational operators.
753    EQ, NE,           // [C99 6.5.9] Equality operators.
754    And,              // [C99 6.5.10] Bitwise AND operator.
755    Xor,              // [C99 6.5.11] Bitwise XOR operator.
756    Or,               // [C99 6.5.12] Bitwise OR operator.
757    LAnd,             // [C99 6.5.13] Logical AND operator.
758    LOr,              // [C99 6.5.14] Logical OR operator.
759    Assign, MulAssign,// [C99 6.5.16] Assignment operators.
760    DivAssign, RemAssign,
761    AddAssign, SubAssign,
762    ShlAssign, ShrAssign,
763    AndAssign, XorAssign,
764    OrAssign,
765    Comma             // [C99 6.5.17] Comma operator.
766  };
767private:
768  enum { LHS, RHS, END_EXPR };
769  Expr* SubExprs[END_EXPR];
770  Opcode Opc;
771  SourceLocation OpLoc;
772public:
773
774  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
775                 SourceLocation opLoc)
776    : Expr(BinaryOperatorClass, ResTy), Opc(opc), OpLoc(opLoc) {
777    SubExprs[LHS] = lhs;
778    SubExprs[RHS] = rhs;
779    assert(!isCompoundAssignmentOp() &&
780           "Use ArithAssignBinaryOperator for compound assignments");
781  }
782
783  SourceLocation getOperatorLoc() const { return OpLoc; }
784  Opcode getOpcode() const { return Opc; }
785  Expr *getLHS() const { return SubExprs[LHS]; }
786  Expr *getRHS() const { return SubExprs[RHS]; }
787  virtual SourceRange getSourceRange() const {
788    return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
789  }
790
791  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
792  /// corresponds to, e.g. "<<=".
793  static const char *getOpcodeStr(Opcode Op);
794
795  /// predicates to categorize the respective opcodes.
796  bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; }
797  bool isAdditiveOp() const { return Opc == Add || Opc == Sub; }
798  bool isShiftOp() const { return Opc == Shl || Opc == Shr; }
799  bool isBitwiseOp() const { return Opc >= And && Opc <= Or; }
800  bool isRelationalOp() const { return Opc >= LT && Opc <= GE; }
801  bool isEqualityOp() const { return Opc == EQ || Opc == NE; }
802  bool isLogicalOp() const { return Opc == LAnd || Opc == LOr; }
803  bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; }
804  bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;}
805  bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
806
807  static bool classof(const Stmt *S) {
808    return S->getStmtClass() == BinaryOperatorClass ||
809           S->getStmtClass() == CompoundAssignOperatorClass;
810  }
811  static bool classof(const BinaryOperator *) { return true; }
812
813  // Iterators
814  virtual child_iterator child_begin();
815  virtual child_iterator child_end();
816
817  virtual void directEmit(llvm::Serializer& S) const;
818  static BinaryOperator* directMaterialize(llvm::Deserializer& D);
819
820protected:
821  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
822                 SourceLocation oploc, bool dead)
823    : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc), OpLoc(oploc) {
824    SubExprs[LHS] = lhs;
825    SubExprs[RHS] = rhs;
826  }
827};
828
829/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
830/// track of the type the operation is performed in.  Due to the semantics of
831/// these operators, the operands are promoted, the aritmetic performed, an
832/// implicit conversion back to the result type done, then the assignment takes
833/// place.  This captures the intermediate type which the computation is done
834/// in.
835class CompoundAssignOperator : public BinaryOperator {
836  QualType ComputationType;
837public:
838  CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc,
839                         QualType ResType, QualType CompType,
840                         SourceLocation OpLoc)
841    : BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true),
842      ComputationType(CompType) {
843    assert(isCompoundAssignmentOp() &&
844           "Only should be used for compound assignments");
845  }
846
847  QualType getComputationType() const { return ComputationType; }
848
849  static bool classof(const CompoundAssignOperator *) { return true; }
850  static bool classof(const Stmt *S) {
851    return S->getStmtClass() == CompoundAssignOperatorClass;
852  }
853};
854
855/// ConditionalOperator - The ?: operator.  Note that LHS may be null when the
856/// GNU "missing LHS" extension is in use.
857///
858class ConditionalOperator : public Expr {
859  enum { COND, LHS, RHS, END_EXPR };
860  Expr* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
861public:
862  ConditionalOperator(Expr *cond, Expr *lhs, Expr *rhs, QualType t)
863    : Expr(ConditionalOperatorClass, t) {
864    SubExprs[COND] = cond;
865    SubExprs[LHS] = lhs;
866    SubExprs[RHS] = rhs;
867  }
868
869  Expr *getCond() const { return SubExprs[COND]; }
870  Expr *getLHS() const { return SubExprs[LHS]; }
871  Expr *getRHS() const { return SubExprs[RHS]; }
872
873  virtual SourceRange getSourceRange() const {
874    return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
875  }
876  static bool classof(const Stmt *T) {
877    return T->getStmtClass() == ConditionalOperatorClass;
878  }
879  static bool classof(const ConditionalOperator *) { return true; }
880
881  // Iterators
882  virtual child_iterator child_begin();
883  virtual child_iterator child_end();
884};
885
886/// AddrLabelExpr - The GNU address of label extension, representing &&label.
887class AddrLabelExpr : public Expr {
888  SourceLocation AmpAmpLoc, LabelLoc;
889  LabelStmt *Label;
890public:
891  AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
892                QualType t)
893    : Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
894
895  virtual SourceRange getSourceRange() const {
896    return SourceRange(AmpAmpLoc, LabelLoc);
897  }
898
899  LabelStmt *getLabel() const { return Label; }
900
901  static bool classof(const Stmt *T) {
902    return T->getStmtClass() == AddrLabelExprClass;
903  }
904  static bool classof(const AddrLabelExpr *) { return true; }
905
906  // Iterators
907  virtual child_iterator child_begin();
908  virtual child_iterator child_end();
909};
910
911/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
912/// The StmtExpr contains a single CompoundStmt node, which it evaluates and
913/// takes the value of the last subexpression.
914class StmtExpr : public Expr {
915  CompoundStmt *SubStmt;
916  SourceLocation LParenLoc, RParenLoc;
917public:
918  StmtExpr(CompoundStmt *substmt, QualType T,
919           SourceLocation lp, SourceLocation rp) :
920    Expr(StmtExprClass, T), SubStmt(substmt),  LParenLoc(lp), RParenLoc(rp) { }
921
922  CompoundStmt *getSubStmt() { return SubStmt; }
923  const CompoundStmt *getSubStmt() const { return SubStmt; }
924
925  virtual SourceRange getSourceRange() const {
926    return SourceRange(LParenLoc, RParenLoc);
927  }
928
929  static bool classof(const Stmt *T) {
930    return T->getStmtClass() == StmtExprClass;
931  }
932  static bool classof(const StmtExpr *) { return true; }
933
934  // Iterators
935  virtual child_iterator child_begin();
936  virtual child_iterator child_end();
937};
938
939/// TypesCompatibleExpr - GNU builtin-in function __builtin_type_compatible_p.
940/// This AST node represents a function that returns 1 if two *types* (not
941/// expressions) are compatible. The result of this built-in function can be
942/// used in integer constant expressions.
943class TypesCompatibleExpr : public Expr {
944  QualType Type1;
945  QualType Type2;
946  SourceLocation BuiltinLoc, RParenLoc;
947public:
948  TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
949                      QualType t1, QualType t2, SourceLocation RP) :
950    Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2),
951    BuiltinLoc(BLoc), RParenLoc(RP) {}
952
953  QualType getArgType1() const { return Type1; }
954  QualType getArgType2() const { return Type2; }
955
956  virtual SourceRange getSourceRange() const {
957    return SourceRange(BuiltinLoc, RParenLoc);
958  }
959  static bool classof(const Stmt *T) {
960    return T->getStmtClass() == TypesCompatibleExprClass;
961  }
962  static bool classof(const TypesCompatibleExpr *) { return true; }
963
964  // Iterators
965  virtual child_iterator child_begin();
966  virtual child_iterator child_end();
967};
968
969/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
970/// This AST node is similar to the conditional operator (?:) in C, with
971/// the following exceptions:
972/// - the test expression much be a constant expression.
973/// - the expression returned has it's type unaltered by promotion rules.
974/// - does not evaluate the expression that was not chosen.
975class ChooseExpr : public Expr {
976  enum { COND, LHS, RHS, END_EXPR };
977  Expr* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
978  SourceLocation BuiltinLoc, RParenLoc;
979public:
980  ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t,
981             SourceLocation RP)
982    : Expr(ChooseExprClass, t),
983      BuiltinLoc(BLoc), RParenLoc(RP) {
984      SubExprs[COND] = cond;
985      SubExprs[LHS] = lhs;
986      SubExprs[RHS] = rhs;
987    }
988
989  /// isConditionTrue - Return true if the condition is true.  This is always
990  /// statically knowable for a well-formed choosexpr.
991  bool isConditionTrue(ASTContext &C) const;
992
993  Expr *getCond() const { return SubExprs[COND]; }
994  Expr *getLHS() const { return SubExprs[LHS]; }
995  Expr *getRHS() const { return SubExprs[RHS]; }
996
997  virtual SourceRange getSourceRange() const {
998    return SourceRange(BuiltinLoc, RParenLoc);
999  }
1000  static bool classof(const Stmt *T) {
1001    return T->getStmtClass() == ChooseExprClass;
1002  }
1003  static bool classof(const ChooseExpr *) { return true; }
1004
1005  // Iterators
1006  virtual child_iterator child_begin();
1007  virtual child_iterator child_end();
1008};
1009
1010/// VAArgExpr, used for the builtin function __builtin_va_start.
1011class VAArgExpr : public Expr {
1012  Expr *Val;
1013  SourceLocation BuiltinLoc, RParenLoc;
1014public:
1015  VAArgExpr(SourceLocation BLoc, Expr* e, QualType t, SourceLocation RPLoc)
1016    : Expr(VAArgExprClass, t),
1017      Val(e),
1018      BuiltinLoc(BLoc),
1019      RParenLoc(RPLoc) { }
1020
1021  const Expr *getSubExpr() const { return Val; }
1022  Expr *getSubExpr() { return Val; }
1023  virtual SourceRange getSourceRange() const {
1024    return SourceRange(BuiltinLoc, RParenLoc);
1025  }
1026  static bool classof(const Stmt *T) {
1027    return T->getStmtClass() == VAArgExprClass;
1028  }
1029  static bool classof(const VAArgExpr *) { return true; }
1030
1031  // Iterators
1032  virtual child_iterator child_begin();
1033  virtual child_iterator child_end();
1034};
1035
1036/// InitListExpr, used for struct and array initializers.
1037class InitListExpr : public Expr {
1038  Expr **InitExprs;
1039  unsigned NumInits;
1040  SourceLocation LBraceLoc, RBraceLoc;
1041public:
1042  InitListExpr(SourceLocation lbraceloc, Expr **initexprs, unsigned numinits,
1043               SourceLocation rbraceloc);
1044  ~InitListExpr() {
1045    delete [] InitExprs;
1046  }
1047
1048  unsigned getNumInits() const { return NumInits; }
1049
1050  const Expr* getInit(unsigned Init) const {
1051    assert(Init < NumInits && "Initializer access out of range!");
1052    return InitExprs[Init];
1053  }
1054
1055  Expr* getInit(unsigned Init) {
1056    assert(Init < NumInits && "Initializer access out of range!");
1057    return InitExprs[Init];
1058  }
1059
1060  void setInit(unsigned Init, Expr *expr) {
1061    assert(Init < NumInits && "Initializer access out of range!");
1062    InitExprs[Init] = expr;
1063  }
1064
1065  virtual SourceRange getSourceRange() const {
1066    return SourceRange(LBraceLoc, RBraceLoc);
1067  }
1068  static bool classof(const Stmt *T) {
1069    return T->getStmtClass() == InitListExprClass;
1070  }
1071  static bool classof(const InitListExpr *) { return true; }
1072
1073  // Iterators
1074  virtual child_iterator child_begin();
1075  virtual child_iterator child_end();
1076};
1077
1078/// ObjCStringLiteral, used for Objective-C string literals
1079/// i.e. @"foo".
1080class ObjCStringLiteral : public Expr {
1081  StringLiteral *String;
1082  SourceLocation AtLoc;
1083public:
1084  ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
1085    : Expr(ObjCStringLiteralClass, T), String(SL), AtLoc(L) {}
1086
1087  StringLiteral* getString() { return String; }
1088
1089  const StringLiteral* getString() const { return String; }
1090
1091  virtual SourceRange getSourceRange() const {
1092    return SourceRange(AtLoc, String->getLocEnd());
1093  }
1094
1095  static bool classof(const Stmt *T) {
1096    return T->getStmtClass() == ObjCStringLiteralClass;
1097  }
1098  static bool classof(const ObjCStringLiteral *) { return true; }
1099
1100  // Iterators
1101  virtual child_iterator child_begin();
1102  virtual child_iterator child_end();
1103};
1104
1105/// ObjCEncodeExpr, used for @encode in Objective-C.
1106class ObjCEncodeExpr : public Expr {
1107  QualType EncType;
1108  SourceLocation AtLoc, RParenLoc;
1109public:
1110  ObjCEncodeExpr(QualType T, QualType ET,
1111                 SourceLocation at, SourceLocation rp)
1112    : Expr(ObjCEncodeExprClass, T), EncType(ET), AtLoc(at), RParenLoc(rp) {}
1113
1114  SourceLocation getAtLoc() const { return AtLoc; }
1115  SourceLocation getRParenLoc() const { return RParenLoc; }
1116
1117  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1118
1119  QualType getEncodedType() const { return EncType; }
1120
1121  static bool classof(const Stmt *T) {
1122    return T->getStmtClass() == ObjCEncodeExprClass;
1123  }
1124  static bool classof(const ObjCEncodeExpr *) { return true; }
1125
1126  // Iterators
1127  virtual child_iterator child_begin();
1128  virtual child_iterator child_end();
1129};
1130
1131/// ObjCSelectorExpr used for @selector in Objective-C.
1132class ObjCSelectorExpr : public Expr {
1133
1134  Selector SelName;
1135
1136  SourceLocation AtLoc, RParenLoc;
1137public:
1138  ObjCSelectorExpr(QualType T, Selector selInfo,
1139                   SourceLocation at, SourceLocation rp)
1140  : Expr(ObjCSelectorExprClass, T), SelName(selInfo),
1141  AtLoc(at), RParenLoc(rp) {}
1142
1143  const Selector &getSelector() const { return SelName; }
1144  Selector &getSelector() { return SelName; }
1145
1146  SourceLocation getAtLoc() const { return AtLoc; }
1147  SourceLocation getRParenLoc() const { return RParenLoc; }
1148  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1149
1150  /// getNumArgs - Return the number of actual arguments to this call.
1151  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1152
1153  static bool classof(const Stmt *T) {
1154    return T->getStmtClass() == ObjCSelectorExprClass;
1155  }
1156  static bool classof(const ObjCSelectorExpr *) { return true; }
1157
1158  // Iterators
1159  virtual child_iterator child_begin();
1160  virtual child_iterator child_end();
1161
1162};
1163
1164/// ObjCProtocolExpr used for protocol in Objective-C.
1165class ObjCProtocolExpr : public Expr {
1166
1167  ObjcProtocolDecl *Protocol;
1168
1169  SourceLocation AtLoc, RParenLoc;
1170  public:
1171  ObjCProtocolExpr(QualType T, ObjcProtocolDecl *protocol,
1172                   SourceLocation at, SourceLocation rp)
1173  : Expr(ObjCProtocolExprClass, T), Protocol(protocol),
1174  AtLoc(at), RParenLoc(rp) {}
1175
1176  ObjcProtocolDecl *getProtocol() const { return Protocol; }
1177
1178  SourceLocation getAtLoc() const { return AtLoc; }
1179  SourceLocation getRParenLoc() const { return RParenLoc; }
1180  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1181
1182  static bool classof(const Stmt *T) {
1183    return T->getStmtClass() == ObjCProtocolExprClass;
1184  }
1185  static bool classof(const ObjCProtocolExpr *) { return true; }
1186
1187  // Iterators
1188  virtual child_iterator child_begin();
1189  virtual child_iterator child_end();
1190
1191};
1192
1193class ObjCMessageExpr : public Expr {
1194  enum { RECEIVER=0, ARGS_START=1 };
1195
1196  Expr **SubExprs;
1197
1198  // A unigue name for this message.
1199  Selector SelName;
1200
1201  // A method prototype for this message (optional).
1202  // FIXME: Since method decls contain the selector, and most messages have a
1203  // prototype, consider devising a scheme for unifying SelName/MethodProto.
1204  ObjcMethodDecl *MethodProto;
1205
1206  IdentifierInfo *ClassName; // optional - 0 for instance messages.
1207
1208  SourceLocation LBracloc, RBracloc;
1209public:
1210  // constructor for class messages.
1211  // FIXME: clsName should be typed to ObjCInterfaceType
1212  ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
1213                  QualType retType, ObjcMethodDecl *methDecl,
1214                  SourceLocation LBrac, SourceLocation RBrac,
1215                  Expr **ArgExprs);
1216  // constructor for instance messages.
1217  ObjCMessageExpr(Expr *receiver, Selector selInfo,
1218                  QualType retType, ObjcMethodDecl *methDecl,
1219                  SourceLocation LBrac, SourceLocation RBrac,
1220                  Expr **ArgExprs);
1221  ~ObjCMessageExpr() {
1222    delete [] SubExprs;
1223  }
1224
1225  const Expr *getReceiver() const { return SubExprs[RECEIVER]; }
1226  Expr *getReceiver() { return SubExprs[RECEIVER]; }
1227
1228  const Selector &getSelector() const { return SelName; }
1229  Selector &getSelector() { return SelName; }
1230
1231  const ObjcMethodDecl *getMethodDecl() const { return MethodProto; }
1232  ObjcMethodDecl *getMethodDecl() { return MethodProto; }
1233
1234  const IdentifierInfo *getClassName() const { return ClassName; }
1235  IdentifierInfo *getClassName() { return ClassName; }
1236
1237  /// getNumArgs - Return the number of actual arguments to this call.
1238  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1239
1240/// getArg - Return the specified argument.
1241  Expr *getArg(unsigned Arg) {
1242    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1243    return SubExprs[Arg+ARGS_START];
1244  }
1245  const Expr *getArg(unsigned Arg) const {
1246    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1247    return SubExprs[Arg+ARGS_START];
1248  }
1249  /// setArg - Set the specified argument.
1250  void setArg(unsigned Arg, Expr *ArgExpr) {
1251    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1252    SubExprs[Arg+ARGS_START] = ArgExpr;
1253  }
1254  SourceRange getSourceRange() const { return SourceRange(LBracloc, RBracloc); }
1255
1256  static bool classof(const Stmt *T) {
1257    return T->getStmtClass() == ObjCMessageExprClass;
1258  }
1259  static bool classof(const ObjCMessageExpr *) { return true; }
1260
1261  // Iterators
1262  virtual child_iterator child_begin();
1263  virtual child_iterator child_end();
1264};
1265
1266}  // end namespace clang
1267
1268#endif
1269