r194099 - Simplify: we don't care why constant evaluation might have failed when we're
Richard Smith
richard-llvm at metafoo.co.uk
Tue Nov 5 14:23:31 PST 2013
Author: rsmith
Date: Tue Nov 5 16:23:30 2013
New Revision: 194099
URL: http://llvm.org/viewvc/llvm-project?rev=194099&view=rev
Log:
Simplify: we don't care why constant evaluation might have failed when we're
checking an expression for constant overflow.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=194099&r1=194098&r2=194099&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Nov 5 16:23:30 2013
@@ -579,15 +579,14 @@ public:
/// \brief Determine whether this expression involves a call to any function
/// that is not trivial.
bool hasNonTrivialCall(ASTContext &Ctx);
-
+
/// EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded
/// integer. This must be called on an expression that constant folds to an
/// integer.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx,
SmallVectorImpl<PartialDiagnosticAt> *Diag=0) const;
-
- void EvaluateForOverflow(const ASTContext &Ctx,
- SmallVectorImpl<PartialDiagnosticAt> *Diag) const;
+
+ void EvaluateForOverflow(const ASTContext &Ctx) const;
/// EvaluateAsLValue - Evaluate an expression to see if we can fold it to an
/// lvalue with link time known address, with no side-effects.
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=194099&r1=194098&r2=194099&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Nov 5 16:23:30 2013
@@ -566,12 +566,12 @@ namespace {
switch (EvalMode) {
case EM_ConstantExpression:
case EM_PotentialConstantExpression:
- case EM_EvaluateForOverflow:
HasActiveDiagnostic = false;
return OptionalDiagnostic();
case EM_ConstantFold:
case EM_IgnoreSideEffects:
+ case EM_EvaluateForOverflow:
break;
}
}
@@ -615,8 +615,7 @@ namespace {
unsigned ExtraNotes = 0) {
// Don't override a previous diagnostic. Don't bother collecting
// diagnostics if we're evaluating for overflow.
- if (!EvalStatus.Diag || !EvalStatus.Diag->empty() ||
- EvalMode == EM_EvaluateForOverflow) {
+ if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) {
HasActiveDiagnostic = false;
return OptionalDiagnostic();
}
@@ -8133,11 +8132,9 @@ APSInt Expr::EvaluateKnownConstInt(const
return EvalResult.Val.getInt();
}
-void Expr::EvaluateForOverflow(const ASTContext &Ctx,
- SmallVectorImpl<PartialDiagnosticAt> *Diags) const {
+void Expr::EvaluateForOverflow(const ASTContext &Ctx) const {
bool IsConst;
EvalResult EvalResult;
- EvalResult.Diag = Diags;
if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst)) {
EvalInfo Info(Ctx, EvalResult, EvalInfo::EM_EvaluateForOverflow);
(void)::EvaluateAsRValue(Info, this, EvalResult.Val);
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=194099&r1=194098&r2=194099&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Nov 5 16:23:30 2013
@@ -5620,10 +5620,8 @@ void Sema::CheckImplicitConversions(Expr
/// Diagnose when expression is an integer constant expression and its evaluation
/// results in integer overflow
void Sema::CheckForIntOverflow (Expr *E) {
- if (isa<BinaryOperator>(E->IgnoreParens())) {
- SmallVector<PartialDiagnosticAt, 4> Diags;
- E->EvaluateForOverflow(Context, &Diags);
- }
+ if (isa<BinaryOperator>(E->IgnoreParens()))
+ E->EvaluateForOverflow(Context);
}
namespace {
More information about the cfe-commits
mailing list