From af49ac60cdddfda8c8a2afcc7aed4f5548e90c88 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:15:22 -0400 Subject: [PATCH] fix shl by 16 constant being mistaken for a dynamic bitfield construction (#600) --- decompiler/IR2/bitfields.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/decompiler/IR2/bitfields.cpp b/decompiler/IR2/bitfields.cpp index 514d40a4a5..6459f81c1b 100644 --- a/decompiler/IR2/bitfields.cpp +++ b/decompiler/IR2/bitfields.cpp @@ -581,6 +581,19 @@ std::optional get_goal_integer_constant(Form* in, const Env&) { return result; } } + + // also (shl 16) + matcher = Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::SHL), + {Matcher::any(1), Matcher::integer(16)}); + mr = match(matcher, in); + if (mr.matched) { + auto arg_as_atom = form_as_atom(mr.maps.forms.at(1)); + if (arg_as_atom && arg_as_atom->is_int()) { + u64 result = arg_as_atom->get_int(); + result <<= 16ull; + return result; + } + } return {}; }