From 7115cb8e826d10872c386cf5d47887e0b6cccd20 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 16 Dec 2021 11:18:57 -0500 Subject: [PATCH] Fixed bitcast null issue --- IDEHelper/Compiler/BfIRBuilder.cpp | 1 + IDEHelper/Compiler/BfModule.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index 8e1ace33..95307c23 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -866,6 +866,7 @@ BfIRValue BfIRConstHolder::CreateConstBitCast(BfIRValue val, BfIRType type) bitCast->mConstType = BfConstType_BitCastNull; else bitCast->mConstType = BfConstType_BitCast; + BF_ASSERT(val.mId != -1); bitCast->mTarget = val.mId; bitCast->mToType = type; diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index ba13dae6..1454d2ec 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -10880,6 +10880,8 @@ void BfModule::CurrentAddToConstHolder(BfIRValue& irVal) newVal = BfIRValue(BfIRValueFlags_Const, bitcast->mTarget); CurrentAddToConstHolder(newVal); } + else + newVal = mCurTypeInstance->GetOrCreateConstHolder()->CreateConstNull(); irVal = mCurTypeInstance->GetOrCreateConstHolder()->CreateConstBitCast(newVal, bitcast->mToType); return; }