mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
Iterate statement form
This commit is contained in:
parent
b2bc1eb019
commit
3644c120c0
1 changed files with 25 additions and 13 deletions
|
@ -3058,23 +3058,35 @@ PcodeOp *BlockWhileDo::testTerminal(Funcdata &data,int4 slot) const
|
|||
return resOp;
|
||||
}
|
||||
|
||||
/// This is a final sanity check on the \e iterate statement. If statement is just a
|
||||
/// CAST or COPY, we revert to displaying the whole loop using \e while
|
||||
/// \return \b true is the statement looks like a suitable for-loop iterator.
|
||||
/// Make sure the loop variable is involved as input in the iterator statement.
|
||||
/// \return \b true if the loop variable is an input to the iterator statement
|
||||
bool BlockWhileDo::testIterateForm(void) const
|
||||
|
||||
{
|
||||
PcodeOp *curOp = iterateOp;
|
||||
OpCode opc = curOp->code();
|
||||
while(opc == CPUI_COPY || opc == CPUI_CAST) {
|
||||
Varnode *vn = curOp->getIn(0);
|
||||
if (!curOp->notPrinted())
|
||||
if (vn->isExplicit()) return false; // End of statement, no substantive op seen
|
||||
if (!vn->isWritten()) return false;
|
||||
curOp = vn->getDef();
|
||||
opc = curOp->code();
|
||||
Varnode *targetVn = loopDef->getOut();
|
||||
HighVariable *high = targetVn->getHigh();
|
||||
|
||||
vector<PcodeOpNode> path;
|
||||
PcodeOp *op = iterateOp;
|
||||
path.push_back(PcodeOpNode(op,0));
|
||||
while(!path.empty()) {
|
||||
PcodeOpNode &node(path.back());
|
||||
if (node.op->numInput() <= node.slot) {
|
||||
path.pop_back();
|
||||
continue;
|
||||
}
|
||||
Varnode *vn = node.op->getIn(node.slot);
|
||||
node.slot += 1;
|
||||
if (vn->isAnnotation()) continue;
|
||||
if (vn->getHigh() == high) {
|
||||
return true;
|
||||
}
|
||||
if (vn->isExplicit()) continue; // Truncate at explicit
|
||||
if (!vn->isWritten()) continue;
|
||||
op = vn->getDef();
|
||||
path.push_back(PcodeOpNode(vn->getDef(),0));
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void BlockWhileDo::markLabelBumpUp(bool bump)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue