ExprCXX.h revision 16006c901315fa12a108b4e571f187f4b676e426
1//===--- ExprCXX.h - Classes for representing expressions -------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the Expr interface and subclasses for C++ expressions. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_AST_EXPRCXX_H 15#define LLVM_CLANG_AST_EXPRCXX_H 16 17#include "clang/Basic/TypeTraits.h" 18#include "clang/AST/Expr.h" 19#include "clang/AST/Decl.h" 20#include "clang/AST/TemplateBase.h" 21 22namespace clang { 23 24 class CXXConstructorDecl; 25 class CXXDestructorDecl; 26 class CXXMethodDecl; 27 class CXXTemporary; 28 class TemplateArgumentListInfo; 29 30//===--------------------------------------------------------------------===// 31// C++ Expressions. 32//===--------------------------------------------------------------------===// 33 34/// \brief A call to an overloaded operator written using operator 35/// syntax. 36/// 37/// Represents a call to an overloaded operator written using operator 38/// syntax, e.g., "x + y" or "*p". While semantically equivalent to a 39/// normal call, this AST node provides better information about the 40/// syntactic representation of the call. 41/// 42/// In a C++ template, this expression node kind will be used whenever 43/// any of the arguments are type-dependent. In this case, the 44/// function itself will be a (possibly empty) set of functions and 45/// function templates that were found by name lookup at template 46/// definition time. 47class CXXOperatorCallExpr : public CallExpr { 48 /// \brief The overloaded operator. 49 OverloadedOperatorKind Operator; 50 51public: 52 CXXOperatorCallExpr(ASTContext& C, OverloadedOperatorKind Op, Expr *fn, 53 Expr **args, unsigned numargs, QualType t, 54 SourceLocation operatorloc) 55 : CallExpr(C, CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc), 56 Operator(Op) {} 57 explicit CXXOperatorCallExpr(ASTContext& C, EmptyShell Empty) : 58 CallExpr(C, CXXOperatorCallExprClass, Empty) { } 59 60 61 /// getOperator - Returns the kind of overloaded operator that this 62 /// expression refers to. 63 OverloadedOperatorKind getOperator() const { return Operator; } 64 void setOperator(OverloadedOperatorKind Kind) { Operator = Kind; } 65 66 /// getOperatorLoc - Returns the location of the operator symbol in 67 /// the expression. When @c getOperator()==OO_Call, this is the 68 /// location of the right parentheses; when @c 69 /// getOperator()==OO_Subscript, this is the location of the right 70 /// bracket. 71 SourceLocation getOperatorLoc() const { return getRParenLoc(); } 72 73 virtual SourceRange getSourceRange() const; 74 75 static bool classof(const Stmt *T) { 76 return T->getStmtClass() == CXXOperatorCallExprClass; 77 } 78 static bool classof(const CXXOperatorCallExpr *) { return true; } 79}; 80 81/// CXXMemberCallExpr - Represents a call to a member function that 82/// may be written either with member call syntax (e.g., "obj.func()" 83/// or "objptr->func()") or with normal function-call syntax 84/// ("func()") within a member function that ends up calling a member 85/// function. The callee in either case is a MemberExpr that contains 86/// both the object argument and the member function, while the 87/// arguments are the arguments within the parentheses (not including 88/// the object argument). 89class CXXMemberCallExpr : public CallExpr { 90public: 91 CXXMemberCallExpr(ASTContext& C, Expr *fn, Expr **args, unsigned numargs, 92 QualType t, SourceLocation rparenloc) 93 : CallExpr(C, CXXMemberCallExprClass, fn, args, numargs, t, rparenloc) {} 94 95 /// getImplicitObjectArgument - Retrieves the implicit object 96 /// argument for the member call. For example, in "x.f(5)", this 97 /// operation would return "x". 98 Expr *getImplicitObjectArgument(); 99 100 virtual SourceRange getSourceRange() const; 101 102 static bool classof(const Stmt *T) { 103 return T->getStmtClass() == CXXMemberCallExprClass; 104 } 105 static bool classof(const CXXMemberCallExpr *) { return true; } 106}; 107 108/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 109/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 110/// const_cast. 111/// 112/// This abstract class is inherited by all of the classes 113/// representing "named" casts, e.g., CXXStaticCastExpr, 114/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 115class CXXNamedCastExpr : public ExplicitCastExpr { 116private: 117 SourceLocation Loc; // the location of the casting op 118 119protected: 120 CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, 121 QualType writtenTy, SourceLocation l) 122 : ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {} 123 124public: 125 const char *getCastName() const; 126 127 /// \brief Retrieve the location of the cast operator keyword, e.g., 128 /// "static_cast". 129 SourceLocation getOperatorLoc() const { return Loc; } 130 void setOperatorLoc(SourceLocation L) { Loc = L; } 131 132 virtual SourceRange getSourceRange() const { 133 return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 134 } 135 static bool classof(const Stmt *T) { 136 switch (T->getStmtClass()) { 137 case CXXNamedCastExprClass: 138 case CXXStaticCastExprClass: 139 case CXXDynamicCastExprClass: 140 case CXXReinterpretCastExprClass: 141 case CXXConstCastExprClass: 142 return true; 143 default: 144 return false; 145 } 146 } 147 static bool classof(const CXXNamedCastExpr *) { return true; } 148}; 149 150/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 151/// 152/// This expression node represents a C++ static cast, e.g., 153/// @c static_cast<int>(1.0). 154class CXXStaticCastExpr : public CXXNamedCastExpr { 155public: 156 CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, 157 QualType writtenTy, SourceLocation l) 158 : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {} 159 160 static bool classof(const Stmt *T) { 161 return T->getStmtClass() == CXXStaticCastExprClass; 162 } 163 static bool classof(const CXXStaticCastExpr *) { return true; } 164}; 165 166/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 167/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 168/// determine how to perform the type cast. 169/// 170/// This expression node represents a dynamic cast, e.g., 171/// @c dynamic_cast<Derived*>(BasePtr). 172class CXXDynamicCastExpr : public CXXNamedCastExpr { 173public: 174 CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy, 175 SourceLocation l) 176 : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {} 177 178 static bool classof(const Stmt *T) { 179 return T->getStmtClass() == CXXDynamicCastExprClass; 180 } 181 static bool classof(const CXXDynamicCastExpr *) { return true; } 182}; 183 184/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 185/// [expr.reinterpret.cast]), which provides a differently-typed view 186/// of a value but performs no actual work at run time. 187/// 188/// This expression node represents a reinterpret cast, e.g., 189/// @c reinterpret_cast<int>(VoidPtr). 190class CXXReinterpretCastExpr : public CXXNamedCastExpr { 191public: 192 CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op, 193 QualType writtenTy, SourceLocation l) 194 : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, 195 writtenTy, l) {} 196 197 static bool classof(const Stmt *T) { 198 return T->getStmtClass() == CXXReinterpretCastExprClass; 199 } 200 static bool classof(const CXXReinterpretCastExpr *) { return true; } 201}; 202 203/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 204/// which can remove type qualifiers but does not change the underlying value. 205/// 206/// This expression node represents a const cast, e.g., 207/// @c const_cast<char*>(PtrToConstChar). 208class CXXConstCastExpr : public CXXNamedCastExpr { 209public: 210 CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 211 SourceLocation l) 212 : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {} 213 214 static bool classof(const Stmt *T) { 215 return T->getStmtClass() == CXXConstCastExprClass; 216 } 217 static bool classof(const CXXConstCastExpr *) { return true; } 218}; 219 220/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 221/// 222class CXXBoolLiteralExpr : public Expr { 223 bool Value; 224 SourceLocation Loc; 225public: 226 CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 227 Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 228 229 bool getValue() const { return Value; } 230 231 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 232 233 static bool classof(const Stmt *T) { 234 return T->getStmtClass() == CXXBoolLiteralExprClass; 235 } 236 static bool classof(const CXXBoolLiteralExpr *) { return true; } 237 238 // Iterators 239 virtual child_iterator child_begin(); 240 virtual child_iterator child_end(); 241}; 242 243/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 244class CXXNullPtrLiteralExpr : public Expr { 245 SourceLocation Loc; 246public: 247 CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 248 Expr(CXXNullPtrLiteralExprClass, Ty), Loc(l) {} 249 250 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 251 252 static bool classof(const Stmt *T) { 253 return T->getStmtClass() == CXXNullPtrLiteralExprClass; 254 } 255 static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 256 257 virtual child_iterator child_begin(); 258 virtual child_iterator child_end(); 259}; 260 261/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 262/// the type_info that corresponds to the supplied type, or the (possibly 263/// dynamic) type of the supplied expression. 264/// 265/// This represents code like @c typeid(int) or @c typeid(*objPtr) 266class CXXTypeidExpr : public Expr { 267private: 268 bool isTypeOp : 1; 269 union { 270 void *Ty; 271 Stmt *Ex; 272 } Operand; 273 SourceRange Range; 274 275public: 276 CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 277 Expr(CXXTypeidExprClass, Ty, 278 // typeid is never type-dependent (C++ [temp.dep.expr]p4) 279 false, 280 // typeid is value-dependent if the type or expression are dependent 281 (isTypeOp ? QualType::getFromOpaquePtr(op)->isDependentType() 282 : static_cast<Expr*>(op)->isValueDependent())), 283 isTypeOp(isTypeOp), Range(r) { 284 if (isTypeOp) 285 Operand.Ty = op; 286 else 287 // op was an Expr*, so cast it back to that to be safe 288 Operand.Ex = static_cast<Expr*>(op); 289 } 290 291 bool isTypeOperand() const { return isTypeOp; } 292 QualType getTypeOperand() const { 293 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 294 return QualType::getFromOpaquePtr(Operand.Ty); 295 } 296 Expr* getExprOperand() const { 297 assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 298 return static_cast<Expr*>(Operand.Ex); 299 } 300 301 virtual SourceRange getSourceRange() const { 302 return Range; 303 } 304 static bool classof(const Stmt *T) { 305 return T->getStmtClass() == CXXTypeidExprClass; 306 } 307 static bool classof(const CXXTypeidExpr *) { return true; } 308 309 // Iterators 310 virtual child_iterator child_begin(); 311 virtual child_iterator child_end(); 312}; 313 314/// CXXThisExpr - Represents the "this" expression in C++, which is a 315/// pointer to the object on which the current member function is 316/// executing (C++ [expr.prim]p3). Example: 317/// 318/// @code 319/// class Foo { 320/// public: 321/// void bar(); 322/// void test() { this->bar(); } 323/// }; 324/// @endcode 325class CXXThisExpr : public Expr { 326 SourceLocation Loc; 327 328public: 329 CXXThisExpr(SourceLocation L, QualType Type) 330 : Expr(CXXThisExprClass, Type, 331 // 'this' is type-dependent if the class type of the enclosing 332 // member function is dependent (C++ [temp.dep.expr]p2) 333 Type->isDependentType(), Type->isDependentType()), 334 Loc(L) { } 335 336 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 337 338 static bool classof(const Stmt *T) { 339 return T->getStmtClass() == CXXThisExprClass; 340 } 341 static bool classof(const CXXThisExpr *) { return true; } 342 343 // Iterators 344 virtual child_iterator child_begin(); 345 virtual child_iterator child_end(); 346}; 347 348/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 349/// 'throw' and 'throw' assignment-expression. When 350/// assignment-expression isn't present, Op will be null. 351/// 352class CXXThrowExpr : public Expr { 353 Stmt *Op; 354 SourceLocation ThrowLoc; 355public: 356 // Ty is the void type which is used as the result type of the 357 // exepression. The l is the location of the throw keyword. expr 358 // can by null, if the optional expression to throw isn't present. 359 CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 360 Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 361 const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 362 Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 363 void setSubExpr(Expr *E) { Op = E; } 364 365 SourceLocation getThrowLoc() const { return ThrowLoc; } 366 void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 367 368 virtual SourceRange getSourceRange() const { 369 if (getSubExpr() == 0) 370 return SourceRange(ThrowLoc, ThrowLoc); 371 return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 372 } 373 374 static bool classof(const Stmt *T) { 375 return T->getStmtClass() == CXXThrowExprClass; 376 } 377 static bool classof(const CXXThrowExpr *) { return true; } 378 379 // Iterators 380 virtual child_iterator child_begin(); 381 virtual child_iterator child_end(); 382}; 383 384/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 385/// function call argument that was created from the corresponding 386/// parameter's default argument, when the call did not explicitly 387/// supply arguments for all of the parameters. 388class CXXDefaultArgExpr : public Expr { 389 ParmVarDecl *Param; 390 391protected: 392 CXXDefaultArgExpr(StmtClass SC, ParmVarDecl *param) 393 : Expr(SC, param->hasUnparsedDefaultArg() ? 394 param->getType().getNonReferenceType() 395 : param->getDefaultArg()->getType()), 396 Param(param) { } 397 398public: 399 // Param is the parameter whose default argument is used by this 400 // expression. 401 static CXXDefaultArgExpr *Create(ASTContext &C, ParmVarDecl *Param) { 402 return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Param); 403 } 404 405 // Retrieve the parameter that the argument was created from. 406 const ParmVarDecl *getParam() const { return Param; } 407 ParmVarDecl *getParam() { return Param; } 408 409 // Retrieve the actual argument to the function call. 410 const Expr *getExpr() const { return Param->getDefaultArg(); } 411 Expr *getExpr() { return Param->getDefaultArg(); } 412 413 virtual SourceRange getSourceRange() const { 414 // Default argument expressions have no representation in the 415 // source, so they have an empty source range. 416 return SourceRange(); 417 } 418 419 static bool classof(const Stmt *T) { 420 return T->getStmtClass() == CXXDefaultArgExprClass; 421 } 422 static bool classof(const CXXDefaultArgExpr *) { return true; } 423 424 // Iterators 425 virtual child_iterator child_begin(); 426 virtual child_iterator child_end(); 427}; 428 429/// CXXTemporary - Represents a C++ temporary. 430class CXXTemporary { 431 /// Destructor - The destructor that needs to be called. 432 const CXXDestructorDecl *Destructor; 433 434 CXXTemporary(const CXXDestructorDecl *destructor) 435 : Destructor(destructor) { } 436 ~CXXTemporary() { } 437 438public: 439 static CXXTemporary *Create(ASTContext &C, 440 const CXXDestructorDecl *Destructor); 441 442 void Destroy(ASTContext &Ctx); 443 444 const CXXDestructorDecl *getDestructor() const { return Destructor; } 445}; 446 447/// CXXBindTemporaryExpr - Represents binding an expression to a temporary, 448/// so its destructor can be called later. 449class CXXBindTemporaryExpr : public Expr { 450 CXXTemporary *Temp; 451 452 Stmt *SubExpr; 453 454 CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) 455 : Expr(CXXBindTemporaryExprClass, 456 subexpr->getType()), Temp(temp), SubExpr(subexpr) { } 457 ~CXXBindTemporaryExpr() { } 458 459protected: 460 virtual void DoDestroy(ASTContext &C); 461 462public: 463 static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 464 Expr* SubExpr); 465 466 CXXTemporary *getTemporary() { return Temp; } 467 const CXXTemporary *getTemporary() const { return Temp; } 468 469 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 470 Expr *getSubExpr() { return cast<Expr>(SubExpr); } 471 void setSubExpr(Expr *E) { SubExpr = E; } 472 473 virtual SourceRange getSourceRange() const { 474 return SubExpr->getSourceRange(); 475 } 476 477 // Implement isa/cast/dyncast/etc. 478 static bool classof(const Stmt *T) { 479 return T->getStmtClass() == CXXBindTemporaryExprClass; 480 } 481 static bool classof(const CXXBindTemporaryExpr *) { return true; } 482 483 // Iterators 484 virtual child_iterator child_begin(); 485 virtual child_iterator child_end(); 486}; 487 488/// CXXConstructExpr - Represents a call to a C++ constructor. 489class CXXConstructExpr : public Expr { 490 CXXConstructorDecl *Constructor; 491 492 SourceLocation Loc; 493 bool Elidable : 1; 494 bool ZeroInitialization : 1; 495 Stmt **Args; 496 unsigned NumArgs; 497 498protected: 499 CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 500 SourceLocation Loc, 501 CXXConstructorDecl *d, bool elidable, 502 Expr **args, unsigned numargs, 503 bool ZeroInitialization = false); 504 ~CXXConstructExpr() { } 505 506 virtual void DoDestroy(ASTContext &C); 507 508public: 509 /// \brief Construct an empty C++ construction expression that will store 510 /// \p numargs arguments. 511 CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs); 512 513 static CXXConstructExpr *Create(ASTContext &C, QualType T, 514 SourceLocation Loc, 515 CXXConstructorDecl *D, bool Elidable, 516 Expr **Args, unsigned NumArgs, 517 bool ZeroInitialization = false); 518 519 520 CXXConstructorDecl* getConstructor() const { return Constructor; } 521 void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 522 523 SourceLocation getLocation() const { return Loc; } 524 void setLocation(SourceLocation Loc) { this->Loc = Loc; } 525 526 /// \brief Whether this construction is elidable. 527 bool isElidable() const { return Elidable; } 528 void setElidable(bool E) { Elidable = E; } 529 530 /// \brief Whether this construction first requires 531 /// zero-initialization before the initializer is called. 532 bool requiresZeroInitialization() const { return ZeroInitialization; } 533 void setRequiresZeroInitialization(bool ZeroInit) { 534 ZeroInitialization = ZeroInit; 535 } 536 537 typedef ExprIterator arg_iterator; 538 typedef ConstExprIterator const_arg_iterator; 539 540 arg_iterator arg_begin() { return Args; } 541 arg_iterator arg_end() { return Args + NumArgs; } 542 const_arg_iterator arg_begin() const { return Args; } 543 const_arg_iterator arg_end() const { return Args + NumArgs; } 544 545 Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 546 unsigned getNumArgs() const { return NumArgs; } 547 548 /// getArg - Return the specified argument. 549 Expr *getArg(unsigned Arg) { 550 assert(Arg < NumArgs && "Arg access out of range!"); 551 return cast<Expr>(Args[Arg]); 552 } 553 const Expr *getArg(unsigned Arg) const { 554 assert(Arg < NumArgs && "Arg access out of range!"); 555 return cast<Expr>(Args[Arg]); 556 } 557 558 /// setArg - Set the specified argument. 559 void setArg(unsigned Arg, Expr *ArgExpr) { 560 assert(Arg < NumArgs && "Arg access out of range!"); 561 Args[Arg] = ArgExpr; 562 } 563 564 virtual SourceRange getSourceRange() const { 565 // FIXME: Should we know where the parentheses are, if there are any? 566 if (NumArgs == 0) 567 return SourceRange(Loc); 568 569 return SourceRange(Loc, Args[NumArgs - 1]->getLocEnd()); 570 } 571 572 static bool classof(const Stmt *T) { 573 return T->getStmtClass() == CXXConstructExprClass || 574 T->getStmtClass() == CXXTemporaryObjectExprClass; 575 } 576 static bool classof(const CXXConstructExpr *) { return true; } 577 578 // Iterators 579 virtual child_iterator child_begin(); 580 virtual child_iterator child_end(); 581}; 582 583/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 584/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 585/// x = int(0.5); 586class CXXFunctionalCastExpr : public ExplicitCastExpr { 587 SourceLocation TyBeginLoc; 588 SourceLocation RParenLoc; 589public: 590 CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 591 SourceLocation tyBeginLoc, CastKind kind, 592 Expr *castExpr, SourceLocation rParenLoc) 593 : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, 594 writtenTy), 595 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 596 597 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 598 SourceLocation getRParenLoc() const { return RParenLoc; } 599 600 virtual SourceRange getSourceRange() const { 601 return SourceRange(TyBeginLoc, RParenLoc); 602 } 603 static bool classof(const Stmt *T) { 604 return T->getStmtClass() == CXXFunctionalCastExprClass; 605 } 606 static bool classof(const CXXFunctionalCastExpr *) { return true; } 607}; 608 609/// @brief Represents a C++ functional cast expression that builds a 610/// temporary object. 611/// 612/// This expression type represents a C++ "functional" cast 613/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 614/// constructor to build a temporary object. If N == 0 but no 615/// constructor will be called (because the functional cast is 616/// performing a value-initialized an object whose class type has no 617/// user-declared constructors), CXXZeroInitValueExpr will represent 618/// the functional cast. Finally, with N == 1 arguments the functional 619/// cast expression will be represented by CXXFunctionalCastExpr. 620/// Example: 621/// @code 622/// struct X { X(int, float); } 623/// 624/// X create_X() { 625/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 626/// }; 627/// @endcode 628class CXXTemporaryObjectExpr : public CXXConstructExpr { 629 SourceLocation TyBeginLoc; 630 SourceLocation RParenLoc; 631 632public: 633 CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 634 QualType writtenTy, SourceLocation tyBeginLoc, 635 Expr **Args,unsigned NumArgs, 636 SourceLocation rParenLoc); 637 638 ~CXXTemporaryObjectExpr() { } 639 640 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 641 SourceLocation getRParenLoc() const { return RParenLoc; } 642 643 virtual SourceRange getSourceRange() const { 644 return SourceRange(TyBeginLoc, RParenLoc); 645 } 646 static bool classof(const Stmt *T) { 647 return T->getStmtClass() == CXXTemporaryObjectExprClass; 648 } 649 static bool classof(const CXXTemporaryObjectExpr *) { return true; } 650}; 651 652/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 653/// Expression "T()" which creates a value-initialized rvalue of type 654/// T, which is either a non-class type or a class type without any 655/// user-defined constructors. 656/// 657class CXXZeroInitValueExpr : public Expr { 658 SourceLocation TyBeginLoc; 659 SourceLocation RParenLoc; 660 661public: 662 CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 663 SourceLocation rParenLoc ) : 664 Expr(CXXZeroInitValueExprClass, ty, false, false), 665 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 666 667 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 668 SourceLocation getRParenLoc() const { return RParenLoc; } 669 670 /// @brief Whether this initialization expression was 671 /// implicitly-generated. 672 bool isImplicit() const { 673 return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 674 } 675 676 virtual SourceRange getSourceRange() const { 677 return SourceRange(TyBeginLoc, RParenLoc); 678 } 679 680 static bool classof(const Stmt *T) { 681 return T->getStmtClass() == CXXZeroInitValueExprClass; 682 } 683 static bool classof(const CXXZeroInitValueExpr *) { return true; } 684 685 // Iterators 686 virtual child_iterator child_begin(); 687 virtual child_iterator child_end(); 688}; 689 690/// CXXNewExpr - A new expression for memory allocation and constructor calls, 691/// e.g: "new CXXNewExpr(foo)". 692class CXXNewExpr : public Expr { 693 // Was the usage ::new, i.e. is the global new to be used? 694 bool GlobalNew : 1; 695 // Was the form (type-id) used? Otherwise, it was new-type-id. 696 bool ParenTypeId : 1; 697 // Is there an initializer? If not, built-ins are uninitialized, else they're 698 // value-initialized. 699 bool Initializer : 1; 700 // Do we allocate an array? If so, the first SubExpr is the size expression. 701 bool Array : 1; 702 // The number of placement new arguments. 703 unsigned NumPlacementArgs : 14; 704 // The number of constructor arguments. This may be 1 even for non-class 705 // types; use the pseudo copy constructor. 706 unsigned NumConstructorArgs : 14; 707 // Contains an optional array size expression, any number of optional 708 // placement arguments, and any number of optional constructor arguments, 709 // in that order. 710 Stmt **SubExprs; 711 // Points to the allocation function used. 712 FunctionDecl *OperatorNew; 713 // Points to the deallocation function used in case of error. May be null. 714 FunctionDecl *OperatorDelete; 715 // Points to the constructor used. Cannot be null if AllocType is a record; 716 // it would still point at the default constructor (even an implicit one). 717 // Must be null for all other types. 718 CXXConstructorDecl *Constructor; 719 720 SourceLocation StartLoc; 721 SourceLocation EndLoc; 722 723public: 724 CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 725 unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 726 CXXConstructorDecl *constructor, bool initializer, 727 Expr **constructorArgs, unsigned numConsArgs, 728 FunctionDecl *operatorDelete, QualType ty, 729 SourceLocation startLoc, SourceLocation endLoc); 730 ~CXXNewExpr() { 731 delete[] SubExprs; 732 } 733 734 QualType getAllocatedType() const { 735 assert(getType()->isPointerType()); 736 return getType()->getAs<PointerType>()->getPointeeType(); 737 } 738 739 FunctionDecl *getOperatorNew() const { return OperatorNew; } 740 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 741 CXXConstructorDecl *getConstructor() const { return Constructor; } 742 743 bool isArray() const { return Array; } 744 Expr *getArraySize() { 745 return Array ? cast<Expr>(SubExprs[0]) : 0; 746 } 747 const Expr *getArraySize() const { 748 return Array ? cast<Expr>(SubExprs[0]) : 0; 749 } 750 751 unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 752 Expr *getPlacementArg(unsigned i) { 753 assert(i < NumPlacementArgs && "Index out of range"); 754 return cast<Expr>(SubExprs[Array + i]); 755 } 756 const Expr *getPlacementArg(unsigned i) const { 757 assert(i < NumPlacementArgs && "Index out of range"); 758 return cast<Expr>(SubExprs[Array + i]); 759 } 760 761 bool isGlobalNew() const { return GlobalNew; } 762 bool isParenTypeId() const { return ParenTypeId; } 763 bool hasInitializer() const { return Initializer; } 764 765 unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 766 Expr *getConstructorArg(unsigned i) { 767 assert(i < NumConstructorArgs && "Index out of range"); 768 return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 769 } 770 const Expr *getConstructorArg(unsigned i) const { 771 assert(i < NumConstructorArgs && "Index out of range"); 772 return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 773 } 774 775 typedef ExprIterator arg_iterator; 776 typedef ConstExprIterator const_arg_iterator; 777 778 arg_iterator placement_arg_begin() { 779 return SubExprs + Array; 780 } 781 arg_iterator placement_arg_end() { 782 return SubExprs + Array + getNumPlacementArgs(); 783 } 784 const_arg_iterator placement_arg_begin() const { 785 return SubExprs + Array; 786 } 787 const_arg_iterator placement_arg_end() const { 788 return SubExprs + Array + getNumPlacementArgs(); 789 } 790 791 arg_iterator constructor_arg_begin() { 792 return SubExprs + Array + getNumPlacementArgs(); 793 } 794 arg_iterator constructor_arg_end() { 795 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 796 } 797 const_arg_iterator constructor_arg_begin() const { 798 return SubExprs + Array + getNumPlacementArgs(); 799 } 800 const_arg_iterator constructor_arg_end() const { 801 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 802 } 803 804 virtual SourceRange getSourceRange() const { 805 return SourceRange(StartLoc, EndLoc); 806 } 807 808 static bool classof(const Stmt *T) { 809 return T->getStmtClass() == CXXNewExprClass; 810 } 811 static bool classof(const CXXNewExpr *) { return true; } 812 813 // Iterators 814 virtual child_iterator child_begin(); 815 virtual child_iterator child_end(); 816}; 817 818/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 819/// calls, e.g. "delete[] pArray". 820class CXXDeleteExpr : public Expr { 821 // Is this a forced global delete, i.e. "::delete"? 822 bool GlobalDelete : 1; 823 // Is this the array form of delete, i.e. "delete[]"? 824 bool ArrayForm : 1; 825 // Points to the operator delete overload that is used. Could be a member. 826 FunctionDecl *OperatorDelete; 827 // The pointer expression to be deleted. 828 Stmt *Argument; 829 // Location of the expression. 830 SourceLocation Loc; 831public: 832 CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 833 FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 834 : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 835 ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 836 Loc(loc) { } 837 838 bool isGlobalDelete() const { return GlobalDelete; } 839 bool isArrayForm() const { return ArrayForm; } 840 841 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 842 843 Expr *getArgument() { return cast<Expr>(Argument); } 844 const Expr *getArgument() const { return cast<Expr>(Argument); } 845 846 virtual SourceRange getSourceRange() const { 847 return SourceRange(Loc, Argument->getLocEnd()); 848 } 849 850 static bool classof(const Stmt *T) { 851 return T->getStmtClass() == CXXDeleteExprClass; 852 } 853 static bool classof(const CXXDeleteExpr *) { return true; } 854 855 // Iterators 856 virtual child_iterator child_begin(); 857 virtual child_iterator child_end(); 858}; 859 860/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 861/// 862/// Example: 863/// 864/// \code 865/// template<typename T> 866/// void destroy(T* ptr) { 867/// ptr->~T(); 868/// } 869/// \endcode 870/// 871/// When the template is parsed, the expression \c ptr->~T will be stored as 872/// a member reference expression. If it then instantiated with a scalar type 873/// as a template argument for T, the resulting expression will be a 874/// pseudo-destructor expression. 875class CXXPseudoDestructorExpr : public Expr { 876 /// \brief The base expression (that is being destroyed). 877 Stmt *Base; 878 879 /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 880 /// period ('.'). 881 bool IsArrow : 1; 882 883 /// \brief The location of the '.' or '->' operator. 884 SourceLocation OperatorLoc; 885 886 /// \brief The nested-name-specifier that follows the operator, if present. 887 NestedNameSpecifier *Qualifier; 888 889 /// \brief The source range that covers the nested-name-specifier, if 890 /// present. 891 SourceRange QualifierRange; 892 893 /// \brief The type being destroyed. 894 QualType DestroyedType; 895 896 /// \brief The location of the type after the '~'. 897 SourceLocation DestroyedTypeLoc; 898 899public: 900 CXXPseudoDestructorExpr(ASTContext &Context, 901 Expr *Base, bool isArrow, SourceLocation OperatorLoc, 902 NestedNameSpecifier *Qualifier, 903 SourceRange QualifierRange, 904 QualType DestroyedType, 905 SourceLocation DestroyedTypeLoc) 906 : Expr(CXXPseudoDestructorExprClass, 907 Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, 908 false, 0)), 909 /*isTypeDependent=*/false, 910 /*isValueDependent=*/Base->isValueDependent()), 911 Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), 912 OperatorLoc(OperatorLoc), Qualifier(Qualifier), 913 QualifierRange(QualifierRange), DestroyedType(DestroyedType), 914 DestroyedTypeLoc(DestroyedTypeLoc) { } 915 916 void setBase(Expr *E) { Base = E; } 917 Expr *getBase() const { return cast<Expr>(Base); } 918 919 /// \brief Determines whether this member expression actually had 920 /// a C++ nested-name-specifier prior to the name of the member, e.g., 921 /// x->Base::foo. 922 bool hasQualifier() const { return Qualifier != 0; } 923 924 /// \brief If the member name was qualified, retrieves the source range of 925 /// the nested-name-specifier that precedes the member name. Otherwise, 926 /// returns an empty source range. 927 SourceRange getQualifierRange() const { return QualifierRange; } 928 929 /// \brief If the member name was qualified, retrieves the 930 /// nested-name-specifier that precedes the member name. Otherwise, returns 931 /// NULL. 932 NestedNameSpecifier *getQualifier() const { return Qualifier; } 933 934 /// \brief Determine whether this pseudo-destructor expression was written 935 /// using an '->' (otherwise, it used a '.'). 936 bool isArrow() const { return IsArrow; } 937 void setArrow(bool A) { IsArrow = A; } 938 939 /// \brief Retrieve the location of the '.' or '->' operator. 940 SourceLocation getOperatorLoc() const { return OperatorLoc; } 941 942 /// \brief Retrieve the type that is being destroyed. 943 QualType getDestroyedType() const { return DestroyedType; } 944 945 /// \brief Retrieve the location of the type being destroyed. 946 SourceLocation getDestroyedTypeLoc() const { return DestroyedTypeLoc; } 947 948 virtual SourceRange getSourceRange() const { 949 return SourceRange(Base->getLocStart(), DestroyedTypeLoc); 950 } 951 952 static bool classof(const Stmt *T) { 953 return T->getStmtClass() == CXXPseudoDestructorExprClass; 954 } 955 static bool classof(const CXXPseudoDestructorExpr *) { return true; } 956 957 // Iterators 958 virtual child_iterator child_begin(); 959 virtual child_iterator child_end(); 960}; 961 962/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 963/// implementation of TR1/C++0x type trait templates. 964/// Example: 965/// __is_pod(int) == true 966/// __is_enum(std::string) == false 967class UnaryTypeTraitExpr : public Expr { 968 /// UTT - The trait. 969 UnaryTypeTrait UTT; 970 971 /// Loc - The location of the type trait keyword. 972 SourceLocation Loc; 973 974 /// RParen - The location of the closing paren. 975 SourceLocation RParen; 976 977 /// QueriedType - The type we're testing. 978 QualType QueriedType; 979 980public: 981 UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 982 SourceLocation rparen, QualType ty) 983 : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 984 UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 985 986 virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 987 988 UnaryTypeTrait getTrait() const { return UTT; } 989 990 QualType getQueriedType() const { return QueriedType; } 991 992 bool EvaluateTrait(ASTContext&) const; 993 994 static bool classof(const Stmt *T) { 995 return T->getStmtClass() == UnaryTypeTraitExprClass; 996 } 997 static bool classof(const UnaryTypeTraitExpr *) { return true; } 998 999 // Iterators 1000 virtual child_iterator child_begin(); 1001 virtual child_iterator child_end(); 1002}; 1003 1004/// \brief A reference to a name which we were able to look up during 1005/// parsing but could not resolve to a specific declaration. This 1006/// arises in several ways: 1007/// * we might be waiting for argument-dependent lookup 1008/// * the name might resolve to an overloaded function 1009/// and eventually: 1010/// * the lookup might have included a function template 1011/// These never include UnresolvedUsingValueDecls, which are always 1012/// class members and therefore appear only in 1013/// UnresolvedMemberLookupExprs. 1014class UnresolvedLookupExpr : public Expr { 1015 /// The results. These are undesugared, which is to say, they may 1016 /// include UsingShadowDecls. 1017 UnresolvedSet Results; 1018 1019 /// The name declared. 1020 DeclarationName Name; 1021 1022 /// The qualifier given, if any. 1023 NestedNameSpecifier *Qualifier; 1024 1025 /// The source range of the nested name specifier. 1026 SourceRange QualifierRange; 1027 1028 /// The location of the name. 1029 SourceLocation NameLoc; 1030 1031 /// True if these lookup results should be extended by 1032 /// argument-dependent lookup if this is the operand of a function 1033 /// call. 1034 bool RequiresADL; 1035 1036 /// True if these lookup results are overloaded. This is pretty 1037 /// trivially rederivable if we urgently need to kill this field. 1038 bool Overloaded; 1039 1040 /// True if the name looked up had explicit template arguments. 1041 /// This requires all the results to be function templates. 1042 bool HasExplicitTemplateArgs; 1043 1044 UnresolvedLookupExpr(QualType T, bool Dependent, 1045 NestedNameSpecifier *Qualifier, SourceRange QRange, 1046 DeclarationName Name, SourceLocation NameLoc, 1047 bool RequiresADL, bool Overloaded, bool HasTemplateArgs) 1048 : Expr(UnresolvedLookupExprClass, T, Dependent, Dependent), 1049 Name(Name), Qualifier(Qualifier), QualifierRange(QRange), 1050 NameLoc(NameLoc), RequiresADL(RequiresADL), Overloaded(Overloaded), 1051 HasExplicitTemplateArgs(HasTemplateArgs) 1052 {} 1053 1054public: 1055 static UnresolvedLookupExpr *Create(ASTContext &C, 1056 bool Dependent, 1057 NestedNameSpecifier *Qualifier, 1058 SourceRange QualifierRange, 1059 DeclarationName Name, 1060 SourceLocation NameLoc, 1061 bool ADL, bool Overloaded) { 1062 return new(C) UnresolvedLookupExpr(Dependent ? C.DependentTy : C.OverloadTy, 1063 Dependent, Qualifier, QualifierRange, 1064 Name, NameLoc, ADL, Overloaded, false); 1065 } 1066 1067 static UnresolvedLookupExpr *Create(ASTContext &C, 1068 bool Dependent, 1069 NestedNameSpecifier *Qualifier, 1070 SourceRange QualifierRange, 1071 DeclarationName Name, 1072 SourceLocation NameLoc, 1073 bool ADL, 1074 const TemplateArgumentListInfo &Args); 1075 1076 /// Computes whether an unresolved lookup on the given declarations 1077 /// and optional template arguments is type- and value-dependent. 1078 static bool ComputeDependence(NamedDecl * const *Begin, 1079 NamedDecl * const *End, 1080 const TemplateArgumentListInfo *Args); 1081 1082 void addDecl(NamedDecl *Decl) { 1083 Results.addDecl(Decl); 1084 } 1085 1086 typedef UnresolvedSet::iterator decls_iterator; 1087 decls_iterator decls_begin() const { return Results.begin(); } 1088 decls_iterator decls_end() const { return Results.end(); } 1089 1090 /// True if this declaration should be extended by 1091 /// argument-dependent lookup. 1092 bool requiresADL() const { return RequiresADL; } 1093 1094 /// True if this lookup is overloaded. 1095 bool isOverloaded() const { return Overloaded; } 1096 1097 /// Fetches the name looked up. 1098 DeclarationName getName() const { return Name; } 1099 1100 /// Gets the location of the name. 1101 SourceLocation getNameLoc() const { return NameLoc; } 1102 1103 /// Fetches the nested-name qualifier, if one was given. 1104 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1105 1106 /// Fetches the range of the nested-name qualifier. 1107 SourceRange getQualifierRange() const { return QualifierRange; } 1108 1109 /// Determines whether this lookup had explicit template arguments. 1110 bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 1111 1112 // Note that, inconsistently with the explicit-template-argument AST 1113 // nodes, users are *forbidden* from calling these methods on objects 1114 // without explicit template arguments. 1115 1116 /// Gets a reference to the explicit template argument list. 1117 const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1118 assert(hasExplicitTemplateArgs()); 1119 return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1120 } 1121 1122 /// \brief Copies the template arguments (if present) into the given 1123 /// structure. 1124 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1125 getExplicitTemplateArgs().copyInto(List); 1126 } 1127 1128 SourceLocation getLAngleLoc() const { 1129 return getExplicitTemplateArgs().LAngleLoc; 1130 } 1131 1132 SourceLocation getRAngleLoc() const { 1133 return getExplicitTemplateArgs().RAngleLoc; 1134 } 1135 1136 TemplateArgumentLoc const *getTemplateArgs() const { 1137 return getExplicitTemplateArgs().getTemplateArgs(); 1138 } 1139 1140 unsigned getNumTemplateArgs() const { 1141 return getExplicitTemplateArgs().NumTemplateArgs; 1142 } 1143 1144 virtual SourceRange getSourceRange() const { 1145 SourceRange Range(NameLoc); 1146 if (Qualifier) Range.setBegin(QualifierRange.getBegin()); 1147 if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc()); 1148 return Range; 1149 } 1150 1151 virtual StmtIterator child_begin(); 1152 virtual StmtIterator child_end(); 1153 1154 static bool classof(const Stmt *T) { 1155 return T->getStmtClass() == UnresolvedLookupExprClass; 1156 } 1157 static bool classof(const UnresolvedLookupExpr *) { return true; } 1158}; 1159 1160/// \brief A qualified reference to a name whose declaration cannot 1161/// yet be resolved. 1162/// 1163/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 1164/// it expresses a reference to a declaration such as 1165/// X<T>::value. The difference, however, is that an 1166/// DependentScopeDeclRefExpr node is used only within C++ templates when 1167/// the qualification (e.g., X<T>::) refers to a dependent type. In 1168/// this case, X<T>::value cannot resolve to a declaration because the 1169/// declaration will differ from on instantiation of X<T> to the 1170/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 1171/// qualifier (X<T>::) and the name of the entity being referenced 1172/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 1173/// declaration can be found. 1174class DependentScopeDeclRefExpr : public Expr { 1175 /// The name of the entity we will be referencing. 1176 DeclarationName Name; 1177 1178 /// Location of the name of the declaration we're referencing. 1179 SourceLocation Loc; 1180 1181 /// QualifierRange - The source range that covers the 1182 /// nested-name-specifier. 1183 SourceRange QualifierRange; 1184 1185 /// \brief The nested-name-specifier that qualifies this unresolved 1186 /// declaration name. 1187 NestedNameSpecifier *Qualifier; 1188 1189 /// \brief Whether the name includes explicit template arguments. 1190 bool HasExplicitTemplateArgs; 1191 1192 DependentScopeDeclRefExpr(QualType T, 1193 NestedNameSpecifier *Qualifier, 1194 SourceRange QualifierRange, 1195 DeclarationName Name, 1196 SourceLocation NameLoc, 1197 bool HasExplicitTemplateArgs) 1198 : Expr(DependentScopeDeclRefExprClass, T, true, true), 1199 Name(Name), Loc(NameLoc), 1200 QualifierRange(QualifierRange), Qualifier(Qualifier), 1201 HasExplicitTemplateArgs(HasExplicitTemplateArgs) 1202 {} 1203 1204public: 1205 static DependentScopeDeclRefExpr *Create(ASTContext &C, 1206 NestedNameSpecifier *Qualifier, 1207 SourceRange QualifierRange, 1208 DeclarationName Name, 1209 SourceLocation NameLoc, 1210 const TemplateArgumentListInfo *TemplateArgs = 0); 1211 1212 /// \brief Retrieve the name that this expression refers to. 1213 DeclarationName getDeclName() const { return Name; } 1214 1215 /// \brief Retrieve the location of the name within the expression. 1216 SourceLocation getLocation() const { return Loc; } 1217 1218 /// \brief Retrieve the source range of the nested-name-specifier. 1219 SourceRange getQualifierRange() const { return QualifierRange; } 1220 1221 /// \brief Retrieve the nested-name-specifier that qualifies this 1222 /// declaration. 1223 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1224 1225 /// Determines whether this lookup had explicit template arguments. 1226 bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 1227 1228 // Note that, inconsistently with the explicit-template-argument AST 1229 // nodes, users are *forbidden* from calling these methods on objects 1230 // without explicit template arguments. 1231 1232 /// Gets a reference to the explicit template argument list. 1233 const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1234 assert(hasExplicitTemplateArgs()); 1235 return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1236 } 1237 1238 /// \brief Copies the template arguments (if present) into the given 1239 /// structure. 1240 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1241 getExplicitTemplateArgs().copyInto(List); 1242 } 1243 1244 SourceLocation getLAngleLoc() const { 1245 return getExplicitTemplateArgs().LAngleLoc; 1246 } 1247 1248 SourceLocation getRAngleLoc() const { 1249 return getExplicitTemplateArgs().RAngleLoc; 1250 } 1251 1252 TemplateArgumentLoc const *getTemplateArgs() const { 1253 return getExplicitTemplateArgs().getTemplateArgs(); 1254 } 1255 1256 unsigned getNumTemplateArgs() const { 1257 return getExplicitTemplateArgs().NumTemplateArgs; 1258 } 1259 1260 virtual SourceRange getSourceRange() const { 1261 SourceRange Range(QualifierRange.getBegin(), getLocation()); 1262 if (hasExplicitTemplateArgs()) 1263 Range.setEnd(getRAngleLoc()); 1264 return Range; 1265 } 1266 1267 static bool classof(const Stmt *T) { 1268 return T->getStmtClass() == DependentScopeDeclRefExprClass; 1269 } 1270 static bool classof(const DependentScopeDeclRefExpr *) { return true; } 1271 1272 virtual StmtIterator child_begin(); 1273 virtual StmtIterator child_end(); 1274}; 1275 1276class CXXExprWithTemporaries : public Expr { 1277 Stmt *SubExpr; 1278 1279 CXXTemporary **Temps; 1280 unsigned NumTemps; 1281 1282 CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps, 1283 unsigned NumTemps); 1284 ~CXXExprWithTemporaries(); 1285 1286protected: 1287 virtual void DoDestroy(ASTContext &C); 1288 1289public: 1290 static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, 1291 CXXTemporary **Temps, 1292 unsigned NumTemps); 1293 1294 unsigned getNumTemporaries() const { return NumTemps; } 1295 CXXTemporary *getTemporary(unsigned i) { 1296 assert(i < NumTemps && "Index out of range"); 1297 return Temps[i]; 1298 } 1299 const CXXTemporary *getTemporary(unsigned i) const { 1300 return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i); 1301 } 1302 1303 Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1304 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 1305 void setSubExpr(Expr *E) { SubExpr = E; } 1306 1307 virtual SourceRange getSourceRange() const { 1308 return SubExpr->getSourceRange(); 1309 } 1310 1311 // Implement isa/cast/dyncast/etc. 1312 static bool classof(const Stmt *T) { 1313 return T->getStmtClass() == CXXExprWithTemporariesClass; 1314 } 1315 static bool classof(const CXXExprWithTemporaries *) { return true; } 1316 1317 // Iterators 1318 virtual child_iterator child_begin(); 1319 virtual child_iterator child_end(); 1320}; 1321 1322/// \brief Describes an explicit type conversion that uses functional 1323/// notion but could not be resolved because one or more arguments are 1324/// type-dependent. 1325/// 1326/// The explicit type conversions expressed by 1327/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 1328/// where \c T is some type and \c a1, a2, ..., aN are values, and 1329/// either \C T is a dependent type or one or more of the \c a's is 1330/// type-dependent. For example, this would occur in a template such 1331/// as: 1332/// 1333/// \code 1334/// template<typename T, typename A1> 1335/// inline T make_a(const A1& a1) { 1336/// return T(a1); 1337/// } 1338/// \endcode 1339/// 1340/// When the returned expression is instantiated, it may resolve to a 1341/// constructor call, conversion function call, or some kind of type 1342/// conversion. 1343class CXXUnresolvedConstructExpr : public Expr { 1344 /// \brief The starting location of the type 1345 SourceLocation TyBeginLoc; 1346 1347 /// \brief The type being constructed. 1348 QualType Type; 1349 1350 /// \brief The location of the left parentheses ('('). 1351 SourceLocation LParenLoc; 1352 1353 /// \brief The location of the right parentheses (')'). 1354 SourceLocation RParenLoc; 1355 1356 /// \brief The number of arguments used to construct the type. 1357 unsigned NumArgs; 1358 1359 CXXUnresolvedConstructExpr(SourceLocation TyBegin, 1360 QualType T, 1361 SourceLocation LParenLoc, 1362 Expr **Args, 1363 unsigned NumArgs, 1364 SourceLocation RParenLoc); 1365 1366public: 1367 static CXXUnresolvedConstructExpr *Create(ASTContext &C, 1368 SourceLocation TyBegin, 1369 QualType T, 1370 SourceLocation LParenLoc, 1371 Expr **Args, 1372 unsigned NumArgs, 1373 SourceLocation RParenLoc); 1374 1375 /// \brief Retrieve the source location where the type begins. 1376 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 1377 void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 1378 1379 /// \brief Retrieve the type that is being constructed, as specified 1380 /// in the source code. 1381 QualType getTypeAsWritten() const { return Type; } 1382 void setTypeAsWritten(QualType T) { Type = T; } 1383 1384 /// \brief Retrieve the location of the left parentheses ('(') that 1385 /// precedes the argument list. 1386 SourceLocation getLParenLoc() const { return LParenLoc; } 1387 void setLParenLoc(SourceLocation L) { LParenLoc = L; } 1388 1389 /// \brief Retrieve the location of the right parentheses (')') that 1390 /// follows the argument list. 1391 SourceLocation getRParenLoc() const { return RParenLoc; } 1392 void setRParenLoc(SourceLocation L) { RParenLoc = L; } 1393 1394 /// \brief Retrieve the number of arguments. 1395 unsigned arg_size() const { return NumArgs; } 1396 1397 typedef Expr** arg_iterator; 1398 arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 1399 arg_iterator arg_end() { return arg_begin() + NumArgs; } 1400 1401 Expr *getArg(unsigned I) { 1402 assert(I < NumArgs && "Argument index out-of-range"); 1403 return *(arg_begin() + I); 1404 } 1405 1406 virtual SourceRange getSourceRange() const { 1407 return SourceRange(TyBeginLoc, RParenLoc); 1408 } 1409 static bool classof(const Stmt *T) { 1410 return T->getStmtClass() == CXXUnresolvedConstructExprClass; 1411 } 1412 static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 1413 1414 // Iterators 1415 virtual child_iterator child_begin(); 1416 virtual child_iterator child_end(); 1417}; 1418 1419/// \brief Represents a C++ member access expression where the actual 1420/// member referenced could not be resolved because the base 1421/// expression or the member name was dependent. 1422/// 1423/// Like UnresolvedMemberExprs, these can be either implicit or 1424/// explicit accesses. It is only possible to get one of these with 1425/// an implicit access if a qualifier is provided. 1426class CXXDependentScopeMemberExpr : public Expr { 1427 /// \brief The expression for the base pointer or class reference, 1428 /// e.g., the \c x in x.f. Can be null in implicit accesses. 1429 Stmt *Base; 1430 1431 /// \brief The type of the base expression. Never null, even for 1432 /// implicit accesses. 1433 QualType BaseType; 1434 1435 /// \brief Whether this member expression used the '->' operator or 1436 /// the '.' operator. 1437 bool IsArrow : 1; 1438 1439 /// \brief Whether this member expression has explicitly-specified template 1440 /// arguments. 1441 bool HasExplicitTemplateArgs : 1; 1442 1443 /// \brief The location of the '->' or '.' operator. 1444 SourceLocation OperatorLoc; 1445 1446 /// \brief The nested-name-specifier that precedes the member name, if any. 1447 NestedNameSpecifier *Qualifier; 1448 1449 /// \brief The source range covering the nested name specifier. 1450 SourceRange QualifierRange; 1451 1452 /// \brief In a qualified member access expression such as t->Base::f, this 1453 /// member stores the resolves of name lookup in the context of the member 1454 /// access expression, to be used at instantiation time. 1455 /// 1456 /// FIXME: This member, along with the Qualifier and QualifierRange, could 1457 /// be stuck into a structure that is optionally allocated at the end of 1458 /// the CXXDependentScopeMemberExpr, to save space in the common case. 1459 NamedDecl *FirstQualifierFoundInScope; 1460 1461 /// \brief The member to which this member expression refers, which 1462 /// can be name, overloaded operator, or destructor. 1463 /// FIXME: could also be a template-id 1464 DeclarationName Member; 1465 1466 /// \brief The location of the member name. 1467 SourceLocation MemberLoc; 1468 1469 /// \brief Retrieve the explicit template argument list that followed the 1470 /// member template name, if any. 1471 ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { 1472 assert(HasExplicitTemplateArgs); 1473 return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 1474 } 1475 1476 /// \brief Retrieve the explicit template argument list that followed the 1477 /// member template name, if any. 1478 const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { 1479 return const_cast<CXXDependentScopeMemberExpr *>(this) 1480 ->getExplicitTemplateArgumentList(); 1481 } 1482 1483 CXXDependentScopeMemberExpr(ASTContext &C, 1484 Expr *Base, QualType BaseType, bool IsArrow, 1485 SourceLocation OperatorLoc, 1486 NestedNameSpecifier *Qualifier, 1487 SourceRange QualifierRange, 1488 NamedDecl *FirstQualifierFoundInScope, 1489 DeclarationName Member, 1490 SourceLocation MemberLoc, 1491 const TemplateArgumentListInfo *TemplateArgs); 1492 1493public: 1494 CXXDependentScopeMemberExpr(ASTContext &C, 1495 Expr *Base, QualType BaseType, 1496 bool IsArrow, 1497 SourceLocation OperatorLoc, 1498 NestedNameSpecifier *Qualifier, 1499 SourceRange QualifierRange, 1500 NamedDecl *FirstQualifierFoundInScope, 1501 DeclarationName Member, 1502 SourceLocation MemberLoc) 1503 : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true), 1504 Base(Base), BaseType(BaseType), IsArrow(IsArrow), 1505 HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc), 1506 Qualifier(Qualifier), QualifierRange(QualifierRange), 1507 FirstQualifierFoundInScope(FirstQualifierFoundInScope), 1508 Member(Member), MemberLoc(MemberLoc) { } 1509 1510 static CXXDependentScopeMemberExpr * 1511 Create(ASTContext &C, 1512 Expr *Base, QualType BaseType, bool IsArrow, 1513 SourceLocation OperatorLoc, 1514 NestedNameSpecifier *Qualifier, 1515 SourceRange QualifierRange, 1516 NamedDecl *FirstQualifierFoundInScope, 1517 DeclarationName Member, 1518 SourceLocation MemberLoc, 1519 const TemplateArgumentListInfo *TemplateArgs); 1520 1521 /// \brief True if this is an implicit access, i.e. one in which the 1522 /// member being accessed was not written in the source. The source 1523 /// location of the operator is invalid in this case. 1524 bool isImplicitAccess() const { return Base == 0; } 1525 1526 /// \brief Retrieve the base object of this member expressions, 1527 /// e.g., the \c x in \c x.m. 1528 Expr *getBase() const { 1529 assert(!isImplicitAccess()); 1530 return cast<Expr>(Base); 1531 } 1532 void setBase(Expr *E) { Base = E; } 1533 1534 QualType getBaseType() const { return BaseType; } 1535 1536 /// \brief Determine whether this member expression used the '->' 1537 /// operator; otherwise, it used the '.' operator. 1538 bool isArrow() const { return IsArrow; } 1539 void setArrow(bool A) { IsArrow = A; } 1540 1541 /// \brief Retrieve the location of the '->' or '.' operator. 1542 SourceLocation getOperatorLoc() const { return OperatorLoc; } 1543 void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 1544 1545 /// \brief Retrieve the nested-name-specifier that qualifies the member 1546 /// name. 1547 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1548 1549 /// \brief Retrieve the source range covering the nested-name-specifier 1550 /// that qualifies the member name. 1551 SourceRange getQualifierRange() const { return QualifierRange; } 1552 1553 /// \brief Retrieve the first part of the nested-name-specifier that was 1554 /// found in the scope of the member access expression when the member access 1555 /// was initially parsed. 1556 /// 1557 /// This function only returns a useful result when member access expression 1558 /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 1559 /// returned by this function describes what was found by unqualified name 1560 /// lookup for the identifier "Base" within the scope of the member access 1561 /// expression itself. At template instantiation time, this information is 1562 /// combined with the results of name lookup into the type of the object 1563 /// expression itself (the class type of x). 1564 NamedDecl *getFirstQualifierFoundInScope() const { 1565 return FirstQualifierFoundInScope; 1566 } 1567 1568 /// \brief Retrieve the name of the member that this expression 1569 /// refers to. 1570 DeclarationName getMember() const { return Member; } 1571 void setMember(DeclarationName N) { Member = N; } 1572 1573 // \brief Retrieve the location of the name of the member that this 1574 // expression refers to. 1575 SourceLocation getMemberLoc() const { return MemberLoc; } 1576 void setMemberLoc(SourceLocation L) { MemberLoc = L; } 1577 1578 /// \brief Determines whether this member expression actually had a C++ 1579 /// template argument list explicitly specified, e.g., x.f<int>. 1580 bool hasExplicitTemplateArgs() const { 1581 return HasExplicitTemplateArgs; 1582 } 1583 1584 /// \brief Copies the template arguments (if present) into the given 1585 /// structure. 1586 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1587 assert(HasExplicitTemplateArgs); 1588 getExplicitTemplateArgumentList()->copyInto(List); 1589 } 1590 1591 /// \brief Retrieve the location of the left angle bracket following the 1592 /// member name ('<'), if any. 1593 SourceLocation getLAngleLoc() const { 1594 assert(HasExplicitTemplateArgs); 1595 return getExplicitTemplateArgumentList()->LAngleLoc; 1596 } 1597 1598 /// \brief Retrieve the template arguments provided as part of this 1599 /// template-id. 1600 const TemplateArgumentLoc *getTemplateArgs() const { 1601 assert(HasExplicitTemplateArgs); 1602 return getExplicitTemplateArgumentList()->getTemplateArgs(); 1603 } 1604 1605 /// \brief Retrieve the number of template arguments provided as part of this 1606 /// template-id. 1607 unsigned getNumTemplateArgs() const { 1608 assert(HasExplicitTemplateArgs); 1609 return getExplicitTemplateArgumentList()->NumTemplateArgs; 1610 } 1611 1612 /// \brief Retrieve the location of the right angle bracket following the 1613 /// template arguments ('>'). 1614 SourceLocation getRAngleLoc() const { 1615 assert(HasExplicitTemplateArgs); 1616 return getExplicitTemplateArgumentList()->RAngleLoc; 1617 } 1618 1619 virtual SourceRange getSourceRange() const { 1620 SourceRange Range; 1621 if (!isImplicitAccess()) 1622 Range.setBegin(Base->getSourceRange().getBegin()); 1623 else if (getQualifier()) 1624 Range.setBegin(getQualifierRange().getBegin()); 1625 else 1626 Range.setBegin(MemberLoc); 1627 1628 if (hasExplicitTemplateArgs()) 1629 Range.setEnd(getRAngleLoc()); 1630 else 1631 Range.setEnd(MemberLoc); 1632 return Range; 1633 } 1634 1635 static bool classof(const Stmt *T) { 1636 return T->getStmtClass() == CXXDependentScopeMemberExprClass; 1637 } 1638 static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 1639 1640 // Iterators 1641 virtual child_iterator child_begin(); 1642 virtual child_iterator child_end(); 1643}; 1644 1645/// \brief Represents a C++ member access expression for which lookup 1646/// produced a set of overloaded functions. 1647/// 1648/// The member access may be explicit or implicit: 1649/// struct A { 1650/// int a, b; 1651/// int explicitAccess() { return this->a + this->A::b; } 1652/// int implicitAccess() { return a + A::b; } 1653/// }; 1654/// 1655/// In the final AST, an explicit access always becomes a MemberExpr. 1656/// An implicit access may become either a MemberExpr or a 1657/// DeclRefExpr, depending on whether the member is static. 1658class UnresolvedMemberExpr : public Expr { 1659 /// The results. These are undesugared, which is to say, they may 1660 /// include UsingShadowDecls. 1661 UnresolvedSet Results; 1662 1663 /// \brief The expression for the base pointer or class reference, 1664 /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 1665 /// member expression 1666 Stmt *Base; 1667 1668 /// \brief The type of the base expression; never null. 1669 QualType BaseType; 1670 1671 /// \brief Whether this member expression used the '->' operator or 1672 /// the '.' operator. 1673 bool IsArrow : 1; 1674 1675 /// \brief Whether the lookup results contain an unresolved using 1676 /// declaration. 1677 bool HasUnresolvedUsing : 1; 1678 1679 /// \brief Whether this member expression has explicitly-specified template 1680 /// arguments. 1681 bool HasExplicitTemplateArgs : 1; 1682 1683 /// \brief The location of the '->' or '.' operator. 1684 SourceLocation OperatorLoc; 1685 1686 /// \brief The nested-name-specifier that precedes the member name, if any. 1687 NestedNameSpecifier *Qualifier; 1688 1689 /// \brief The source range covering the nested name specifier. 1690 SourceRange QualifierRange; 1691 1692 /// \brief The member to which this member expression refers, which 1693 /// can be a name or an overloaded operator. 1694 DeclarationName MemberName; 1695 1696 /// \brief The location of the member name. 1697 SourceLocation MemberLoc; 1698 1699 /// \brief Retrieve the explicit template argument list that followed the 1700 /// member template name. 1701 ExplicitTemplateArgumentList *getExplicitTemplateArgs() { 1702 assert(HasExplicitTemplateArgs); 1703 return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 1704 } 1705 1706 /// \brief Retrieve the explicit template argument list that followed the 1707 /// member template name, if any. 1708 const ExplicitTemplateArgumentList *getExplicitTemplateArgs() const { 1709 return const_cast<UnresolvedMemberExpr*>(this)->getExplicitTemplateArgs(); 1710 } 1711 1712 UnresolvedMemberExpr(QualType T, bool Dependent, 1713 bool HasUnresolvedUsing, 1714 Expr *Base, QualType BaseType, bool IsArrow, 1715 SourceLocation OperatorLoc, 1716 NestedNameSpecifier *Qualifier, 1717 SourceRange QualifierRange, 1718 DeclarationName Member, 1719 SourceLocation MemberLoc, 1720 const TemplateArgumentListInfo *TemplateArgs); 1721 1722public: 1723 static UnresolvedMemberExpr * 1724 Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing, 1725 Expr *Base, QualType BaseType, bool IsArrow, 1726 SourceLocation OperatorLoc, 1727 NestedNameSpecifier *Qualifier, 1728 SourceRange QualifierRange, 1729 DeclarationName Member, 1730 SourceLocation MemberLoc, 1731 const TemplateArgumentListInfo *TemplateArgs); 1732 1733 /// Adds a declaration to the unresolved set. By assumption, all of 1734 /// these happen at initialization time and properties like 1735 /// 'Dependent' and 'HasUnresolvedUsing' take them into account. 1736 void addDecl(NamedDecl *Decl) { 1737 Results.addDecl(Decl); 1738 } 1739 1740 typedef UnresolvedSet::iterator decls_iterator; 1741 decls_iterator decls_begin() const { return Results.begin(); } 1742 decls_iterator decls_end() const { return Results.end(); } 1743 1744 unsigned getNumDecls() const { return Results.size(); } 1745 1746 /// \brief True if this is an implicit access, i.e. one in which the 1747 /// member being accessed was not written in the source. The source 1748 /// location of the operator is invalid in this case. 1749 bool isImplicitAccess() const { return Base == 0; } 1750 1751 /// \brief Retrieve the base object of this member expressions, 1752 /// e.g., the \c x in \c x.m. 1753 Expr *getBase() { 1754 assert(!isImplicitAccess()); 1755 return cast<Expr>(Base); 1756 } 1757 void setBase(Expr *E) { Base = E; } 1758 1759 QualType getBaseType() const { return BaseType; } 1760 1761 /// \brief Determine whether this member expression used the '->' 1762 /// operator; otherwise, it used the '.' operator. 1763 bool isArrow() const { return IsArrow; } 1764 void setArrow(bool A) { IsArrow = A; } 1765 1766 /// \brief Retrieve the location of the '->' or '.' operator. 1767 SourceLocation getOperatorLoc() const { return OperatorLoc; } 1768 void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 1769 1770 /// \brief Retrieve the nested-name-specifier that qualifies the member 1771 /// name. 1772 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1773 1774 /// \brief Retrieve the source range covering the nested-name-specifier 1775 /// that qualifies the member name. 1776 SourceRange getQualifierRange() const { return QualifierRange; } 1777 1778 /// \brief Retrieve the name of the member that this expression 1779 /// refers to. 1780 DeclarationName getMemberName() const { return MemberName; } 1781 void setMemberName(DeclarationName N) { MemberName = N; } 1782 1783 // \brief Retrieve the location of the name of the member that this 1784 // expression refers to. 1785 SourceLocation getMemberLoc() const { return MemberLoc; } 1786 void setMemberLoc(SourceLocation L) { MemberLoc = L; } 1787 1788 /// \brief Determines whether this member expression actually had a C++ 1789 /// template argument list explicitly specified, e.g., x.f<int>. 1790 bool hasExplicitTemplateArgs() const { 1791 return HasExplicitTemplateArgs; 1792 } 1793 1794 /// \brief Copies the template arguments into the given structure. 1795 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1796 getExplicitTemplateArgs()->copyInto(List); 1797 } 1798 1799 /// \brief Retrieve the location of the left angle bracket following 1800 /// the member name ('<'). 1801 SourceLocation getLAngleLoc() const { 1802 return getExplicitTemplateArgs()->LAngleLoc; 1803 } 1804 1805 /// \brief Retrieve the template arguments provided as part of this 1806 /// template-id. 1807 const TemplateArgumentLoc *getTemplateArgs() const { 1808 return getExplicitTemplateArgs()->getTemplateArgs(); 1809 } 1810 1811 /// \brief Retrieve the number of template arguments provided as 1812 /// part of this template-id. 1813 unsigned getNumTemplateArgs() const { 1814 return getExplicitTemplateArgs()->NumTemplateArgs; 1815 } 1816 1817 /// \brief Retrieve the location of the right angle bracket 1818 /// following the template arguments ('>'). 1819 SourceLocation getRAngleLoc() const { 1820 return getExplicitTemplateArgs()->RAngleLoc; 1821 } 1822 1823 virtual SourceRange getSourceRange() const { 1824 SourceRange Range; 1825 if (!isImplicitAccess()) 1826 Range.setBegin(Base->getSourceRange().getBegin()); 1827 else if (getQualifier()) 1828 Range.setBegin(getQualifierRange().getBegin()); 1829 else 1830 Range.setBegin(MemberLoc); 1831 1832 if (hasExplicitTemplateArgs()) 1833 Range.setEnd(getRAngleLoc()); 1834 else 1835 Range.setEnd(MemberLoc); 1836 return Range; 1837 } 1838 1839 static bool classof(const Stmt *T) { 1840 return T->getStmtClass() == UnresolvedMemberExprClass; 1841 } 1842 static bool classof(const UnresolvedMemberExpr *) { return true; } 1843 1844 // Iterators 1845 virtual child_iterator child_begin(); 1846 virtual child_iterator child_end(); 1847}; 1848 1849} // end namespace clang 1850 1851#endif 1852