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

Function QStringList1

test/cfg/qt.cpp:397–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395#endif
396
397void QStringList1(QStringList stringlistArg)
398{
399 for (int i = 0; i <= stringlistArg.size(); ++i) {
400 // cppcheck-suppress stlOutOfBounds
401 stringlistArg[i] = "abc";
402 }
403 // cppcheck-suppress containerOutOfBoundsIndexExpression
404 stringlistArg[stringlistArg.length()] = "ab";
405 stringlistArg[stringlistArg.length() - 1] = "ab"; // could be valid
406 // cppcheck-suppress containerOutOfBoundsIndexExpression
407 stringlistArg[stringlistArg.count()] = "12";
408 stringlistArg[stringlistArg.count() - 1] = "12"; // could be valid
409 // cppcheck-suppress containerOutOfBoundsIndexExpression
410 (void)stringlistArg[stringlistArg.size()];
411 (void)stringlistArg[stringlistArg.size() - 1]; // could be valid
412
413 QStringList qstringlist1{"one", "two"};
414 (void)qstringlist1[1];
415
416 QStringList qstringlist2 = {"one", "two"};
417 (void)qstringlist2[1];
418
419 QStringList qstringlist3;
420 qstringlist3 << "one" << "two";
421 (void)qstringlist3[1];
422 // FIXME: The following should have a containerOutOfBounds suppression #9242
423 (void)qstringlist3[3];
424 // cppcheck-suppress ignoredReturnValue
425 qstringlist3.startsWith("one");
426 // cppcheck-suppress ignoredReturnValue
427 qstringlist3.endsWith("one");
428 // cppcheck-suppress ignoredReturnValue
429 qstringlist3.count();
430 // cppcheck-suppress ignoredReturnValue
431 qstringlist3.length();
432 // cppcheck-suppress ignoredReturnValue
433 qstringlist3.size();
434 // cppcheck-suppress ignoredReturnValue
435 qstringlist3.at(5);
436 // cppcheck-suppress invalidFunctionArg
437 (void)qstringlist3.at(-5);
438}
439
440QStringList::iterator QStringList2()
441{

Callers

nothing calls this directly

Calls 4

startsWithMethod · 0.80
endsWithMethod · 0.80
atMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected