Simplify: we don't care why constant evaluation might have failed when we're
checking an expression for constant overflow. llvm-svn: 194099
This commit is contained in:
parent
6d4c6586c9
commit
e9ff770f8b
|
@ -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.
|
||||
|
|
|
@ -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 ASTContext &Ctx,
|
|||
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);
|
||||
|
|
|
@ -5620,10 +5620,8 @@ void Sema::CheckImplicitConversions(Expr *E, SourceLocation CC) {
|
|||
/// 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 {
|
||||
|
|
Loading…
Reference in New Issue