| 724 | } |
| 725 | |
| 726 | void assume(const Token* tok, bool state, unsigned int flags) override { |
| 727 | // Update program state |
| 728 | pms.removeModifiedVars(tok); |
| 729 | pms.addState(tok, getProgramState()); |
| 730 | pms.assume(tok, state, flags & Assume::ContainerEmpty); |
| 731 | |
| 732 | bool isCondBlock = false; |
| 733 | const Token* parent = tok->astParent(); |
| 734 | if (parent) { |
| 735 | isCondBlock = Token::Match(parent->previous(), "if|while ("); |
| 736 | } |
| 737 | |
| 738 | if (isCondBlock) { |
| 739 | const Token* startBlock = parent->link()->next(); |
| 740 | if (Token::simpleMatch(startBlock, ";") && Token::simpleMatch(parent->tokAt(-2), "} while (")) |
| 741 | startBlock = parent->linkAt(-2); |
| 742 | const Token* endBlock = startBlock->link(); |
| 743 | if (state) { |
| 744 | pms.removeModifiedVars(endBlock); |
| 745 | pms.addState(endBlock->previous(), getProgramState()); |
| 746 | } else { |
| 747 | if (Token::simpleMatch(endBlock, "} else {")) |
| 748 | pms.addState(endBlock->linkAt(2)->previous(), getProgramState()); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | if (!(flags & Assume::Quiet)) { |
| 753 | if (flags & Assume::ContainerEmpty) { |
| 754 | std::string s = state ? "empty" : "not empty"; |
| 755 | addErrorPath(tok, "Assuming container is " + s); |
| 756 | } else { |
| 757 | std::string s = bool_to_string(state); |
| 758 | addErrorPath(tok, "Assuming condition is " + s); |
| 759 | } |
| 760 | } |
| 761 | if (!(flags & Assume::Absolute)) |
| 762 | makeConditional(); |
| 763 | } |
| 764 | |
| 765 | void updateState(const Token* tok) override |
| 766 | { |
nothing calls this directly
no test coverage detected