Skip to content

Commit a06186a

Browse files
committed
rebase, fix ci
1 parent 5f7a4af commit a06186a

1 file changed

Lines changed: 33 additions & 33 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,8 @@ namespace {
16001600

16011601
ExprIdKey key;
16021602
key.parentOp = tok->astParent()->str();
1603+
key.operand1 = op1 ? op1->exprId() : 0;
1604+
key.operand2 = op2 ? op2->exprId() : 0;
16031605

16041606
if (tok->astParent()->isCast() && tok->astParent()->str() == "(") {
16051607
const Token* typeStartToken;
@@ -1618,42 +1620,40 @@ namespace {
16181620
key.parentOp += type;
16191621
}
16201622

1621-
const auto& refs1 = followAllReferences(op1);
1622-
const auto& refs2 = followAllReferences(op2);
1623-
1624-
for (int i1 = 0; i1 < 1 + refs1.size(); ++i1) {
1625-
for (int i2 = 0; i2 < 1 + refs2.size(); ++i2) {
1626-
key.operand1 = op1 ? (i1 >= refs1.size() ? op1->exprId() : refs1[i1].token->exprId()) : 0;
1627-
key.operand2 = op2 ? (i2 >= refs2.size() ? op2->exprId() : refs2[i2].token->exprId()) : 0;
1628-
1629-
if (key.operand1 > key.operand2 && key.operand2 &&
1630-
Token::Match(tok->astParent(), "%or%|%oror%|+|*|&|&&|^|==|!=")) {
1631-
// In C++ the order of operands of + might matter
1632-
if (!cpp ||
1633-
key.parentOp != "+" ||
1634-
!tok->astParent()->valueType() ||
1635-
tok->astParent()->valueType()->isIntegral() ||
1636-
tok->astParent()->valueType()->isFloat() ||
1637-
tok->astParent()->valueType()->pointer > 0)
1638-
std::swap(key.operand1, key.operand2);
1639-
}
1640-
1641-
const auto it = exprIdMap.find(key);
1642-
if (it == exprIdMap.end()) {
1643-
if (i1 < refs1.size() || i2 < refs2.size())
1644-
// try to find another reference
1645-
continue;
1646-
exprIdMap[key] = id;
1647-
tok->astParent()->exprId(id);
1648-
++id;
1649-
} else {
1650-
tok->astParent()->exprId(it->second);
1651-
}
1652-
setParentExprId(tok->astParent(), cpp, exprIdMap, id);
1653-
i1 = 1 + refs1.size();
1623+
for (const auto& ref: followAllReferences(op1)) {
1624+
if (ref.token->exprId() != 0) {
1625+
key.operand1 = ref.token->exprId();
1626+
break;
1627+
}
1628+
}
1629+
for (const auto& ref: followAllReferences(op2)) {
1630+
if (ref.token->exprId() != 0) {
1631+
key.operand2 = ref.token->exprId();
16541632
break;
16551633
}
16561634
}
1635+
1636+
if (key.operand1 > key.operand2 && key.operand2 &&
1637+
Token::Match(tok->astParent(), "%or%|%oror%|+|*|&|&&|^|==|!=")) {
1638+
// In C++ the order of operands of + might matter
1639+
if (!cpp ||
1640+
key.parentOp != "+" ||
1641+
!tok->astParent()->valueType() ||
1642+
tok->astParent()->valueType()->isIntegral() ||
1643+
tok->astParent()->valueType()->isFloat() ||
1644+
tok->astParent()->valueType()->pointer > 0)
1645+
std::swap(key.operand1, key.operand2);
1646+
}
1647+
1648+
const auto it = exprIdMap.find(key);
1649+
if (it == exprIdMap.end()) {
1650+
exprIdMap[key] = id;
1651+
tok->astParent()->exprId(id);
1652+
++id;
1653+
} else {
1654+
tok->astParent()->exprId(it->second);
1655+
}
1656+
setParentExprId(tok->astParent(), cpp, exprIdMap, id);
16571657
}
16581658
}
16591659

0 commit comments

Comments
 (0)