Expr.h revision 49b4526992a8c8a6a290aa3efa9828154a24af8d
1//===--- Expr.h - Classes for representing expressions ----------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file was developed by Chris Lattner and is distributed under 6// the University of Illinois Open Source License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines the Expr interface and subclasses. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_AST_EXPR_H 15#define LLVM_CLANG_AST_EXPR_H 16 17#include "clang/AST/Stmt.h" 18#include "clang/AST/Type.h" 19#include "clang/AST/Decl.h" 20#include "llvm/ADT/APSInt.h" 21 22namespace clang { 23 class IdentifierInfo; 24 class Decl; 25 26/// Expr - This represents one expression. Note that Expr's are subclasses of 27/// Stmt. This allows an expression to be transparently used any place a Stmt 28/// is required. 29/// 30class Expr : public Stmt { 31 QualType TR; 32protected: 33 Expr(StmtClass SC, QualType T) : Stmt(SC), TR(T) {} 34 ~Expr() {} 35public: 36 QualType getType() const { return TR; } 37 38 /// SourceLocation tokens are not useful in isolation - they are low level 39 /// value objects created/interpreted by SourceManager. We assume AST 40 /// clients will have a pointer to the respective SourceManager. 41 virtual SourceRange getSourceRange() const = 0; 42 SourceLocation getLocStart() const { return getSourceRange().Begin(); } 43 SourceLocation getLocEnd() const { return getSourceRange().End(); } 44 45 /// getExprLoc - Return the preferred location for the arrow when diagnosing 46 /// a problem with a generic expression. 47 virtual SourceLocation getExprLoc() const { return getLocStart(); } 48 49 /// hasLocalSideEffect - Return true if this immediate expression has side 50 /// effects, not counting any sub-expressions. 51 bool hasLocalSideEffect() const; 52 53 /// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or 54 /// incomplete type other than void. Nonarray expressions that can be lvalues: 55 /// - name, where name must be a variable 56 /// - e[i] 57 /// - (e), where e must be an lvalue 58 /// - e.name, where e must be an lvalue 59 /// - e->name 60 /// - *e, the type of e cannot be a function type 61 /// - string-constant 62 /// 63 enum isLvalueResult { 64 LV_Valid, 65 LV_NotObjectType, 66 LV_IncompleteVoidType, 67 LV_InvalidExpression 68 }; 69 isLvalueResult isLvalue(); 70 71 /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, 72 /// does not have an incomplete type, does not have a const-qualified type, 73 /// and if it is a structure or union, does not have any member (including, 74 /// recursively, any member or element of all contained aggregates or unions) 75 /// with a const-qualified type. 76 enum isModifiableLvalueResult { 77 MLV_Valid, 78 MLV_NotObjectType, 79 MLV_IncompleteVoidType, 80 MLV_InvalidExpression, 81 MLV_IncompleteType, 82 MLV_ConstQualified, 83 MLV_ArrayType 84 }; 85 isModifiableLvalueResult isModifiableLvalue(); 86 87 bool isNullPointerConstant() const; 88 89 /// isIntegerConstantExpr - Return true if this expression is a valid integer 90 /// constant expression, and, if so, return its value in Result. If not a 91 /// valid i-c-e, return false and fill in Loc (if specified) with the location 92 /// of the invalid expression. 93 bool isIntegerConstantExpr(llvm::APSInt &Result, SourceLocation *Loc = 0, 94 bool isEvaluated = true) const; 95 bool isIntegerConstantExpr(SourceLocation *Loc = 0) const { 96 llvm::APSInt X(32); 97 return isIntegerConstantExpr(X, Loc); 98 } 99 100 virtual void visit(StmtVisitor &Visitor); 101 static bool classof(const Stmt *T) { 102 return T->getStmtClass() >= firstExprConstant && 103 T->getStmtClass() <= lastExprConstant; 104 } 105 static bool classof(const Expr *) { return true; } 106}; 107 108//===----------------------------------------------------------------------===// 109// Primary Expressions. 110//===----------------------------------------------------------------------===// 111 112/// DeclRefExpr - [C99 6.5.1p2] - A reference to a declared variable, function, 113/// enum, etc. 114class DeclRefExpr : public Expr { 115 Decl *D; // a ValueDecl or EnumConstantDecl 116 SourceLocation Loc; 117public: 118 DeclRefExpr(Decl *d, QualType t, SourceLocation l) : 119 Expr(DeclRefExprClass, t), D(d), Loc(l) {} 120 121 Decl *getDecl() { return D; } 122 const Decl *getDecl() const { return D; } 123 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 124 125 126 virtual void visit(StmtVisitor &Visitor); 127 static bool classof(const Stmt *T) { 128 return T->getStmtClass() == DeclRefExprClass; 129 } 130 static bool classof(const DeclRefExpr *) { return true; } 131}; 132 133class IntegerLiteral : public Expr { 134 llvm::APInt Value; 135 SourceLocation Loc; 136public: 137 // type should be IntTy, LongTy, LongLongTy, UnsignedIntTy, UnsignedLongTy, 138 // or UnsignedLongLongTy 139 IntegerLiteral(const llvm::APInt &V, QualType type, SourceLocation l) 140 : Expr(IntegerLiteralClass, type), Value(V), Loc(l) { 141 assert(type->isIntegerType() && "Illegal type in IntegerLiteral"); 142 } 143 const llvm::APInt &getValue() const { return Value; } 144 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 145 146 virtual void visit(StmtVisitor &Visitor); 147 static bool classof(const Stmt *T) { 148 return T->getStmtClass() == IntegerLiteralClass; 149 } 150 static bool classof(const IntegerLiteral *) { return true; } 151}; 152 153class CharacterLiteral : public Expr { 154 unsigned Value; 155 SourceLocation Loc; 156public: 157 // type should be IntTy 158 CharacterLiteral(unsigned value, QualType type, SourceLocation l) 159 : Expr(CharacterLiteralClass, type), Value(value), Loc(l) { 160 } 161 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 162 163 unsigned getValue() const { return Value; } 164 165 virtual void visit(StmtVisitor &Visitor); 166 static bool classof(const Stmt *T) { 167 return T->getStmtClass() == CharacterLiteralClass; 168 } 169 static bool classof(const CharacterLiteral *) { return true; } 170}; 171 172class FloatingLiteral : public Expr { 173 float Value; // FIXME 174 SourceLocation Loc; 175public: 176 FloatingLiteral(float value, QualType type, SourceLocation l) 177 : Expr(FloatingLiteralClass, type), Value(value), Loc(l) {} 178 179 float getValue() const { return Value; } 180 181 virtual SourceRange getSourceRange() const { return SourceRange(Loc); } 182 183 virtual void visit(StmtVisitor &Visitor); 184 static bool classof(const Stmt *T) { 185 return T->getStmtClass() == FloatingLiteralClass; 186 } 187 static bool classof(const FloatingLiteral *) { return true; } 188}; 189 190class StringLiteral : public Expr { 191 const char *StrData; 192 unsigned ByteLength; 193 bool IsWide; 194 // if the StringLiteral was composed using token pasting, both locations 195 // are needed. If not (the common case), firstTokLoc == lastTokLoc. 196 // FIXME: if space becomes an issue, we should create a sub-class. 197 SourceLocation firstTokLoc, lastTokLoc; 198public: 199 StringLiteral(const char *strData, unsigned byteLength, bool Wide, 200 QualType t, SourceLocation b, SourceLocation e); 201 virtual ~StringLiteral(); 202 203 const char *getStrData() const { return StrData; } 204 unsigned getByteLength() const { return ByteLength; } 205 bool isWide() const { return IsWide; } 206 207 virtual SourceRange getSourceRange() const { 208 return SourceRange(firstTokLoc,lastTokLoc); 209 } 210 virtual void visit(StmtVisitor &Visitor); 211 static bool classof(const Stmt *T) { 212 return T->getStmtClass() == StringLiteralClass; 213 } 214 static bool classof(const StringLiteral *) { return true; } 215}; 216 217/// ParenExpr - This represents a parethesized expression, e.g. "(1)". This 218/// AST node is only formed if full location information is requested. 219class ParenExpr : public Expr { 220 SourceLocation L, R; 221 Expr *Val; 222public: 223 ParenExpr(SourceLocation l, SourceLocation r, Expr *val) 224 : Expr(ParenExprClass, val->getType()), L(l), R(r), Val(val) {} 225 226 const Expr *getSubExpr() const { return Val; } 227 Expr *getSubExpr() { return Val; } 228 SourceRange getSourceRange() const { return SourceRange(L, R); } 229 230 virtual void visit(StmtVisitor &Visitor); 231 static bool classof(const Stmt *T) { 232 return T->getStmtClass() == ParenExprClass; 233 } 234 static bool classof(const ParenExpr *) { return true; } 235}; 236 237 238/// UnaryOperator - This represents the unary-expression's (except sizeof of 239/// types), the postinc/postdec operators from postfix-expression, and various 240/// extensions. 241class UnaryOperator : public Expr { 242public: 243 enum Opcode { 244 PostInc, PostDec, // [C99 6.5.2.4] Postfix increment and decrement operators 245 PreInc, PreDec, // [C99 6.5.3.1] Prefix increment and decrement operators. 246 AddrOf, Deref, // [C99 6.5.3.2] Address and indirection operators. 247 Plus, Minus, // [C99 6.5.3.3] Unary arithmetic operators. 248 Not, LNot, // [C99 6.5.3.3] Unary arithmetic operators. 249 SizeOf, AlignOf, // [C99 6.5.3.4] Sizeof (expr, not type) operator. 250 Real, Imag, // "__real expr"/"__imag expr" Extension. 251 Extension // __extension__ marker. 252 }; 253private: 254 Expr *Val; 255 Opcode Opc; 256 SourceLocation Loc; 257public: 258 259 UnaryOperator(Expr *input, Opcode opc, QualType type, SourceLocation l) 260 : Expr(UnaryOperatorClass, type), Val(input), Opc(opc), Loc(l) {} 261 262 Opcode getOpcode() const { return Opc; } 263 Expr *getSubExpr() const { return Val; } 264 265 /// getOperatorLoc - Return the location of the operator. 266 SourceLocation getOperatorLoc() const { return Loc; } 267 268 /// isPostfix - Return true if this is a postfix operation, like x++. 269 static bool isPostfix(Opcode Op); 270 271 bool isPostfix() const { return isPostfix(Opc); } 272 bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; } 273 bool isSizeOfAlignOfOp() const { return Opc == SizeOf || Opc == AlignOf; } 274 static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; } 275 276 /// getDecl - a recursive routine that derives the base decl for an 277 /// expression. For example, it will return the declaration for "s" from 278 /// the following complex expression "s.zz[2].bb.vv". 279 static bool isAddressable(Expr *e); 280 281 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it 282 /// corresponds to, e.g. "sizeof" or "[pre]++" 283 static const char *getOpcodeStr(Opcode Op); 284 285 virtual SourceRange getSourceRange() const { 286 if (isPostfix()) 287 return SourceRange(Val->getLocStart(), Loc); 288 else 289 return SourceRange(Loc, Val->getLocEnd()); 290 } 291 virtual SourceLocation getExprLoc() const { return Loc; } 292 293 virtual void visit(StmtVisitor &Visitor); 294 static bool classof(const Stmt *T) { 295 return T->getStmtClass() == UnaryOperatorClass; 296 } 297 static bool classof(const UnaryOperator *) { return true; } 298}; 299 300/// SizeOfAlignOfTypeExpr - [C99 6.5.3.4] - This is only for sizeof/alignof of 301/// *types*. sizeof(expr) is handled by UnaryOperator. 302class SizeOfAlignOfTypeExpr : public Expr { 303 bool isSizeof; // true if sizeof, false if alignof. 304 QualType Ty; 305 SourceLocation OpLoc, RParenLoc; 306public: 307 SizeOfAlignOfTypeExpr(bool issizeof, QualType argType, QualType resultType, 308 SourceLocation op, SourceLocation rp) : 309 Expr(SizeOfAlignOfTypeExprClass, resultType), 310 isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {} 311 312 bool isSizeOf() const { return isSizeof; } 313 QualType getArgumentType() const { return Ty; } 314 SourceRange getSourceRange() const { return SourceRange(OpLoc, RParenLoc); } 315 316 virtual void visit(StmtVisitor &Visitor); 317 static bool classof(const Stmt *T) { 318 return T->getStmtClass() == SizeOfAlignOfTypeExprClass; 319 } 320 static bool classof(const SizeOfAlignOfTypeExpr *) { return true; } 321}; 322 323//===----------------------------------------------------------------------===// 324// Postfix Operators. 325//===----------------------------------------------------------------------===// 326 327/// ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting. 328class ArraySubscriptExpr : public Expr { 329 Expr *Base, *Idx; 330 SourceLocation RBracketLoc; 331public: 332 ArraySubscriptExpr(Expr *base, Expr *idx, QualType t, 333 SourceLocation rbracketloc) : 334 Expr(ArraySubscriptExprClass, t), 335 Base(base), Idx(idx), RBracketLoc(rbracketloc) {} 336 337 Expr *getBase() { return Base; } 338 const Expr *getBase() const { return Base; } 339 Expr *getIdx() { return Idx; } 340 const Expr *getIdx() const { return Idx; } 341 342 SourceRange getSourceRange() const { 343 return SourceRange(Base->getLocStart(), RBracketLoc); 344 } 345 virtual SourceLocation getExprLoc() const { return RBracketLoc; } 346 347 virtual void visit(StmtVisitor &Visitor); 348 static bool classof(const Stmt *T) { 349 return T->getStmtClass() == ArraySubscriptExprClass; 350 } 351 static bool classof(const ArraySubscriptExpr *) { return true; } 352}; 353 354 355/// CallExpr - [C99 6.5.2.2] Function Calls. 356/// 357class CallExpr : public Expr { 358 Expr *Fn; 359 Expr **Args; 360 unsigned NumArgs; 361 SourceLocation RParenLoc; 362public: 363 CallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t, 364 SourceLocation rparenloc); 365 ~CallExpr() { 366 delete [] Args; 367 } 368 369 const Expr *getCallee() const { return Fn; } 370 Expr *getCallee() { return Fn; } 371 372 /// getNumArgs - Return the number of actual arguments to this call. 373 /// 374 unsigned getNumArgs() const { return NumArgs; } 375 376 /// getArg - Return the specified argument. 377 Expr *getArg(unsigned Arg) { 378 assert(Arg < NumArgs && "Arg access out of range!"); 379 return Args[Arg]; 380 } 381 const Expr *getArg(unsigned Arg) const { 382 assert(Arg < NumArgs && "Arg access out of range!"); 383 return Args[Arg]; 384 } 385 386 /// getNumCommas - Return the number of commas that must have been present in 387 /// this function call. 388 unsigned getNumCommas() const { return NumArgs ? NumArgs - 1 : 0; } 389 390 SourceRange getSourceRange() const { 391 return SourceRange(Fn->getLocStart(), RParenLoc); 392 } 393 394 virtual void visit(StmtVisitor &Visitor); 395 static bool classof(const Stmt *T) { 396 return T->getStmtClass() == CallExprClass; 397 } 398 static bool classof(const CallExpr *) { return true; } 399}; 400 401/// MemberExpr - [C99 6.5.2.3] Structure and Union Members. 402/// 403class MemberExpr : public Expr { 404 Expr *Base; 405 FieldDecl *MemberDecl; 406 SourceLocation MemberLoc; 407 bool IsArrow; // True if this is "X->F", false if this is "X.F". 408public: 409 MemberExpr(Expr *base, bool isarrow, FieldDecl *memberdecl, SourceLocation l) 410 : Expr(MemberExprClass, memberdecl->getType()), 411 Base(base), MemberDecl(memberdecl), MemberLoc(l), IsArrow(isarrow) {} 412 413 Expr *getBase() const { return Base; } 414 FieldDecl *getMemberDecl() const { return MemberDecl; } 415 bool isArrow() const { return IsArrow; } 416 417 virtual SourceRange getSourceRange() const { 418 return SourceRange(getBase()->getLocStart(), MemberLoc); 419 } 420 virtual SourceLocation getExprLoc() const { return MemberLoc; } 421 422 virtual void visit(StmtVisitor &Visitor); 423 static bool classof(const Stmt *T) { 424 return T->getStmtClass() == MemberExprClass; 425 } 426 static bool classof(const MemberExpr *) { return true; } 427}; 428 429/// ImplicitCastExpr - Allows us to explicitly represent implicit type 430/// conversions. For example: converting T[]->T*, void f()->void (*f)(), 431/// float->double, short->int, etc. 432/// 433class ImplicitCastExpr : public Expr { 434 QualType Ty; 435 Expr *Op; 436public: 437 ImplicitCastExpr(QualType ty, Expr *op) : 438 Expr(ImplicitCastExprClass, ty), Ty(ty), Op(op) {} 439 440 virtual void visit(StmtVisitor &Visitor); 441 static bool classof(const Stmt *T) { 442 return T->getStmtClass() == ImplicitCastExprClass; 443 } 444 static bool classof(const ImplicitCastExpr *) { return true; } 445}; 446 447/// CastExpr - [C99 6.5.4] Cast Operators. 448/// 449class CastExpr : public Expr { 450 QualType Ty; 451 Expr *Op; 452 SourceLocation Loc; // the location of the left paren 453public: 454 CastExpr(QualType ty, Expr *op, SourceLocation l) : 455 Expr(CastExprClass, ty), Ty(ty), Op(op), Loc(l) {} 456 457 SourceLocation getLParenLoc() const { return Loc; } 458 459 QualType getDestType() const { return Ty; } 460 Expr *getSubExpr() const { return Op; } 461 462 virtual SourceRange getSourceRange() const { 463 return SourceRange(Loc, getSubExpr()->getSourceRange().End()); 464 } 465 virtual void visit(StmtVisitor &Visitor); 466 static bool classof(const Stmt *T) { 467 return T->getStmtClass() == CastExprClass; 468 } 469 static bool classof(const CastExpr *) { return true; } 470}; 471 472 473class BinaryOperator : public Expr { 474public: 475 enum Opcode { 476 // Operators listed in order of precedence. 477 Mul, Div, Rem, // [C99 6.5.5] Multiplicative operators. 478 Add, Sub, // [C99 6.5.6] Additive operators. 479 Shl, Shr, // [C99 6.5.7] Bitwise shift operators. 480 LT, GT, LE, GE, // [C99 6.5.8] Relational operators. 481 EQ, NE, // [C99 6.5.9] Equality operators. 482 And, // [C99 6.5.10] Bitwise AND operator. 483 Xor, // [C99 6.5.11] Bitwise XOR operator. 484 Or, // [C99 6.5.12] Bitwise OR operator. 485 LAnd, // [C99 6.5.13] Logical AND operator. 486 LOr, // [C99 6.5.14] Logical OR operator. 487 Assign, MulAssign,// [C99 6.5.16] Assignment operators. 488 DivAssign, RemAssign, 489 AddAssign, SubAssign, 490 ShlAssign, ShrAssign, 491 AndAssign, XorAssign, 492 OrAssign, 493 Comma // [C99 6.5.17] Comma operator. 494 }; 495 496 BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy) 497 : Expr(BinaryOperatorClass, ResTy), LHS(lhs), RHS(rhs), Opc(opc) { 498 assert(!isCompoundAssignmentOp() && 499 "Use ArithAssignBinaryOperator for compound assignments"); 500 } 501 502 Opcode getOpcode() const { return Opc; } 503 Expr *getLHS() const { return LHS; } 504 Expr *getRHS() const { return RHS; } 505 virtual SourceRange getSourceRange() const { 506 return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd()); 507 } 508 509 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it 510 /// corresponds to, e.g. "<<=". 511 static const char *getOpcodeStr(Opcode Op); 512 513 /// predicates to categorize the respective opcodes. 514 bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; } 515 bool isAdditiveOp() const { return Opc == Add || Opc == Sub; } 516 bool isShiftOp() const { return Opc == Shl || Opc == Shr; } 517 bool isBitwiseOp() const { return Opc >= And && Opc <= Or; } 518 bool isRelationalOp() const { return Opc >= LT && Opc <= GE; } 519 bool isEqualityOp() const { return Opc == EQ || Opc == NE; } 520 bool isLogicalOp() const { return Opc == LAnd || Opc == LOr; } 521 bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; } 522 bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;} 523 bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; } 524 525 virtual void visit(StmtVisitor &Visitor); 526 static bool classof(const Stmt *T) { 527 return T->getStmtClass() == BinaryOperatorClass; 528 } 529 static bool classof(const BinaryOperator *) { return true; } 530private: 531 Expr *LHS, *RHS; 532 Opcode Opc; 533protected: 534 BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, bool dead) 535 : Expr(BinaryOperatorClass, ResTy), LHS(lhs), RHS(rhs), Opc(opc) { 536 } 537}; 538 539/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep 540/// track of the type the operation is performed in. Due to the semantics of 541/// these operators, the operands are promoted, the aritmetic performed, an 542/// implicit conversion back to the result type done, then the assignment takes 543/// place. This captures the intermediate type which the computation is done 544/// in. 545class CompoundAssignOperator : public BinaryOperator { 546 QualType ComputationType; 547public: 548 CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc, 549 QualType ResType, QualType CompType) 550 : BinaryOperator(lhs, rhs, opc, ResType, true), ComputationType(CompType) { 551 assert(isCompoundAssignmentOp() && 552 "Only should be used for compound assignments"); 553 } 554 555 QualType getComputationType() const { return ComputationType; } 556 557 static bool classof(const CompoundAssignOperator *) { return true; } 558 static bool classof(const BinaryOperator *B) { 559 return B->isCompoundAssignmentOp(); 560 } 561 static bool classof(const Stmt *S) { 562 return isa<BinaryOperator>(S) && classof(cast<BinaryOperator>(S)); 563 } 564}; 565 566/// ConditionalOperator - The ?: operator. Note that LHS may be null when the 567/// GNU "missing LHS" extension is in use. 568/// 569class ConditionalOperator : public Expr { 570 Expr *Cond, *LHS, *RHS; // Left/Middle/Right hand sides. 571public: 572 ConditionalOperator(Expr *cond, Expr *lhs, Expr *rhs, QualType t) 573 : Expr(ConditionalOperatorClass, t), Cond(cond), LHS(lhs), RHS(rhs) {} 574 575 Expr *getCond() const { return Cond; } 576 Expr *getLHS() const { return LHS; } 577 Expr *getRHS() const { return RHS; } 578 579 virtual SourceRange getSourceRange() const { 580 return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd()); 581 } 582 virtual void visit(StmtVisitor &Visitor); 583 static bool classof(const Stmt *T) { 584 return T->getStmtClass() == ConditionalOperatorClass; 585 } 586 static bool classof(const ConditionalOperator *) { return true; } 587}; 588 589/// AddrLabel - The GNU address of label extension, representing &&label. 590class AddrLabel : public Expr { 591 SourceLocation AmpAmpLoc, LabelLoc; 592 LabelStmt *Label; 593public: 594 AddrLabel(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L, QualType t) 595 : Expr(AddrLabelClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {} 596 597 virtual SourceRange getSourceRange() const { 598 return SourceRange(AmpAmpLoc, LabelLoc); 599 } 600 601 LabelStmt *getLabel() const { return Label; } 602 603 virtual void visit(StmtVisitor &Visitor); 604 static bool classof(const Stmt *T) { 605 return T->getStmtClass() == AddrLabelClass; 606 } 607 static bool classof(const AddrLabel *) { return true; } 608}; 609 610} // end namespace clang 611 612#endif 613