@@ -4714,7 +4714,8 @@ template <class Emitter>
4714
4714
VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
4715
4715
bool IsConstexprUnknown) {
4716
4716
4717
- auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true , IsConstexprUnknown);
4717
+ auto R = this ->visitVarDecl (VD, VD->getInit (), /* Toplevel=*/ true ,
4718
+ IsConstexprUnknown);
4718
4719
4719
4720
if (R.notCreated ())
4720
4721
return R;
@@ -4740,22 +4741,20 @@ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
4740
4741
// / We get here from evaluateAsInitializer().
4741
4742
// / We need to evaluate the initializer and return its value.
4742
4743
template <class Emitter >
4743
- bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
4744
+ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD, const Expr *Init,
4744
4745
bool ConstantContext) {
4745
-
4746
4746
// We only create variables if we're evaluating in a constant context.
4747
4747
// Otherwise, just evaluate the initializer and return it.
4748
4748
if (!ConstantContext) {
4749
4749
DeclScope<Emitter> LS (this , VD);
4750
- const Expr *Init = VD->getInit ();
4751
4750
if (!this ->visit (Init))
4752
4751
return false ;
4753
4752
return this ->emitRet (classify (Init).value_or (PT_Ptr), VD) &&
4754
4753
LS.destroyLocals () && this ->emitCheckAllocations (VD);
4755
4754
}
4756
4755
4757
4756
LocalScope<Emitter> VDScope (this , VD);
4758
- if (!this ->visitVarDecl (VD, /* Toplevel=*/ true ))
4757
+ if (!this ->visitVarDecl (VD, Init, /* Toplevel=*/ true ))
4759
4758
return false ;
4760
4759
4761
4760
OptPrimType VarT = classify (VD->getType ());
@@ -4802,9 +4801,9 @@ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
4802
4801
}
4803
4802
4804
4803
template <class Emitter >
4805
- VarCreationState Compiler<Emitter>::visitVarDecl( const VarDecl *VD,
4806
- bool Toplevel ,
4807
- bool IsConstexprUnknown) {
4804
+ VarCreationState
4805
+ Compiler<Emitter>::visitVarDecl( const VarDecl *VD, const Expr *Init ,
4806
+ bool Toplevel, bool IsConstexprUnknown) {
4808
4807
// We don't know what to do with these, so just return false.
4809
4808
if (VD->getType ().isNull ())
4810
4809
return false ;
@@ -4814,7 +4813,6 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
4814
4813
if (!this ->isActive ())
4815
4814
return VarCreationState::NotCreated ();
4816
4815
4817
- const Expr *Init = VD->getInit ();
4818
4816
OptPrimType VarT = classify (VD->getType ());
4819
4817
4820
4818
if (Init && Init->isValueDependent ())
@@ -5488,7 +5486,8 @@ template <class Emitter>
5488
5486
bool Compiler<Emitter>::maybeEmitDeferredVarInit(const VarDecl *VD) {
5489
5487
if (auto *DD = dyn_cast_if_present<DecompositionDecl>(VD)) {
5490
5488
for (auto *BD : DD->flat_bindings ())
5491
- if (auto *KD = BD->getHoldingVar (); KD && !this ->visitVarDecl (KD))
5489
+ if (auto *KD = BD->getHoldingVar ();
5490
+ KD && !this ->visitVarDecl (KD, KD->getInit ()))
5492
5491
return false ;
5493
5492
}
5494
5493
return true ;
@@ -5552,7 +5551,7 @@ bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS,
5552
5551
const auto *VD = dyn_cast<VarDecl>(D);
5553
5552
if (!VD)
5554
5553
return false ;
5555
- if (!this ->visitVarDecl (VD))
5554
+ if (!this ->visitVarDecl (VD, VD-> getInit () ))
5556
5555
return false ;
5557
5556
5558
5557
// Register decomposition decl holding vars.
0 commit comments