| 1810 | } |
| 1811 | |
| 1812 | static bool isZeroBoundCond(const Token * const cond, bool reverse) |
| 1813 | { |
| 1814 | if (cond == nullptr || !cond->isBinaryOp()) |
| 1815 | return false; |
| 1816 | |
| 1817 | const Token* op = reverse ? cond->astOperand1() : cond->astOperand2(); |
| 1818 | if (!op->hasKnownIntValue()) |
| 1819 | return true; |
| 1820 | |
| 1821 | // Assume unsigned |
| 1822 | const bool isZero = op->getKnownIntValue() == 0; |
| 1823 | std::string cmp = cond->str(); |
| 1824 | if (reverse) { |
| 1825 | if (cmp[0] == '>') |
| 1826 | cmp[0] = '<'; |
| 1827 | else if (cmp[0] == '<') |
| 1828 | cmp[0] = '>'; |
| 1829 | } |
| 1830 | |
| 1831 | if (cmp == "==" || cmp == ">=") |
| 1832 | return isZero; |
| 1833 | if (cmp == "<=") |
| 1834 | return true; |
| 1835 | if (cmp == "<") |
| 1836 | return !isZero; |
| 1837 | return false; |
| 1838 | } |
| 1839 | |
| 1840 | bool isOppositeCond(bool isNot, const Token * const cond1, const Token * const cond2, const Settings& settings, bool pure, bool followVar, ErrorPath* errors) |
| 1841 | { |
no test coverage detected