From 251a8bb3791745d2d80663ef499187b23cbde6ca Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 26 Oct 2020 12:51:01 -0700 Subject: [PATCH] Fixed boxing from ternary operator --- IDEHelper/Compiler/BfExprEvaluator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index a6819824..85983951 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -16046,7 +16046,7 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr) } if (isConstBranch) - { + { BfExpression* actualExpr = (constResult) ? condExpr->mTrueExpression : condExpr->mFalseExpression; BfExpression* ignoredExpr = (constResult) ? condExpr->mFalseExpression : condExpr->mTrueExpression; @@ -16090,6 +16090,8 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr) mModule->mBfIRBuilder->CreateCondBr(condResult.mValue, trueBB, falseBB); + SetAndRestoreValue prevInCondBlock(mModule->mCurMethodState->mCurScope->mInnerIsConditional, true); + mModule->AddBasicBlock(trueBB); auto trueValue = mModule->CreateValueFromExpression(condExpr->mTrueExpression, mExpectingType, (BfEvalExprFlags)(BfEvalExprFlags_NoCast | BfEvalExprFlags_CreateConditionalScope)); if ((mExpectingType != NULL) && (trueValue) && (trueValue.mType != mExpectingType)) @@ -16116,6 +16118,8 @@ void BfExprEvaluator::Visit(BfConditionalExpression* condExpr) mModule->FixIntUnknown(falseValue); } + prevInCondBlock.Restore(); + bool isValid = trueValue && falseValue; if (isValid)