Skip to content

Commit 494de63

Browse files
Update fwdanalysis.cpp
1 parent a04c97c commit 494de63

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

lib/fwdanalysis.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "token.h"
2727
#include "vfvalue.h"
2828

29+
#include <deque>
2930
#include <list>
3031
#include <string>
3132
#include <utility>
@@ -478,9 +479,18 @@ bool FwdAnalysis::hasOperand(const Token *tok, const Token *lhs) const
478479
{
479480
if (!tok)
480481
return false;
481-
if (isSameExpression(false, tok, lhs, mSettings, false, false, nullptr))
482-
return true;
483-
return hasOperand(tok->astOperand1(), lhs) || hasOperand(tok->astOperand2(), lhs);
482+
std::deque<const Token*> nodes{ tok };
483+
while (!nodes.empty()) {
484+
const Token* node = nodes.front();
485+
if (isSameExpression(false, node, lhs, mSettings, false, false, nullptr))
486+
return true;
487+
if (node->astOperand1())
488+
nodes.emplace_back(node->astOperand1());
489+
if (node->astOperand2())
490+
nodes.emplace_back(node->astOperand2());
491+
nodes.pop_front();
492+
}
493+
return false;
484494
}
485495

486496
const Token *FwdAnalysis::reassign(const Token *expr, const Token *startToken, const Token *endToken)

0 commit comments

Comments
 (0)