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

Function QList1

test/cfg/qt.cpp:282–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void QList1(QList<int> intListArg)
283{
284 for (int i = 0; i <= intListArg.size(); ++i) {
285 // cppcheck-suppress stlOutOfBounds
286 intListArg[i] = 1;
287 }
288 // cppcheck-suppress containerOutOfBoundsIndexExpression
289 intListArg[intListArg.length()] = 5;
290 // cppcheck-suppress containerOutOfBoundsIndexExpression
291 intListArg[intListArg.count()] = 10;
292 // cppcheck-suppress containerOutOfBoundsIndexExpression
293 printf("val: %d\n", intListArg[intListArg.size()]);
294
295 QList<QString> qstringList1{"one", "two"};
296 (void)qstringList1[1];
297
298 QList<QString> qstringList2 = {"one", "two"};
299 (void)qstringList2[1];
300 qstringList2.clear();
301 // cppcheck-suppress containerOutOfBounds
302 (void)qstringList2[1];
303
304 QList<QString> qstringList3;
305 qstringList3 << "one" << "two";
306 (void)qstringList3[1];
307 // FIXME: The following should have a containerOutOfBounds suppression #9242
308 (void)qstringList3[3];
309 // cppcheck-suppress ignoredReturnValue
310 qstringList3.startsWith("one");
311 // cppcheck-suppress ignoredReturnValue
312 qstringList3.endsWith("one");
313 // cppcheck-suppress ignoredReturnValue
314 qstringList3.count();
315 // cppcheck-suppress ignoredReturnValue
316 qstringList3.length();
317 // cppcheck-suppress ignoredReturnValue
318 qstringList3.size();
319 // cppcheck-suppress ignoredReturnValue
320 qstringList3.at(5);
321 // cppcheck-suppress invalidFunctionArg
322 (void)qstringList3.at(-5);
323
324 QList<QString> qstringList4;
325 // cppcheck-suppress containerOutOfBounds
326 (void)qstringList4[0];
327 qstringList4.append("a");
328 (void)qstringList4[0];
329 qstringList4.clear();
330 // cppcheck-suppress containerOutOfBounds
331 (void)qstringList4[0];
332}
333
334QList<int> QList2() { // #10556
335 QList<int> v;

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected