@@ -4714,7 +4714,8 @@ template <class Emitter>
47144714VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
47154715 bool IsConstexprUnknown) {
47164716
4717- auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true , IsConstexprUnknown);
4717+ auto R = this ->visitVarDecl (VD, VD->getInit (), /* Toplevel=*/ true ,
4718+ IsConstexprUnknown);
47184719
47194720 if (R.notCreated ())
47204721 return R;
@@ -4740,22 +4741,20 @@ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
47404741// / We get here from evaluateAsInitializer().
47414742// / We need to evaluate the initializer and return its value.
47424743template <class Emitter >
4743- bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
4744+ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD, const Expr *Init,
47444745 bool ConstantContext) {
4745-
47464746 // We only create variables if we're evaluating in a constant context.
47474747 // Otherwise, just evaluate the initializer and return it.
47484748 if (!ConstantContext) {
47494749 DeclScope<Emitter> LS (this , VD);
4750- const Expr *Init = VD->getInit ();
47514750 if (!this ->visit (Init))
47524751 return false ;
47534752 return this ->emitRet (classify (Init).value_or (PT_Ptr), VD) &&
47544753 LS.destroyLocals () && this ->emitCheckAllocations (VD);
47554754 }
47564755
47574756 LocalScope<Emitter> VDScope (this , VD);
4758- if (!this ->visitVarDecl (VD, /* Toplevel=*/ true ))
4757+ if (!this ->visitVarDecl (VD, Init, /* Toplevel=*/ true ))
47594758 return false ;
47604759
47614760 OptPrimType VarT = classify (VD->getType ());
@@ -4802,9 +4801,9 @@ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
48024801}
48034802
48044803template <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) {
48084807 // We don't know what to do with these, so just return false.
48094808 if (VD->getType ().isNull ())
48104809 return false ;
@@ -4814,7 +4813,6 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
48144813 if (!this ->isActive ())
48154814 return VarCreationState::NotCreated ();
48164815
4817- const Expr *Init = VD->getInit ();
48184816 OptPrimType VarT = classify (VD->getType ());
48194817
48204818 if (Init && Init->isValueDependent ())
@@ -5488,7 +5486,8 @@ template <class Emitter>
54885486bool Compiler<Emitter>::maybeEmitDeferredVarInit(const VarDecl *VD) {
54895487 if (auto *DD = dyn_cast_if_present<DecompositionDecl>(VD)) {
54905488 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 ()))
54925491 return false ;
54935492 }
54945493 return true ;
@@ -5552,7 +5551,7 @@ bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS,
55525551 const auto *VD = dyn_cast<VarDecl>(D);
55535552 if (!VD)
55545553 return false ;
5555- if (!this ->visitVarDecl (VD))
5554+ if (!this ->visitVarDecl (VD, VD-> getInit () ))
55565555 return false ;
55575556
55585557 // Register decomposition decl holding vars.
0 commit comments