Expr.h revision a7c20dd6c78db562ff463ee5fb13e248a1d3c93f
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
753class BinaryOperator : public Expr {
754public:
755  enum Opcode {
756    // Operators listed in order of precedence.
757    // Note that additions to this should also update the StmtVisitor class.
758    Mul, Div, Rem,    // [C99 6.5.5] Multiplicative operators.
759    Add, Sub,         // [C99 6.5.6] Additive operators.
760    Shl, Shr,         // [C99 6.5.7] Bitwise shift operators.
761    LT, GT, LE, GE,   // [C99 6.5.8] Relational operators.
762    EQ, NE,           // [C99 6.5.9] Equality operators.
763    And,              // [C99 6.5.10] Bitwise AND operator.
764    Xor,              // [C99 6.5.11] Bitwise XOR operator.
765    Or,               // [C99 6.5.12] Bitwise OR operator.
766    LAnd,             // [C99 6.5.13] Logical AND operator.
767    LOr,              // [C99 6.5.14] Logical OR operator.
768    Assign, MulAssign,// [C99 6.5.16] Assignment operators.
769    DivAssign, RemAssign,
770    AddAssign, SubAssign,
771    ShlAssign, ShrAssign,
772    AndAssign, XorAssign,
773    OrAssign,
774    Comma             // [C99 6.5.17] Comma operator.
775  };
776private:
777  enum { LHS, RHS, END_EXPR };
778  Expr* SubExprs[END_EXPR];
779  Opcode Opc;
780  SourceLocation OpLoc;
781public:
782
783  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
784                 SourceLocation opLoc)
785    : Expr(BinaryOperatorClass, ResTy), Opc(opc), OpLoc(opLoc) {
786    SubExprs[LHS] = lhs;
787    SubExprs[RHS] = rhs;
788    assert(!isCompoundAssignmentOp() &&
789           "Use ArithAssignBinaryOperator for compound assignments");
790  }
791
792  SourceLocation getOperatorLoc() const { return OpLoc; }
793  Opcode getOpcode() const { return Opc; }
794  Expr *getLHS() const { return SubExprs[LHS]; }
795  Expr *getRHS() const { return SubExprs[RHS]; }
796  virtual SourceRange getSourceRange() const {
797    return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
798  }
799
800  /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
801  /// corresponds to, e.g. "<<=".
802  static const char *getOpcodeStr(Opcode Op);
803
804  /// predicates to categorize the respective opcodes.
805  bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; }
806  bool isAdditiveOp() const { return Opc == Add || Opc == Sub; }
807  bool isShiftOp() const { return Opc == Shl || Opc == Shr; }
808  bool isBitwiseOp() const { return Opc >= And && Opc <= Or; }
809  bool isRelationalOp() const { return Opc >= LT && Opc <= GE; }
810  bool isEqualityOp() const { return Opc == EQ || Opc == NE; }
811  bool isLogicalOp() const { return Opc == LAnd || Opc == LOr; }
812  bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; }
813  bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;}
814  bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
815
816  static bool classof(const Stmt *S) {
817    return S->getStmtClass() == BinaryOperatorClass ||
818           S->getStmtClass() == CompoundAssignOperatorClass;
819  }
820  static bool classof(const BinaryOperator *) { return true; }
821
822  // Iterators
823  virtual child_iterator child_begin();
824  virtual child_iterator child_end();
825
826  virtual void directEmit(llvm::Serializer& S) const;
827  static BinaryOperator* directMaterialize(llvm::Deserializer& D);
828
829protected:
830  BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
831                 SourceLocation oploc, bool dead)
832    : Expr(CompoundAssignOperatorClass, ResTy), Opc(opc), OpLoc(oploc) {
833    SubExprs[LHS] = lhs;
834    SubExprs[RHS] = rhs;
835  }
836};
837
838/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep
839/// track of the type the operation is performed in.  Due to the semantics of
840/// these operators, the operands are promoted, the aritmetic performed, an
841/// implicit conversion back to the result type done, then the assignment takes
842/// place.  This captures the intermediate type which the computation is done
843/// in.
844class CompoundAssignOperator : public BinaryOperator {
845  QualType ComputationType;
846public:
847  CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc,
848                         QualType ResType, QualType CompType,
849                         SourceLocation OpLoc)
850    : BinaryOperator(lhs, rhs, opc, ResType, OpLoc, true),
851      ComputationType(CompType) {
852    assert(isCompoundAssignmentOp() &&
853           "Only should be used for compound assignments");
854  }
855
856  QualType getComputationType() const { return ComputationType; }
857
858  static bool classof(const CompoundAssignOperator *) { return true; }
859  static bool classof(const Stmt *S) {
860    return S->getStmtClass() == CompoundAssignOperatorClass;
861  }
862};
863
864/// ConditionalOperator - The ?: operator.  Note that LHS may be null when the
865/// GNU "missing LHS" extension is in use.
866///
867class ConditionalOperator : public Expr {
868  enum { COND, LHS, RHS, END_EXPR };
869  Expr* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
870public:
871  ConditionalOperator(Expr *cond, Expr *lhs, Expr *rhs, QualType t)
872    : Expr(ConditionalOperatorClass, t) {
873    SubExprs[COND] = cond;
874    SubExprs[LHS] = lhs;
875    SubExprs[RHS] = rhs;
876  }
877
878  Expr *getCond() const { return SubExprs[COND]; }
879  Expr *getLHS() const { return SubExprs[LHS]; }
880  Expr *getRHS() const { return SubExprs[RHS]; }
881
882  virtual SourceRange getSourceRange() const {
883    return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
884  }
885  static bool classof(const Stmt *T) {
886    return T->getStmtClass() == ConditionalOperatorClass;
887  }
888  static bool classof(const ConditionalOperator *) { return true; }
889
890  // Iterators
891  virtual child_iterator child_begin();
892  virtual child_iterator child_end();
893};
894
895/// AddrLabelExpr - The GNU address of label extension, representing &&label.
896class AddrLabelExpr : public Expr {
897  SourceLocation AmpAmpLoc, LabelLoc;
898  LabelStmt *Label;
899public:
900  AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
901                QualType t)
902    : Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
903
904  virtual SourceRange getSourceRange() const {
905    return SourceRange(AmpAmpLoc, LabelLoc);
906  }
907
908  LabelStmt *getLabel() const { return Label; }
909
910  static bool classof(const Stmt *T) {
911    return T->getStmtClass() == AddrLabelExprClass;
912  }
913  static bool classof(const AddrLabelExpr *) { return true; }
914
915  // Iterators
916  virtual child_iterator child_begin();
917  virtual child_iterator child_end();
918};
919
920/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
921/// The StmtExpr contains a single CompoundStmt node, which it evaluates and
922/// takes the value of the last subexpression.
923class StmtExpr : public Expr {
924  CompoundStmt *SubStmt;
925  SourceLocation LParenLoc, RParenLoc;
926public:
927  StmtExpr(CompoundStmt *substmt, QualType T,
928           SourceLocation lp, SourceLocation rp) :
929    Expr(StmtExprClass, T), SubStmt(substmt),  LParenLoc(lp), RParenLoc(rp) { }
930
931  CompoundStmt *getSubStmt() { return SubStmt; }
932  const CompoundStmt *getSubStmt() const { return SubStmt; }
933
934  virtual SourceRange getSourceRange() const {
935    return SourceRange(LParenLoc, RParenLoc);
936  }
937
938  static bool classof(const Stmt *T) {
939    return T->getStmtClass() == StmtExprClass;
940  }
941  static bool classof(const StmtExpr *) { return true; }
942
943  // Iterators
944  virtual child_iterator child_begin();
945  virtual child_iterator child_end();
946};
947
948/// TypesCompatibleExpr - GNU builtin-in function __builtin_type_compatible_p.
949/// This AST node represents a function that returns 1 if two *types* (not
950/// expressions) are compatible. The result of this built-in function can be
951/// used in integer constant expressions.
952class TypesCompatibleExpr : public Expr {
953  QualType Type1;
954  QualType Type2;
955  SourceLocation BuiltinLoc, RParenLoc;
956public:
957  TypesCompatibleExpr(QualType ReturnType, SourceLocation BLoc,
958                      QualType t1, QualType t2, SourceLocation RP) :
959    Expr(TypesCompatibleExprClass, ReturnType), Type1(t1), Type2(t2),
960    BuiltinLoc(BLoc), RParenLoc(RP) {}
961
962  QualType getArgType1() const { return Type1; }
963  QualType getArgType2() const { return Type2; }
964
965  virtual SourceRange getSourceRange() const {
966    return SourceRange(BuiltinLoc, RParenLoc);
967  }
968  static bool classof(const Stmt *T) {
969    return T->getStmtClass() == TypesCompatibleExprClass;
970  }
971  static bool classof(const TypesCompatibleExpr *) { return true; }
972
973  // Iterators
974  virtual child_iterator child_begin();
975  virtual child_iterator child_end();
976};
977
978/// ChooseExpr - GNU builtin-in function __builtin_choose_expr.
979/// This AST node is similar to the conditional operator (?:) in C, with
980/// the following exceptions:
981/// - the test expression much be a constant expression.
982/// - the expression returned has it's type unaltered by promotion rules.
983/// - does not evaluate the expression that was not chosen.
984class ChooseExpr : public Expr {
985  enum { COND, LHS, RHS, END_EXPR };
986  Expr* SubExprs[END_EXPR]; // Left/Middle/Right hand sides.
987  SourceLocation BuiltinLoc, RParenLoc;
988public:
989  ChooseExpr(SourceLocation BLoc, Expr *cond, Expr *lhs, Expr *rhs, QualType t,
990             SourceLocation RP)
991    : Expr(ChooseExprClass, t),
992      BuiltinLoc(BLoc), RParenLoc(RP) {
993      SubExprs[COND] = cond;
994      SubExprs[LHS] = lhs;
995      SubExprs[RHS] = rhs;
996    }
997
998  /// isConditionTrue - Return true if the condition is true.  This is always
999  /// statically knowable for a well-formed choosexpr.
1000  bool isConditionTrue(ASTContext &C) const;
1001
1002  Expr *getCond() const { return SubExprs[COND]; }
1003  Expr *getLHS() const { return SubExprs[LHS]; }
1004  Expr *getRHS() const { return SubExprs[RHS]; }
1005
1006  virtual SourceRange getSourceRange() const {
1007    return SourceRange(BuiltinLoc, RParenLoc);
1008  }
1009  static bool classof(const Stmt *T) {
1010    return T->getStmtClass() == ChooseExprClass;
1011  }
1012  static bool classof(const ChooseExpr *) { return true; }
1013
1014  // Iterators
1015  virtual child_iterator child_begin();
1016  virtual child_iterator child_end();
1017};
1018
1019/// VAArgExpr, used for the builtin function __builtin_va_start.
1020class VAArgExpr : public Expr {
1021  Expr *Val;
1022  SourceLocation BuiltinLoc, RParenLoc;
1023public:
1024  VAArgExpr(SourceLocation BLoc, Expr* e, QualType t, SourceLocation RPLoc)
1025    : Expr(VAArgExprClass, t),
1026      Val(e),
1027      BuiltinLoc(BLoc),
1028      RParenLoc(RPLoc) { }
1029
1030  const Expr *getSubExpr() const { return Val; }
1031  Expr *getSubExpr() { return Val; }
1032  virtual SourceRange getSourceRange() const {
1033    return SourceRange(BuiltinLoc, RParenLoc);
1034  }
1035  static bool classof(const Stmt *T) {
1036    return T->getStmtClass() == VAArgExprClass;
1037  }
1038  static bool classof(const VAArgExpr *) { return true; }
1039
1040  // Iterators
1041  virtual child_iterator child_begin();
1042  virtual child_iterator child_end();
1043};
1044
1045/// InitListExpr, used for struct and array initializers.
1046class InitListExpr : public Expr {
1047  Expr **InitExprs;
1048  unsigned NumInits;
1049  SourceLocation LBraceLoc, RBraceLoc;
1050public:
1051  InitListExpr(SourceLocation lbraceloc, Expr **initexprs, unsigned numinits,
1052               SourceLocation rbraceloc);
1053  ~InitListExpr() {
1054    delete [] InitExprs;
1055  }
1056
1057  unsigned getNumInits() const { return NumInits; }
1058
1059  const Expr* getInit(unsigned Init) const {
1060    assert(Init < NumInits && "Initializer access out of range!");
1061    return InitExprs[Init];
1062  }
1063
1064  Expr* getInit(unsigned Init) {
1065    assert(Init < NumInits && "Initializer access out of range!");
1066    return InitExprs[Init];
1067  }
1068
1069  void setInit(unsigned Init, Expr *expr) {
1070    assert(Init < NumInits && "Initializer access out of range!");
1071    InitExprs[Init] = expr;
1072  }
1073
1074  virtual SourceRange getSourceRange() const {
1075    return SourceRange(LBraceLoc, RBraceLoc);
1076  }
1077  static bool classof(const Stmt *T) {
1078    return T->getStmtClass() == InitListExprClass;
1079  }
1080  static bool classof(const InitListExpr *) { return true; }
1081
1082  // Iterators
1083  virtual child_iterator child_begin();
1084  virtual child_iterator child_end();
1085};
1086
1087/// ObjCStringLiteral, used for Objective-C string literals
1088/// i.e. @"foo".
1089class ObjCStringLiteral : public Expr {
1090  StringLiteral *String;
1091  SourceLocation AtLoc;
1092public:
1093  ObjCStringLiteral(StringLiteral *SL, QualType T, SourceLocation L)
1094    : Expr(ObjCStringLiteralClass, T), String(SL), AtLoc(L) {}
1095
1096  StringLiteral* getString() { return String; }
1097
1098  const StringLiteral* getString() const { return String; }
1099
1100  virtual SourceRange getSourceRange() const {
1101    return SourceRange(AtLoc, String->getLocEnd());
1102  }
1103
1104  static bool classof(const Stmt *T) {
1105    return T->getStmtClass() == ObjCStringLiteralClass;
1106  }
1107  static bool classof(const ObjCStringLiteral *) { return true; }
1108
1109  // Iterators
1110  virtual child_iterator child_begin();
1111  virtual child_iterator child_end();
1112};
1113
1114/// ObjCEncodeExpr, used for @encode in Objective-C.
1115class ObjCEncodeExpr : public Expr {
1116  QualType EncType;
1117  SourceLocation AtLoc, RParenLoc;
1118public:
1119  ObjCEncodeExpr(QualType T, QualType ET,
1120                 SourceLocation at, SourceLocation rp)
1121    : Expr(ObjCEncodeExprClass, T), EncType(ET), AtLoc(at), RParenLoc(rp) {}
1122
1123  SourceLocation getAtLoc() const { return AtLoc; }
1124  SourceLocation getRParenLoc() const { return RParenLoc; }
1125
1126  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1127
1128  QualType getEncodedType() const { return EncType; }
1129
1130  static bool classof(const Stmt *T) {
1131    return T->getStmtClass() == ObjCEncodeExprClass;
1132  }
1133  static bool classof(const ObjCEncodeExpr *) { return true; }
1134
1135  // Iterators
1136  virtual child_iterator child_begin();
1137  virtual child_iterator child_end();
1138};
1139
1140/// ObjCSelectorExpr used for @selector in Objective-C.
1141class ObjCSelectorExpr : public Expr {
1142
1143  Selector SelName;
1144
1145  SourceLocation AtLoc, RParenLoc;
1146public:
1147  ObjCSelectorExpr(QualType T, Selector selInfo,
1148                   SourceLocation at, SourceLocation rp)
1149  : Expr(ObjCSelectorExprClass, T), SelName(selInfo),
1150  AtLoc(at), RParenLoc(rp) {}
1151
1152  const Selector &getSelector() const { return SelName; }
1153  Selector &getSelector() { return SelName; }
1154
1155  SourceLocation getAtLoc() const { return AtLoc; }
1156  SourceLocation getRParenLoc() const { return RParenLoc; }
1157  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1158
1159  /// getNumArgs - Return the number of actual arguments to this call.
1160  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1161
1162  static bool classof(const Stmt *T) {
1163    return T->getStmtClass() == ObjCSelectorExprClass;
1164  }
1165  static bool classof(const ObjCSelectorExpr *) { return true; }
1166
1167  // Iterators
1168  virtual child_iterator child_begin();
1169  virtual child_iterator child_end();
1170
1171};
1172
1173/// ObjCProtocolExpr used for protocol in Objective-C.
1174class ObjCProtocolExpr : public Expr {
1175
1176  ObjcProtocolDecl *Protocol;
1177
1178  SourceLocation AtLoc, RParenLoc;
1179  public:
1180  ObjCProtocolExpr(QualType T, ObjcProtocolDecl *protocol,
1181                   SourceLocation at, SourceLocation rp)
1182  : Expr(ObjCProtocolExprClass, T), Protocol(protocol),
1183  AtLoc(at), RParenLoc(rp) {}
1184
1185  ObjcProtocolDecl *getProtocol() const { return Protocol; }
1186
1187  SourceLocation getAtLoc() const { return AtLoc; }
1188  SourceLocation getRParenLoc() const { return RParenLoc; }
1189  SourceRange getSourceRange() const { return SourceRange(AtLoc, RParenLoc); }
1190
1191  static bool classof(const Stmt *T) {
1192    return T->getStmtClass() == ObjCProtocolExprClass;
1193  }
1194  static bool classof(const ObjCProtocolExpr *) { return true; }
1195
1196  // Iterators
1197  virtual child_iterator child_begin();
1198  virtual child_iterator child_end();
1199
1200};
1201
1202class ObjCMessageExpr : public Expr {
1203  enum { RECEIVER=0, ARGS_START=1 };
1204
1205  Expr **SubExprs;
1206
1207  // A unigue name for this message.
1208  Selector SelName;
1209
1210  // A method prototype for this message (optional).
1211  // FIXME: Since method decls contain the selector, and most messages have a
1212  // prototype, consider devising a scheme for unifying SelName/MethodProto.
1213  ObjcMethodDecl *MethodProto;
1214
1215  IdentifierInfo *ClassName; // optional - 0 for instance messages.
1216
1217  SourceLocation LBracloc, RBracloc;
1218public:
1219  // constructor for class messages.
1220  // FIXME: clsName should be typed to ObjCInterfaceType
1221  ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
1222                  QualType retType, ObjcMethodDecl *methDecl,
1223                  SourceLocation LBrac, SourceLocation RBrac,
1224                  Expr **ArgExprs);
1225  // constructor for instance messages.
1226  ObjCMessageExpr(Expr *receiver, Selector selInfo,
1227                  QualType retType, ObjcMethodDecl *methDecl,
1228                  SourceLocation LBrac, SourceLocation RBrac,
1229                  Expr **ArgExprs);
1230  ~ObjCMessageExpr() {
1231    delete [] SubExprs;
1232  }
1233
1234  const Expr *getReceiver() const { return SubExprs[RECEIVER]; }
1235  Expr *getReceiver() { return SubExprs[RECEIVER]; }
1236
1237  const Selector &getSelector() const { return SelName; }
1238  Selector &getSelector() { return SelName; }
1239
1240  const ObjcMethodDecl *getMethodDecl() const { return MethodProto; }
1241  ObjcMethodDecl *getMethodDecl() { return MethodProto; }
1242
1243  const IdentifierInfo *getClassName() const { return ClassName; }
1244  IdentifierInfo *getClassName() { return ClassName; }
1245
1246  /// getNumArgs - Return the number of actual arguments to this call.
1247  unsigned getNumArgs() const { return SelName.getNumArgs(); }
1248
1249/// getArg - Return the specified argument.
1250  Expr *getArg(unsigned Arg) {
1251    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1252    return SubExprs[Arg+ARGS_START];
1253  }
1254  const Expr *getArg(unsigned Arg) const {
1255    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1256    return SubExprs[Arg+ARGS_START];
1257  }
1258  /// setArg - Set the specified argument.
1259  void setArg(unsigned Arg, Expr *ArgExpr) {
1260    assert(Arg < SelName.getNumArgs() && "Arg access out of range!");
1261    SubExprs[Arg+ARGS_START] = ArgExpr;
1262  }
1263  SourceRange getSourceRange() const { return SourceRange(LBracloc, RBracloc); }
1264
1265  static bool classof(const Stmt *T) {
1266    return T->getStmtClass() == ObjCMessageExprClass;
1267  }
1268  static bool classof(const ObjCMessageExpr *) { return true; }
1269
1270  // Iterators
1271  virtual child_iterator child_begin();
1272  virtual child_iterator child_end();
1273};
1274
1275}  // end namespace clang
1276
1277#endif
1278