ExprCXX.h revision d457589fc69dc7a9c80cd74d317c0b81a35a27c9
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/AST/Expr.h" 18#include "clang/AST/Decl.h" 19 20namespace clang { 21 22 class CXXConstructorDecl; 23 24//===--------------------------------------------------------------------===// 25// C++ Expressions. 26//===--------------------------------------------------------------------===// 27 28/// CXXOperatorCallExpr - Represents a call to an overloaded operator 29/// written using operator syntax, e.g., "x + y" or "*p". While 30/// semantically equivalent to a normal call, this AST node provides 31/// better information about the syntactic representation of the call. 32class CXXOperatorCallExpr : public CallExpr { 33public: 34 CXXOperatorCallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t, 35 SourceLocation operatorloc) 36 : CallExpr(CXXOperatorCallExprClass, fn, args, numargs, t, operatorloc) { } 37 38 /// getOperator - Returns the kind of overloaded operator that this 39 /// expression refers to. 40 OverloadedOperatorKind getOperator() const; 41 42 /// getOperatorLoc - Returns the location of the operator symbol in 43 /// the expression. When @c getOperator()==OO_Call, this is the 44 /// location of the right parentheses; when @c 45 /// getOperator()==OO_Subscript, this is the location of the right 46 /// bracket. 47 SourceLocation getOperatorLoc() const { return getRParenLoc(); } 48 49 virtual SourceRange getSourceRange() const; 50 51 static bool classof(const Stmt *T) { 52 return T->getStmtClass() == CXXOperatorCallExprClass; 53 } 54 static bool classof(const CXXOperatorCallExpr *) { return true; } 55}; 56 57/// CXXNamedCastExpr - Abstract class common to all of the C++ "named" 58/// casts, @c static_cast, @c dynamic_cast, @c reinterpret_cast, or @c 59/// const_cast. 60/// 61/// This abstract class is inherited by all of the classes 62/// representing "named" casts, e.g., CXXStaticCastExpr, 63/// CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr. 64class CXXNamedCastExpr : public ExplicitCastExpr { 65private: 66 SourceLocation Loc; // the location of the casting op 67 68protected: 69 CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy, 70 SourceLocation l) 71 : ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {} 72 73public: 74 const char *getCastName() const; 75 76 virtual SourceRange getSourceRange() const { 77 return SourceRange(Loc, getSubExpr()->getSourceRange().getEnd()); 78 } 79 static bool classof(const Stmt *T) { 80 switch (T->getStmtClass()) { 81 case CXXNamedCastExprClass: 82 case CXXStaticCastExprClass: 83 case CXXDynamicCastExprClass: 84 case CXXReinterpretCastExprClass: 85 case CXXConstCastExprClass: 86 return true; 87 default: 88 return false; 89 } 90 } 91 static bool classof(const CXXNamedCastExpr *) { return true; } 92 93 virtual void EmitImpl(llvm::Serializer& S) const; 94 static CXXNamedCastExpr *CreateImpl(llvm::Deserializer& D, ASTContext& C, 95 StmtClass SC); 96}; 97 98/// CXXStaticCastExpr - A C++ @c static_cast expression (C++ [expr.static.cast]). 99/// 100/// This expression node represents a C++ static cast, e.g., 101/// @c static_cast<int>(1.0). 102class CXXStaticCastExpr : public CXXNamedCastExpr { 103public: 104 CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 105 : CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {} 106 107 static bool classof(const Stmt *T) { 108 return T->getStmtClass() == CXXStaticCastExprClass; 109 } 110 static bool classof(const CXXStaticCastExpr *) { return true; } 111}; 112 113/// CXXDynamicCastExpr - A C++ @c dynamic_cast expression 114/// (C++ [expr.dynamic.cast]), which may perform a run-time check to 115/// determine how to perform the type cast. 116/// 117/// This expression node represents a dynamic cast, e.g., 118/// @c dynamic_cast<Derived*>(BasePtr). 119class CXXDynamicCastExpr : public CXXNamedCastExpr { 120public: 121 CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l) 122 : CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {} 123 124 static bool classof(const Stmt *T) { 125 return T->getStmtClass() == CXXDynamicCastExprClass; 126 } 127 static bool classof(const CXXDynamicCastExpr *) { return true; } 128}; 129 130/// CXXReinterpretCastExpr - A C++ @c reinterpret_cast expression (C++ 131/// [expr.reinterpret.cast]), which provides a differently-typed view 132/// of a value but performs no actual work at run time. 133/// 134/// This expression node represents a reinterpret cast, e.g., 135/// @c reinterpret_cast<int>(VoidPtr). 136class CXXReinterpretCastExpr : public CXXNamedCastExpr { 137public: 138 CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy, 139 SourceLocation l) 140 : CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {} 141 142 static bool classof(const Stmt *T) { 143 return T->getStmtClass() == CXXReinterpretCastExprClass; 144 } 145 static bool classof(const CXXReinterpretCastExpr *) { return true; } 146}; 147 148/// CXXConstCastExpr - A C++ @c const_cast expression (C++ [expr.const.cast]), 149/// which can remove type qualifiers but does not change the underlying value. 150/// 151/// This expression node represents a const cast, e.g., 152/// @c const_cast<char*>(PtrToConstChar). 153class CXXConstCastExpr : public CXXNamedCastExpr { 154public: 155 CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy, 156 SourceLocation l) 157 : CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {} 158 159 static bool classof(const Stmt *T) { 160 return T->getStmtClass() == CXXConstCastExprClass; 161 } 162 static bool classof(const CXXConstCastExpr *) { return true; } 163}; 164 165/// CXXBoolLiteralExpr - [C++ 2.13.5] C++ Boolean Literal. 166/// 167class CXXBoolLiteralExpr : public Expr { 168 bool Value; 169 SourceLocation Loc; 170public: 171 CXXBoolLiteralExpr(bool val, QualType Ty, SourceLocation l) : 172 Expr(CXXBoolLiteralExprClass, Ty), Value(val), Loc(l) {} 173 174 bool getValue() const { return Value; } 175 176 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 177 178 static bool classof(const Stmt *T) { 179 return T->getStmtClass() == CXXBoolLiteralExprClass; 180 } 181 static bool classof(const CXXBoolLiteralExpr *) { return true; } 182 183 // Iterators 184 virtual child_iterator child_begin(); 185 virtual child_iterator child_end(); 186}; 187 188/// CXXTypeidExpr - A C++ @c typeid expression (C++ [expr.typeid]), which gets 189/// the type_info that corresponds to the supplied type, or the (possibly 190/// dynamic) type of the supplied expression. 191/// 192/// This represents code like @c typeid(int) or @c typeid(*objPtr) 193class CXXTypeidExpr : public Expr { 194private: 195 bool isTypeOp : 1; 196 union { 197 void *Ty; 198 Stmt *Ex; 199 } Operand; 200 SourceRange Range; 201 202public: 203 CXXTypeidExpr(bool isTypeOp, void *op, QualType Ty, const SourceRange r) : 204 Expr(CXXTypeidExprClass, Ty), isTypeOp(isTypeOp), Range(r) { 205 if (isTypeOp) 206 Operand.Ty = op; 207 else 208 // op was an Expr*, so cast it back to that to be safe 209 Operand.Ex = static_cast<Stmt*>(op); 210 } 211 212 bool isTypeOperand() const { return isTypeOp; } 213 QualType getTypeOperand() const { 214 assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); 215 return QualType::getFromOpaquePtr(Operand.Ty); 216 } 217 Expr* getExprOperand() const { 218 assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); 219 return static_cast<Expr*>(Operand.Ex); 220 } 221 222 virtual SourceRange getSourceRange() const { 223 return Range; 224 } 225 static bool classof(const Stmt *T) { 226 return T->getStmtClass() == CXXTypeidExprClass; 227 } 228 static bool classof(const CXXTypeidExpr *) { return true; } 229 230 // Iterators 231 virtual child_iterator child_begin(); 232 virtual child_iterator child_end(); 233 234 virtual void EmitImpl(llvm::Serializer& S) const; 235 static CXXTypeidExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 236}; 237 238/// CXXThisExpr - Represents the "this" expression in C++, which is a 239/// pointer to the object on which the current member function is 240/// executing (C++ [expr.prim]p3). Example: 241/// 242/// @code 243/// class Foo { 244/// public: 245/// void bar(); 246/// void test() { this->bar(); } 247/// }; 248/// @endcode 249class CXXThisExpr : public Expr { 250 SourceLocation Loc; 251 252public: 253 CXXThisExpr(SourceLocation L, QualType Type) 254 : Expr(CXXThisExprClass, Type), Loc(L) { } 255 256 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 257 258 static bool classof(const Stmt *T) { 259 return T->getStmtClass() == CXXThisExprClass; 260 } 261 static bool classof(const CXXThisExpr *) { return true; } 262 263 // Iterators 264 virtual child_iterator child_begin(); 265 virtual child_iterator child_end(); 266 267 virtual void EmitImpl(llvm::Serializer& S) const; 268 static CXXThisExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 269}; 270 271/// CXXThrowExpr - [C++ 15] C++ Throw Expression. This handles 272/// 'throw' and 'throw' assignment-expression. When 273/// assignment-expression isn't present, Op will be null. 274/// 275class CXXThrowExpr : public Expr { 276 Stmt *Op; 277 SourceLocation ThrowLoc; 278public: 279 // Ty is the void type which is used as the result type of the 280 // exepression. The l is the location of the throw keyword. expr 281 // can by null, if the optional expression to throw isn't present. 282 CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) : 283 Expr(CXXThrowExprClass, Ty), Op(expr), ThrowLoc(l) {} 284 const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); } 285 Expr *getSubExpr() { return cast_or_null<Expr>(Op); } 286 287 virtual SourceRange getSourceRange() const { 288 if (getSubExpr() == 0) 289 return SourceRange(ThrowLoc, ThrowLoc); 290 return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); 291 } 292 293 static bool classof(const Stmt *T) { 294 return T->getStmtClass() == CXXThrowExprClass; 295 } 296 static bool classof(const CXXThrowExpr *) { return true; } 297 298 // Iterators 299 virtual child_iterator child_begin(); 300 virtual child_iterator child_end(); 301}; 302 303/// CXXDefaultArgExpr - C++ [dcl.fct.default]. This wraps up a 304/// function call argument that was created from the corresponding 305/// parameter's default argument, when the call did not explicitly 306/// supply arguments for all of the parameters. 307class CXXDefaultArgExpr : public Expr { 308 ParmVarDecl *Param; 309public: 310 // Param is the parameter whose default argument is used by this 311 // expression. 312 explicit CXXDefaultArgExpr(ParmVarDecl *param) 313 : Expr(CXXDefaultArgExprClass, param->getDefaultArg()->getType()), 314 Param(param) { } 315 316 // Retrieve the parameter that the argument was created from. 317 const ParmVarDecl *getParam() const { return Param; } 318 ParmVarDecl *getParam() { return Param; } 319 320 // Retrieve the actual argument to the function call. 321 const Expr *getExpr() const { return Param->getDefaultArg(); } 322 Expr *getExpr() { return Param->getDefaultArg(); } 323 324 virtual SourceRange getSourceRange() const { 325 // Default argument expressions have no representation in the 326 // source, so they have an empty source range. 327 return SourceRange(); 328 } 329 330 static bool classof(const Stmt *T) { 331 return T->getStmtClass() == CXXDefaultArgExprClass; 332 } 333 static bool classof(const CXXDefaultArgExpr *) { return true; } 334 335 // Iterators 336 virtual child_iterator child_begin(); 337 virtual child_iterator child_end(); 338 339 // Serialization 340 virtual void EmitImpl(llvm::Serializer& S) const; 341 static CXXDefaultArgExpr* CreateImpl(llvm::Deserializer& D, 342 ASTContext& C); 343}; 344 345/// CXXFunctionalCastExpr - Represents an explicit C++ type conversion 346/// that uses "functional" notion (C++ [expr.type.conv]). Example: @c 347/// x = int(0.5); 348class CXXFunctionalCastExpr : public ExplicitCastExpr { 349 SourceLocation TyBeginLoc; 350 SourceLocation RParenLoc; 351public: 352 CXXFunctionalCastExpr(QualType ty, QualType writtenTy, 353 SourceLocation tyBeginLoc, Expr *castExpr, 354 SourceLocation rParenLoc) : 355 ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy), 356 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 357 358 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 359 SourceLocation getRParenLoc() const { return RParenLoc; } 360 361 virtual SourceRange getSourceRange() const { 362 return SourceRange(TyBeginLoc, RParenLoc); 363 } 364 static bool classof(const Stmt *T) { 365 return T->getStmtClass() == CXXFunctionalCastExprClass; 366 } 367 static bool classof(const CXXFunctionalCastExpr *) { return true; } 368 369 virtual void EmitImpl(llvm::Serializer& S) const; 370 static CXXFunctionalCastExpr * 371 CreateImpl(llvm::Deserializer& D, ASTContext& C); 372}; 373 374/// CXXZeroInitValueExpr - [C++ 5.2.3p2] 375/// Expression "T()" which creates a value-initialized Rvalue of non-class 376/// type T. 377/// 378class CXXZeroInitValueExpr : public Expr { 379 SourceLocation TyBeginLoc; 380 SourceLocation RParenLoc; 381 382public: 383 CXXZeroInitValueExpr(QualType ty, SourceLocation tyBeginLoc, 384 SourceLocation rParenLoc ) : 385 Expr(CXXZeroInitValueExprClass, ty), 386 TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {} 387 388 SourceLocation getTypeBeginLoc() const { return TyBeginLoc; } 389 SourceLocation getRParenLoc() const { return RParenLoc; } 390 391 virtual SourceRange getSourceRange() const { 392 return SourceRange(TyBeginLoc, RParenLoc); 393 } 394 395 static bool classof(const Stmt *T) { 396 return T->getStmtClass() == CXXZeroInitValueExprClass; 397 } 398 static bool classof(const CXXZeroInitValueExpr *) { return true; } 399 400 // Iterators 401 virtual child_iterator child_begin(); 402 virtual child_iterator child_end(); 403 404 virtual void EmitImpl(llvm::Serializer& S) const; 405 static CXXZeroInitValueExpr * 406 CreateImpl(llvm::Deserializer& D, ASTContext& C); 407}; 408 409/// CXXConditionDeclExpr - Condition declaration of a if/switch/while/for 410/// statement, e.g: "if (int x = f()) {...}". 411/// The main difference with DeclRefExpr is that CXXConditionDeclExpr owns the 412/// decl that it references. 413/// 414class CXXConditionDeclExpr : public DeclRefExpr { 415public: 416 CXXConditionDeclExpr(SourceLocation startLoc, 417 SourceLocation eqLoc, VarDecl *var) 418 : DeclRefExpr(CXXConditionDeclExprClass, var, 419 var->getType().getNonReferenceType(), startLoc) {} 420 421 virtual void Destroy(ASTContext& Ctx); 422 423 SourceLocation getStartLoc() const { return getLocation(); } 424 425 VarDecl *getVarDecl() { return cast<VarDecl>(getDecl()); } 426 const VarDecl *getVarDecl() const { return cast<VarDecl>(getDecl()); } 427 428 virtual SourceRange getSourceRange() const { 429 return SourceRange(getStartLoc(), getVarDecl()->getInit()->getLocEnd()); 430 } 431 432 static bool classof(const Stmt *T) { 433 return T->getStmtClass() == CXXConditionDeclExprClass; 434 } 435 static bool classof(const CXXConditionDeclExpr *) { return true; } 436 437 // Iterators 438 virtual child_iterator child_begin(); 439 virtual child_iterator child_end(); 440 441 // FIXME: Implement these. 442 //virtual void EmitImpl(llvm::Serializer& S) const; 443 //static CXXConditionDeclExpr * 444 // CreateImpl(llvm::Deserializer& D, ASTContext& C); 445}; 446 447/// CXXNewExpr - A new expression for memory allocation and constructor calls, 448/// e.g: "new CXXNewExpr(foo)". 449class CXXNewExpr : public Expr { 450 // Was the usage ::new, i.e. is the global new to be used? 451 bool GlobalNew : 1; 452 // Was the form (type-id) used? Otherwise, it was new-type-id. 453 bool ParenTypeId : 1; 454 // Is there an initializer? If not, built-ins are uninitialized, else they're 455 // value-initialized. 456 bool Initializer : 1; 457 // Do we allocate an array? If so, the first SubExpr is the size expression. 458 bool Array : 1; 459 // The number of placement new arguments. 460 unsigned NumPlacementArgs : 14; 461 // The number of constructor arguments. This may be 1 even for non-class 462 // types; use the pseudo copy constructor. 463 unsigned NumConstructorArgs : 14; 464 // Contains an optional array size expression, any number of optional 465 // placement arguments, and any number of optional constructor arguments, 466 // in that order. 467 Stmt **SubExprs; 468 // Points to the allocation function used. 469 FunctionDecl *OperatorNew; 470 // Points to the deallocation function used in case of error. May be null. 471 FunctionDecl *OperatorDelete; 472 // Points to the constructor used. Cannot be null if AllocType is a record; 473 // it would still point at the default constructor (even an implicit one). 474 // Must be null for all other types. 475 CXXConstructorDecl *Constructor; 476 477 SourceLocation StartLoc; 478 SourceLocation EndLoc; 479 480 // Deserialization constructor 481 CXXNewExpr(QualType ty, bool globalNew, bool parenTypeId, bool initializer, 482 bool array, unsigned numPlaceArgs, unsigned numConsArgs, 483 Stmt **subExprs, FunctionDecl *operatorNew, 484 FunctionDecl *operatorDelete, CXXConstructorDecl *constructor, 485 SourceLocation startLoc, SourceLocation endLoc) 486 : Expr(CXXNewExprClass, ty), GlobalNew(globalNew), ParenTypeId(parenTypeId), 487 Initializer(initializer), Array(array), NumPlacementArgs(numPlaceArgs), 488 NumConstructorArgs(numConsArgs), SubExprs(subExprs), 489 OperatorNew(operatorNew), OperatorDelete(operatorDelete), 490 Constructor(constructor), StartLoc(startLoc), EndLoc(endLoc) 491 { } 492public: 493 CXXNewExpr(bool globalNew, FunctionDecl *operatorNew, Expr **placementArgs, 494 unsigned numPlaceArgs, bool ParenTypeId, Expr *arraySize, 495 CXXConstructorDecl *constructor, bool initializer, 496 Expr **constructorArgs, unsigned numConsArgs, 497 FunctionDecl *operatorDelete, QualType ty, 498 SourceLocation startLoc, SourceLocation endLoc); 499 ~CXXNewExpr() { 500 delete[] SubExprs; 501 } 502 503 QualType getAllocatedType() const { 504 assert(getType()->isPointerType()); 505 return getType()->getAsPointerType()->getPointeeType(); 506 } 507 508 FunctionDecl *getOperatorNew() const { return OperatorNew; } 509 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 510 CXXConstructorDecl *getConstructor() const { return Constructor; } 511 512 bool isArray() const { return Array; } 513 Expr *getArraySize() { 514 return Array ? cast<Expr>(SubExprs[0]) : 0; 515 } 516 const Expr *getArraySize() const { 517 return Array ? cast<Expr>(SubExprs[0]) : 0; 518 } 519 520 unsigned getNumPlacementArgs() const { return NumPlacementArgs; } 521 Expr *getPlacementArg(unsigned i) { 522 assert(i < NumPlacementArgs && "Index out of range"); 523 return cast<Expr>(SubExprs[Array + i]); 524 } 525 const Expr *getPlacementArg(unsigned i) const { 526 assert(i < NumPlacementArgs && "Index out of range"); 527 return cast<Expr>(SubExprs[Array + i]); 528 } 529 530 bool isGlobalNew() const { return GlobalNew; } 531 bool isParenTypeId() const { return ParenTypeId; } 532 bool hasInitializer() const { return Initializer; } 533 534 unsigned getNumConstructorArgs() const { return NumConstructorArgs; } 535 Expr *getConstructorArg(unsigned i) { 536 assert(i < NumConstructorArgs && "Index out of range"); 537 return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 538 } 539 const Expr *getConstructorArg(unsigned i) const { 540 assert(i < NumConstructorArgs && "Index out of range"); 541 return cast<Expr>(SubExprs[Array + NumPlacementArgs + i]); 542 } 543 544 typedef ExprIterator arg_iterator; 545 typedef ConstExprIterator const_arg_iterator; 546 547 arg_iterator placement_arg_begin() { 548 return SubExprs + Array; 549 } 550 arg_iterator placement_arg_end() { 551 return SubExprs + Array + getNumPlacementArgs(); 552 } 553 const_arg_iterator placement_arg_begin() const { 554 return SubExprs + Array; 555 } 556 const_arg_iterator placement_arg_end() const { 557 return SubExprs + Array + getNumPlacementArgs(); 558 } 559 560 arg_iterator constructor_arg_begin() { 561 return SubExprs + Array + getNumPlacementArgs(); 562 } 563 arg_iterator constructor_arg_end() { 564 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 565 } 566 const_arg_iterator constructor_arg_begin() const { 567 return SubExprs + Array + getNumPlacementArgs(); 568 } 569 const_arg_iterator constructor_arg_end() const { 570 return SubExprs + Array + getNumPlacementArgs() + getNumConstructorArgs(); 571 } 572 573 virtual SourceRange getSourceRange() const { 574 return SourceRange(StartLoc, EndLoc); 575 } 576 577 static bool classof(const Stmt *T) { 578 return T->getStmtClass() == CXXNewExprClass; 579 } 580 static bool classof(const CXXNewExpr *) { return true; } 581 582 // Iterators 583 virtual child_iterator child_begin(); 584 virtual child_iterator child_end(); 585 586 virtual void EmitImpl(llvm::Serializer& S) const; 587 static CXXNewExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); 588}; 589 590/// CXXDeleteExpr - A delete expression for memory deallocation and destructor 591/// calls, e.g. "delete[] pArray". 592class CXXDeleteExpr : public Expr { 593 // Is this a forced global delete, i.e. "::delete"? 594 bool GlobalDelete : 1; 595 // Is this the array form of delete, i.e. "delete[]"? 596 bool ArrayForm : 1; 597 // Points to the operator delete overload that is used. Could be a member. 598 FunctionDecl *OperatorDelete; 599 // The pointer expression to be deleted. 600 Stmt *Argument; 601 // Location of the expression. 602 SourceLocation Loc; 603public: 604 CXXDeleteExpr(QualType ty, bool globalDelete, bool arrayForm, 605 FunctionDecl *operatorDelete, Expr *arg, SourceLocation loc) 606 : Expr(CXXDeleteExprClass, ty), GlobalDelete(globalDelete), 607 ArrayForm(arrayForm), OperatorDelete(operatorDelete), Argument(arg), 608 Loc(loc) { } 609 610 bool isGlobalDelete() const { return GlobalDelete; } 611 bool isArrayForm() const { return ArrayForm; } 612 613 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } 614 615 Expr *getArgument() { return cast<Expr>(Argument); } 616 const Expr *getArgument() const { return cast<Expr>(Argument); } 617 618 virtual SourceRange getSourceRange() const { 619 return SourceRange(Loc, Argument->getLocEnd()); 620 } 621 622 static bool classof(const Stmt *T) { 623 return T->getStmtClass() == CXXDeleteExprClass; 624 } 625 static bool classof(const CXXDeleteExpr *) { return true; } 626 627 // Iterators 628 virtual child_iterator child_begin(); 629 virtual child_iterator child_end(); 630 631 virtual void EmitImpl(llvm::Serializer& S) const; 632 static CXXDeleteExpr * CreateImpl(llvm::Deserializer& D, ASTContext& C); 633}; 634 635} // end namespace clang 636 637#endif 638