From 549452b7b975f11169a1b0872d17555268284a99 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 31 Jul 2019 13:58:55 +0200 Subject: [PATCH] qt.cfg: Add container and function configurations for QVector (#2052) Reference: https://doc.qt.io/qt-5/qvector.html --- cfg/qt.cfg | 275 ++++++++++++++++++++++++++++++++++++++++++++++++ test/cfg/qt.cpp | 39 +++++++ 2 files changed, 314 insertions(+) diff --git a/cfg/qt.cfg b/cfg/qt.cfg index 7af983487..1e5e8c4c3 100644 --- a/cfg/qt.cfg +++ b/cfg/qt.cfg @@ -3242,6 +3242,261 @@ + + + + + + false + + + + + + + + + false + + + + + + 0: + + + + + false + + + + + false + + + + + + + + + + + + false + + + + + + + + + + + + false + + + + + false + + + + + + + false + + + + + + + + + + false + + + + + + + + + + + false + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + false + + + + + + + false + + + + + + + + + + + + + + + false + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + + + + false + + + + + + + + false + + + + + + + + false + + + + 0: + + + + + + + + false + + + + + + + + false + + + + + + + + false + + + + + + + false + + + + + false + + + + + + + + + + + false + + + + + + + false + + + + + + + + + + @@ -3276,6 +3531,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index 482696f7f..ab5a8a23c 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,44 @@ int QString2() return s.size(); } +void QVector1(QVector intVectorArg) +{ + for (int i = 0; i <= intVectorArg.size(); ++i) { + // cppcheck-suppress stlOutOfBounds + intVectorArg[i] = 1; + } + // cppcheck-suppress containerOutOfBoundsIndexExpression + intVectorArg[intVectorArg.length()] = 5; + // cppcheck-suppress containerOutOfBoundsIndexExpression + intVectorArg[intVectorArg.count()] = 10; + // cppcheck-suppress containerOutOfBoundsIndexExpression + printf("val: %d\n", intVectorArg[intVectorArg.size()]); + + QVector qstringVector1{"one", "two"}; + (void)qstringVector1[1]; + + QVector qstringVector2 = {"one", "two"}; + (void)qstringVector2[1]; + + QVector qstringVector3; + qstringVector3 << "one" << "two"; + //(void)qstringVector3[1]; // TODO: no containerOutOfBounds error should be shown #9242 + // cppcheck-suppress ignoredReturnValue + qstringVector3.startsWith("one"); + // cppcheck-suppress ignoredReturnValue + qstringVector3.endsWith("one"); + // cppcheck-suppress ignoredReturnValue + qstringVector3.count(); + // cppcheck-suppress ignoredReturnValue + qstringVector3.length(); + // cppcheck-suppress ignoredReturnValue + qstringVector3.size(); + // cppcheck-suppress ignoredReturnValue + qstringVector3.at(5); + // cppcheck-suppress invalidFunctionArg + (void)qstringVector3.at(-5); +} + // Verify that Qt macros do not result in syntax errors, false positives or other issues. class MacroTest1: public QObject { Q_OBJECT