From 7870b20f96fc383f9cd74fa03a2bb0414a5d3d91 Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Fri, 10 May 2019 09:56:09 -0400 Subject: [PATCH] hidden extensions with multiple descendants --- .../Decompiler/src/decompile/cpp/printc.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc index ecb93d8d70..3d6e4a6d9f 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc @@ -1289,14 +1289,15 @@ bool PrintC::isExtensionCastImplied(const PcodeOp *op) const } else { - PcodeOp *expOp = outVn->loneDescend(); - if (expOp != (PcodeOp *)0) { - type_metatype metatype = outVn->getHigh()->getType()->getMetatype(); + type_metatype metatype = outVn->getHigh()->getType()->getMetatype(); + list::const_iterator iter; + for(iter=outVn->beginDescend();iter!=outVn->endDescend();++iter) { + PcodeOp *expOp = *iter; Varnode *otherVn; int4 slot; switch(expOp->code()) { case CPUI_PTRADD: - return true; + break; case CPUI_INT_ADD: case CPUI_INT_SUB: case CPUI_INT_MULT: @@ -1311,13 +1312,16 @@ bool PrintC::isExtensionCastImplied(const PcodeOp *op) const slot = expOp->getSlot(outVn); otherVn = expOp->getIn(1-slot); // Check if the expression involves an explicit variable of the right integer type - if (otherVn->isExplicit() && otherVn->getHigh()->getType()->getMetatype() == metatype) - return true; + if (!otherVn->isExplicit()) + return false; + if (otherVn->getHigh()->getType()->getMetatype() != metatype) + return false; break; default: - break; + return false; } } + return true; // Everything is integer promotion } return false; }