| 517 | } |
| 518 | |
| 519 | bool isSameSymbolicValue(const Token* tok, ValueFlow::Value* value = nullptr) const |
| 520 | { |
| 521 | if (!useSymbolicValues()) |
| 522 | return false; |
| 523 | if (Token::Match(tok, "%assign%")) |
| 524 | return false; |
| 525 | const ValueFlow::Value* currValue = getValue(tok); |
| 526 | if (!currValue) |
| 527 | return false; |
| 528 | // If the same symbolic value is already there then skip |
| 529 | if (currValue->isSymbolicValue() && |
| 530 | std::any_of(tok->values().cbegin(), tok->values().cend(), [&](const ValueFlow::Value& v) { |
| 531 | return v.isSymbolicValue() && currValue->equalValue(v); |
| 532 | })) |
| 533 | return false; |
| 534 | const bool isPoint = currValue->bound == ValueFlow::Value::Bound::Point && currValue->isIntValue(); |
| 535 | const bool exact = !currValue->isIntValue() || currValue->isImpossible(); |
| 536 | for (const ValueFlow::Value& v : tok->values()) { |
| 537 | if (!v.isSymbolicValue()) |
| 538 | continue; |
| 539 | if (currValue->equalValue(v)) |
| 540 | continue; |
| 541 | const bool toImpossible = v.isImpossible() && currValue->isKnown(); |
| 542 | if (!v.isKnown() && !toImpossible) |
| 543 | continue; |
| 544 | if (exact && v.intvalue != 0 && !isPoint) |
| 545 | continue; |
| 546 | if (astIsUnsigned(tok) != astIsUnsigned(v.tokvalue)) |
| 547 | continue; |
| 548 | std::vector<MathLib::bigint> r; |
| 549 | ValueFlow::Value::Bound bound = currValue->bound; |
| 550 | if (match(v.tokvalue)) { |
| 551 | r = {currValue->intvalue}; |
| 552 | } else if (!exact && findMatch(v.tokvalue)) { |
| 553 | r = evaluate(Evaluate::Integral, v.tokvalue, tok); |
| 554 | if (bound == ValueFlow::Value::Bound::Point) |
| 555 | bound = v.bound; |
| 556 | } |
| 557 | if (!r.empty()) { |
| 558 | if (value) { |
| 559 | value->errorPath.insert(value->errorPath.end(), v.errorPath.cbegin(), v.errorPath.cend()); |
| 560 | value->intvalue = r.front() + v.intvalue; |
| 561 | if (toImpossible) |
| 562 | value->setImpossible(); |
| 563 | value->bound = bound; |
| 564 | } |
| 565 | return true; |
| 566 | } |
| 567 | } |
| 568 | return false; |
| 569 | } |
| 570 | |
| 571 | Action analyzeMatch(const Token* tok, Direction d) const { |
| 572 | const Token* parent = tok->astParent(); |
no test coverage detected