[Clang] Treat constexpr-unknown value as invalid in `EvaluateAsInitia… · llvm/llvm-project@9010db1 (original) (raw)

`@@ -3628,8 +3628,6 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,

`

3628

3628

` if (AllowConstexprUnknown) {

`

3629

3629

` if (!Result)

`

3630

3630

` Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);

`

3631

``

`-

else

`

3632

``

`-

Result->setConstexprUnknown();

`

3633

3631

` }

`

3634

3632

` return true;

`

3635

3633

`}

`

`@@ -17000,6 +16998,18 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,

`

17000

16998

``

17001

16999

` if (!Info.discardCleanups())

`

17002

17000

` llvm_unreachable("Unhandled cleanup; missing full expression marker?");

`

``

17001

+

``

17002

`+

if (Value.allowConstexprUnknown()) {

`

``

17003

`+

assert(Value.isLValue() && "Expected an lvalue");

`

``

17004

`+

auto Base = Value.getLValueBase();

`

``

17005

`+

const auto *NewVD = Base.dyn_cast<const ValueDecl *>();

`

``

17006

`+

if (!NewVD)

`

``

17007

`+

NewVD = VD;

`

``

17008

`+

Info.FFDiag(getExprLoc(), diag::note_constexpr_var_init_non_constant, 1)

`

``

17009

`+

<< NewVD;

`

``

17010

`+

NoteLValueLocation(Info, Base);

`

``

17011

`+

return false;

`

``

17012

`+

}

`

17003

17013

` }

`

17004

17014

``

17005

17015

` return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,

`