From 13445bad31b60db063d454fefa6d6697889f428d Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Mon, 14 Apr 2025 10:10:42 -0400 Subject: Handle var assign with split src in pseudo C/Rust Fixes issue with absent rhs when the instruction is HLIL_ASSIGN with a source expression of HLIL_SPLIT (var_60.q = r1:r0) --- lang/c/pseudoc.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'lang/c/pseudoc.cpp') diff --git a/lang/c/pseudoc.cpp b/lang/c/pseudoc.cpp index ac1fe3bb..55a3c2c1 100644 --- a/lang/c/pseudoc.cpp +++ b/lang/c/pseudoc.cpp @@ -1310,9 +1310,9 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H std::optional assignUpdateOperator; std::optional assignUpdateSource; bool assignUpdateNegate = false; - const auto isSplit = destExpr.operation == HLIL_SPLIT; + const auto destIsSplit = destExpr.operation == HLIL_SPLIT; std::optional assignSignedHint; - if (isSplit) + if (destIsSplit) { const auto high = destExpr.GetHighExpr(); const auto low = destExpr.GetLowExpr(); @@ -1328,6 +1328,23 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H tokens.NewLine(); GetExprTextInternal(low, tokens, settings, precedence); } + else if (srcExpr.operation == HLIL_SPLIT) + { + const auto high = srcExpr.GetHighExpr(); + const auto low = srcExpr.GetLowExpr(); + GetExprTextInternal(destExpr, tokens, settings, precedence); + tokens.Append(OperationToken, " = "); + tokens.AppendOpenParen(); + GetExprTextInternal(high, tokens, settings, precedence); + tokens.Append(OperationToken, " << "); + tokens.Append(IntegerToken, std::to_string(low.size * 8)); + tokens.AppendCloseParen(); + tokens.Append(OperationToken, " | "); + GetExprTextInternal(low, tokens, settings, precedence); + tokens.AppendSemicolon(); + tokens.NewLine(); + return; + } else { // Check for assignment with an operator on the same variable as the destination @@ -1454,7 +1471,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H appearsDead = false; } - if (isSplit) + if (destIsSplit) { // const auto high = destExpr.GetHighExpr(); const auto low = destExpr.GetLowExpr(); @@ -1484,7 +1501,7 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H GetExprTextInternal(srcExpr, tokens, settings, AssignmentOperatorPrecedence, false, assignSignedHint); } - if (isSplit) + if (destIsSplit) tokens.AppendCloseParen(); if (appearsDead) -- cgit v1.3.1