diff options
author | Anders Carlsson <andersca@mac.com> | 2008-11-25 17:16:39 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-11-25 17:16:39 +0000 |
commit | c9ad94e12aaf667e02c7297a663fc93090e1d2cb (patch) | |
tree | 34e9c104b26aef1e4c606c2d2f9d99700edb8270 /lib/AST/Expr.cpp | |
parent | 704e4907ee0116e53f270d778c955da9f01fc2d8 (diff) |
Remove more #ifdeffed code
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60033 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 144 |
1 files changed, 0 insertions, 144 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 6d29dd1f31..835a467fc2 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -622,10 +622,7 @@ Expr *Expr::IgnoreParenCasts() { } } -#define USE_EVALUATE - bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const { -#ifdef USE_EVALUATE switch (getStmtClass()) { default: if (!isEvaluatable(Ctx)) { @@ -634,7 +631,6 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const { } break; case StringLiteralClass: - case ObjCStringLiteralClass: return true; case InitListExprClass: { const InitListExpr *Exp = cast<InitListExpr>(this); @@ -647,146 +643,6 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const { } return true; -#else - switch (getStmtClass()) { - default: - if (Loc) *Loc = getLocStart(); - return false; - case ParenExprClass: - return cast<ParenExpr>(this)->getSubExpr()->isConstantExpr(Ctx, Loc); - case StringLiteralClass: - case ObjCStringLiteralClass: - case FloatingLiteralClass: - case IntegerLiteralClass: - case CharacterLiteralClass: - case ImaginaryLiteralClass: - case TypesCompatibleExprClass: - case CXXBoolLiteralExprClass: - case AddrLabelExprClass: - return true; - case CallExprClass: - case CXXOperatorCallExprClass: { - const CallExpr *CE = cast<CallExpr>(this); - - // Allow any constant foldable calls to builtins. - if (CE->isBuiltinCall() && CE->isEvaluatable(Ctx)) - return true; - - if (Loc) *Loc = getLocStart(); - return false; - } - case DeclRefExprClass: { - const Decl *D = cast<DeclRefExpr>(this)->getDecl(); - // Accept address of function. - if (isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D)) - return true; - if (Loc) *Loc = getLocStart(); - if (isa<VarDecl>(D)) - return TR->isArrayType(); - return false; - } - case CompoundLiteralExprClass: - if (Loc) *Loc = getLocStart(); - // Allow "(int []){2,4}", since the array will be converted to a pointer. - // Allow "(vector type){2,4}" since the elements are all constant. - return TR->isArrayType() || TR->isVectorType(); - case UnaryOperatorClass: { - const UnaryOperator *Exp = cast<UnaryOperator>(this); - - // C99 6.6p9 - if (Exp->getOpcode() == UnaryOperator::AddrOf) { - if (!Exp->getSubExpr()->hasGlobalStorage()) { - if (Loc) *Loc = getLocStart(); - return false; - } - return true; - } - - // Get the operand value. If this is sizeof/alignof, do not evalute the - // operand. This affects C99 6.6p3. - if (Exp->getOpcode() != UnaryOperator::OffsetOf && - !Exp->getSubExpr()->isConstantExpr(Ctx, Loc)) - return false; - - switch (Exp->getOpcode()) { - // Address, indirect, pre/post inc/dec, etc are not valid constant exprs. - // See C99 6.6p3. - default: - if (Loc) *Loc = Exp->getOperatorLoc(); - return false; - case UnaryOperator::Extension: - return true; // FIXME: this is wrong. - case UnaryOperator::OffsetOf: - if (!Exp->getSubExpr()->getType()->isConstantSizeType()) { - if (Loc) *Loc = Exp->getOperatorLoc(); - return false; - } - return true; - case UnaryOperator::LNot: - case UnaryOperator::Plus: - case UnaryOperator::Minus: - case UnaryOperator::Not: - return true; - } - } - case SizeOfAlignOfExprClass: { - const SizeOfAlignOfExpr *Exp = cast<SizeOfAlignOfExpr>(this); - // alignof always evaluates to a constant. - if (Exp->isSizeOf()) { - QualType ArgTy = Exp->getTypeOfArgument(); - if (!ArgTy->isVoidType() && !ArgTy->isConstantSizeType()) { - if (Loc) *Loc = Exp->getOperatorLoc(); - return false; - } - } - return true; - } - case BinaryOperatorClass: { - const BinaryOperator *Exp = cast<BinaryOperator>(this); - - // The LHS of a constant expr is always evaluated and needed. - if (!Exp->getLHS()->isConstantExpr(Ctx, Loc)) - return false; - - if (!Exp->getRHS()->isConstantExpr(Ctx, Loc)) - return false; - return true; - } - case ImplicitCastExprClass: - case CStyleCastExprClass: - case CXXFunctionalCastExprClass: { - const Expr *SubExpr = cast<CastExpr>(this)->getSubExpr(); - SourceLocation CastLoc = getLocStart(); - if (!SubExpr->isConstantExpr(Ctx, Loc)) { - if (Loc) *Loc = SubExpr->getLocStart(); - return false; - } - return true; - } - case ConditionalOperatorClass: { - const ConditionalOperator *Exp = cast<ConditionalOperator>(this); - if (!Exp->getCond()->isConstantExpr(Ctx, Loc) || - // Handle the GNU extension for missing LHS. - !(Exp->getLHS() && Exp->getLHS()->isConstantExpr(Ctx, Loc)) || - !Exp->getRHS()->isConstantExpr(Ctx, Loc)) - return false; - return true; - } - case InitListExprClass: { - const InitListExpr *Exp = cast<InitListExpr>(this); - unsigned numInits = Exp->getNumInits(); - for (unsigned i = 0; i < numInits; i++) { - if (!Exp->getInit(i)->isConstantExpr(Ctx, Loc)) { - if (Loc) *Loc = Exp->getInit(i)->getLocStart(); - return false; - } - } - return true; - } - case CXXDefaultArgExprClass: - return cast<CXXDefaultArgExpr>(this)->getExpr()->isConstantExpr(Ctx, Loc); - } -#endif } /// isIntegerConstantExpr - this recursive routine will test if an expression is |