]> granicus.if.org Git - clang/commitdiff
[AST] Follow-up for r201468, move the check to the caller and add an assertion.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 20 Feb 2014 04:00:01 +0000 (04:00 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 20 Feb 2014 04:00:01 +0000 (04:00 +0000)
Suggested by Richard Smith.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201753 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp

index b11e9e8a272567837057cd327b1afd5de8fc2f65..e172c9147858ba81618fcb46db27b9c12e74a25b 100644 (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;