@@ -4057,7 +4057,7 @@ template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
40574057 return true ;
40584058
40594059 // Convert pointers to bool.
4060- if (T == PT_Ptr || T == PT_FnPtr ) {
4060+ if (T == PT_Ptr) {
40614061 if (!this ->emitNull (*T, 0 , nullptr , E))
40624062 return false ;
40634063 return this ->emitNE (*T, E);
@@ -4103,8 +4103,6 @@ bool Compiler<Emitter>::visitZeroInitializer(PrimType T, QualType QT,
41034103 case PT_Ptr:
41044104 return this ->emitNullPtr (Ctx.getASTContext ().getTargetNullPointerValue (QT),
41054105 nullptr , E);
4106- case PT_FnPtr:
4107- return this ->emitNullFnPtr (0 , nullptr , E);
41084106 case PT_MemberPtr:
41094107 return this ->emitNullMemberPtr (0 , nullptr , E);
41104108 case PT_Float:
@@ -4255,7 +4253,6 @@ bool Compiler<Emitter>::emitConst(T Value, PrimType Ty, const Expr *E) {
42554253 case PT_Bool:
42564254 return this ->emitConstBool (Value, E);
42574255 case PT_Ptr:
4258- case PT_FnPtr:
42594256 case PT_MemberPtr:
42604257 case PT_Float:
42614258 case PT_IntAP:
@@ -4293,7 +4290,8 @@ bool Compiler<Emitter>::emitConst(const APSInt &Value, const Expr *E) {
42934290
42944291template <class Emitter >
42954292unsigned Compiler<Emitter>::allocateLocalPrimitive(
4296- DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl) {
4293+ DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl,
4294+ bool IsConstexprUnknown) {
42974295 // Make sure we don't accidentally register the same decl twice.
42984296 if (const auto *VD =
42994297 dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>())) {
@@ -4307,6 +4305,7 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(
43074305 // or isa<MaterializeTemporaryExpr>().
43084306 Descriptor *D = P.createDescriptor (Src, Ty, nullptr , Descriptor::InlineDescMD,
43094307 IsConst, isa<const Expr *>(Src));
4308+ D->IsConstexprUnknown = IsConstexprUnknown;
43104309 Scope::Local Local = this ->createLocal (D);
43114310 if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>()))
43124311 Locals.insert ({VD, Local});
@@ -4320,7 +4319,8 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(
43204319template <class Emitter >
43214320std::optional<unsigned >
43224321Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
4323- const ValueDecl *ExtendingDecl) {
4322+ const ValueDecl *ExtendingDecl,
4323+ bool IsConstexprUnknown) {
43244324 // Make sure we don't accidentally register the same decl twice.
43254325 if ([[maybe_unused]] const auto *VD =
43264326 dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>())) {
@@ -4349,6 +4349,7 @@ Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
43494349 IsTemporary, /* IsMutable=*/ false , Init);
43504350 if (!D)
43514351 return std::nullopt ;
4352+ D->IsConstexprUnknown = IsConstexprUnknown;
43524353
43534354 Scope::Local Local = this ->createLocal (D);
43544355 if (Key)
@@ -4460,9 +4461,10 @@ bool Compiler<Emitter>::visitExpr(const Expr *E, bool DestroyToplevelScope) {
44604461}
44614462
44624463template <class Emitter >
4463- VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD) {
4464+ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD,
4465+ bool IsConstexprUnknown) {
44644466
4465- auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true );
4467+ auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true , IsConstexprUnknown );
44664468
44674469 if (R.notCreated ())
44684470 return R;
@@ -4550,7 +4552,8 @@ bool Compiler<Emitter>::visitDeclAndReturn(const VarDecl *VD,
45504552
45514553template <class Emitter >
45524554VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
4553- bool Toplevel) {
4555+ bool Toplevel,
4556+ bool IsConstexprUnknown) {
45544557 // We don't know what to do with these, so just return false.
45554558 if (VD->getType ().isNull ())
45564559 return false ;
@@ -4620,7 +4623,8 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46204623
46214624 if (VarT) {
46224625 unsigned Offset = this ->allocateLocalPrimitive (
4623- VD, *VarT, VD->getType ().isConstQualified ());
4626+ VD, *VarT, VD->getType ().isConstQualified (), nullptr ,
4627+ IsConstexprUnknown);
46244628 if (Init) {
46254629 // If this is a toplevel declaration, create a scope for the
46264630 // initializer.
@@ -4636,7 +4640,8 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD,
46364640 }
46374641 }
46384642 } else {
4639- if (std::optional<unsigned > Offset = this ->allocateLocal (VD)) {
4643+ if (std::optional<unsigned > Offset = this ->allocateLocal (
4644+ VD, VD->getType (), nullptr , IsConstexprUnknown)) {
46404645 if (!Init)
46414646 return true ;
46424647
@@ -4948,7 +4953,7 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
49484953 // If we know the callee already, check the known parametrs for nullability.
49494954 if (FuncDecl && NonNullArgs[ArgIndex]) {
49504955 PrimType ArgT = classify (Arg).value_or (PT_Ptr);
4951- if (ArgT == PT_Ptr || ArgT == PT_FnPtr ) {
4956+ if (ArgT == PT_Ptr) {
49524957 if (!this ->emitCheckNonNullArg (ArgT, Arg))
49534958 return false ;
49544959 }
@@ -5989,7 +5994,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
59895994 if (!this ->visit (SubExpr))
59905995 return false ;
59915996
5992- if (T == PT_Ptr || T == PT_FnPtr ) {
5997+ if (T == PT_Ptr) {
59935998 if (!this ->emitIncPtr (E))
59945999 return false ;
59956000
@@ -6013,7 +6018,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
60136018 if (!this ->visit (SubExpr))
60146019 return false ;
60156020
6016- if (T == PT_Ptr || T == PT_FnPtr ) {
6021+ if (T == PT_Ptr) {
60176022 if (!this ->emitDecPtr (E))
60186023 return false ;
60196024
@@ -6037,7 +6042,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
60376042 if (!this ->visit (SubExpr))
60386043 return false ;
60396044
6040- if (T == PT_Ptr || T == PT_FnPtr ) {
6045+ if (T == PT_Ptr) {
60416046 if (!this ->emitLoadPtr (E))
60426047 return false ;
60436048 if (!this ->emitConstUint8 (1 , E))
@@ -6080,7 +6085,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
60806085 if (!this ->visit (SubExpr))
60816086 return false ;
60826087
6083- if (T == PT_Ptr || T == PT_FnPtr ) {
6088+ if (T == PT_Ptr) {
60846089 if (!this ->emitLoadPtr (E))
60856090 return false ;
60866091 if (!this ->emitConstUint8 (1 , E))
@@ -6461,7 +6466,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
64616466
64626467 // In case we need to re-visit a declaration.
64636468 auto revisit = [&](const VarDecl *VD) -> bool {
6464- auto VarState = this ->visitDecl (VD);
6469+ auto VarState = this ->visitDecl (VD, /* IsConstexprUnknown= */ true );
64656470
64666471 if (VarState.notCreated ())
64676472 return true ;
0 commit comments