Expr.h revision d0d560a0975c2f8c4a9559e84ec556b6a0baf7df
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 Expr *Op; 435public: 436 ImplicitCastExpr(QualType ty, Expr *op) : 437 Expr(ImplicitCastExprClass, ty), Op(op) {} 438 439 Expr *getSubExpr() { return Op; } 440 const Expr *getSubExpr() const { return Op; } 441 442 virtual void visit(StmtVisitor &Visitor); 443 static bool classof(const Stmt *T) { 444 return T->getStmtClass() == ImplicitCastExprClass; 445 } 446 static bool classof(const ImplicitCastExpr *) { return true; } 447}; 448 449/// CastExpr - [C99 6.5.4] Cast Operators. 450/// 451class CastExpr : public Expr { 452 QualType Ty; 453 Expr *Op; 454 SourceLocation Loc; // the location of the left paren 455public: 456 CastExpr(QualType ty, Expr *op, SourceLocation l) : 457 Expr(CastExprClass, ty), Ty(ty), Op(op), Loc(l) {} 458 459 SourceLocation getLParenLoc() const { return Loc; } 460 461 QualType getDestType() const { return Ty; } 462 Expr *getSubExpr() const { return Op; } 463 464 virtual SourceRange getSourceRange() const { 465 return SourceRange(Loc, getSubExpr()->getSourceRange().End()); 466 } 467 virtual void visit(StmtVisitor &Visitor); 468 static bool classof(const Stmt *T) { 469 return T->getStmtClass() == CastExprClass; 470 } 471 static bool classof(const CastExpr *) { return true; } 472}; 473 474 475class BinaryOperator : public Expr { 476public: 477 enum Opcode { 478 // Operators listed in order of precedence. 479 Mul, Div, Rem, // [C99 6.5.5] Multiplicative operators. 480 Add, Sub, // [C99 6.5.6] Additive operators. 481 Shl, Shr, // [C99 6.5.7] Bitwise shift operators. 482 LT, GT, LE, GE, // [C99 6.5.8] Relational operators. 483 EQ, NE, // [C99 6.5.9] Equality operators. 484 And, // [C99 6.5.10] Bitwise AND operator. 485 Xor, // [C99 6.5.11] Bitwise XOR operator. 486 Or, // [C99 6.5.12] Bitwise OR operator. 487 LAnd, // [C99 6.5.13] Logical AND operator. 488 LOr, // [C99 6.5.14] Logical OR operator. 489 Assign, MulAssign,// [C99 6.5.16] Assignment operators. 490 DivAssign, RemAssign, 491 AddAssign, SubAssign, 492 ShlAssign, ShrAssign, 493 AndAssign, XorAssign, 494 OrAssign, 495 Comma // [C99 6.5.17] Comma operator. 496 }; 497 498 BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy) 499 : Expr(BinaryOperatorClass, ResTy), LHS(lhs), RHS(rhs), Opc(opc) { 500 assert(!isCompoundAssignmentOp() && 501 "Use ArithAssignBinaryOperator for compound assignments"); 502 } 503 504 Opcode getOpcode() const { return Opc; } 505 Expr *getLHS() const { return LHS; } 506 Expr *getRHS() const { return RHS; } 507 virtual SourceRange getSourceRange() const { 508 return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd()); 509 } 510 511 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it 512 /// corresponds to, e.g. "<<=". 513 static const char *getOpcodeStr(Opcode Op); 514 515 /// predicates to categorize the respective opcodes. 516 bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; } 517 bool isAdditiveOp() const { return Opc == Add || Opc == Sub; } 518 bool isShiftOp() const { return Opc == Shl || Opc == Shr; } 519 bool isBitwiseOp() const { return Opc >= And && Opc <= Or; } 520 bool isRelationalOp() const { return Opc >= LT && Opc <= GE; } 521 bool isEqualityOp() const { return Opc == EQ || Opc == NE; } 522 bool isLogicalOp() const { return Opc == LAnd || Opc == LOr; } 523 bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; } 524 bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;} 525 bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; } 526 527 virtual void visit(StmtVisitor &Visitor); 528 static bool classof(const Stmt *T) { 529 return T->getStmtClass() == BinaryOperatorClass; 530 } 531 static bool classof(const BinaryOperator *) { return true; } 532private: 533 Expr *LHS, *RHS; 534 Opcode Opc; 535protected: 536 BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, bool dead) 537 : Expr(BinaryOperatorClass, ResTy), LHS(lhs), RHS(rhs), Opc(opc) { 538 } 539}; 540 541/// CompoundAssignOperator - For compound assignments (e.g. +=), we keep 542/// track of the type the operation is performed in. Due to the semantics of 543/// these operators, the operands are promoted, the aritmetic performed, an 544/// implicit conversion back to the result type done, then the assignment takes 545/// place. This captures the intermediate type which the computation is done 546/// in. 547class CompoundAssignOperator : public BinaryOperator { 548 QualType ComputationType; 549public: 550 CompoundAssignOperator(Expr *lhs, Expr *rhs, Opcode opc, 551 QualType ResType, QualType CompType) 552 : BinaryOperator(lhs, rhs, opc, ResType, true), ComputationType(CompType) { 553 assert(isCompoundAssignmentOp() && 554 "Only should be used for compound assignments"); 555 } 556 557 QualType getComputationType() const { return ComputationType; } 558 559 static bool classof(const CompoundAssignOperator *) { return true; } 560 static bool classof(const BinaryOperator *B) { 561 return B->isCompoundAssignmentOp(); 562 } 563 static bool classof(const Stmt *S) { 564 return isa<BinaryOperator>(S) && classof(cast<BinaryOperator>(S)); 565 } 566}; 567 568/// ConditionalOperator - The ?: operator. Note that LHS may be null when the 569/// GNU "missing LHS" extension is in use. 570/// 571class ConditionalOperator : public Expr { 572 Expr *Cond, *LHS, *RHS; // Left/Middle/Right hand sides. 573public: 574 ConditionalOperator(Expr *cond, Expr *lhs, Expr *rhs, QualType t) 575 : Expr(ConditionalOperatorClass, t), Cond(cond), LHS(lhs), RHS(rhs) {} 576 577 Expr *getCond() const { return Cond; } 578 Expr *getLHS() const { return LHS; } 579 Expr *getRHS() const { return RHS; } 580 581 virtual SourceRange getSourceRange() const { 582 return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd()); 583 } 584 virtual void visit(StmtVisitor &Visitor); 585 static bool classof(const Stmt *T) { 586 return T->getStmtClass() == ConditionalOperatorClass; 587 } 588 static bool classof(const ConditionalOperator *) { return true; } 589}; 590 591/// AddrLabel - The GNU address of label extension, representing &&label. 592class AddrLabel : public Expr { 593 SourceLocation AmpAmpLoc, LabelLoc; 594 LabelStmt *Label; 595public: 596 AddrLabel(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L, QualType t) 597 : Expr(AddrLabelClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {} 598 599 virtual SourceRange getSourceRange() const { 600 return SourceRange(AmpAmpLoc, LabelLoc); 601 } 602 603 LabelStmt *getLabel() const { return Label; } 604 605 virtual void visit(StmtVisitor &Visitor); 606 static bool classof(const Stmt *T) { 607 return T->getStmtClass() == AddrLabelClass; 608 } 609 static bool classof(const AddrLabel *) { return true; } 610}; 611 612} // end namespace clang 613 614#endif 615