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 | 6736d1a2bb9e690cf88d2fe9bcb3896a66334833 (patch) | |
tree | 1d411f8c73dffa41c0f66b8b3bf1b3e524edbecf /clang/lib/Sema/SemaDecl.cpp | |
parent | 0869f78555d7799c2e3cb35d2fcffa22cbaff08f (diff) | |
download | bcm5719-llvm-6736d1a2bb9e690cf88d2fe9bcb3896a66334833.tar.gz bcm5719-llvm-6736d1a2bb9e690cf88d2fe9bcb3896a66334833.zip |
Get rid of the old Expr::Evaluate variant.
llvm-svn: 61260
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 6c1af5f8787..86af21024b6 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/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); |