ExprCXX.h revision 63ef464c3fad1e8b9f9360baa6c81f974b712e90
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/UnresolvedSet.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 CXXMemberCallExpr(ASTContext &C, EmptyShell Empty) 96 : CallExpr(C, CXXMemberCallExprClass, Empty) { } 97 98 /// getImplicitObjectArgument - Retrieves the implicit object 99 /// argument for the member call. For example, in "x.f(5)", this 100 /// operation would return "x". 101 Expr *getImplicitObjectArgument(); 102 103 virtual SourceRange getSourceRange() const; 104 105 static bool classof(const Stmt *T) { 106 return T->getStmtClass() == CXXMemberCallExprClass; 107 } 108 static bool classof(const CXXMemberCallExpr *) { return true; } 109}; 110 111/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 112/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 113/// const_cast. 114/// 115/// This abstract class is inherited by all of the classes 116/// representing "named" casts, e.g., CXXStaticCastExpr, 117/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 118class CXXNamedCastExpr : public ExplicitCastExpr { 119private: 120 SourceLocation Loc; // the location of the casting op 121 122protected: 123 CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op, 124 CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, 125 SourceLocation l) 126 : ExplicitCastExpr(SC, ty, kind, op, BasePath, writtenTy), Loc(l) {} 127 128 explicit CXXNamedCastExpr(StmtClass SC, EmptyShell Shell) 129 : ExplicitCastExpr(SC, Shell) { } 130 131public: 132 const char *getCastName() const; 133 134 /// \brief Retrieve the location of the cast operator keyword, e.g., 135 /// "static_cast". 136 SourceLocation getOperatorLoc() const { return Loc; } 137 void setOperatorLoc(SourceLocation L) { Loc = L; } 138 139 virtual SourceRange getSourceRange() const { 140 return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 141 } 142 static bool classof(const Stmt *T) { 143 switch (T->getStmtClass()) { 144 case CXXStaticCastExprClass: 145 case CXXDynamicCastExprClass: 146 case CXXReinterpretCastExprClass: 147 case CXXConstCastExprClass: 148 return true; 149 default: 150 return false; 151 } 152 } 153 static bool classof(const CXXNamedCastExpr *) { return true; } 154}; 155 156/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 157/// 158/// This expression node represents a C++ static cast, e.g., 159/// @c static_cast<int>(1.0). 160class CXXStaticCastExpr : public CXXNamedCastExpr { 161public: 162 CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, 163 CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, 164 SourceLocation l) 165 : CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, BasePath, writtenTy, l) {} 166 167 explicit CXXStaticCastExpr(EmptyShell Empty) 168 : CXXNamedCastExpr(CXXStaticCastExprClass, Empty) { } 169 170 static bool classof(const Stmt *T) { 171 return T->getStmtClass() == CXXStaticCastExprClass; 172 } 173 static bool classof(const CXXStaticCastExpr *) { return true; } 174}; 175 176/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 177/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 178/// determine how to perform the type cast. 179/// 180/// This expression node represents a dynamic cast, e.g., 181/// @c dynamic_cast<Derived*>(BasePtr). 182class CXXDynamicCastExpr : public CXXNamedCastExpr { 183public: 184 CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, 185 CXXBaseSpecifierArray BasePath, TypeSourceInfo *writtenTy, 186 SourceLocation l) 187 : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, BasePath, 188 writtenTy, l) {} 189 190 explicit CXXDynamicCastExpr(EmptyShell Empty) 191 : CXXNamedCastExpr(CXXDynamicCastExprClass, Empty) { } 192 193 static bool classof(const Stmt *T) { 194 return T->getStmtClass() == CXXDynamicCastExprClass; 195 } 196 static bool classof(const CXXDynamicCastExpr *) { return true; } 197}; 198 199/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 200/// [expr.reinterpret.cast]), which provides a differently-typed view 201/// of a value but performs no actual work at run time. 202/// 203/// This expression node represents a reinterpret cast, e.g., 204/// @c reinterpret_cast<int>(VoidPtr). 205class CXXReinterpretCastExpr : public CXXNamedCastExpr { 206public: 207 CXXReinterpretCastExpr(QualType ty, CastKind kind, Expr *op, 208 CXXBaseSpecifierArray BasePath, 209 TypeSourceInfo *writtenTy, SourceLocation l) 210 : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, kind, op, BasePath, 211 writtenTy, l) {} 212 213 explicit CXXReinterpretCastExpr(EmptyShell Empty) 214 : CXXNamedCastExpr(CXXReinterpretCastExprClass, Empty) { } 215 216 static bool classof(const Stmt *T) { 217 return T->getStmtClass() == CXXReinterpretCastExprClass; 218 } 219 static bool classof(const CXXReinterpretCastExpr *) { return true; } 220}; 221 222/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 223/// which can remove type qualifiers but does not change the underlying value. 224/// 225/// This expression node represents a const cast, e.g., 226/// @c const_cast<char*>(PtrToConstChar). 227class CXXConstCastExpr : public CXXNamedCastExpr { 228public: 229 CXXConstCastExpr(QualType ty, Expr *op, TypeSourceInfo *writtenTy, 230 SourceLocation l) 231 : CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, 232 CXXBaseSpecifierArray(), writtenTy, l) {} 233 234 explicit CXXConstCastExpr(EmptyShell Empty) 235 : CXXNamedCastExpr(CXXConstCastExprClass, Empty) { } 236 237 static bool classof(const Stmt *T) { 238 return T->getStmtClass() == CXXConstCastExprClass; 239 } 240 static bool classof(const CXXConstCastExpr *) { return true; } 241}; 242 243/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 244/// 245class CXXBoolLiteralExpr : public Expr { 246 bool Value; 247 SourceLocation Loc; 248public: 249 CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 250 Expr(CXXBoolLiteralExprClass, Ty, false, false), Value(val), Loc(l) {} 251 252 explicit CXXBoolLiteralExpr(EmptyShell Empty) 253 : Expr(CXXBoolLiteralExprClass, Empty) { } 254 255 bool getValue() const { return Value; } 256 void setValue(bool V) { Value = V; } 257 258 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 259 260 SourceLocation getLocation() const { return Loc; } 261 void setLocation(SourceLocation L) { Loc = L; } 262 263 static bool classof(const Stmt *T) { 264 return T->getStmtClass() == CXXBoolLiteralExprClass; 265 } 266 static bool classof(const CXXBoolLiteralExpr *) { return true; } 267 268 // Iterators 269 virtual child_iterator child_begin(); 270 virtual child_iterator child_end(); 271}; 272 273/// CXXNullPtrLiteralExpr - [C++0x 2.14.7] C++ Pointer Literal 274class CXXNullPtrLiteralExpr : public Expr { 275 SourceLocation Loc; 276public: 277 CXXNullPtrLiteralExpr(QualType Ty, SourceLocation l) : 278 Expr(CXXNullPtrLiteralExprClass, Ty, false, false), Loc(l) {} 279 280 explicit CXXNullPtrLiteralExpr(EmptyShell Empty) 281 : Expr(CXXNullPtrLiteralExprClass, Empty) { } 282 283 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 284 285 SourceLocation getLocation() const { return Loc; } 286 void setLocation(SourceLocation L) { Loc = L; } 287 288 static bool classof(const Stmt *T) { 289 return T->getStmtClass() == CXXNullPtrLiteralExprClass; 290 } 291 static bool classof(const CXXNullPtrLiteralExpr *) { return true; } 292 293 virtual child_iterator child_begin(); 294 virtual child_iterator child_end(); 295}; 296 297/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 298/// the type_info that corresponds to the supplied type, or the (possibly 299/// dynamic) type of the supplied expression. 300/// 301/// This represents code like @c typeid(int) or @c typeid(*objPtr) 302class CXXTypeidExpr : public Expr { 303private: 304 llvm::PointerUnion<Stmt *, TypeSourceInfo *> Operand; 305 SourceRange Range; 306 307public: 308 CXXTypeidExpr(QualType Ty, TypeSourceInfo *Operand, SourceRange R) 309 : Expr(CXXTypeidExprClass, Ty, 310 // typeid is never type-dependent (C++ [temp.dep.expr]p4) 311 false, 312 // typeid is value-dependent if the type or expression are dependent 313 Operand->getType()->isDependentType()), 314 Operand(Operand), Range(R) { } 315 316 CXXTypeidExpr(QualType Ty, Expr *Operand, SourceRange R) 317 : Expr(CXXTypeidExprClass, Ty, 318 // typeid is never type-dependent (C++ [temp.dep.expr]p4) 319 false, 320 // typeid is value-dependent if the type or expression are dependent 321 Operand->isTypeDependent() || Operand->isValueDependent()), 322 Operand(Operand), Range(R) { } 323 324 CXXTypeidExpr(EmptyShell Empty, bool isExpr) 325 : Expr(CXXTypeidExprClass, Empty) { 326 if (isExpr) 327 Operand = (Expr*)0; 328 else 329 Operand = (TypeSourceInfo*)0; 330 } 331 332 bool isTypeOperand() const { return Operand.is<TypeSourceInfo *>(); } 333 334 /// \brief Retrieves the type operand of this typeid() expression after 335 /// various required adjustments (removing reference types, cv-qualifiers). 336 QualType getTypeOperand() const; 337 338 /// \brief Retrieve source information for the type operand. 339 TypeSourceInfo *getTypeOperandSourceInfo() const { 340 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 341 return Operand.get<TypeSourceInfo *>(); 342 } 343 344 void setTypeOperandSourceInfo(TypeSourceInfo *TSI) { 345 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 346 Operand = TSI; 347 } 348 349 Expr *getExprOperand() const { 350 assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 351 return static_cast<Expr*>(Operand.get<Stmt *>()); 352 } 353 354 void setExprOperand(Expr *E) { 355 assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 356 Operand = E; 357 } 358 359 virtual SourceRange getSourceRange() const { return Range; } 360 void setSourceRange(SourceRange R) { Range = R; } 361 362 static bool classof(const Stmt *T) { 363 return T->getStmtClass() == CXXTypeidExprClass; 364 } 365 static bool classof(const CXXTypeidExpr *) { return true; } 366 367 // Iterators 368 virtual child_iterator child_begin(); 369 virtual child_iterator child_end(); 370}; 371 372/// CXXThisExpr - Represents the "this" expression in C++, which is a 373/// pointer to the object on which the current member function is 374/// executing (C++ [expr.prim]p3). Example: 375/// 376/// @code 377/// class Foo { 378/// public: 379/// void bar(); 380/// void test() { this->bar(); } 381/// }; 382/// @endcode 383class CXXThisExpr : public Expr { 384 SourceLocation Loc; 385 bool Implicit : 1; 386 387public: 388 CXXThisExpr(SourceLocation L, QualType Type, bool isImplicit) 389 : Expr(CXXThisExprClass, Type, 390 // 'this' is type-dependent if the class type of the enclosing 391 // member function is dependent (C++ [temp.dep.expr]p2) 392 Type->isDependentType(), Type->isDependentType()), 393 Loc(L), Implicit(isImplicit) { } 394 395 CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {} 396 397 SourceLocation getLocation() const { return Loc; } 398 void setLocation(SourceLocation L) { Loc = L; } 399 400 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 401 402 bool isImplicit() const { return Implicit; } 403 void setImplicit(bool I) { Implicit = I; } 404 405 static bool classof(const Stmt *T) { 406 return T->getStmtClass() == CXXThisExprClass; 407 } 408 static bool classof(const CXXThisExpr *) { return true; } 409 410 // Iterators 411 virtual child_iterator child_begin(); 412 virtual child_iterator child_end(); 413}; 414 415/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 416/// 'throw' and 'throw' assignment-expression. When 417/// assignment-expression isn't present, Op will be null. 418/// 419class CXXThrowExpr : public Expr { 420 Stmt *Op; 421 SourceLocation ThrowLoc; 422public: 423 // Ty is the void type which is used as the result type of the 424 // exepression. The l is the location of the throw keyword. expr 425 // can by null, if the optional expression to throw isn't present. 426 CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 427 Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {} 428 CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {} 429 430 const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 431 Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 432 void setSubExpr(Expr *E) { Op = E; } 433 434 SourceLocation getThrowLoc() const { return ThrowLoc; } 435 void setThrowLoc(SourceLocation L) { ThrowLoc = L; } 436 437 virtual SourceRange getSourceRange() const { 438 if (getSubExpr() == 0) 439 return SourceRange(ThrowLoc, ThrowLoc); 440 return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 441 } 442 443 static bool classof(const Stmt *T) { 444 return T->getStmtClass() == CXXThrowExprClass; 445 } 446 static bool classof(const CXXThrowExpr *) { return true; } 447 448 // Iterators 449 virtual child_iterator child_begin(); 450 virtual child_iterator child_end(); 451}; 452 453/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 454/// function call argument that was created from the corresponding 455/// parameter's default argument, when the call did not explicitly 456/// supply arguments for all of the parameters. 457class CXXDefaultArgExpr : public Expr { 458 /// \brief The parameter whose default is being used. 459 /// 460 /// When the bit is set, the subexpression is stored after the 461 /// CXXDefaultArgExpr itself. When the bit is clear, the parameter's 462 /// actual default expression is the subexpression. 463 llvm::PointerIntPair<ParmVarDecl *, 1, bool> Param; 464 465 /// \brief The location where the default argument expression was used. 466 SourceLocation Loc; 467 468 CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param) 469 : Expr(SC, 470 param->hasUnparsedDefaultArg() 471 ? param->getType().getNonReferenceType() 472 : param->getDefaultArg()->getType(), 473 false, false), 474 Param(param, false), Loc(Loc) { } 475 476 CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *param, 477 Expr *SubExpr) 478 : Expr(SC, SubExpr->getType(), false, false), Param(param, true), Loc(Loc) { 479 *reinterpret_cast<Expr **>(this + 1) = SubExpr; 480 } 481 482protected: 483 virtual void DoDestroy(ASTContext &C); 484 485public: 486 CXXDefaultArgExpr(EmptyShell Empty) : Expr(CXXDefaultArgExprClass, Empty) {} 487 488 489 // Param is the parameter whose default argument is used by this 490 // expression. 491 static CXXDefaultArgExpr *Create(ASTContext &C, SourceLocation Loc, 492 ParmVarDecl *Param) { 493 return new (C) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param); 494 } 495 496 // Param is the parameter whose default argument is used by this 497 // expression, and SubExpr is the expression that will actually be used. 498 static CXXDefaultArgExpr *Create(ASTContext &C, 499 SourceLocation Loc, 500 ParmVarDecl *Param, 501 Expr *SubExpr); 502 503 // Retrieve the parameter that the argument was created from. 504 const ParmVarDecl *getParam() const { return Param.getPointer(); } 505 ParmVarDecl *getParam() { return Param.getPointer(); } 506 507 // Retrieve the actual argument to the function call. 508 const Expr *getExpr() const { 509 if (Param.getInt()) 510 return *reinterpret_cast<Expr const * const*> (this + 1); 511 return getParam()->getDefaultArg(); 512 } 513 Expr *getExpr() { 514 if (Param.getInt()) 515 return *reinterpret_cast<Expr **> (this + 1); 516 return getParam()->getDefaultArg(); 517 } 518 519 /// \brief Retrieve the location where this default argument was actually 520 /// used. 521 SourceLocation getUsedLocation() const { return Loc; } 522 523 virtual SourceRange getSourceRange() const { 524 // Default argument expressions have no representation in the 525 // source, so they have an empty source range. 526 return SourceRange(); 527 } 528 529 static bool classof(const Stmt *T) { 530 return T->getStmtClass() == CXXDefaultArgExprClass; 531 } 532 static bool classof(const CXXDefaultArgExpr *) { return true; } 533 534 // Iterators 535 virtual child_iterator child_begin(); 536 virtual child_iterator child_end(); 537 538 friend class PCHStmtReader; 539 friend class PCHStmtWriter; 540}; 541 542/// CXXTemporary - Represents a C++ temporary. 543class CXXTemporary { 544 /// Destructor - The destructor that needs to be called. 545 const CXXDestructorDecl *Destructor; 546 547 CXXTemporary(const CXXDestructorDecl *destructor) 548 : Destructor(destructor) { } 549 ~CXXTemporary() { } 550 551public: 552 static CXXTemporary *Create(ASTContext &C, 553 const CXXDestructorDecl *Destructor); 554 555 void Destroy(ASTContext &Ctx); 556 557 const CXXDestructorDecl *getDestructor() const { return Destructor; } 558}; 559 560/// \brief Represents binding an expression to a temporary. 561/// 562/// This ensures the destructor is called for the temporary. It should only be 563/// needed for non-POD, non-trivially destructable class types. For example: 564/// 565/// \code 566/// struct S { 567/// S() { } // User defined constructor makes S non-POD. 568/// ~S() { } // User defined destructor makes it non-trivial. 569/// }; 570/// void test() { 571/// const S &s_ref = S(); // Requires a CXXBindTemporaryExpr. 572/// } 573/// \endcode 574class CXXBindTemporaryExpr : public Expr { 575 CXXTemporary *Temp; 576 577 Stmt *SubExpr; 578 579 CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr) 580 : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false), 581 Temp(temp), SubExpr(subexpr) { } 582 ~CXXBindTemporaryExpr() { } 583 584protected: 585 virtual void DoDestroy(ASTContext &C); 586 587public: 588 CXXBindTemporaryExpr(EmptyShell Empty) 589 : Expr(CXXBindTemporaryExprClass, Empty), Temp(0), SubExpr(0) {} 590 591 static CXXBindTemporaryExpr *Create(ASTContext &C, CXXTemporary *Temp, 592 Expr* SubExpr); 593 594 CXXTemporary *getTemporary() { return Temp; } 595 const CXXTemporary *getTemporary() const { return Temp; } 596 void setTemporary(CXXTemporary *T) { Temp = T; } 597 598 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 599 Expr *getSubExpr() { return cast<Expr>(SubExpr); } 600 void setSubExpr(Expr *E) { SubExpr = E; } 601 602 virtual SourceRange getSourceRange() const { 603 return SubExpr->getSourceRange(); 604 } 605 606 // Implement isa/cast/dyncast/etc. 607 static bool classof(const Stmt *T) { 608 return T->getStmtClass() == CXXBindTemporaryExprClass; 609 } 610 static bool classof(const CXXBindTemporaryExpr *) { return true; } 611 612 // Iterators 613 virtual child_iterator child_begin(); 614 virtual child_iterator child_end(); 615}; 616 617/// CXXBindReferenceExpr - Represents binding an expression to a reference. 618/// In the example: 619/// 620/// const int &i = 10; 621/// 622/// a bind reference expression is inserted to indicate that 10 is bound to 623/// a reference, and that a temporary needs to be created to hold the 624/// value. 625class CXXBindReferenceExpr : public Expr { 626 // SubExpr - The expression being bound. 627 Stmt *SubExpr; 628 629 // ExtendsLifetime - Whether binding this reference extends the lifetime of 630 // the expression being bound. FIXME: Add C++ reference. 631 bool ExtendsLifetime; 632 633 /// RequiresTemporaryCopy - Whether binding the subexpression requires a 634 /// temporary copy. 635 bool RequiresTemporaryCopy; 636 637 CXXBindReferenceExpr(Expr *subexpr, bool ExtendsLifetime, 638 bool RequiresTemporaryCopy) 639 : Expr(CXXBindReferenceExprClass, subexpr->getType(), false, false), 640 SubExpr(subexpr), ExtendsLifetime(ExtendsLifetime), 641 RequiresTemporaryCopy(RequiresTemporaryCopy) { } 642 ~CXXBindReferenceExpr() { } 643 644protected: 645 virtual void DoDestroy(ASTContext &C); 646 647public: 648 static CXXBindReferenceExpr *Create(ASTContext &C, Expr *SubExpr, 649 bool ExtendsLifetime, 650 bool RequiresTemporaryCopy); 651 652 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 653 Expr *getSubExpr() { return cast<Expr>(SubExpr); } 654 void setSubExpr(Expr *E) { SubExpr = E; } 655 656 virtual SourceRange getSourceRange() const { 657 return SubExpr->getSourceRange(); 658 } 659 660 /// requiresTemporaryCopy - Whether binding the subexpression requires a 661 /// temporary copy. 662 bool requiresTemporaryCopy() const { return RequiresTemporaryCopy; } 663 664 // extendsLifetime - Whether binding this reference extends the lifetime of 665 // the expression being bound. FIXME: Add C++ reference. 666 bool extendsLifetime() { return ExtendsLifetime; } 667 668 // Implement isa/cast/dyncast/etc. 669 static bool classof(const Stmt *T) { 670 return T->getStmtClass() == CXXBindReferenceExprClass; 671 } 672 static bool classof(const CXXBindReferenceExpr *) { return true; } 673 674 // Iterators 675 virtual child_iterator child_begin(); 676 virtual child_iterator child_end(); 677}; 678 679/// CXXConstructExpr - Represents a call to a C++ constructor. 680class CXXConstructExpr : public Expr { 681public: 682 enum ConstructionKind { 683 CK_Complete, 684 CK_NonVirtualBase, 685 CK_VirtualBase 686 }; 687 688private: 689 CXXConstructorDecl *Constructor; 690 691 SourceLocation Loc; 692 bool Elidable : 1; 693 bool ZeroInitialization : 1; 694 unsigned ConstructKind : 2; 695 Stmt **Args; 696 unsigned NumArgs; 697 698protected: 699 CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T, 700 SourceLocation Loc, 701 CXXConstructorDecl *d, bool elidable, 702 Expr **args, unsigned numargs, 703 bool ZeroInitialization = false, 704 ConstructionKind ConstructKind = CK_Complete); 705 ~CXXConstructExpr() { } 706 707 virtual void DoDestroy(ASTContext &C); 708 709public: 710 /// \brief Construct an empty C++ construction expression that will store 711 /// \p numargs arguments. 712 CXXConstructExpr(EmptyShell Empty, ASTContext &C, unsigned numargs); 713 714 static CXXConstructExpr *Create(ASTContext &C, QualType T, 715 SourceLocation Loc, 716 CXXConstructorDecl *D, bool Elidable, 717 Expr **Args, unsigned NumArgs, 718 bool ZeroInitialization = false, 719 ConstructionKind ConstructKind = CK_Complete); 720 721 722 CXXConstructorDecl* getConstructor() const { return Constructor; } 723 void setConstructor(CXXConstructorDecl *C) { Constructor = C; } 724 725 SourceLocation getLocation() const { return Loc; } 726 void setLocation(SourceLocation Loc) { this->Loc = Loc; } 727 728 /// \brief Whether this construction is elidable. 729 bool isElidable() const { return Elidable; } 730 void setElidable(bool E) { Elidable = E; } 731 732 /// \brief Whether this construction first requires 733 /// zero-initialization before the initializer is called. 734 bool requiresZeroInitialization() const { return ZeroInitialization; } 735 void setRequiresZeroInitialization(bool ZeroInit) { 736 ZeroInitialization = ZeroInit; 737 } 738 739 /// \brief Determines whether this constructor is actually constructing 740 /// a base class (rather than a complete object). 741 ConstructionKind getConstructionKind() const { 742 return (ConstructionKind)ConstructKind; 743 } 744 void setConstructionKind(ConstructionKind CK) { 745 ConstructKind = CK; 746 } 747 748 typedef ExprIterator arg_iterator; 749 typedef ConstExprIterator const_arg_iterator; 750 751 arg_iterator arg_begin() { return Args; } 752 arg_iterator arg_end() { return Args + NumArgs; } 753 const_arg_iterator arg_begin() const { return Args; } 754 const_arg_iterator arg_end() const { return Args + NumArgs; } 755 756 Expr **getArgs() const { return reinterpret_cast<Expr **>(Args); } 757 unsigned getNumArgs() const { return NumArgs; } 758 759 /// getArg - Return the specified argument. 760 Expr *getArg(unsigned Arg) { 761 assert(Arg < NumArgs && "Arg access out of range!"); 762 return cast<Expr>(Args[Arg]); 763 } 764 const Expr *getArg(unsigned Arg) const { 765 assert(Arg < NumArgs && "Arg access out of range!"); 766 return cast<Expr>(Args[Arg]); 767 } 768 769 /// setArg - Set the specified argument. 770 void setArg(unsigned Arg, Expr *ArgExpr) { 771 assert(Arg < NumArgs && "Arg access out of range!"); 772 Args[Arg] = ArgExpr; 773 } 774 775 virtual SourceRange getSourceRange() const; 776 777 static bool classof(const Stmt *T) { 778 return T->getStmtClass() == CXXConstructExprClass || 779 T->getStmtClass() == CXXTemporaryObjectExprClass; 780 } 781 static bool classof(const CXXConstructExpr *) { return true; } 782 783 // Iterators 784 virtual child_iterator child_begin(); 785 virtual child_iterator child_end(); 786}; 787 788/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 789/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 790/// x = int(0.5); 791class CXXFunctionalCastExpr : public ExplicitCastExpr { 792 SourceLocation TyBeginLoc; 793 SourceLocation RParenLoc; 794public: 795 CXXFunctionalCastExpr(QualType ty, TypeSourceInfo *writtenTy, 796 SourceLocation tyBeginLoc, CastKind kind, 797 Expr *castExpr, CXXBaseSpecifierArray BasePath, 798 SourceLocation rParenLoc) 799 : ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, 800 BasePath, writtenTy), 801 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 802 803 explicit CXXFunctionalCastExpr(EmptyShell Shell) 804 : ExplicitCastExpr(CXXFunctionalCastExprClass, Shell) { } 805 806 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 807 void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 808 SourceLocation getRParenLoc() const { return RParenLoc; } 809 void setRParenLoc(SourceLocation L) { RParenLoc = L; } 810 811 virtual SourceRange getSourceRange() const { 812 return SourceRange(TyBeginLoc, RParenLoc); 813 } 814 static bool classof(const Stmt *T) { 815 return T->getStmtClass() == CXXFunctionalCastExprClass; 816 } 817 static bool classof(const CXXFunctionalCastExpr *) { return true; } 818}; 819 820/// @brief Represents a C++ functional cast expression that builds a 821/// temporary object. 822/// 823/// This expression type represents a C++ "functional" cast 824/// (C++[expr.type.conv]) with N != 1 arguments that invokes a 825/// constructor to build a temporary object. With N == 1 arguments the 826/// functional cast expression will be represented by CXXFunctionalCastExpr. 827/// Example: 828/// @code 829/// struct X { X(int, float); } 830/// 831/// X create_X() { 832/// return X(1, 3.14f); // creates a CXXTemporaryObjectExpr 833/// }; 834/// @endcode 835class CXXTemporaryObjectExpr : public CXXConstructExpr { 836 SourceLocation TyBeginLoc; 837 SourceLocation RParenLoc; 838 839public: 840 CXXTemporaryObjectExpr(ASTContext &C, CXXConstructorDecl *Cons, 841 QualType writtenTy, SourceLocation tyBeginLoc, 842 Expr **Args,unsigned NumArgs, 843 SourceLocation rParenLoc, 844 bool ZeroInitialization = false); 845 846 ~CXXTemporaryObjectExpr() { } 847 848 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 849 SourceLocation getRParenLoc() const { return RParenLoc; } 850 851 virtual SourceRange getSourceRange() const { 852 return SourceRange(TyBeginLoc, RParenLoc); 853 } 854 static bool classof(const Stmt *T) { 855 return T->getStmtClass() == CXXTemporaryObjectExprClass; 856 } 857 static bool classof(const CXXTemporaryObjectExpr *) { return true; } 858}; 859 860/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 861/// Expression "T()" which creates a value-initialized rvalue of type 862/// T, which is a non-class type. 863/// 864class CXXZeroInitValueExpr : public Expr { 865 SourceLocation TyBeginLoc; 866 SourceLocation RParenLoc; 867 868public: 869 CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 870 SourceLocation rParenLoc ) : 871 Expr(CXXZeroInitValueExprClass, ty, false, false), 872 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 873 explicit CXXZeroInitValueExpr(EmptyShell Shell) 874 : Expr(CXXZeroInitValueExprClass, Shell) { } 875 876 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 877 SourceLocation getRParenLoc() const { return RParenLoc; } 878 879 void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 880 void setRParenLoc(SourceLocation L) { RParenLoc = L; } 881 882 /// @brief Whether this initialization expression was 883 /// implicitly-generated. 884 bool isImplicit() const { 885 return TyBeginLoc.isInvalid() && RParenLoc.isInvalid(); 886 } 887 888 virtual SourceRange getSourceRange() const { 889 return SourceRange(TyBeginLoc, RParenLoc); 890 } 891 892 static bool classof(const Stmt *T) { 893 return T->getStmtClass() == CXXZeroInitValueExprClass; 894 } 895 static bool classof(const CXXZeroInitValueExpr *) { return true; } 896 897 // Iterators 898 virtual child_iterator child_begin(); 899 virtual child_iterator child_end(); 900}; 901 902/// CXXNewExpr - A new expression for memory allocation and constructor calls, 903/// e.g: "new CXXNewExpr(foo)". 904class CXXNewExpr : public Expr { 905 // Was the usage ::new, i.e. is the global new to be used? 906 bool GlobalNew : 1; 907 // Was the form (type-id) used? Otherwise, it was new-type-id. 908 bool ParenTypeId : 1; 909 // Is there an initializer? If not, built-ins are uninitialized, else they're 910 // value-initialized. 911 bool Initializer : 1; 912 // Do we allocate an array? If so, the first SubExpr is the size expression. 913 bool Array : 1; 914 // The number of placement new arguments. 915 unsigned NumPlacementArgs : 14; 916 // The number of constructor arguments. This may be 1 even for non-class 917 // types; use the pseudo copy constructor. 918 unsigned NumConstructorArgs : 14; 919 // Contains an optional array size expression, any number of optional 920 // placement arguments, and any number of optional constructor arguments, 921 // in that order. 922 Stmt **SubExprs; 923 // Points to the allocation function used. 924 FunctionDecl *OperatorNew; 925 // Points to the deallocation function used in case of error. May be null. 926 FunctionDecl *OperatorDelete; 927 // Points to the constructor used. Cannot be null if AllocType is a record; 928 // it would still point at the default constructor (even an implicit one). 929 // Must be null for all other types. 930 CXXConstructorDecl *Constructor; 931 932 SourceLocation StartLoc; 933 SourceLocation EndLoc; 934 935public: 936 CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew, 937 Expr **placementArgs, unsigned numPlaceArgs, bool ParenTypeId, 938 Expr *arraySize, CXXConstructorDecl *constructor, bool initializer, 939 Expr **constructorArgs, unsigned numConsArgs, 940 FunctionDecl *operatorDelete, QualType ty, 941 SourceLocation startLoc, SourceLocation endLoc); 942 explicit CXXNewExpr(EmptyShell Shell) 943 : Expr(CXXNewExprClass, Shell), SubExprs(0) { } 944 945 void AllocateArgsArray(ASTContext &C, bool isArray, unsigned numPlaceArgs, 946 unsigned numConsArgs); 947 948 virtual void DoDestroy(ASTContext &C); 949 950 QualType getAllocatedType() const { 951 assert(getType()->isPointerType()); 952 return getType()->getAs<PointerType>()->getPointeeType(); 953 } 954 955 FunctionDecl *getOperatorNew() const { return OperatorNew; } 956 void setOperatorNew(FunctionDecl *D) { OperatorNew = D; } 957 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 958 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 959 CXXConstructorDecl *getConstructor() const { return Constructor; } 960 void setConstructor(CXXConstructorDecl *D) { Constructor = D; } 961 962 bool isArray() const { return Array; } 963 Expr *getArraySize() { 964 return Array ? cast<Expr>(SubExprs[0]) : 0; 965 } 966 const Expr *getArraySize() const { 967 return Array ? cast<Expr>(SubExprs[0]) : 0; 968 } 969 970 unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 971 Expr *getPlacementArg(unsigned i) { 972 assert(i < NumPlacementArgs && "Index out of range"); 973 return cast<Expr>(SubExprs[Array + i]); 974 } 975 const Expr *getPlacementArg(unsigned i) const { 976 assert(i < NumPlacementArgs && "Index out of range"); 977 return cast<Expr>(SubExprs[Array + i]); 978 } 979 980 bool isGlobalNew() const { return GlobalNew; } 981 void setGlobalNew(bool V) { GlobalNew = V; } 982 bool isParenTypeId() const { return ParenTypeId; } 983 void setParenTypeId(bool V) { ParenTypeId = V; } 984 bool hasInitializer() const { return Initializer; } 985 void setHasInitializer(bool V) { Initializer = V; } 986 987 unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 988 Expr *getConstructorArg(unsigned i) { 989 assert(i < NumConstructorArgs && "Index out of range"); 990 return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 991 } 992 const Expr *getConstructorArg(unsigned i) const { 993 assert(i < NumConstructorArgs && "Index out of range"); 994 return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 995 } 996 997 typedef ExprIterator arg_iterator; 998 typedef ConstExprIterator const_arg_iterator; 999 1000 arg_iterator placement_arg_begin() { 1001 return SubExprs + Array; 1002 } 1003 arg_iterator placement_arg_end() { 1004 return SubExprs + Array + getNumPlacementArgs(); 1005 } 1006 const_arg_iterator placement_arg_begin() const { 1007 return SubExprs + Array; 1008 } 1009 const_arg_iterator placement_arg_end() const { 1010 return SubExprs + Array + getNumPlacementArgs(); 1011 } 1012 1013 arg_iterator constructor_arg_begin() { 1014 return SubExprs + Array + getNumPlacementArgs(); 1015 } 1016 arg_iterator constructor_arg_end() { 1017 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 1018 } 1019 const_arg_iterator constructor_arg_begin() const { 1020 return SubExprs + Array + getNumPlacementArgs(); 1021 } 1022 const_arg_iterator constructor_arg_end() const { 1023 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 1024 } 1025 1026 typedef Stmt **raw_arg_iterator; 1027 raw_arg_iterator raw_arg_begin() { return SubExprs; } 1028 raw_arg_iterator raw_arg_end() { 1029 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 1030 } 1031 const_arg_iterator raw_arg_begin() const { return SubExprs; } 1032 const_arg_iterator raw_arg_end() const { return constructor_arg_end(); } 1033 1034 1035 SourceLocation getStartLoc() const { return StartLoc; } 1036 void setStartLoc(SourceLocation L) { StartLoc = L; } 1037 SourceLocation getEndLoc() const { return EndLoc; } 1038 void setEndLoc(SourceLocation L) { EndLoc = L; } 1039 1040 virtual SourceRange getSourceRange() const { 1041 return SourceRange(StartLoc, EndLoc); 1042 } 1043 1044 static bool classof(const Stmt *T) { 1045 return T->getStmtClass() == CXXNewExprClass; 1046 } 1047 static bool classof(const CXXNewExpr *) { return true; } 1048 1049 // Iterators 1050 virtual child_iterator child_begin(); 1051 virtual child_iterator child_end(); 1052}; 1053 1054/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 1055/// calls, e.g. "delete[] pArray". 1056class CXXDeleteExpr : public Expr { 1057 // Is this a forced global delete, i.e. "::delete"? 1058 bool GlobalDelete : 1; 1059 // Is this the array form of delete, i.e. "delete[]"? 1060 bool ArrayForm : 1; 1061 // Points to the operator delete overload that is used. Could be a member. 1062 FunctionDecl *OperatorDelete; 1063 // The pointer expression to be deleted. 1064 Stmt *Argument; 1065 // Location of the expression. 1066 SourceLocation Loc; 1067public: 1068 CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 1069 FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 1070 : Expr(CXXDeleteExprClass, ty, false, false), GlobalDelete(globalDelete), 1071 ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 1072 Loc(loc) { } 1073 explicit CXXDeleteExpr(EmptyShell Shell) 1074 : Expr(CXXDeleteExprClass, Shell), OperatorDelete(0), Argument(0) { } 1075 1076 bool isGlobalDelete() const { return GlobalDelete; } 1077 bool isArrayForm() const { return ArrayForm; } 1078 1079 void setGlobalDelete(bool V) { GlobalDelete = V; } 1080 void setArrayForm(bool V) { ArrayForm = V; } 1081 1082 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 1083 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } 1084 1085 Expr *getArgument() { return cast<Expr>(Argument); } 1086 const Expr *getArgument() const { return cast<Expr>(Argument); } 1087 void setArgument(Expr *E) { Argument = E; } 1088 1089 virtual SourceRange getSourceRange() const { 1090 return SourceRange(Loc, Argument->getLocEnd()); 1091 } 1092 void setStartLoc(SourceLocation L) { Loc = L; } 1093 1094 static bool classof(const Stmt *T) { 1095 return T->getStmtClass() == CXXDeleteExprClass; 1096 } 1097 static bool classof(const CXXDeleteExpr *) { return true; } 1098 1099 // Iterators 1100 virtual child_iterator child_begin(); 1101 virtual child_iterator child_end(); 1102}; 1103 1104/// \brief Structure used to store the type being destroyed by a 1105/// pseudo-destructor expression. 1106class PseudoDestructorTypeStorage { 1107 /// \brief Either the type source information or the name of the type, if 1108 /// it couldn't be resolved due to type-dependence. 1109 llvm::PointerUnion<TypeSourceInfo *, IdentifierInfo *> Type; 1110 1111 /// \brief The starting source location of the pseudo-destructor type. 1112 SourceLocation Location; 1113 1114public: 1115 PseudoDestructorTypeStorage() { } 1116 1117 PseudoDestructorTypeStorage(IdentifierInfo *II, SourceLocation Loc) 1118 : Type(II), Location(Loc) { } 1119 1120 PseudoDestructorTypeStorage(TypeSourceInfo *Info); 1121 1122 TypeSourceInfo *getTypeSourceInfo() const { 1123 return Type.dyn_cast<TypeSourceInfo *>(); 1124 } 1125 1126 IdentifierInfo *getIdentifier() const { 1127 return Type.dyn_cast<IdentifierInfo *>(); 1128 } 1129 1130 SourceLocation getLocation() const { return Location; } 1131}; 1132 1133/// \brief Represents a C++ pseudo-destructor (C++ [expr.pseudo]). 1134/// 1135/// A pseudo-destructor is an expression that looks like a member access to a 1136/// destructor of a scalar type, except that scalar types don't have 1137/// destructors. For example: 1138/// 1139/// \code 1140/// typedef int T; 1141/// void f(int *p) { 1142/// p->T::~T(); 1143/// } 1144/// \endcode 1145/// 1146/// Pseudo-destructors typically occur when instantiating templates such as: 1147/// 1148/// \code 1149/// template<typename T> 1150/// void destroy(T* ptr) { 1151/// ptr->T::~T(); 1152/// } 1153/// \endcode 1154/// 1155/// for scalar types. A pseudo-destructor expression has no run-time semantics 1156/// beyond evaluating the base expression. 1157class CXXPseudoDestructorExpr : public Expr { 1158 /// \brief The base expression (that is being destroyed). 1159 Stmt *Base; 1160 1161 /// \brief Whether the operator was an arrow ('->'); otherwise, it was a 1162 /// period ('.'). 1163 bool IsArrow : 1; 1164 1165 /// \brief The location of the '.' or '->' operator. 1166 SourceLocation OperatorLoc; 1167 1168 /// \brief The nested-name-specifier that follows the operator, if present. 1169 NestedNameSpecifier *Qualifier; 1170 1171 /// \brief The source range that covers the nested-name-specifier, if 1172 /// present. 1173 SourceRange QualifierRange; 1174 1175 /// \brief The type that precedes the '::' in a qualified pseudo-destructor 1176 /// expression. 1177 TypeSourceInfo *ScopeType; 1178 1179 /// \brief The location of the '::' in a qualified pseudo-destructor 1180 /// expression. 1181 SourceLocation ColonColonLoc; 1182 1183 /// \brief The location of the '~'. 1184 SourceLocation TildeLoc; 1185 1186 /// \brief The type being destroyed, or its name if we were unable to 1187 /// resolve the name. 1188 PseudoDestructorTypeStorage DestroyedType; 1189 1190public: 1191 CXXPseudoDestructorExpr(ASTContext &Context, 1192 Expr *Base, bool isArrow, SourceLocation OperatorLoc, 1193 NestedNameSpecifier *Qualifier, 1194 SourceRange QualifierRange, 1195 TypeSourceInfo *ScopeType, 1196 SourceLocation ColonColonLoc, 1197 SourceLocation TildeLoc, 1198 PseudoDestructorTypeStorage DestroyedType) 1199 : Expr(CXXPseudoDestructorExprClass, 1200 Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0, 1201 false, 0, false, 1202 false, 0, 0, 1203 FunctionType::ExtInfo())), 1204 /*isTypeDependent=*/(Base->isTypeDependent() || 1205 (DestroyedType.getTypeSourceInfo() && 1206 DestroyedType.getTypeSourceInfo()->getType()->isDependentType())), 1207 /*isValueDependent=*/Base->isValueDependent()), 1208 Base(static_cast<Stmt *>(Base)), IsArrow(isArrow), 1209 OperatorLoc(OperatorLoc), Qualifier(Qualifier), 1210 QualifierRange(QualifierRange), 1211 ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc), 1212 DestroyedType(DestroyedType) { } 1213 1214 explicit CXXPseudoDestructorExpr(EmptyShell Shell) 1215 : Expr(CXXPseudoDestructorExprClass, Shell), 1216 Base(0), IsArrow(false), Qualifier(0), ScopeType(0) { } 1217 1218 void setBase(Expr *E) { Base = E; } 1219 Expr *getBase() const { return cast<Expr>(Base); } 1220 1221 /// \brief Determines whether this member expression actually had 1222 /// a C++ nested-name-specifier prior to the name of the member, e.g., 1223 /// x->Base::foo. 1224 bool hasQualifier() const { return Qualifier != 0; } 1225 1226 /// \brief If the member name was qualified, retrieves the source range of 1227 /// the nested-name-specifier that precedes the member name. Otherwise, 1228 /// returns an empty source range. 1229 SourceRange getQualifierRange() const { return QualifierRange; } 1230 void setQualifierRange(SourceRange R) { QualifierRange = R; } 1231 1232 /// \brief If the member name was qualified, retrieves the 1233 /// nested-name-specifier that precedes the member name. Otherwise, returns 1234 /// NULL. 1235 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1236 void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 1237 1238 /// \brief Determine whether this pseudo-destructor expression was written 1239 /// using an '->' (otherwise, it used a '.'). 1240 bool isArrow() const { return IsArrow; } 1241 void setArrow(bool A) { IsArrow = A; } 1242 1243 /// \brief Retrieve the location of the '.' or '->' operator. 1244 SourceLocation getOperatorLoc() const { return OperatorLoc; } 1245 void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 1246 1247 /// \brief Retrieve the scope type in a qualified pseudo-destructor 1248 /// expression. 1249 /// 1250 /// Pseudo-destructor expressions can have extra qualification within them 1251 /// that is not part of the nested-name-specifier, e.g., \c p->T::~T(). 1252 /// Here, if the object type of the expression is (or may be) a scalar type, 1253 /// \p T may also be a scalar type and, therefore, cannot be part of a 1254 /// nested-name-specifier. It is stored as the "scope type" of the pseudo- 1255 /// destructor expression. 1256 TypeSourceInfo *getScopeTypeInfo() const { return ScopeType; } 1257 void setScopeTypeInfo(TypeSourceInfo *Info) { ScopeType = Info; } 1258 1259 /// \brief Retrieve the location of the '::' in a qualified pseudo-destructor 1260 /// expression. 1261 SourceLocation getColonColonLoc() const { return ColonColonLoc; } 1262 void setColonColonLoc(SourceLocation L) { ColonColonLoc = L; } 1263 1264 /// \brief Retrieve the location of the '~'. 1265 SourceLocation getTildeLoc() const { return TildeLoc; } 1266 void setTildeLoc(SourceLocation L) { TildeLoc = L; } 1267 1268 /// \brief Retrieve the source location information for the type 1269 /// being destroyed. 1270 /// 1271 /// This type-source information is available for non-dependent 1272 /// pseudo-destructor expressions and some dependent pseudo-destructor 1273 /// expressions. Returns NULL if we only have the identifier for a 1274 /// dependent pseudo-destructor expression. 1275 TypeSourceInfo *getDestroyedTypeInfo() const { 1276 return DestroyedType.getTypeSourceInfo(); 1277 } 1278 1279 /// \brief In a dependent pseudo-destructor expression for which we do not 1280 /// have full type information on the destroyed type, provides the name 1281 /// of the destroyed type. 1282 IdentifierInfo *getDestroyedTypeIdentifier() const { 1283 return DestroyedType.getIdentifier(); 1284 } 1285 1286 /// \brief Retrieve the type being destroyed. 1287 QualType getDestroyedType() const; 1288 1289 /// \brief Retrieve the starting location of the type being destroyed. 1290 SourceLocation getDestroyedTypeLoc() const { 1291 return DestroyedType.getLocation(); 1292 } 1293 1294 /// \brief Set the name of destroyed type for a dependent pseudo-destructor 1295 /// expression. 1296 void setDestroyedType(IdentifierInfo *II, SourceLocation Loc) { 1297 DestroyedType = PseudoDestructorTypeStorage(II, Loc); 1298 } 1299 1300 /// \brief Set the destroyed type. 1301 void setDestroyedType(TypeSourceInfo *Info) { 1302 DestroyedType = PseudoDestructorTypeStorage(Info); 1303 } 1304 1305 virtual SourceRange getSourceRange() const; 1306 1307 static bool classof(const Stmt *T) { 1308 return T->getStmtClass() == CXXPseudoDestructorExprClass; 1309 } 1310 static bool classof(const CXXPseudoDestructorExpr *) { return true; } 1311 1312 // Iterators 1313 virtual child_iterator child_begin(); 1314 virtual child_iterator child_end(); 1315}; 1316 1317/// UnaryTypeTraitExpr - A GCC or MS unary type trait, as used in the 1318/// implementation of TR1/C++0x type trait templates. 1319/// Example: 1320/// __is_pod(int) == true 1321/// __is_enum(std::string) == false 1322class UnaryTypeTraitExpr : public Expr { 1323 /// UTT - The trait. 1324 UnaryTypeTrait UTT; 1325 1326 /// Loc - The location of the type trait keyword. 1327 SourceLocation Loc; 1328 1329 /// RParen - The location of the closing paren. 1330 SourceLocation RParen; 1331 1332 /// QueriedType - The type we're testing. 1333 QualType QueriedType; 1334 1335public: 1336 UnaryTypeTraitExpr(SourceLocation loc, UnaryTypeTrait utt, QualType queried, 1337 SourceLocation rparen, QualType ty) 1338 : Expr(UnaryTypeTraitExprClass, ty, false, queried->isDependentType()), 1339 UTT(utt), Loc(loc), RParen(rparen), QueriedType(queried) { } 1340 1341 virtual SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} 1342 1343 UnaryTypeTrait getTrait() const { return UTT; } 1344 1345 QualType getQueriedType() const { return QueriedType; } 1346 1347 bool EvaluateTrait(ASTContext&) const; 1348 1349 static bool classof(const Stmt *T) { 1350 return T->getStmtClass() == UnaryTypeTraitExprClass; 1351 } 1352 static bool classof(const UnaryTypeTraitExpr *) { return true; } 1353 1354 // Iterators 1355 virtual child_iterator child_begin(); 1356 virtual child_iterator child_end(); 1357}; 1358 1359/// \brief A reference to an overloaded function set, either an 1360/// \t UnresolvedLookupExpr or an \t UnresolvedMemberExpr. 1361class OverloadExpr : public Expr { 1362 /// The results. These are undesugared, which is to say, they may 1363 /// include UsingShadowDecls. Access is relative to the naming 1364 /// class. 1365 // FIXME: Allocate this data after the OverloadExpr subclass. 1366 DeclAccessPair *Results; 1367 unsigned NumResults; 1368 1369 /// The common name of these declarations. 1370 DeclarationName Name; 1371 1372 /// The scope specifier, if any. 1373 NestedNameSpecifier *Qualifier; 1374 1375 /// The source range of the scope specifier. 1376 SourceRange QualifierRange; 1377 1378 /// The location of the name. 1379 SourceLocation NameLoc; 1380 1381protected: 1382 /// True if the name was a template-id. 1383 bool HasExplicitTemplateArgs; 1384 1385 OverloadExpr(StmtClass K, ASTContext &C, QualType T, bool Dependent, 1386 NestedNameSpecifier *Qualifier, SourceRange QRange, 1387 DeclarationName Name, SourceLocation NameLoc, 1388 bool HasTemplateArgs, 1389 UnresolvedSetIterator Begin, UnresolvedSetIterator End); 1390 1391 OverloadExpr(StmtClass K, EmptyShell Empty) 1392 : Expr(K, Empty), Results(0), NumResults(0), 1393 Qualifier(0), HasExplicitTemplateArgs(false) { } 1394 1395public: 1396 /// Computes whether an unresolved lookup on the given declarations 1397 /// and optional template arguments is type- and value-dependent. 1398 static bool ComputeDependence(UnresolvedSetIterator Begin, 1399 UnresolvedSetIterator End, 1400 const TemplateArgumentListInfo *Args); 1401 1402 /// Finds the overloaded expression in the given expression of 1403 /// OverloadTy. 1404 /// 1405 /// \return the expression (which must be there) and true if it is 1406 /// within an address-of operator. 1407 static llvm::PointerIntPair<OverloadExpr*,1> find(Expr *E) { 1408 assert(E->getType()->isSpecificBuiltinType(BuiltinType::Overload)); 1409 1410 bool op = false; 1411 E = E->IgnoreParens(); 1412 if (isa<UnaryOperator>(E)) 1413 op = true, E = cast<UnaryOperator>(E)->getSubExpr()->IgnoreParens(); 1414 return llvm::PointerIntPair<OverloadExpr*,1>(cast<OverloadExpr>(E), op); 1415 } 1416 1417 /// Gets the naming class of this lookup, if any. 1418 CXXRecordDecl *getNamingClass() const; 1419 1420 typedef UnresolvedSetImpl::iterator decls_iterator; 1421 decls_iterator decls_begin() const { return UnresolvedSetIterator(Results); } 1422 decls_iterator decls_end() const { 1423 return UnresolvedSetIterator(Results + NumResults); 1424 } 1425 1426 void initializeResults(ASTContext &C, 1427 UnresolvedSetIterator Begin,UnresolvedSetIterator End); 1428 1429 /// Gets the number of declarations in the unresolved set. 1430 unsigned getNumDecls() const { return NumResults; } 1431 1432 /// Gets the name looked up. 1433 DeclarationName getName() const { return Name; } 1434 void setName(DeclarationName N) { Name = N; } 1435 1436 /// Gets the location of the name. 1437 SourceLocation getNameLoc() const { return NameLoc; } 1438 void setNameLoc(SourceLocation Loc) { NameLoc = Loc; } 1439 1440 /// Fetches the nested-name qualifier, if one was given. 1441 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1442 void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 1443 1444 /// Fetches the range of the nested-name qualifier. 1445 SourceRange getQualifierRange() const { return QualifierRange; } 1446 void setQualifierRange(SourceRange R) { QualifierRange = R; } 1447 1448 /// \brief Determines whether this expression had an explicit 1449 /// template argument list, e.g. f<int>. 1450 bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 1451 1452 ExplicitTemplateArgumentList &getExplicitTemplateArgs(); // defined far below 1453 1454 const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1455 return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); 1456 } 1457 1458 ExplicitTemplateArgumentList *getOptionalExplicitTemplateArgs() { 1459 if (hasExplicitTemplateArgs()) 1460 return &getExplicitTemplateArgs(); 1461 return 0; 1462 } 1463 1464 static bool classof(const Stmt *T) { 1465 return T->getStmtClass() == UnresolvedLookupExprClass || 1466 T->getStmtClass() == UnresolvedMemberExprClass; 1467 } 1468 static bool classof(const OverloadExpr *) { return true; } 1469}; 1470 1471/// \brief A reference to a name which we were able to look up during 1472/// parsing but could not resolve to a specific declaration. This 1473/// arises in several ways: 1474/// * we might be waiting for argument-dependent lookup 1475/// * the name might resolve to an overloaded function 1476/// and eventually: 1477/// * the lookup might have included a function template 1478/// These never include UnresolvedUsingValueDecls, which are always 1479/// class members and therefore appear only in 1480/// UnresolvedMemberLookupExprs. 1481class UnresolvedLookupExpr : public OverloadExpr { 1482 /// True if these lookup results should be extended by 1483 /// argument-dependent lookup if this is the operand of a function 1484 /// call. 1485 bool RequiresADL; 1486 1487 /// True if these lookup results are overloaded. This is pretty 1488 /// trivially rederivable if we urgently need to kill this field. 1489 bool Overloaded; 1490 1491 /// The naming class (C++ [class.access.base]p5) of the lookup, if 1492 /// any. This can generally be recalculated from the context chain, 1493 /// but that can be fairly expensive for unqualified lookups. If we 1494 /// want to improve memory use here, this could go in a union 1495 /// against the qualified-lookup bits. 1496 CXXRecordDecl *NamingClass; 1497 1498 UnresolvedLookupExpr(ASTContext &C, QualType T, bool Dependent, 1499 CXXRecordDecl *NamingClass, 1500 NestedNameSpecifier *Qualifier, SourceRange QRange, 1501 DeclarationName Name, SourceLocation NameLoc, 1502 bool RequiresADL, bool Overloaded, bool HasTemplateArgs, 1503 UnresolvedSetIterator Begin, UnresolvedSetIterator End) 1504 : OverloadExpr(UnresolvedLookupExprClass, C, T, Dependent, Qualifier, 1505 QRange, Name, NameLoc, HasTemplateArgs, Begin, End), 1506 RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass) 1507 {} 1508 1509 UnresolvedLookupExpr(EmptyShell Empty) 1510 : OverloadExpr(UnresolvedLookupExprClass, Empty), 1511 RequiresADL(false), Overloaded(false), NamingClass(0) 1512 {} 1513 1514public: 1515 static UnresolvedLookupExpr *Create(ASTContext &C, 1516 bool Dependent, 1517 CXXRecordDecl *NamingClass, 1518 NestedNameSpecifier *Qualifier, 1519 SourceRange QualifierRange, 1520 DeclarationName Name, 1521 SourceLocation NameLoc, 1522 bool ADL, bool Overloaded, 1523 UnresolvedSetIterator Begin, 1524 UnresolvedSetIterator End) { 1525 return new(C) UnresolvedLookupExpr(C, 1526 Dependent ? C.DependentTy : C.OverloadTy, 1527 Dependent, NamingClass, 1528 Qualifier, QualifierRange, 1529 Name, NameLoc, ADL, Overloaded, false, 1530 Begin, End); 1531 } 1532 1533 static UnresolvedLookupExpr *Create(ASTContext &C, 1534 bool Dependent, 1535 CXXRecordDecl *NamingClass, 1536 NestedNameSpecifier *Qualifier, 1537 SourceRange QualifierRange, 1538 DeclarationName Name, 1539 SourceLocation NameLoc, 1540 bool ADL, 1541 const TemplateArgumentListInfo &Args, 1542 UnresolvedSetIterator Begin, 1543 UnresolvedSetIterator End); 1544 1545 static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, 1546 unsigned NumTemplateArgs); 1547 1548 /// True if this declaration should be extended by 1549 /// argument-dependent lookup. 1550 bool requiresADL() const { return RequiresADL; } 1551 void setRequiresADL(bool V) { RequiresADL = V; } 1552 1553 /// True if this lookup is overloaded. 1554 bool isOverloaded() const { return Overloaded; } 1555 void setOverloaded(bool V) { Overloaded = V; } 1556 1557 /// Gets the 'naming class' (in the sense of C++0x 1558 /// [class.access.base]p5) of the lookup. This is the scope 1559 /// that was looked in to find these results. 1560 CXXRecordDecl *getNamingClass() const { return NamingClass; } 1561 void setNamingClass(CXXRecordDecl *D) { NamingClass = D; } 1562 1563 // Note that, inconsistently with the explicit-template-argument AST 1564 // nodes, users are *forbidden* from calling these methods on objects 1565 // without explicit template arguments. 1566 1567 ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 1568 assert(hasExplicitTemplateArgs()); 1569 return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 1570 } 1571 1572 /// Gets a reference to the explicit template argument list. 1573 const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1574 assert(hasExplicitTemplateArgs()); 1575 return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1576 } 1577 1578 /// \brief Copies the template arguments (if present) into the given 1579 /// structure. 1580 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1581 getExplicitTemplateArgs().copyInto(List); 1582 } 1583 1584 SourceLocation getLAngleLoc() const { 1585 return getExplicitTemplateArgs().LAngleLoc; 1586 } 1587 1588 SourceLocation getRAngleLoc() const { 1589 return getExplicitTemplateArgs().RAngleLoc; 1590 } 1591 1592 TemplateArgumentLoc const *getTemplateArgs() const { 1593 return getExplicitTemplateArgs().getTemplateArgs(); 1594 } 1595 1596 unsigned getNumTemplateArgs() const { 1597 return getExplicitTemplateArgs().NumTemplateArgs; 1598 } 1599 1600 virtual SourceRange getSourceRange() const { 1601 SourceRange Range(getNameLoc()); 1602 if (getQualifier()) Range.setBegin(getQualifierRange().getBegin()); 1603 if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc()); 1604 return Range; 1605 } 1606 1607 virtual StmtIterator child_begin(); 1608 virtual StmtIterator child_end(); 1609 1610 static bool classof(const Stmt *T) { 1611 return T->getStmtClass() == UnresolvedLookupExprClass; 1612 } 1613 static bool classof(const UnresolvedLookupExpr *) { return true; } 1614}; 1615 1616/// \brief A qualified reference to a name whose declaration cannot 1617/// yet be resolved. 1618/// 1619/// DependentScopeDeclRefExpr is similar to DeclRefExpr in that 1620/// it expresses a reference to a declaration such as 1621/// X<T>::value. The difference, however, is that an 1622/// DependentScopeDeclRefExpr node is used only within C++ templates when 1623/// the qualification (e.g., X<T>::) refers to a dependent type. In 1624/// this case, X<T>::value cannot resolve to a declaration because the 1625/// declaration will differ from on instantiation of X<T> to the 1626/// next. Therefore, DependentScopeDeclRefExpr keeps track of the 1627/// qualifier (X<T>::) and the name of the entity being referenced 1628/// ("value"). Such expressions will instantiate to a DeclRefExpr once the 1629/// declaration can be found. 1630class DependentScopeDeclRefExpr : public Expr { 1631 /// The name of the entity we will be referencing. 1632 DeclarationName Name; 1633 1634 /// Location of the name of the declaration we're referencing. 1635 SourceLocation Loc; 1636 1637 /// QualifierRange - The source range that covers the 1638 /// nested-name-specifier. 1639 SourceRange QualifierRange; 1640 1641 /// \brief The nested-name-specifier that qualifies this unresolved 1642 /// declaration name. 1643 NestedNameSpecifier *Qualifier; 1644 1645 /// \brief Whether the name includes explicit template arguments. 1646 bool HasExplicitTemplateArgs; 1647 1648 DependentScopeDeclRefExpr(QualType T, 1649 NestedNameSpecifier *Qualifier, 1650 SourceRange QualifierRange, 1651 DeclarationName Name, 1652 SourceLocation NameLoc, 1653 bool HasExplicitTemplateArgs) 1654 : Expr(DependentScopeDeclRefExprClass, T, true, true), 1655 Name(Name), Loc(NameLoc), 1656 QualifierRange(QualifierRange), Qualifier(Qualifier), 1657 HasExplicitTemplateArgs(HasExplicitTemplateArgs) 1658 {} 1659 1660public: 1661 static DependentScopeDeclRefExpr *Create(ASTContext &C, 1662 NestedNameSpecifier *Qualifier, 1663 SourceRange QualifierRange, 1664 DeclarationName Name, 1665 SourceLocation NameLoc, 1666 const TemplateArgumentListInfo *TemplateArgs = 0); 1667 1668 static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, 1669 unsigned NumTemplateArgs); 1670 1671 /// \brief Retrieve the name that this expression refers to. 1672 DeclarationName getDeclName() const { return Name; } 1673 void setDeclName(DeclarationName N) { Name = N; } 1674 1675 /// \brief Retrieve the location of the name within the expression. 1676 SourceLocation getLocation() const { return Loc; } 1677 void setLocation(SourceLocation L) { Loc = L; } 1678 1679 /// \brief Retrieve the source range of the nested-name-specifier. 1680 SourceRange getQualifierRange() const { return QualifierRange; } 1681 void setQualifierRange(SourceRange R) { QualifierRange = R; } 1682 1683 /// \brief Retrieve the nested-name-specifier that qualifies this 1684 /// declaration. 1685 NestedNameSpecifier *getQualifier() const { return Qualifier; } 1686 void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 1687 1688 /// Determines whether this lookup had explicit template arguments. 1689 bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } 1690 1691 // Note that, inconsistently with the explicit-template-argument AST 1692 // nodes, users are *forbidden* from calling these methods on objects 1693 // without explicit template arguments. 1694 1695 ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 1696 assert(hasExplicitTemplateArgs()); 1697 return *reinterpret_cast<ExplicitTemplateArgumentList*>(this + 1); 1698 } 1699 1700 /// Gets a reference to the explicit template argument list. 1701 const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 1702 assert(hasExplicitTemplateArgs()); 1703 return *reinterpret_cast<const ExplicitTemplateArgumentList*>(this + 1); 1704 } 1705 1706 /// \brief Copies the template arguments (if present) into the given 1707 /// structure. 1708 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 1709 getExplicitTemplateArgs().copyInto(List); 1710 } 1711 1712 SourceLocation getLAngleLoc() const { 1713 return getExplicitTemplateArgs().LAngleLoc; 1714 } 1715 1716 SourceLocation getRAngleLoc() const { 1717 return getExplicitTemplateArgs().RAngleLoc; 1718 } 1719 1720 TemplateArgumentLoc const *getTemplateArgs() const { 1721 return getExplicitTemplateArgs().getTemplateArgs(); 1722 } 1723 1724 unsigned getNumTemplateArgs() const { 1725 return getExplicitTemplateArgs().NumTemplateArgs; 1726 } 1727 1728 virtual SourceRange getSourceRange() const { 1729 SourceRange Range(QualifierRange.getBegin(), getLocation()); 1730 if (hasExplicitTemplateArgs()) 1731 Range.setEnd(getRAngleLoc()); 1732 return Range; 1733 } 1734 1735 static bool classof(const Stmt *T) { 1736 return T->getStmtClass() == DependentScopeDeclRefExprClass; 1737 } 1738 static bool classof(const DependentScopeDeclRefExpr *) { return true; } 1739 1740 virtual StmtIterator child_begin(); 1741 virtual StmtIterator child_end(); 1742}; 1743 1744class CXXExprWithTemporaries : public Expr { 1745 Stmt *SubExpr; 1746 1747 CXXTemporary **Temps; 1748 unsigned NumTemps; 1749 1750 CXXExprWithTemporaries(ASTContext &C, Expr *SubExpr, CXXTemporary **Temps, 1751 unsigned NumTemps); 1752 ~CXXExprWithTemporaries(); 1753 1754protected: 1755 virtual void DoDestroy(ASTContext &C); 1756 1757public: 1758 CXXExprWithTemporaries(EmptyShell Empty) 1759 : Expr(CXXExprWithTemporariesClass, Empty), 1760 SubExpr(0), Temps(0), NumTemps(0) {} 1761 1762 static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr, 1763 CXXTemporary **Temps, 1764 unsigned NumTemps); 1765 1766 unsigned getNumTemporaries() const { return NumTemps; } 1767 void setNumTemporaries(ASTContext &C, unsigned N); 1768 1769 CXXTemporary *getTemporary(unsigned i) { 1770 assert(i < NumTemps && "Index out of range"); 1771 return Temps[i]; 1772 } 1773 const CXXTemporary *getTemporary(unsigned i) const { 1774 return const_cast<CXXExprWithTemporaries*>(this)->getTemporary(i); 1775 } 1776 void setTemporary(unsigned i, CXXTemporary *T) { 1777 assert(i < NumTemps && "Index out of range"); 1778 Temps[i] = T; 1779 } 1780 1781 Expr *getSubExpr() { return cast<Expr>(SubExpr); } 1782 const Expr *getSubExpr() const { return cast<Expr>(SubExpr); } 1783 void setSubExpr(Expr *E) { SubExpr = E; } 1784 1785 virtual SourceRange getSourceRange() const { 1786 return SubExpr->getSourceRange(); 1787 } 1788 1789 // Implement isa/cast/dyncast/etc. 1790 static bool classof(const Stmt *T) { 1791 return T->getStmtClass() == CXXExprWithTemporariesClass; 1792 } 1793 static bool classof(const CXXExprWithTemporaries *) { return true; } 1794 1795 // Iterators 1796 virtual child_iterator child_begin(); 1797 virtual child_iterator child_end(); 1798}; 1799 1800/// \brief Describes an explicit type conversion that uses functional 1801/// notion but could not be resolved because one or more arguments are 1802/// type-dependent. 1803/// 1804/// The explicit type conversions expressed by 1805/// CXXUnresolvedConstructExpr have the form \c T(a1, a2, ..., aN), 1806/// where \c T is some type and \c a1, a2, ..., aN are values, and 1807/// either \C T is a dependent type or one or more of the \c a's is 1808/// type-dependent. For example, this would occur in a template such 1809/// as: 1810/// 1811/// \code 1812/// template<typename T, typename A1> 1813/// inline T make_a(const A1& a1) { 1814/// return T(a1); 1815/// } 1816/// \endcode 1817/// 1818/// When the returned expression is instantiated, it may resolve to a 1819/// constructor call, conversion function call, or some kind of type 1820/// conversion. 1821class CXXUnresolvedConstructExpr : public Expr { 1822 /// \brief The starting location of the type 1823 SourceLocation TyBeginLoc; 1824 1825 /// \brief The type being constructed. 1826 QualType Type; 1827 1828 /// \brief The location of the left parentheses ('('). 1829 SourceLocation LParenLoc; 1830 1831 /// \brief The location of the right parentheses (')'). 1832 SourceLocation RParenLoc; 1833 1834 /// \brief The number of arguments used to construct the type. 1835 unsigned NumArgs; 1836 1837 CXXUnresolvedConstructExpr(SourceLocation TyBegin, 1838 QualType T, 1839 SourceLocation LParenLoc, 1840 Expr **Args, 1841 unsigned NumArgs, 1842 SourceLocation RParenLoc); 1843 1844 CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) 1845 : Expr(CXXUnresolvedConstructExprClass, Empty), NumArgs(NumArgs) { } 1846 1847public: 1848 static CXXUnresolvedConstructExpr *Create(ASTContext &C, 1849 SourceLocation TyBegin, 1850 QualType T, 1851 SourceLocation LParenLoc, 1852 Expr **Args, 1853 unsigned NumArgs, 1854 SourceLocation RParenLoc); 1855 1856 static CXXUnresolvedConstructExpr *CreateEmpty(ASTContext &C, 1857 unsigned NumArgs); 1858 1859 /// \brief Retrieve the source location where the type begins. 1860 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 1861 void setTypeBeginLoc(SourceLocation L) { TyBeginLoc = L; } 1862 1863 /// \brief Retrieve the type that is being constructed, as specified 1864 /// in the source code. 1865 QualType getTypeAsWritten() const { return Type; } 1866 void setTypeAsWritten(QualType T) { Type = T; } 1867 1868 /// \brief Retrieve the location of the left parentheses ('(') that 1869 /// precedes the argument list. 1870 SourceLocation getLParenLoc() const { return LParenLoc; } 1871 void setLParenLoc(SourceLocation L) { LParenLoc = L; } 1872 1873 /// \brief Retrieve the location of the right parentheses (')') that 1874 /// follows the argument list. 1875 SourceLocation getRParenLoc() const { return RParenLoc; } 1876 void setRParenLoc(SourceLocation L) { RParenLoc = L; } 1877 1878 /// \brief Retrieve the number of arguments. 1879 unsigned arg_size() const { return NumArgs; } 1880 1881 typedef Expr** arg_iterator; 1882 arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } 1883 arg_iterator arg_end() { return arg_begin() + NumArgs; } 1884 1885 typedef const Expr* const * const_arg_iterator; 1886 const_arg_iterator arg_begin() const { 1887 return reinterpret_cast<const Expr* const *>(this + 1); 1888 } 1889 const_arg_iterator arg_end() const { 1890 return arg_begin() + NumArgs; 1891 } 1892 1893 Expr *getArg(unsigned I) { 1894 assert(I < NumArgs && "Argument index out-of-range"); 1895 return *(arg_begin() + I); 1896 } 1897 1898 const Expr *getArg(unsigned I) const { 1899 assert(I < NumArgs && "Argument index out-of-range"); 1900 return *(arg_begin() + I); 1901 } 1902 1903 void setArg(unsigned I, Expr *E) { 1904 assert(I < NumArgs && "Argument index out-of-range"); 1905 *(arg_begin() + I) = E; 1906 } 1907 1908 virtual SourceRange getSourceRange() const { 1909 return SourceRange(TyBeginLoc, RParenLoc); 1910 } 1911 static bool classof(const Stmt *T) { 1912 return T->getStmtClass() == CXXUnresolvedConstructExprClass; 1913 } 1914 static bool classof(const CXXUnresolvedConstructExpr *) { return true; } 1915 1916 // Iterators 1917 virtual child_iterator child_begin(); 1918 virtual child_iterator child_end(); 1919}; 1920 1921/// \brief Represents a C++ member access expression where the actual 1922/// member referenced could not be resolved because the base 1923/// expression or the member name was dependent. 1924/// 1925/// Like UnresolvedMemberExprs, these can be either implicit or 1926/// explicit accesses. It is only possible to get one of these with 1927/// an implicit access if a qualifier is provided. 1928class CXXDependentScopeMemberExpr : public Expr { 1929 /// \brief The expression for the base pointer or class reference, 1930 /// e.g., the \c x in x.f. Can be null in implicit accesses. 1931 Stmt *Base; 1932 1933 /// \brief The type of the base expression. Never null, even for 1934 /// implicit accesses. 1935 QualType BaseType; 1936 1937 /// \brief Whether this member expression used the '->' operator or 1938 /// the '.' operator. 1939 bool IsArrow : 1; 1940 1941 /// \brief Whether this member expression has explicitly-specified template 1942 /// arguments. 1943 bool HasExplicitTemplateArgs : 1; 1944 1945 /// \brief The location of the '->' or '.' operator. 1946 SourceLocation OperatorLoc; 1947 1948 /// \brief The nested-name-specifier that precedes the member name, if any. 1949 NestedNameSpecifier *Qualifier; 1950 1951 /// \brief The source range covering the nested name specifier. 1952 SourceRange QualifierRange; 1953 1954 /// \brief In a qualified member access expression such as t->Base::f, this 1955 /// member stores the resolves of name lookup in the context of the member 1956 /// access expression, to be used at instantiation time. 1957 /// 1958 /// FIXME: This member, along with the Qualifier and QualifierRange, could 1959 /// be stuck into a structure that is optionally allocated at the end of 1960 /// the CXXDependentScopeMemberExpr, to save space in the common case. 1961 NamedDecl *FirstQualifierFoundInScope; 1962 1963 /// \brief The member to which this member expression refers, which 1964 /// can be name, overloaded operator, or destructor. 1965 /// FIXME: could also be a template-id 1966 DeclarationName Member; 1967 1968 /// \brief The location of the member name. 1969 SourceLocation MemberLoc; 1970 1971 CXXDependentScopeMemberExpr(ASTContext &C, 1972 Expr *Base, QualType BaseType, bool IsArrow, 1973 SourceLocation OperatorLoc, 1974 NestedNameSpecifier *Qualifier, 1975 SourceRange QualifierRange, 1976 NamedDecl *FirstQualifierFoundInScope, 1977 DeclarationName Member, 1978 SourceLocation MemberLoc, 1979 const TemplateArgumentListInfo *TemplateArgs); 1980 1981public: 1982 CXXDependentScopeMemberExpr(ASTContext &C, 1983 Expr *Base, QualType BaseType, 1984 bool IsArrow, 1985 SourceLocation OperatorLoc, 1986 NestedNameSpecifier *Qualifier, 1987 SourceRange QualifierRange, 1988 NamedDecl *FirstQualifierFoundInScope, 1989 DeclarationName Member, 1990 SourceLocation MemberLoc) 1991 : Expr(CXXDependentScopeMemberExprClass, C.DependentTy, true, true), 1992 Base(Base), BaseType(BaseType), IsArrow(IsArrow), 1993 HasExplicitTemplateArgs(false), OperatorLoc(OperatorLoc), 1994 Qualifier(Qualifier), QualifierRange(QualifierRange), 1995 FirstQualifierFoundInScope(FirstQualifierFoundInScope), 1996 Member(Member), MemberLoc(MemberLoc) { } 1997 1998 static CXXDependentScopeMemberExpr * 1999 Create(ASTContext &C, 2000 Expr *Base, QualType BaseType, bool IsArrow, 2001 SourceLocation OperatorLoc, 2002 NestedNameSpecifier *Qualifier, 2003 SourceRange QualifierRange, 2004 NamedDecl *FirstQualifierFoundInScope, 2005 DeclarationName Member, 2006 SourceLocation MemberLoc, 2007 const TemplateArgumentListInfo *TemplateArgs); 2008 2009 static CXXDependentScopeMemberExpr * 2010 CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); 2011 2012 /// \brief True if this is an implicit access, i.e. one in which the 2013 /// member being accessed was not written in the source. The source 2014 /// location of the operator is invalid in this case. 2015 bool isImplicitAccess() const { return Base == 0; } 2016 2017 /// \brief Retrieve the base object of this member expressions, 2018 /// e.g., the \c x in \c x.m. 2019 Expr *getBase() const { 2020 assert(!isImplicitAccess()); 2021 return cast<Expr>(Base); 2022 } 2023 void setBase(Expr *E) { Base = E; } 2024 2025 QualType getBaseType() const { return BaseType; } 2026 void setBaseType(QualType T) { BaseType = T; } 2027 2028 /// \brief Determine whether this member expression used the '->' 2029 /// operator; otherwise, it used the '.' operator. 2030 bool isArrow() const { return IsArrow; } 2031 void setArrow(bool A) { IsArrow = A; } 2032 2033 /// \brief Retrieve the location of the '->' or '.' operator. 2034 SourceLocation getOperatorLoc() const { return OperatorLoc; } 2035 void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 2036 2037 /// \brief Retrieve the nested-name-specifier that qualifies the member 2038 /// name. 2039 NestedNameSpecifier *getQualifier() const { return Qualifier; } 2040 void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; } 2041 2042 /// \brief Retrieve the source range covering the nested-name-specifier 2043 /// that qualifies the member name. 2044 SourceRange getQualifierRange() const { return QualifierRange; } 2045 void setQualifierRange(SourceRange R) { QualifierRange = R; } 2046 2047 /// \brief Retrieve the first part of the nested-name-specifier that was 2048 /// found in the scope of the member access expression when the member access 2049 /// was initially parsed. 2050 /// 2051 /// This function only returns a useful result when member access expression 2052 /// uses a qualified member name, e.g., "x.Base::f". Here, the declaration 2053 /// returned by this function describes what was found by unqualified name 2054 /// lookup for the identifier "Base" within the scope of the member access 2055 /// expression itself. At template instantiation time, this information is 2056 /// combined with the results of name lookup into the type of the object 2057 /// expression itself (the class type of x). 2058 NamedDecl *getFirstQualifierFoundInScope() const { 2059 return FirstQualifierFoundInScope; 2060 } 2061 void setFirstQualifierFoundInScope(NamedDecl *D) { 2062 FirstQualifierFoundInScope = D; 2063 } 2064 2065 /// \brief Retrieve the name of the member that this expression 2066 /// refers to. 2067 DeclarationName getMember() const { return Member; } 2068 void setMember(DeclarationName N) { Member = N; } 2069 2070 // \brief Retrieve the location of the name of the member that this 2071 // expression refers to. 2072 SourceLocation getMemberLoc() const { return MemberLoc; } 2073 void setMemberLoc(SourceLocation L) { MemberLoc = L; } 2074 2075 /// \brief Determines whether this member expression actually had a C++ 2076 /// template argument list explicitly specified, e.g., x.f<int>. 2077 bool hasExplicitTemplateArgs() const { 2078 return HasExplicitTemplateArgs; 2079 } 2080 2081 /// \brief Retrieve the explicit template argument list that followed the 2082 /// member template name, if any. 2083 ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() { 2084 assert(HasExplicitTemplateArgs); 2085 return reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 2086 } 2087 2088 /// \brief Retrieve the explicit template argument list that followed the 2089 /// member template name, if any. 2090 const ExplicitTemplateArgumentList *getExplicitTemplateArgumentList() const { 2091 return const_cast<CXXDependentScopeMemberExpr *>(this) 2092 ->getExplicitTemplateArgumentList(); 2093 } 2094 2095 /// \brief Copies the template arguments (if present) into the given 2096 /// structure. 2097 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2098 assert(HasExplicitTemplateArgs); 2099 getExplicitTemplateArgumentList()->copyInto(List); 2100 } 2101 2102 /// \brief Initializes the template arguments using the given structure. 2103 void initializeTemplateArgumentsFrom(const TemplateArgumentListInfo &List) { 2104 assert(HasExplicitTemplateArgs); 2105 getExplicitTemplateArgumentList()->initializeFrom(List); 2106 } 2107 2108 /// \brief Retrieve the location of the left angle bracket following the 2109 /// member name ('<'), if any. 2110 SourceLocation getLAngleLoc() const { 2111 assert(HasExplicitTemplateArgs); 2112 return getExplicitTemplateArgumentList()->LAngleLoc; 2113 } 2114 2115 /// \brief Retrieve the template arguments provided as part of this 2116 /// template-id. 2117 const TemplateArgumentLoc *getTemplateArgs() const { 2118 assert(HasExplicitTemplateArgs); 2119 return getExplicitTemplateArgumentList()->getTemplateArgs(); 2120 } 2121 2122 /// \brief Retrieve the number of template arguments provided as part of this 2123 /// template-id. 2124 unsigned getNumTemplateArgs() const { 2125 assert(HasExplicitTemplateArgs); 2126 return getExplicitTemplateArgumentList()->NumTemplateArgs; 2127 } 2128 2129 /// \brief Retrieve the location of the right angle bracket following the 2130 /// template arguments ('>'). 2131 SourceLocation getRAngleLoc() const { 2132 assert(HasExplicitTemplateArgs); 2133 return getExplicitTemplateArgumentList()->RAngleLoc; 2134 } 2135 2136 virtual SourceRange getSourceRange() const { 2137 SourceRange Range; 2138 if (!isImplicitAccess()) 2139 Range.setBegin(Base->getSourceRange().getBegin()); 2140 else if (getQualifier()) 2141 Range.setBegin(getQualifierRange().getBegin()); 2142 else 2143 Range.setBegin(MemberLoc); 2144 2145 if (hasExplicitTemplateArgs()) 2146 Range.setEnd(getRAngleLoc()); 2147 else 2148 Range.setEnd(MemberLoc); 2149 return Range; 2150 } 2151 2152 static bool classof(const Stmt *T) { 2153 return T->getStmtClass() == CXXDependentScopeMemberExprClass; 2154 } 2155 static bool classof(const CXXDependentScopeMemberExpr *) { return true; } 2156 2157 // Iterators 2158 virtual child_iterator child_begin(); 2159 virtual child_iterator child_end(); 2160}; 2161 2162/// \brief Represents a C++ member access expression for which lookup 2163/// produced a set of overloaded functions. 2164/// 2165/// The member access may be explicit or implicit: 2166/// struct A { 2167/// int a, b; 2168/// int explicitAccess() { return this->a + this->A::b; } 2169/// int implicitAccess() { return a + A::b; } 2170/// }; 2171/// 2172/// In the final AST, an explicit access always becomes a MemberExpr. 2173/// An implicit access may become either a MemberExpr or a 2174/// DeclRefExpr, depending on whether the member is static. 2175class UnresolvedMemberExpr : public OverloadExpr { 2176 /// \brief Whether this member expression used the '->' operator or 2177 /// the '.' operator. 2178 bool IsArrow : 1; 2179 2180 /// \brief Whether the lookup results contain an unresolved using 2181 /// declaration. 2182 bool HasUnresolvedUsing : 1; 2183 2184 /// \brief The expression for the base pointer or class reference, 2185 /// e.g., the \c x in x.f. This can be null if this is an 'unbased' 2186 /// member expression 2187 Stmt *Base; 2188 2189 /// \brief The type of the base expression; never null. 2190 QualType BaseType; 2191 2192 /// \brief The location of the '->' or '.' operator. 2193 SourceLocation OperatorLoc; 2194 2195 UnresolvedMemberExpr(ASTContext &C, QualType T, bool Dependent, 2196 bool HasUnresolvedUsing, 2197 Expr *Base, QualType BaseType, bool IsArrow, 2198 SourceLocation OperatorLoc, 2199 NestedNameSpecifier *Qualifier, 2200 SourceRange QualifierRange, 2201 DeclarationName Member, 2202 SourceLocation MemberLoc, 2203 const TemplateArgumentListInfo *TemplateArgs, 2204 UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2205 2206 UnresolvedMemberExpr(EmptyShell Empty) 2207 : OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false), 2208 HasUnresolvedUsing(false), Base(0) { } 2209 2210public: 2211 static UnresolvedMemberExpr * 2212 Create(ASTContext &C, bool Dependent, bool HasUnresolvedUsing, 2213 Expr *Base, QualType BaseType, bool IsArrow, 2214 SourceLocation OperatorLoc, 2215 NestedNameSpecifier *Qualifier, 2216 SourceRange QualifierRange, 2217 DeclarationName Member, 2218 SourceLocation MemberLoc, 2219 const TemplateArgumentListInfo *TemplateArgs, 2220 UnresolvedSetIterator Begin, UnresolvedSetIterator End); 2221 2222 static UnresolvedMemberExpr * 2223 CreateEmpty(ASTContext &C, unsigned NumTemplateArgs); 2224 2225 /// \brief True if this is an implicit access, i.e. one in which the 2226 /// member being accessed was not written in the source. The source 2227 /// location of the operator is invalid in this case. 2228 bool isImplicitAccess() const { return Base == 0; } 2229 2230 /// \brief Retrieve the base object of this member expressions, 2231 /// e.g., the \c x in \c x.m. 2232 Expr *getBase() { 2233 assert(!isImplicitAccess()); 2234 return cast<Expr>(Base); 2235 } 2236 const Expr *getBase() const { 2237 assert(!isImplicitAccess()); 2238 return cast<Expr>(Base); 2239 } 2240 void setBase(Expr *E) { Base = E; } 2241 2242 QualType getBaseType() const { return BaseType; } 2243 void setBaseType(QualType T) { BaseType = T; } 2244 2245 /// \brief Determine whether the lookup results contain an unresolved using 2246 /// declaration. 2247 bool hasUnresolvedUsing() const { return HasUnresolvedUsing; } 2248 void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; } 2249 2250 /// \brief Determine whether this member expression used the '->' 2251 /// operator; otherwise, it used the '.' operator. 2252 bool isArrow() const { return IsArrow; } 2253 void setArrow(bool A) { IsArrow = A; } 2254 2255 /// \brief Retrieve the location of the '->' or '.' operator. 2256 SourceLocation getOperatorLoc() const { return OperatorLoc; } 2257 void setOperatorLoc(SourceLocation L) { OperatorLoc = L; } 2258 2259 /// \brief Retrieves the naming class of this lookup. 2260 CXXRecordDecl *getNamingClass() const; 2261 2262 /// \brief Retrieve the name of the member that this expression 2263 /// refers to. 2264 DeclarationName getMemberName() const { return getName(); } 2265 void setMemberName(DeclarationName N) { setName(N); } 2266 2267 // \brief Retrieve the location of the name of the member that this 2268 // expression refers to. 2269 SourceLocation getMemberLoc() const { return getNameLoc(); } 2270 void setMemberLoc(SourceLocation L) { setNameLoc(L); } 2271 2272 /// \brief Retrieve the explicit template argument list that followed the 2273 /// member template name. 2274 ExplicitTemplateArgumentList &getExplicitTemplateArgs() { 2275 assert(hasExplicitTemplateArgs()); 2276 return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1); 2277 } 2278 2279 /// \brief Retrieve the explicit template argument list that followed the 2280 /// member template name, if any. 2281 const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const { 2282 assert(hasExplicitTemplateArgs()); 2283 return *reinterpret_cast<const ExplicitTemplateArgumentList *>(this + 1); 2284 } 2285 2286 /// \brief Copies the template arguments into the given structure. 2287 void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { 2288 getExplicitTemplateArgs().copyInto(List); 2289 } 2290 2291 /// \brief Retrieve the location of the left angle bracket following 2292 /// the member name ('<'). 2293 SourceLocation getLAngleLoc() const { 2294 return getExplicitTemplateArgs().LAngleLoc; 2295 } 2296 2297 /// \brief Retrieve the template arguments provided as part of this 2298 /// template-id. 2299 const TemplateArgumentLoc *getTemplateArgs() const { 2300 return getExplicitTemplateArgs().getTemplateArgs(); 2301 } 2302 2303 /// \brief Retrieve the number of template arguments provided as 2304 /// part of this template-id. 2305 unsigned getNumTemplateArgs() const { 2306 return getExplicitTemplateArgs().NumTemplateArgs; 2307 } 2308 2309 /// \brief Retrieve the location of the right angle bracket 2310 /// following the template arguments ('>'). 2311 SourceLocation getRAngleLoc() const { 2312 return getExplicitTemplateArgs().RAngleLoc; 2313 } 2314 2315 virtual SourceRange getSourceRange() const { 2316 SourceRange Range; 2317 if (!isImplicitAccess()) 2318 Range.setBegin(Base->getSourceRange().getBegin()); 2319 else if (getQualifier()) 2320 Range.setBegin(getQualifierRange().getBegin()); 2321 else 2322 Range.setBegin(getMemberLoc()); 2323 2324 if (hasExplicitTemplateArgs()) 2325 Range.setEnd(getRAngleLoc()); 2326 else 2327 Range.setEnd(getMemberLoc()); 2328 return Range; 2329 } 2330 2331 static bool classof(const Stmt *T) { 2332 return T->getStmtClass() == UnresolvedMemberExprClass; 2333 } 2334 static bool classof(const UnresolvedMemberExpr *) { return true; } 2335 2336 // Iterators 2337 virtual child_iterator child_begin(); 2338 virtual child_iterator child_end(); 2339}; 2340 2341inline ExplicitTemplateArgumentList &OverloadExpr::getExplicitTemplateArgs() { 2342 if (isa<UnresolvedLookupExpr>(this)) 2343 return cast<UnresolvedLookupExpr>(this)->getExplicitTemplateArgs(); 2344 else 2345 return cast<UnresolvedMemberExpr>(this)->getExplicitTemplateArgs(); 2346} 2347 2348} // end namespace clang 2349 2350#endif 2351