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