[AST] Follow-up for r201468, move the check to the caller and add an assertion.

Suggested by Richard Smith.

llvm-svn: 201753
This commit is contained in:
Argyrios Kyrtzidis 2014-02-20 04:00:01 +00:00
parent 420569be04
commit 3d9e38273b
1 changed files with 8 additions and 4 deletions

View File

@ -3117,14 +3117,18 @@ static bool EvaluateDecl(EvalInfo &Info, const Decl *D) {
Result.set(VD, Info.CurrentCall->Index);
APValue &Val = Info.CurrentCall->createTemporary(VD, true);
if (!VD->getInit()) {
const Expr *InitE = VD->getInit();
if (!InitE) {
Info.Diag(D->getLocStart(), diag::note_constexpr_uninitialized)
<< false << VD->getType();
Val = APValue();
return false;
}
if (!EvaluateInPlace(Val, Info, Result, VD->getInit())) {
if (InitE->isValueDependent())
return false;
if (!EvaluateInPlace(Val, Info, Result, InitE)) {
// Wipe out any partially-computed value, to allow tracking that this
// evaluation failed.
Val = APValue();
@ -8028,8 +8032,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
/// an object can indirectly refer to subobjects which were initialized earlier.
static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
const Expr *E, bool AllowNonLiteralTypes) {
if (E->isTypeDependent() || E->isValueDependent())
return false;
assert(!E->isValueDependent());
if (!AllowNonLiteralTypes && !CheckLiteralType(Info, E, &This))
return false;