@@ -355,7 +355,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
355
355
std::nullopt, true , false ,
356
356
/* IsMutable=*/ false , nullptr );
357
357
}
358
- return this ->emitNull (classifyPrim (CE->getType ()), Desc, CE);
358
+
359
+ uint64_t Val = Ctx.getASTContext ().getTargetNullPointerValue (CE->getType ());
360
+ return this ->emitNull (classifyPrim (CE->getType ()), Val, Desc, CE);
359
361
}
360
362
361
363
case CK_PointerToIntegral: {
@@ -3817,7 +3819,7 @@ template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
3817
3819
3818
3820
// Convert pointers to bool.
3819
3821
if (T == PT_Ptr || T == PT_FnPtr) {
3820
- if (!this ->emitNull (*T, nullptr , E))
3822
+ if (!this ->emitNull (*T, 0 , nullptr , E))
3821
3823
return false ;
3822
3824
return this ->emitNE (*T, E);
3823
3825
}
@@ -3857,11 +3859,12 @@ bool Compiler<Emitter>::visitZeroInitializer(PrimType T, QualType QT,
3857
3859
case PT_IntAPS:
3858
3860
return this ->emitZeroIntAPS (Ctx.getBitWidth (QT), E);
3859
3861
case PT_Ptr:
3860
- return this ->emitNullPtr (nullptr , E);
3862
+ return this ->emitNullPtr (Ctx.getASTContext ().getTargetNullPointerValue (QT),
3863
+ nullptr , E);
3861
3864
case PT_FnPtr:
3862
- return this ->emitNullFnPtr (nullptr , E);
3865
+ return this ->emitNullFnPtr (0 , nullptr , E);
3863
3866
case PT_MemberPtr:
3864
- return this ->emitNullMemberPtr (nullptr , E);
3867
+ return this ->emitNullMemberPtr (0 , nullptr , E);
3865
3868
case PT_Float:
3866
3869
return this ->emitConstFloat (APFloat::getZero (Ctx.getFloatSemantics (QT)), E);
3867
3870
case PT_FixedPoint: {
@@ -4421,7 +4424,7 @@ bool Compiler<Emitter>::visitAPValue(const APValue &Val, PrimType ValType,
4421
4424
4422
4425
if (Val.isLValue ()) {
4423
4426
if (Val.isNullPointer ())
4424
- return this ->emitNull (ValType, nullptr , E);
4427
+ return this ->emitNull (ValType, 0 , nullptr , E);
4425
4428
APValue::LValueBase Base = Val.getLValueBase ();
4426
4429
if (const Expr *BaseExpr = Base.dyn_cast <const Expr *>())
4427
4430
return this ->visit (BaseExpr);
@@ -4431,7 +4434,7 @@ bool Compiler<Emitter>::visitAPValue(const APValue &Val, PrimType ValType,
4431
4434
} else if (Val.isMemberPointer ()) {
4432
4435
if (const ValueDecl *MemberDecl = Val.getMemberPointerDecl ())
4433
4436
return this ->emitGetMemberPtr (MemberDecl, E);
4434
- return this ->emitNullMemberPtr (nullptr , E);
4437
+ return this ->emitNullMemberPtr (0 , nullptr , E);
4435
4438
}
4436
4439
4437
4440
return false ;
@@ -4783,7 +4786,8 @@ bool Compiler<Emitter>::VisitCXXNullPtrLiteralExpr(
4783
4786
if (DiscardResult)
4784
4787
return true ;
4785
4788
4786
- return this ->emitNullPtr (nullptr , E);
4789
+ uint64_t Val = Ctx.getASTContext ().getTargetNullPointerValue (E->getType ());
4790
+ return this ->emitNullPtr (Val, nullptr , E);
4787
4791
}
4788
4792
4789
4793
template <class Emitter >
@@ -5333,7 +5337,7 @@ bool Compiler<Emitter>::emitLambdaStaticInvokerBody(const CXXMethodDecl *MD) {
5333
5337
// one here, and we don't need one either because the lambda cannot have
5334
5338
// any captures, as verified above. Emit a null pointer. This is then
5335
5339
// special-cased when interpreting to not emit any misleading diagnostics.
5336
- if (!this ->emitNullPtr (nullptr , MD))
5340
+ if (!this ->emitNullPtr (0 , nullptr , MD))
5337
5341
return false ;
5338
5342
5339
5343
// Forward all arguments from the static invoker to the lambda call operator.
@@ -6483,7 +6487,7 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
6483
6487
if (!this ->discard (SubExpr))
6484
6488
return false ;
6485
6489
6486
- return this ->emitNullPtr (nullptr , E);
6490
+ return this ->emitNullPtr (0 , nullptr , E);
6487
6491
}
6488
6492
6489
6493
if (FromType->isNullPtrType () && ToT) {
0 commit comments