diff options
| author | Anders Carlsson <andersca@mac.com> | 2008-11-24 05:23:59 +0000 | 
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2008-11-24 05:23:59 +0000 | 
| commit | a7c5eb72a0c7f8dd0fbc6c0d1abb3bd4b439e312 (patch) | |
| tree | 1f0475f805be27adccf6fe9ba7707b919173fa27 /clang/lib/AST/Expr.cpp | |
| parent | 411eaa5c57c6b184d476597aa9c0522a5d38431d (diff) | |
| download | bcm5719-llvm-a7c5eb72a0c7f8dd0fbc6c0d1abb3bd4b439e312.tar.gz bcm5719-llvm-a7c5eb72a0c7f8dd0fbc6c0d1abb3bd4b439e312.zip | |
Reimplement Expr::isConstantExpr in terms of Expr::Evaluate. This fixes PR2832.
llvm-svn: 59946
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 0ff345a1a8d..6d29dd1f319 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -622,8 +622,32 @@ Expr *Expr::IgnoreParenCasts() {    }  } +#define USE_EVALUATE  bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const { +#ifdef USE_EVALUATE +  switch (getStmtClass()) { +  default: +    if (!isEvaluatable(Ctx)) { +      if (Loc) *Loc = getLocStart(); +      return false; +    } +    break; +  case StringLiteralClass: +  case ObjCStringLiteralClass: +    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))  +        return false; +    } +  } +  } + +  return true; +#else    switch (getStmtClass()) {    default:      if (Loc) *Loc = getLocStart(); @@ -762,6 +786,7 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {    case CXXDefaultArgExprClass:      return cast<CXXDefaultArgExpr>(this)->getExpr()->isConstantExpr(Ctx, Loc);    } +#endif  }  /// isIntegerConstantExpr - this recursive routine will test if an expression is | 

