EvalInfo now holds a reference to an EvalResult struct.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60296 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 3efa52b..2b7a646 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -39,27 +39,15 @@
struct EvalInfo {
ASTContext &Ctx;
+ /// EvalResult - Contains information about the evaluation.
+ Expr::EvalResult &EvalResult;
+
/// isEvaluated - True if the subexpression is required to be evaluated, false
/// if it is short-circuited (according to C rules).
bool isEvaluated;
-
- /// ICEDiag - If the expression is unfoldable, then ICEDiag contains the
- /// error diagnostic indicating why it is not foldable and DiagLoc indicates a
- /// caret position for the error. If it is foldable, but the expression is
- /// not an integer constant expression, ICEDiag contains the extension
- /// diagnostic to emit which describes why it isn't an integer constant
- /// expression. If this expression *is* an integer-constant-expr, then
- /// ICEDiag is zero.
- ///
- /// The caller can choose to emit this diagnostic or not, depending on whether
- /// they require an i-c-e or a constant or not. DiagLoc indicates the caret
- /// position for the report.
- ///
- /// If ICEDiag is zero, then this expression is an i-c-e.
- unsigned ICEDiag;
- SourceLocation DiagLoc;
- EvalInfo(ASTContext &ctx) : Ctx(ctx), isEvaluated(true), ICEDiag(0) {}
+ EvalInfo(ASTContext &ctx, Expr::EvalResult& evalresult) : Ctx(ctx),
+ EvalResult(evalresult), isEvaluated(true) {}
};
@@ -342,8 +330,8 @@
}
bool Extension(SourceLocation L, diag::kind D) {
- Info.DiagLoc = L;
- Info.ICEDiag = D;
+ Info.EvalResult.DiagLoc = L;
+ Info.EvalResult.Diag = D;
return true; // still a constant.
}
@@ -359,9 +347,9 @@
}
// Take the first error.
- if (Info.ICEDiag == 0) {
- Info.DiagLoc = L;
- Info.ICEDiag = D;
+ if (Info.EvalResult.Diag == 0) {
+ Info.EvalResult.DiagLoc = L;
+ Info.EvalResult.Diag = D;
}
return false;
}
@@ -1164,7 +1152,9 @@
/// we want to. If this function returns true, it returns the folded constant
/// in Result.
bool Expr::Evaluate(APValue &Result, ASTContext &Ctx, bool *isEvaluated) const {
- EvalInfo Info(Ctx);
+ Expr::EvalResult EvalResult;
+ EvalInfo Info(Ctx, EvalResult);
+
if (getType()->isIntegerType()) {
llvm::APSInt sInt(32);
if (!EvaluateInteger(this, sInt, Info))