diff options
author | Anders Carlsson <andersca@mac.com> | 2008-12-19 20:58:05 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-12-19 20:58:05 +0000 |
commit | 1c0cfd4599e816cfd7a8f348286bf0ad79652ffc (patch) | |
tree | f4596e1bd04d54571b355824f66b0a0fe6acb437 /lib/Sema/SemaDecl.cpp | |
parent | 06c58b191f969e2ae5308cc9b6540bad9511f4ef (diff) |
Get rid of the old Expr::Evaluate variant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6c1af5f878..86af21024b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1888,8 +1888,9 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) { // should always be able to do in theory). If so, we only require the // specified arm of the conditional to be a constant. This is a horrible // hack, but is require by real world code that uses __builtin_constant_p. - APValue Val; - if (!Exp->getCond()->Evaluate(Val, Context)) { + Expr::EvalResult EvalResult; + if (!Exp->getCond()->Evaluate(EvalResult, Context) || + EvalResult.HasSideEffects) { // If Evaluate couldn't fold it, CheckArithmeticConstantExpression // won't be able to either. Use it to emit the diagnostic though. bool Res = CheckArithmeticConstantExpression(Exp->getCond()); @@ -1899,7 +1900,7 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) { // Verify that the side following the condition is also a constant. const Expr *TrueSide = Exp->getLHS(), *FalseSide = Exp->getRHS(); - if (Val.getInt() == 0) + if (EvalResult.Val.getInt() == 0) std::swap(TrueSide, FalseSide); if (TrueSide && CheckArithmeticConstantExpression(TrueSide)) @@ -2717,13 +2718,13 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T, const VariableArrayType* VLATy = dyn_cast<VariableArrayType>(T); if (!VLATy) return QualType(); - APValue Result; + Expr::EvalResult EvalResult; if (!VLATy->getSizeExpr() || - !VLATy->getSizeExpr()->Evaluate(Result, Context)) + !VLATy->getSizeExpr()->Evaluate(EvalResult, Context)) return QualType(); - assert(Result.isInt() && "Size expressions must be integers!"); - llvm::APSInt &Res = Result.getInt(); + assert(EvalResult.Val.isInt() && "Size expressions must be integers!"); + llvm::APSInt &Res = EvalResult.Val.getInt(); if (Res > llvm::APSInt(Res.getBitWidth(), Res.isUnsigned())) return Context.getConstantArrayType(VLATy->getElementType(), Res, ArrayType::Normal, 0); |