@@ -4293,7 +4293,8 @@ bool Compiler<Emitter>::emitConst(const APSInt &Value, const Expr *E) {
42934293
42944294template <class Emitter >
42954295unsigned Compiler<Emitter>::allocateLocalPrimitive(
4296- DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl) {
4296+ DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl,
4297+ bool IsConstexprUnknown) {
42974298 // Make sure we don't accidentally register the same decl twice.
42984299 if (const auto *VD =
42994300 dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>())) {
@@ -4307,6 +4308,7 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(
43074308 // or isa<MaterializeTemporaryExpr>().
43084309 Descriptor *D = P.createDescriptor (Src, Ty, nullptr , Descriptor::InlineDescMD,
43094310 IsConst, isa<const Expr *>(Src));
4311+ D->IsConstexprUnknown = IsConstexprUnknown;
43104312 Scope::Local Local = this ->createLocal (D);
43114313 if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>()))
43124314 Locals.insert ({VD, Local});
@@ -4320,7 +4322,8 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(
43204322template <class Emitter >
43214323std::optional<unsigned >
43224324Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
4323- const ValueDecl *ExtendingDecl) {
4325+ const ValueDecl *ExtendingDecl,
4326+ bool IsConstexprUnknown) {
43244327 // Make sure we don't accidentally register the same decl twice.
43254328 if ([[maybe_unused]] const auto *VD =
43264329 dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>())) {
@@ -4349,6 +4352,7 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
43494352 IsTemporary, /* IsMutable=*/ false , Init);
43504353 if (!D)
43514354 return std::nullopt ;
4355+ D->IsConstexprUnknown = IsConstexprUnknown;
43524356
43534357 Scope::Local Local = this ->createLocal (D);
43544358 if (Key)
@@ -4460,9 +4464,10 @@ bool Compiler<Emitter>::visitExpr(const Expr *E, bool DestroyToplevelScope) {
44604464}
44614465
44624466template <class Emitter >
4463- VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD) {
4467+ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
4468+ bool IsConstexprUnknown) {
44644469
4465- auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true );
4470+ auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true , IsConstexprUnknown );
44664471
44674472 if (R.notCreated ())
44684473 return R;
@@ -4550,7 +4555,8 @@ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
45504555
45514556template <class Emitter >
45524557VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
4553- bool Toplevel) {
4558+ bool Toplevel,
4559+ bool IsConstexprUnknown) {
45544560 // We don't know what to do with these, so just return false.
45554561 if (VD->getType ().isNull ())
45564562 return false ;
@@ -4620,7 +4626,8 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46204626
46214627 if (VarT) {
46224628 unsigned Offset = this ->allocateLocalPrimitive (
4623- VD, *VarT, VD->getType ().isConstQualified ());
4629+ VD, *VarT, VD->getType ().isConstQualified (), nullptr ,
4630+ IsConstexprUnknown);
46244631 if (Init) {
46254632 // If this is a toplevel declaration, create a scope for the
46264633 // initializer.
@@ -4636,7 +4643,8 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46364643 }
46374644 }
46384645 } else {
4639- if (std::optional<unsigned > Offset = this ->allocateLocal (VD)) {
4646+ if (std::optional<unsigned > Offset = this ->allocateLocal (
4647+ VD, VD->getType (), nullptr , IsConstexprUnknown)) {
46404648 if (!Init)
46414649 return true ;
46424650
@@ -6461,7 +6469,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
64616469
64626470 // In case we need to re-visit a declaration.
64636471 auto revisit = [&](const VarDecl *VD) -> bool {
6464- auto VarState = this ->visitDecl (VD);
6472+ auto VarState = this ->visitDecl (VD, /* IsConstexprUnknown= */ true );
64656473
64666474 if (VarState.notCreated ())
64676475 return true ;
0 commit comments