1 //===--- Expr.cpp - Expression AST Node Implementation --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Expr class and subclasses.
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/Expr.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/StmtVisitor.h"
17 #include "clang/Basic/IdentifierTable.h"
18 #include "clang/Basic/TargetInfo.h"
19 using namespace clang;
21 //===----------------------------------------------------------------------===//
22 // Primary Expressions.
23 //===----------------------------------------------------------------------===//
25 StringLiteral::StringLiteral(const char *strData, unsigned byteLength,
26 bool Wide, QualType t, SourceLocation firstLoc,
27 SourceLocation lastLoc) :
28 Expr(StringLiteralClass, t) {
29 // OPTIMIZE: could allocate this appended to the StringLiteral.
30 char *AStrData = new char[byteLength];
31 memcpy(AStrData, strData, byteLength);
33 ByteLength = byteLength;
35 firstTokLoc = firstLoc;
39 StringLiteral::~StringLiteral() {
43 bool UnaryOperator::isPostfix(Opcode Op) {
53 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
54 /// corresponds to, e.g. "sizeof" or "[pre]++".
55 const char *UnaryOperator::getOpcodeStr(Opcode Op) {
57 default: assert(0 && "Unknown unary operator");
58 case PostInc: return "++";
59 case PostDec: return "--";
60 case PreInc: return "++";
61 case PreDec: return "--";
62 case AddrOf: return "&";
63 case Deref: return "*";
64 case Plus: return "+";
65 case Minus: return "-";
67 case LNot: return "!";
68 case Real: return "__real";
69 case Imag: return "__imag";
70 case SizeOf: return "sizeof";
71 case AlignOf: return "alignof";
72 case Extension: return "__extension__";
73 case OffsetOf: return "__builtin_offsetof";
77 //===----------------------------------------------------------------------===//
79 //===----------------------------------------------------------------------===//
82 CallExpr::CallExpr(Expr *fn, Expr **args, unsigned numargs, QualType t,
83 SourceLocation rparenloc)
84 : Expr(CallExprClass, t), NumArgs(numargs) {
85 SubExprs = new Expr*[numargs+1];
87 for (unsigned i = 0; i != numargs; ++i)
88 SubExprs[i+ARGS_START] = args[i];
89 RParenLoc = rparenloc;
92 /// setNumArgs - This changes the number of arguments present in this call.
93 /// Any orphaned expressions are deleted by this, and any new operands are set
95 void CallExpr::setNumArgs(unsigned NumArgs) {
96 // No change, just return.
97 if (NumArgs == getNumArgs()) return;
99 // If shrinking # arguments, just delete the extras and forgot them.
100 if (NumArgs < getNumArgs()) {
101 for (unsigned i = NumArgs, e = getNumArgs(); i != e; ++i)
103 this->NumArgs = NumArgs;
107 // Otherwise, we are growing the # arguments. New an bigger argument array.
108 Expr **NewSubExprs = new Expr*[NumArgs+1];
110 for (unsigned i = 0; i != getNumArgs()+ARGS_START; ++i)
111 NewSubExprs[i] = SubExprs[i];
112 // Null out new args.
113 for (unsigned i = getNumArgs()+ARGS_START; i != NumArgs+ARGS_START; ++i)
117 SubExprs = NewSubExprs;
118 this->NumArgs = NumArgs;
121 bool CallExpr::isBuiltinConstantExpr() const {
122 // All simple function calls (e.g. func()) are implicitly cast to pointer to
123 // function. As a result, we try and obtain the DeclRefExpr from the
125 const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(getCallee());
126 if (!ICE) // FIXME: deal with more complex calls (e.g. (func)(), (*func)()).
129 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr());
133 const FunctionDecl *FDecl = dyn_cast<FunctionDecl>(DRE->getDecl());
137 unsigned builtinID = FDecl->getIdentifier()->getBuiltinID();
141 // We have a builtin that is a constant expression
142 if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
147 bool CallExpr::isBuiltinClassifyType(llvm::APSInt &Result) const {
148 // The following enum mimics gcc's internal "typeclass.h" file.
149 enum gcc_type_class {
151 void_type_class, integer_type_class, char_type_class,
152 enumeral_type_class, boolean_type_class,
153 pointer_type_class, reference_type_class, offset_type_class,
154 real_type_class, complex_type_class,
155 function_type_class, method_type_class,
156 record_type_class, union_type_class,
157 array_type_class, string_type_class,
160 Result.setIsSigned(true);
162 // All simple function calls (e.g. func()) are implicitly cast to pointer to
163 // function. As a result, we try and obtain the DeclRefExpr from the
165 const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(getCallee());
166 if (!ICE) // FIXME: deal with more complex calls (e.g. (func)(), (*func)()).
168 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr());
172 // We have a DeclRefExpr.
173 if (strcmp(DRE->getDecl()->getName(), "__builtin_classify_type") == 0) {
174 // If no argument was supplied, default to "no_type_class". This isn't
175 // ideal, however it's what gcc does.
176 Result = static_cast<uint64_t>(no_type_class);
178 QualType argType = getArg(0)->getType();
180 if (argType->isVoidType())
181 Result = void_type_class;
182 else if (argType->isEnumeralType())
183 Result = enumeral_type_class;
184 else if (argType->isBooleanType())
185 Result = boolean_type_class;
186 else if (argType->isCharType())
187 Result = string_type_class; // gcc doesn't appear to use char_type_class
188 else if (argType->isIntegerType())
189 Result = integer_type_class;
190 else if (argType->isPointerType())
191 Result = pointer_type_class;
192 else if (argType->isReferenceType())
193 Result = reference_type_class;
194 else if (argType->isRealType())
195 Result = real_type_class;
196 else if (argType->isComplexType())
197 Result = complex_type_class;
198 else if (argType->isFunctionType())
199 Result = function_type_class;
200 else if (argType->isStructureType())
201 Result = record_type_class;
202 else if (argType->isUnionType())
203 Result = union_type_class;
204 else if (argType->isArrayType())
205 Result = array_type_class;
206 else if (argType->isUnionType())
207 Result = union_type_class;
208 else // FIXME: offset_type_class, method_type_class, & lang_type_class?
209 assert(0 && "CallExpr::isBuiltinClassifyType(): unimplemented type");
216 /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
217 /// corresponds to, e.g. "<<=".
218 const char *BinaryOperator::getOpcodeStr(Opcode Op) {
220 default: assert(0 && "Unknown binary operator");
221 case Mul: return "*";
222 case Div: return "/";
223 case Rem: return "%";
224 case Add: return "+";
225 case Sub: return "-";
226 case Shl: return "<<";
227 case Shr: return ">>";
230 case LE: return "<=";
231 case GE: return ">=";
232 case EQ: return "==";
233 case NE: return "!=";
234 case And: return "&";
235 case Xor: return "^";
237 case LAnd: return "&&";
238 case LOr: return "||";
239 case Assign: return "=";
240 case MulAssign: return "*=";
241 case DivAssign: return "/=";
242 case RemAssign: return "%=";
243 case AddAssign: return "+=";
244 case SubAssign: return "-=";
245 case ShlAssign: return "<<=";
246 case ShrAssign: return ">>=";
247 case AndAssign: return "&=";
248 case XorAssign: return "^=";
249 case OrAssign: return "|=";
250 case Comma: return ",";
254 InitListExpr::InitListExpr(SourceLocation lbraceloc,
255 Expr **initexprs, unsigned numinits,
256 SourceLocation rbraceloc)
257 : Expr(InitListExprClass, QualType())
259 , LBraceLoc(lbraceloc)
260 , RBraceLoc(rbraceloc)
262 InitExprs = new Expr*[numinits];
263 for (unsigned i = 0; i != numinits; i++)
264 InitExprs[i] = initexprs[i];
267 //===----------------------------------------------------------------------===//
268 // Generic Expression Routines
269 //===----------------------------------------------------------------------===//
271 /// hasLocalSideEffect - Return true if this immediate expression has side
272 /// effects, not counting any sub-expressions.
273 bool Expr::hasLocalSideEffect() const {
274 switch (getStmtClass()) {
278 return cast<ParenExpr>(this)->getSubExpr()->hasLocalSideEffect();
279 case UnaryOperatorClass: {
280 const UnaryOperator *UO = cast<UnaryOperator>(this);
282 switch (UO->getOpcode()) {
283 default: return false;
284 case UnaryOperator::PostInc:
285 case UnaryOperator::PostDec:
286 case UnaryOperator::PreInc:
287 case UnaryOperator::PreDec:
288 return true; // ++/--
290 case UnaryOperator::Deref:
291 // Dereferencing a volatile pointer is a side-effect.
292 return getType().isVolatileQualified();
293 case UnaryOperator::Real:
294 case UnaryOperator::Imag:
295 // accessing a piece of a volatile complex is a side-effect.
296 return UO->getSubExpr()->getType().isVolatileQualified();
298 case UnaryOperator::Extension:
299 return UO->getSubExpr()->hasLocalSideEffect();
302 case BinaryOperatorClass: {
303 const BinaryOperator *BinOp = cast<BinaryOperator>(this);
304 // Consider comma to have side effects if the LHS and RHS both do.
305 if (BinOp->getOpcode() == BinaryOperator::Comma)
306 return BinOp->getLHS()->hasLocalSideEffect() &&
307 BinOp->getRHS()->hasLocalSideEffect();
309 return BinOp->isAssignmentOp();
311 case CompoundAssignOperatorClass:
314 case ConditionalOperatorClass: {
315 const ConditionalOperator *Exp = cast<ConditionalOperator>(this);
316 return Exp->getCond()->hasLocalSideEffect()
317 || (Exp->getLHS() && Exp->getLHS()->hasLocalSideEffect())
318 || (Exp->getRHS() && Exp->getRHS()->hasLocalSideEffect());
321 case MemberExprClass:
322 case ArraySubscriptExprClass:
323 // If the base pointer or element is to a volatile pointer/field, accessing
324 // if is a side effect.
325 return getType().isVolatileQualified();
328 // TODO: check attributes for pure/const. "void foo() { strlen("bar"); }"
331 case ObjCMessageExprClass:
335 // If this is a cast to void, check the operand. Otherwise, the result of
336 // the cast is unused.
337 if (getType()->isVoidType())
338 return cast<CastExpr>(this)->getSubExpr()->hasLocalSideEffect();
343 /// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or an
344 /// incomplete type other than void. Nonarray expressions that can be lvalues:
345 /// - name, where name must be a variable
347 /// - (e), where e must be an lvalue
348 /// - e.name, where e must be an lvalue
350 /// - *e, the type of e cannot be a function type
351 /// - string-constant
352 /// - (__real__ e) and (__imag__ e) where e is an lvalue [GNU extension]
353 /// - reference type [C++ [expr]]
355 Expr::isLvalueResult Expr::isLvalue() const {
356 // first, check the type (C99 6.3.2.1)
357 if (TR->isFunctionType()) // from isObjectType()
358 return LV_NotObjectType;
360 // Allow qualified void which is an incomplete type other than void (yuck).
361 if (TR->isVoidType() && !TR.getCanonicalType().getCVRQualifiers())
362 return LV_IncompleteVoidType;
364 if (TR->isReferenceType()) // C++ [expr]
367 // the type looks fine, now check the expression
368 switch (getStmtClass()) {
369 case StringLiteralClass: // C99 6.5.1p4
371 case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
372 // For vectors, make sure base is an lvalue (i.e. not a function call).
373 if (cast<ArraySubscriptExpr>(this)->getBase()->getType()->isVectorType())
374 return cast<ArraySubscriptExpr>(this)->getBase()->isLvalue();
376 case DeclRefExprClass: // C99 6.5.1p2
377 if (isa<VarDecl>(cast<DeclRefExpr>(this)->getDecl()))
380 case MemberExprClass: { // C99 6.5.2.3p4
381 const MemberExpr *m = cast<MemberExpr>(this);
382 return m->isArrow() ? LV_Valid : m->getBase()->isLvalue();
384 case UnaryOperatorClass:
385 if (cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Deref)
386 return LV_Valid; // C99 6.5.3p4
388 if (cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Real ||
389 cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Imag)
390 return cast<UnaryOperator>(this)->getSubExpr()->isLvalue(); // GNU.
392 case ParenExprClass: // C99 6.5.1p5
393 return cast<ParenExpr>(this)->getSubExpr()->isLvalue();
394 case CompoundLiteralExprClass: // C99 6.5.2.5p5
396 case OCUVectorElementExprClass:
397 if (cast<OCUVectorElementExpr>(this)->containsDuplicateElements())
398 return LV_DuplicateVectorComponents;
400 case ObjCIvarRefExprClass: // ObjC instance variables are lvalues.
402 case PreDefinedExprClass:
407 return LV_InvalidExpression;
410 /// isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type,
411 /// does not have an incomplete type, does not have a const-qualified type, and
412 /// if it is a structure or union, does not have any member (including,
413 /// recursively, any member or element of all contained aggregates or unions)
414 /// with a const-qualified type.
415 Expr::isModifiableLvalueResult Expr::isModifiableLvalue() const {
416 isLvalueResult lvalResult = isLvalue();
418 switch (lvalResult) {
419 case LV_Valid: break;
420 case LV_NotObjectType: return MLV_NotObjectType;
421 case LV_IncompleteVoidType: return MLV_IncompleteVoidType;
422 case LV_DuplicateVectorComponents: return MLV_DuplicateVectorComponents;
423 case LV_InvalidExpression: return MLV_InvalidExpression;
425 if (TR.isConstQualified())
426 return MLV_ConstQualified;
427 if (TR->isArrayType())
428 return MLV_ArrayType;
429 if (TR->isIncompleteType())
430 return MLV_IncompleteType;
432 if (const RecordType *r = dyn_cast<RecordType>(TR.getCanonicalType())) {
433 if (r->hasConstFields())
434 return MLV_ConstQualified;
439 /// hasStaticStorage - Return true if this expression has static storage
440 /// duration. This means that the address of this expression is a link-time
442 bool Expr::hasStaticStorage() const {
443 switch (getStmtClass()) {
447 return cast<ParenExpr>(this)->getSubExpr()->hasStaticStorage();
448 case ImplicitCastExprClass:
449 return cast<ImplicitCastExpr>(this)->getSubExpr()->hasStaticStorage();
450 case CompoundLiteralExprClass:
451 return cast<CompoundLiteralExpr>(this)->isFileScope();
452 case DeclRefExprClass: {
453 const Decl *D = cast<DeclRefExpr>(this)->getDecl();
454 if (const VarDecl *VD = dyn_cast<VarDecl>(D))
455 return VD->hasStaticStorage();
458 case MemberExprClass: {
459 const MemberExpr *M = cast<MemberExpr>(this);
460 return !M->isArrow() && M->getBase()->hasStaticStorage();
462 case ArraySubscriptExprClass:
463 return cast<ArraySubscriptExpr>(this)->getBase()->hasStaticStorage();
464 case PreDefinedExprClass:
469 Expr* Expr::IgnoreParens() {
471 while (ParenExpr* P = dyn_cast<ParenExpr>(E))
477 /// IgnoreParenCasts - Ignore parentheses and casts. Strip off any ParenExpr
478 /// or CastExprs or ImplicitCastExprs, returning their operand.
479 Expr *Expr::IgnoreParenCasts() {
482 if (ParenExpr *P = dyn_cast<ParenExpr>(E))
484 else if (CastExpr *P = dyn_cast<CastExpr>(E))
486 else if (ImplicitCastExpr *P = dyn_cast<ImplicitCastExpr>(E))
494 bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
495 switch (getStmtClass()) {
497 if (Loc) *Loc = getLocStart();
500 return cast<ParenExpr>(this)->getSubExpr()->isConstantExpr(Ctx, Loc);
501 case StringLiteralClass:
502 case ObjCStringLiteralClass:
503 case FloatingLiteralClass:
504 case IntegerLiteralClass:
505 case CharacterLiteralClass:
506 case ImaginaryLiteralClass:
507 case TypesCompatibleExprClass:
508 case CXXBoolLiteralExprClass:
510 case CallExprClass: {
511 const CallExpr *CE = cast<CallExpr>(this);
512 llvm::APSInt Result(32);
514 static_cast<uint32_t>(Ctx.getTypeSize(getType(), CE->getLocStart())));
515 if (CE->isBuiltinClassifyType(Result))
517 if (CE->isBuiltinConstantExpr())
519 if (Loc) *Loc = getLocStart();
522 case DeclRefExprClass: {
523 const Decl *D = cast<DeclRefExpr>(this)->getDecl();
524 // Accept address of function.
525 if (isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D))
527 if (Loc) *Loc = getLocStart();
529 return TR->isArrayType();
532 case CompoundLiteralExprClass:
533 if (Loc) *Loc = getLocStart();
534 // Allow "(int []){2,4}", since the array will be converted to a pointer.
535 // Allow "(vector type){2,4}" since the elements are all constant.
536 return TR->isArrayType() || TR->isVectorType();
537 case UnaryOperatorClass: {
538 const UnaryOperator *Exp = cast<UnaryOperator>(this);
541 if (Exp->getOpcode() == UnaryOperator::AddrOf) {
542 if (!Exp->getSubExpr()->hasStaticStorage()) {
543 if (Loc) *Loc = getLocStart();
549 // Get the operand value. If this is sizeof/alignof, do not evalute the
550 // operand. This affects C99 6.6p3.
551 if (!Exp->isSizeOfAlignOfOp() &&
552 Exp->getOpcode() != UnaryOperator::OffsetOf &&
553 !Exp->getSubExpr()->isConstantExpr(Ctx, Loc))
556 switch (Exp->getOpcode()) {
557 // Address, indirect, pre/post inc/dec, etc are not valid constant exprs.
560 if (Loc) *Loc = Exp->getOperatorLoc();
562 case UnaryOperator::Extension:
563 return true; // FIXME: this is wrong.
564 case UnaryOperator::SizeOf:
565 case UnaryOperator::AlignOf:
566 case UnaryOperator::OffsetOf:
567 // sizeof(vla) is not a constantexpr: C99 6.5.3.4p2.
568 if (!Exp->getSubExpr()->getType()->isConstantSizeType()) {
569 if (Loc) *Loc = Exp->getOperatorLoc();
573 case UnaryOperator::LNot:
574 case UnaryOperator::Plus:
575 case UnaryOperator::Minus:
576 case UnaryOperator::Not:
580 case SizeOfAlignOfTypeExprClass: {
581 const SizeOfAlignOfTypeExpr *Exp = cast<SizeOfAlignOfTypeExpr>(this);
582 // alignof always evaluates to a constant.
583 if (Exp->isSizeOf() && !Exp->getArgumentType()->isVoidType() &&
584 !Exp->getArgumentType()->isConstantSizeType()) {
585 if (Loc) *Loc = Exp->getOperatorLoc();
590 case BinaryOperatorClass: {
591 const BinaryOperator *Exp = cast<BinaryOperator>(this);
593 // The LHS of a constant expr is always evaluated and needed.
594 if (!Exp->getLHS()->isConstantExpr(Ctx, Loc))
597 if (!Exp->getRHS()->isConstantExpr(Ctx, Loc))
601 case ImplicitCastExprClass:
602 case CastExprClass: {
604 SourceLocation CastLoc;
605 if (const CastExpr *C = dyn_cast<CastExpr>(this)) {
606 SubExpr = C->getSubExpr();
607 CastLoc = C->getLParenLoc();
609 SubExpr = cast<ImplicitCastExpr>(this)->getSubExpr();
610 CastLoc = getLocStart();
612 if (!SubExpr->isConstantExpr(Ctx, Loc)) {
613 if (Loc) *Loc = SubExpr->getLocStart();
618 case ConditionalOperatorClass: {
619 const ConditionalOperator *Exp = cast<ConditionalOperator>(this);
620 if (!Exp->getCond()->isConstantExpr(Ctx, Loc) ||
621 // Handle the GNU extension for missing LHS.
622 !(Exp->getLHS() && Exp->getLHS()->isConstantExpr(Ctx, Loc)) ||
623 !Exp->getRHS()->isConstantExpr(Ctx, Loc))
627 case InitListExprClass: {
628 const InitListExpr *Exp = cast<InitListExpr>(this);
629 unsigned numInits = Exp->getNumInits();
630 for (unsigned i = 0; i < numInits; i++) {
631 if (!Exp->getInit(i)->isConstantExpr(Ctx, Loc)) {
632 if (Loc) *Loc = Exp->getInit(i)->getLocStart();
641 /// isIntegerConstantExpr - this recursive routine will test if an expression is
642 /// an integer constant expression. Note: With the introduction of VLA's in
643 /// C99 the result of the sizeof operator is no longer always a constant
644 /// expression. The generalization of the wording to include any subexpression
645 /// that is not evaluated (C99 6.6p3) means that nonconstant subexpressions
646 /// can appear as operands to other operators (e.g. &&, ||, ?:). For instance,
647 /// "0 || f()" can be treated as a constant expression. In C90 this expression,
648 /// occurring in a context requiring a constant, would have been a constraint
649 /// violation. FIXME: This routine currently implements C90 semantics.
650 /// To properly implement C99 semantics this routine will need to evaluate
651 /// expressions involving operators previously mentioned.
653 /// FIXME: Pass up a reason why! Invalid operation in i-c-e, division by zero,
656 /// FIXME: This should ext-warn on overflow during evaluation! ISO C does not
657 /// permit this. This includes things like (int)1e1000
659 /// FIXME: Handle offsetof. Two things to do: Handle GCC's __builtin_offsetof
660 /// to support gcc 4.0+ and handle the idiom GCC recognizes with a null pointer
661 /// cast+dereference.
662 bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
663 SourceLocation *Loc, bool isEvaluated) const {
664 switch (getStmtClass()) {
666 if (Loc) *Loc = getLocStart();
669 return cast<ParenExpr>(this)->getSubExpr()->
670 isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated);
671 case IntegerLiteralClass:
672 Result = cast<IntegerLiteral>(this)->getValue();
674 case CharacterLiteralClass: {
675 const CharacterLiteral *CL = cast<CharacterLiteral>(this);
677 static_cast<uint32_t>(Ctx.getTypeSize(getType(), CL->getLoc())));
678 Result = CL->getValue();
679 Result.setIsUnsigned(!getType()->isSignedIntegerType());
682 case TypesCompatibleExprClass: {
683 const TypesCompatibleExpr *TCE = cast<TypesCompatibleExpr>(this);
685 static_cast<uint32_t>(Ctx.getTypeSize(getType(), TCE->getLocStart())));
686 Result = Ctx.typesAreCompatible(TCE->getArgType1(), TCE->getArgType2());
689 case CallExprClass: {
690 const CallExpr *CE = cast<CallExpr>(this);
692 static_cast<uint32_t>(Ctx.getTypeSize(getType(), CE->getLocStart())));
693 if (CE->isBuiltinClassifyType(Result))
695 if (Loc) *Loc = getLocStart();
698 case DeclRefExprClass:
699 if (const EnumConstantDecl *D =
700 dyn_cast<EnumConstantDecl>(cast<DeclRefExpr>(this)->getDecl())) {
701 Result = D->getInitVal();
704 if (Loc) *Loc = getLocStart();
706 case UnaryOperatorClass: {
707 const UnaryOperator *Exp = cast<UnaryOperator>(this);
709 // Get the operand value. If this is sizeof/alignof, do not evalute the
710 // operand. This affects C99 6.6p3.
711 if (!Exp->isSizeOfAlignOfOp() && !Exp->isOffsetOfOp() &&
712 !Exp->getSubExpr()->isIntegerConstantExpr(Result, Ctx, Loc,isEvaluated))
715 switch (Exp->getOpcode()) {
716 // Address, indirect, pre/post inc/dec, etc are not valid constant exprs.
719 if (Loc) *Loc = Exp->getOperatorLoc();
721 case UnaryOperator::Extension:
722 return true; // FIXME: this is wrong.
723 case UnaryOperator::SizeOf:
724 case UnaryOperator::AlignOf:
725 // Return the result in the right width.
727 static_cast<uint32_t>(Ctx.getTypeSize(getType(),
728 Exp->getOperatorLoc())));
730 // sizeof(void) and __alignof__(void) = 1 as a gcc extension.
731 if (Exp->getSubExpr()->getType()->isVoidType()) {
736 // sizeof(vla) is not a constantexpr: C99 6.5.3.4p2.
737 if (!Exp->getSubExpr()->getType()->isConstantSizeType()) {
738 if (Loc) *Loc = Exp->getOperatorLoc();
742 // Get information about the size or align.
743 if (Exp->getSubExpr()->getType()->isFunctionType()) {
744 // GCC extension: sizeof(function) = 1.
745 Result = Exp->getOpcode() == UnaryOperator::AlignOf ? 4 : 1;
748 Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc()));
750 if (Exp->getOpcode() == UnaryOperator::AlignOf)
751 Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(),
752 Exp->getOperatorLoc()) / CharSize;
754 Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(),
755 Exp->getOperatorLoc()) / CharSize;
758 case UnaryOperator::LNot: {
759 bool Val = Result == 0;
761 static_cast<uint32_t>(Ctx.getTypeSize(getType(),
762 Exp->getOperatorLoc())));
766 case UnaryOperator::Plus:
768 case UnaryOperator::Minus:
771 case UnaryOperator::Not:
774 case UnaryOperator::OffsetOf:
775 Result = Exp->evaluateOffsetOf(Ctx);
779 case SizeOfAlignOfTypeExprClass: {
780 const SizeOfAlignOfTypeExpr *Exp = cast<SizeOfAlignOfTypeExpr>(this);
782 // Return the result in the right width.
784 static_cast<uint32_t>(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())));
786 // sizeof(void) and __alignof__(void) = 1 as a gcc extension.
787 if (Exp->getArgumentType()->isVoidType()) {
792 // alignof always evaluates to a constant, sizeof does if arg is not VLA.
793 if (Exp->isSizeOf() && !Exp->getArgumentType()->isConstantSizeType()) {
794 if (Loc) *Loc = Exp->getOperatorLoc();
798 // Get information about the size or align.
799 if (Exp->getArgumentType()->isFunctionType()) {
800 // GCC extension: sizeof(function) = 1.
801 Result = Exp->isSizeOf() ? 1 : 4;
804 Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc()));
807 Result = Ctx.getTypeSize(Exp->getArgumentType(),
808 Exp->getOperatorLoc()) / CharSize;
810 Result = Ctx.getTypeAlign(Exp->getArgumentType(),
811 Exp->getOperatorLoc()) / CharSize;
816 case BinaryOperatorClass: {
817 const BinaryOperator *Exp = cast<BinaryOperator>(this);
819 // The LHS of a constant expr is always evaluated and needed.
820 if (!Exp->getLHS()->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated))
823 llvm::APSInt RHS(Result);
825 // The short-circuiting &&/|| operators don't necessarily evaluate their
826 // RHS. Make sure to pass isEvaluated down correctly.
827 if (Exp->isLogicalOp()) {
829 if (Exp->getOpcode() == BinaryOperator::LAnd)
830 RHSEval = Result != 0;
832 assert(Exp->getOpcode() == BinaryOperator::LOr &&"Unexpected logical");
833 RHSEval = Result == 0;
836 if (!Exp->getRHS()->isIntegerConstantExpr(RHS, Ctx, Loc,
837 isEvaluated & RHSEval))
840 if (!Exp->getRHS()->isIntegerConstantExpr(RHS, Ctx, Loc, isEvaluated))
844 switch (Exp->getOpcode()) {
846 if (Loc) *Loc = getLocStart();
848 case BinaryOperator::Mul:
851 case BinaryOperator::Div:
853 if (!isEvaluated) break;
854 if (Loc) *Loc = getLocStart();
859 case BinaryOperator::Rem:
861 if (!isEvaluated) break;
862 if (Loc) *Loc = getLocStart();
867 case BinaryOperator::Add: Result += RHS; break;
868 case BinaryOperator::Sub: Result -= RHS; break;
869 case BinaryOperator::Shl:
871 static_cast<uint32_t>(RHS.getLimitedValue(Result.getBitWidth()-1));
873 case BinaryOperator::Shr:
875 static_cast<uint32_t>(RHS.getLimitedValue(Result.getBitWidth()-1));
877 case BinaryOperator::LT: Result = Result < RHS; break;
878 case BinaryOperator::GT: Result = Result > RHS; break;
879 case BinaryOperator::LE: Result = Result <= RHS; break;
880 case BinaryOperator::GE: Result = Result >= RHS; break;
881 case BinaryOperator::EQ: Result = Result == RHS; break;
882 case BinaryOperator::NE: Result = Result != RHS; break;
883 case BinaryOperator::And: Result &= RHS; break;
884 case BinaryOperator::Xor: Result ^= RHS; break;
885 case BinaryOperator::Or: Result |= RHS; break;
886 case BinaryOperator::LAnd:
887 Result = Result != 0 && RHS != 0;
889 case BinaryOperator::LOr:
890 Result = Result != 0 || RHS != 0;
893 case BinaryOperator::Comma:
894 // C99 6.6p3: "shall not contain assignment, ..., or comma operators,
895 // *except* when they are contained within a subexpression that is not
896 // evaluated". Note that Assignment can never happen due to constraints
897 // on the LHS subexpr, so we don't need to check it here.
899 if (Loc) *Loc = getLocStart();
903 // The result of the constant expr is the RHS.
908 assert(!Exp->isAssignmentOp() && "LHS can't be a constant expr!");
911 case ImplicitCastExprClass:
912 case CastExprClass: {
914 SourceLocation CastLoc;
915 if (const CastExpr *C = dyn_cast<CastExpr>(this)) {
916 SubExpr = C->getSubExpr();
917 CastLoc = C->getLParenLoc();
919 SubExpr = cast<ImplicitCastExpr>(this)->getSubExpr();
920 CastLoc = getLocStart();
923 // C99 6.6p6: shall only convert arithmetic types to integer types.
924 if (!SubExpr->getType()->isArithmeticType() ||
925 !getType()->isIntegerType()) {
926 if (Loc) *Loc = SubExpr->getLocStart();
931 static_cast<uint32_t>(Ctx.getTypeSize(getType(), CastLoc));
933 // Handle simple integer->integer casts.
934 if (SubExpr->getType()->isIntegerType()) {
935 if (!SubExpr->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated))
938 // Figure out if this is a truncate, extend or noop cast.
939 // If the input is signed, do a sign extend, noop, or truncate.
940 if (getType()->isBooleanType()) {
941 // Conversion to bool compares against zero.
942 Result = Result != 0;
943 Result.zextOrTrunc(DestWidth);
944 } else if (SubExpr->getType()->isSignedIntegerType())
945 Result.sextOrTrunc(DestWidth);
946 else // If the input is unsigned, do a zero extend, noop, or truncate.
947 Result.zextOrTrunc(DestWidth);
951 // Allow floating constants that are the immediate operands of casts or that
952 // are parenthesized.
953 const Expr *Operand = SubExpr;
954 while (const ParenExpr *PE = dyn_cast<ParenExpr>(Operand))
955 Operand = PE->getSubExpr();
957 // If this isn't a floating literal, we can't handle it.
958 const FloatingLiteral *FL = dyn_cast<FloatingLiteral>(Operand);
960 if (Loc) *Loc = Operand->getLocStart();
964 // If the destination is boolean, compare against zero.
965 if (getType()->isBooleanType()) {
966 Result = !FL->getValue().isZero();
967 Result.zextOrTrunc(DestWidth);
971 // Determine whether we are converting to unsigned or signed.
972 bool DestSigned = getType()->isSignedIntegerType();
974 // TODO: Warn on overflow, but probably not here: isIntegerConstantExpr can
975 // be called multiple times per AST.
977 (void)FL->getValue().convertToInteger(Space, DestWidth, DestSigned,
978 llvm::APFloat::rmTowardZero);
979 Result = llvm::APInt(DestWidth, 4, Space);
982 case ConditionalOperatorClass: {
983 const ConditionalOperator *Exp = cast<ConditionalOperator>(this);
985 if (!Exp->getCond()->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated))
988 const Expr *TrueExp = Exp->getLHS();
989 const Expr *FalseExp = Exp->getRHS();
990 if (Result == 0) std::swap(TrueExp, FalseExp);
992 // Evaluate the false one first, discard the result.
993 if (FalseExp && !FalseExp->isIntegerConstantExpr(Result, Ctx, Loc, false))
995 // Evalute the true one, capture the result.
997 !TrueExp->isIntegerConstantExpr(Result, Ctx, Loc, isEvaluated))
1003 // Cases that are valid constant exprs fall through to here.
1004 Result.setIsUnsigned(getType()->isUnsignedIntegerType());
1008 /// isNullPointerConstant - C99 6.3.2.3p3 - Return true if this is either an
1009 /// integer constant expression with the value zero, or if this is one that is
1011 bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
1012 // Strip off a cast to void*, if it exists.
1013 if (const CastExpr *CE = dyn_cast<CastExpr>(this)) {
1014 // Check that it is a cast to void*.
1015 if (const PointerType *PT = CE->getType()->getAsPointerType()) {
1016 QualType Pointee = PT->getPointeeType();
1017 if (Pointee.getCVRQualifiers() == 0 &&
1018 Pointee->isVoidType() && // to void*
1019 CE->getSubExpr()->getType()->isIntegerType()) // from int.
1020 return CE->getSubExpr()->isNullPointerConstant(Ctx);
1022 } else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(this)) {
1023 // Ignore the ImplicitCastExpr type entirely.
1024 return ICE->getSubExpr()->isNullPointerConstant(Ctx);
1025 } else if (const ParenExpr *PE = dyn_cast<ParenExpr>(this)) {
1026 // Accept ((void*)0) as a null pointer constant, as many other
1027 // implementations do.
1028 return PE->getSubExpr()->isNullPointerConstant(Ctx);
1031 // This expression must be an integer type.
1032 if (!getType()->isIntegerType())
1035 // If we have an integer constant expression, we need to *evaluate* it and
1036 // test for the value 0.
1037 llvm::APSInt Val(32);
1038 return isIntegerConstantExpr(Val, Ctx, 0, true) && Val == 0;
1041 unsigned OCUVectorElementExpr::getNumElements() const {
1042 return strlen(Accessor.getName());
1046 /// getComponentType - Determine whether the components of this access are
1047 /// "point" "color" or "texture" elements.
1048 OCUVectorElementExpr::ElementType
1049 OCUVectorElementExpr::getElementType() const {
1050 // derive the component type, no need to waste space.
1051 const char *compStr = Accessor.getName();
1053 if (OCUVectorType::getPointAccessorIdx(*compStr) != -1) return Point;
1054 if (OCUVectorType::getColorAccessorIdx(*compStr) != -1) return Color;
1056 assert(OCUVectorType::getTextureAccessorIdx(*compStr) != -1 &&
1057 "getComponentType(): Illegal accessor");
1061 /// containsDuplicateElements - Return true if any element access is
1063 bool OCUVectorElementExpr::containsDuplicateElements() const {
1064 const char *compStr = Accessor.getName();
1065 unsigned length = strlen(compStr);
1067 for (unsigned i = 0; i < length-1; i++) {
1068 const char *s = compStr+i;
1069 for (const char c = *s++; *s; s++)
1076 /// getEncodedElementAccess - We encode fields with two bits per component.
1077 unsigned OCUVectorElementExpr::getEncodedElementAccess() const {
1078 const char *compStr = Accessor.getName();
1079 unsigned length = getNumElements();
1081 unsigned Result = 0;
1085 int Idx = OCUVectorType::getAccessorIdx(compStr[length]);
1086 assert(Idx != -1 && "Invalid accessor letter");
1092 // constructor for instance messages.
1093 ObjCMessageExpr::ObjCMessageExpr(Expr *receiver, Selector selInfo,
1094 QualType retType, ObjCMethodDecl *mproto,
1095 SourceLocation LBrac, SourceLocation RBrac,
1096 Expr **ArgExprs, unsigned nargs)
1097 : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
1098 MethodProto(mproto), ClassName(0) {
1100 SubExprs = new Expr*[NumArgs+1];
1101 SubExprs[RECEIVER] = receiver;
1103 for (unsigned i = 0; i != NumArgs; ++i)
1104 SubExprs[i+ARGS_START] = static_cast<Expr *>(ArgExprs[i]);
1110 // constructor for class messages.
1111 // FIXME: clsName should be typed to ObjCInterfaceType
1112 ObjCMessageExpr::ObjCMessageExpr(IdentifierInfo *clsName, Selector selInfo,
1113 QualType retType, ObjCMethodDecl *mproto,
1114 SourceLocation LBrac, SourceLocation RBrac,
1115 Expr **ArgExprs, unsigned nargs)
1116 : Expr(ObjCMessageExprClass, retType), SelName(selInfo),
1117 MethodProto(mproto), ClassName(clsName) {
1119 SubExprs = new Expr*[NumArgs+1];
1120 SubExprs[RECEIVER] = 0;
1122 for (unsigned i = 0; i != NumArgs; ++i)
1123 SubExprs[i+ARGS_START] = static_cast<Expr *>(ArgExprs[i]);
1130 bool ChooseExpr::isConditionTrue(ASTContext &C) const {
1131 llvm::APSInt CondVal(32);
1132 bool IsConst = getCond()->isIntegerConstantExpr(CondVal, C);
1133 assert(IsConst && "Condition of choose expr must be i-c-e"); IsConst=IsConst;
1134 return CondVal != 0;
1137 static int64_t evaluateOffsetOf(ASTContext& C, const Expr *E)
1139 if (const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
1140 QualType Ty = ME->getBase()->getType();
1142 RecordDecl *RD = Ty->getAsRecordType()->getDecl();
1143 const ASTRecordLayout &RL = C.getASTRecordLayout(RD, SourceLocation());
1144 FieldDecl *FD = ME->getMemberDecl();
1146 // FIXME: This is linear time.
1147 unsigned i = 0, e = 0;
1148 for (i = 0, e = RD->getNumMembers(); i != e; i++) {
1149 if (RD->getMember(i) == FD)
1153 return RL.getFieldOffset(i) + evaluateOffsetOf(C, ME->getBase());
1154 } else if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) {
1155 const Expr *Base = ASE->getBase();
1156 llvm::APSInt Idx(32);
1157 bool ICE = ASE->getIdx()->isIntegerConstantExpr(Idx, C);
1158 assert(ICE && "Array index is not a constant integer!");
1160 int64_t size = C.getTypeSize(ASE->getType(), SourceLocation());
1161 size *= Idx.getSExtValue();
1163 return size + evaluateOffsetOf(C, Base);
1164 } else if (isa<CompoundLiteralExpr>(E))
1167 assert(0 && "Unknown offsetof subexpression!");
1171 int64_t UnaryOperator::evaluateOffsetOf(ASTContext& C) const
1173 assert(Opc == OffsetOf && "Unary operator not offsetof!");
1176 C.Target.getCharWidth(C.getFullLoc(getOperatorLoc()));
1178 return ::evaluateOffsetOf(C, Val) / CharSize;
1181 //===----------------------------------------------------------------------===//
1182 // Child Iterators for iterating over subexpressions/substatements
1183 //===----------------------------------------------------------------------===//
1186 Stmt::child_iterator DeclRefExpr::child_begin() { return child_iterator(); }
1187 Stmt::child_iterator DeclRefExpr::child_end() { return child_iterator(); }
1190 Stmt::child_iterator ObjCIvarRefExpr::child_begin() { return child_iterator(); }
1191 Stmt::child_iterator ObjCIvarRefExpr::child_end() { return child_iterator(); }
1194 Stmt::child_iterator PreDefinedExpr::child_begin() { return child_iterator(); }
1195 Stmt::child_iterator PreDefinedExpr::child_end() { return child_iterator(); }
1198 Stmt::child_iterator IntegerLiteral::child_begin() { return child_iterator(); }
1199 Stmt::child_iterator IntegerLiteral::child_end() { return child_iterator(); }
1202 Stmt::child_iterator CharacterLiteral::child_begin() { return child_iterator(); }
1203 Stmt::child_iterator CharacterLiteral::child_end() { return child_iterator(); }
1206 Stmt::child_iterator FloatingLiteral::child_begin() { return child_iterator(); }
1207 Stmt::child_iterator FloatingLiteral::child_end() { return child_iterator(); }
1210 Stmt::child_iterator ImaginaryLiteral::child_begin() {
1211 return reinterpret_cast<Stmt**>(&Val);
1213 Stmt::child_iterator ImaginaryLiteral::child_end() {
1214 return reinterpret_cast<Stmt**>(&Val)+1;
1218 Stmt::child_iterator StringLiteral::child_begin() { return child_iterator(); }
1219 Stmt::child_iterator StringLiteral::child_end() { return child_iterator(); }
1222 Stmt::child_iterator ParenExpr::child_begin() {
1223 return reinterpret_cast<Stmt**>(&Val);
1225 Stmt::child_iterator ParenExpr::child_end() {
1226 return reinterpret_cast<Stmt**>(&Val)+1;
1230 Stmt::child_iterator UnaryOperator::child_begin() {
1231 return reinterpret_cast<Stmt**>(&Val);
1233 Stmt::child_iterator UnaryOperator::child_end() {
1234 return reinterpret_cast<Stmt**>(&Val+1);
1237 // SizeOfAlignOfTypeExpr
1238 Stmt::child_iterator SizeOfAlignOfTypeExpr::child_begin() {
1239 // If the type is a VLA type (and not a typedef), the size expression of the
1240 // VLA needs to be treated as an executable expression.
1241 if (VariableArrayType* T = dyn_cast<VariableArrayType>(Ty.getTypePtr()))
1242 return child_iterator(T);
1244 return child_iterator();
1246 Stmt::child_iterator SizeOfAlignOfTypeExpr::child_end() {
1247 return child_iterator();
1250 // ArraySubscriptExpr
1251 Stmt::child_iterator ArraySubscriptExpr::child_begin() {
1252 return reinterpret_cast<Stmt**>(&SubExprs);
1254 Stmt::child_iterator ArraySubscriptExpr::child_end() {
1255 return reinterpret_cast<Stmt**>(&SubExprs)+END_EXPR;
1259 Stmt::child_iterator CallExpr::child_begin() {
1260 return reinterpret_cast<Stmt**>(&SubExprs[0]);
1262 Stmt::child_iterator CallExpr::child_end() {
1263 return reinterpret_cast<Stmt**>(&SubExprs[NumArgs+ARGS_START]);
1267 Stmt::child_iterator MemberExpr::child_begin() {
1268 return reinterpret_cast<Stmt**>(&Base);
1270 Stmt::child_iterator MemberExpr::child_end() {
1271 return reinterpret_cast<Stmt**>(&Base)+1;
1274 // OCUVectorElementExpr
1275 Stmt::child_iterator OCUVectorElementExpr::child_begin() {
1276 return reinterpret_cast<Stmt**>(&Base);
1278 Stmt::child_iterator OCUVectorElementExpr::child_end() {
1279 return reinterpret_cast<Stmt**>(&Base)+1;
1282 // CompoundLiteralExpr
1283 Stmt::child_iterator CompoundLiteralExpr::child_begin() {
1284 return reinterpret_cast<Stmt**>(&Init);
1286 Stmt::child_iterator CompoundLiteralExpr::child_end() {
1287 return reinterpret_cast<Stmt**>(&Init)+1;
1291 Stmt::child_iterator ImplicitCastExpr::child_begin() {
1292 return reinterpret_cast<Stmt**>(&Op);
1294 Stmt::child_iterator ImplicitCastExpr::child_end() {
1295 return reinterpret_cast<Stmt**>(&Op)+1;
1299 Stmt::child_iterator CastExpr::child_begin() {
1300 return reinterpret_cast<Stmt**>(&Op);
1302 Stmt::child_iterator CastExpr::child_end() {
1303 return reinterpret_cast<Stmt**>(&Op)+1;
1307 Stmt::child_iterator BinaryOperator::child_begin() {
1308 return reinterpret_cast<Stmt**>(&SubExprs);
1310 Stmt::child_iterator BinaryOperator::child_end() {
1311 return reinterpret_cast<Stmt**>(&SubExprs)+END_EXPR;
1314 // ConditionalOperator
1315 Stmt::child_iterator ConditionalOperator::child_begin() {
1316 return reinterpret_cast<Stmt**>(&SubExprs);
1318 Stmt::child_iterator ConditionalOperator::child_end() {
1319 return reinterpret_cast<Stmt**>(&SubExprs)+END_EXPR;
1323 Stmt::child_iterator AddrLabelExpr::child_begin() { return child_iterator(); }
1324 Stmt::child_iterator AddrLabelExpr::child_end() { return child_iterator(); }
1327 Stmt::child_iterator StmtExpr::child_begin() {
1328 return reinterpret_cast<Stmt**>(&SubStmt);
1330 Stmt::child_iterator StmtExpr::child_end() {
1331 return reinterpret_cast<Stmt**>(&SubStmt)+1;
1334 // TypesCompatibleExpr
1335 Stmt::child_iterator TypesCompatibleExpr::child_begin() {
1336 return child_iterator();
1339 Stmt::child_iterator TypesCompatibleExpr::child_end() {
1340 return child_iterator();
1344 Stmt::child_iterator ChooseExpr::child_begin() {
1345 return reinterpret_cast<Stmt**>(&SubExprs);
1348 Stmt::child_iterator ChooseExpr::child_end() {
1349 return reinterpret_cast<Stmt**>(&SubExprs)+END_EXPR;
1353 Stmt::child_iterator OverloadExpr::child_begin() {
1354 return reinterpret_cast<Stmt**>(&SubExprs[0]);
1356 Stmt::child_iterator OverloadExpr::child_end() {
1357 return reinterpret_cast<Stmt**>(&SubExprs[NumExprs]);
1361 Stmt::child_iterator VAArgExpr::child_begin() {
1362 return reinterpret_cast<Stmt**>(&Val);
1365 Stmt::child_iterator VAArgExpr::child_end() {
1366 return reinterpret_cast<Stmt**>(&Val)+1;
1370 Stmt::child_iterator InitListExpr::child_begin() {
1371 return reinterpret_cast<Stmt**>(&InitExprs[0]);
1373 Stmt::child_iterator InitListExpr::child_end() {
1374 return reinterpret_cast<Stmt**>(&InitExprs[NumInits]);
1377 // ObjCStringLiteral
1378 Stmt::child_iterator ObjCStringLiteral::child_begin() {
1379 return child_iterator();
1381 Stmt::child_iterator ObjCStringLiteral::child_end() {
1382 return child_iterator();
1386 Stmt::child_iterator ObjCEncodeExpr::child_begin() { return child_iterator(); }
1387 Stmt::child_iterator ObjCEncodeExpr::child_end() { return child_iterator(); }
1390 Stmt::child_iterator ObjCSelectorExpr::child_begin() {
1391 return child_iterator();
1393 Stmt::child_iterator ObjCSelectorExpr::child_end() {
1394 return child_iterator();
1398 Stmt::child_iterator ObjCProtocolExpr::child_begin() {
1399 return child_iterator();
1401 Stmt::child_iterator ObjCProtocolExpr::child_end() {
1402 return child_iterator();
1406 Stmt::child_iterator ObjCMessageExpr::child_begin() {
1407 return reinterpret_cast<Stmt**>(&SubExprs[0]);
1409 Stmt::child_iterator ObjCMessageExpr::child_end() {
1410 return reinterpret_cast<Stmt**>(&SubExprs[getNumArgs()+ARGS_START]);