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