MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / isContainerSizeGE

Method isContainerSizeGE

lib/checkstl.cpp:288–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288bool CheckStlImpl::isContainerSizeGE(const Token * containerToken, const Token *expr) const
289{
290 if (!expr)
291 return false;
292 if (isContainerSize(containerToken, expr))
293 return true;
294 if (expr->str() == "*") {
295 const Token *mul;
296 if (isContainerSize(containerToken, expr->astOperand1()))
297 mul = expr->astOperand2();
298 else if (isContainerSize(containerToken, expr->astOperand2()))
299 mul = expr->astOperand1();
300 else
301 return false;
302 return mul && (!mul->hasKnownIntValue() || mul->getKnownIntValue() != 0);
303 }
304 if (expr->str() == "+") {
305 const Token *op;
306 if (isContainerSize(containerToken, expr->astOperand1()))
307 op = expr->astOperand2();
308 else if (isContainerSize(containerToken, expr->astOperand2()))
309 op = expr->astOperand1();
310 else
311 return false;
312 return op && op->getValueGE(0, mSettings);
313 }
314 return false;
315}
316
317void CheckStlImpl::outOfBoundsIndexExpression()
318{

Callers

nothing calls this directly

Calls 6

astOperand1Method · 0.80
astOperand2Method · 0.80
getKnownIntValueMethod · 0.80
getValueGEMethod · 0.80
strMethod · 0.45
hasKnownIntValueMethod · 0.45

Tested by

no test coverage detected