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