mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Fixed zero-initialize array of non-aligned-size structs
This commit is contained in:
parent
2e656e88f3
commit
b544f96bf7
2 changed files with 26 additions and 1 deletions
|
@ -16408,7 +16408,13 @@ void BfExprEvaluator::InitializedSizedArray(BfSizedArrayType* arrayType, BfToken
|
||||||
members.push_back(defaultVal.mValue);
|
members.push_back(defaultVal.mValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mModule->mBfIRBuilder->CreateConstArray(mModule->mBfIRBuilder->MapType(checkArrayType), members);
|
if (checkArrayType->mElementType->IsStruct())
|
||||||
|
{
|
||||||
|
// This fixed cases where we have non-size-aligned initializers. Assume zero-initialized
|
||||||
|
return mModule->mBfIRBuilder->CreateConstStructZero(mModule->mBfIRBuilder->MapType(checkArrayType));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return mModule->mBfIRBuilder->CreateConstArray(mModule->mBfIRBuilder->MapType(checkArrayType), members);
|
||||||
};
|
};
|
||||||
|
|
||||||
_GetValues(arrayType, openToken, valueExprs, commas, closeToken, false);
|
_GetValues(arrayType, openToken, valueExprs, commas, closeToken, false);
|
||||||
|
|
|
@ -1288,6 +1288,25 @@ String BfIRBuilder::ToString(BfIRValue irValue)
|
||||||
BfIRValue targetConst(BfIRValueFlags_Const, ptrToIntConst->mTarget);
|
BfIRValue targetConst(BfIRValueFlags_Const, ptrToIntConst->mTarget);
|
||||||
return ToString(targetConst) + StrFormat(" PtrToInt TypeCode:%d", ptrToIntConst->mToTypeCode);
|
return ToString(targetConst) + StrFormat(" PtrToInt TypeCode:%d", ptrToIntConst->mToTypeCode);
|
||||||
}
|
}
|
||||||
|
else if (constant->mConstType == BfConstType_Array)
|
||||||
|
{
|
||||||
|
auto constArray = (BfConstantArray*)constant;
|
||||||
|
String str = ToString(constArray->mType);
|
||||||
|
str += "(";
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)constArray->mValues.size(); i++)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
str += ", ";
|
||||||
|
str += ToString(constArray->mValues[i]);
|
||||||
|
}
|
||||||
|
str += ");";
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
else if (constant->mConstType == BfConstType_AggZero)
|
||||||
|
{
|
||||||
|
return ToString(constant->mIRType) + " zeroinitializer";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BF_FATAL("Unhandled");
|
BF_FATAL("Unhandled");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue