| 199 | } |
| 200 | |
| 201 | static std::string indexValueString(const ValueFlow::Value& indexValue, const std::string& containerName = "") |
| 202 | { |
| 203 | if (indexValue.isIteratorStartValue()) |
| 204 | return "at position " + MathLib::toString(indexValue.intvalue) + " from the beginning"; |
| 205 | if (indexValue.isIteratorEndValue()) |
| 206 | return "at position " + MathLib::toString(-indexValue.intvalue) + " from the end"; |
| 207 | std::string indexString = MathLib::toString(indexValue.intvalue); |
| 208 | if (indexValue.isSymbolicValue()) { |
| 209 | indexString = containerName + ".size()"; |
| 210 | if (indexValue.intvalue != 0) |
| 211 | indexString += "+" + MathLib::toString(indexValue.intvalue); |
| 212 | } |
| 213 | if (indexValue.bound == ValueFlow::Value::Bound::Lower) |
| 214 | return "greater or equal to " + indexString; |
| 215 | return indexString; |
| 216 | } |
| 217 | |
| 218 | void CheckStlImpl::outOfBoundsError(const Token *tok, const std::string &containerName, const ValueFlow::Value *containerSize, const std::string &index, const ValueFlow::Value *indexValue) |
| 219 | { |
no test coverage detected