mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-11 04:52:21 +02:00
ReadConstant handling of null pointers
This commit is contained in:
parent
65ee34e37b
commit
8c1d1e65b3
1 changed files with 16 additions and 0 deletions
|
@ -1413,6 +1413,22 @@ BfIRValue BfIRConstHolder::ReadConstant(void* ptr, BfType* type)
|
||||||
return CreateConst(BfTypeCode_StringId, *(int32*)ptr);
|
return CreateConst(BfTypeCode_StringId, *(int32*)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type->IsPointer())
|
||||||
|
{
|
||||||
|
bool isZero = false;
|
||||||
|
if (mModule->mSystem->mPtrSize == 4)
|
||||||
|
isZero = *(int32*)ptr == 0;
|
||||||
|
else
|
||||||
|
isZero = *(int64*)ptr == 0;
|
||||||
|
if (isZero)
|
||||||
|
{
|
||||||
|
BfIRType irType;
|
||||||
|
irType.mKind = BfIRTypeData::TypeKind_TypeId;
|
||||||
|
irType.mId = type->mTypeId;
|
||||||
|
return CreateConstNull(irType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return BfIRValue();
|
return BfIRValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue