qt.cfg: Add container and function configurations for QVector (#2052)

Reference: https://doc.qt.io/qt-5/qvector.html
This commit is contained in:
Sebastian 2019-07-31 13:58:55 +02:00 committed by GitHub
parent a3dc2db77a
commit 549452b7b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 314 additions and 0 deletions

View File

@ -3242,6 +3242,261 @@
<use-retval/>
<const/>
</function>
<!-- QVector https://doc.qt.io/qt-5/qvector.html -->
<!-- void QVector::append(const T &value) -->
<!-- void QVector::append(T &&value) -->
<!-- void QVector::append(const QVector<T> &value) -->
<function name="QVector::append">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- const T &QVector::at(int i) const -->
<function name="QVector::at">
<noreturn>false</noreturn>
<use-retval/>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>0:</valid>
</arg>
</function>
<!-- void QVector::clear() -->
<function name="QVector::clear">
<noreturn>false</noreturn>
<returnValue type="void"/>
</function>
<!-- bool QVector::contains(const T &value) const -->
<function name="QVector::contains">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int QVector::count(const T &value) const -->
<!-- int QVector::count() const -->
<function name="QVector::count">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<leak-ignore/>
<const/>
<arg nr="1" direction="in" default="">
<not-uninit/>
</arg>
</function>
<!-- T *QVector::data() -->
<!-- const T *QVector::data() const -->
<function name="QVector::data">
<noreturn>false</noreturn>
<use-retval/>
</function>
<!-- bool QVector::empty() const -->
<function name="QVector::empty">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<const/>
</function>
<!-- bool QVector::endsWith(const T &value) const -->
<function name="QVector::endsWith">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- QVector<T> &QVector::fill(const T &value, int size = ...) -->
<function name="QVector::fill">
<noreturn>false</noreturn>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in" default="-1">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- int QVector::indexOf(const T &value, int from = ...) const -->
<function name="QVector::indexOf">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in" default="">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- void QVector::insert(int i, int count, const T &value) -->
<!-- QVector::iterator QVector::insert(QVector::iterator before, int count, const T &value) -->
<function name="QVector::insert">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
</arg>
</function>
<!-- bool QVector::isEmpty() const -->
<function name="QVector::isEmpty">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<const/>
</function>
<!-- int QVector::lastIndexOf(const T &value, int from = ...) const -->
<function name="QVector::lastIndexOf">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
<arg nr="2" direction="in" default="-1">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- int QVector::length() const -->
<function name="QVector::length">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<const/>
</function>
<!-- void QVector::push_back(const T &value) -->
<!-- void QVector::push_back(T &&value) -->
<function name="QVector::push_back">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- void QVector::remove(int i) -->
<!-- void QVector::remove(int i, int count) -->
<function name="QVector::remove">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<arg nr="2" direction="in" default="">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- int QVector::removeAll(const T &t) -->
<function name="QVector::removeAll">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- void QVector::removeAt(int i) -->
<function name="QVector::removeAt">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- void QVector::replace(int i, const T &value) -->
<function name="QVector::replace">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
<valid>0:</valid>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
</arg>
</function>
<!-- void QVector::reserve(int size) -->
<function name="QVector::reserve">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- void QVector::resize(int size) -->
<function name="QVector::resize">
<noreturn>false</noreturn>
<returnValue type="false"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int QVector::size() const -->
<function name="QVector::size">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<const/>
</function>
<!-- void QVector::squeeze() -->
<function name="QVector::squeeze">
<noreturn>false</noreturn>
<returnValue type="void"/>
</function>
<!-- bool QVector::startsWith(const T &value) const -->
<function name="QVector::startsWith">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<leak-ignore/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- void QVector::swap(QVector<T> &other) -->
<function name="QVector::swap">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1"/>
</function>
<!-- T QVector::value(int i) const -->
<!-- T QVector::value(int i, const T &defaultValue) const -->
<function name="QVector::value">
<noreturn>false</noreturn>
<use-retval/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<arg nr="2" direction="in" default="">
<not-uninit/>
</arg>
</function>
<!-- ##### Container ##### -->
<container id="qtContainer" opLessAllowed="false">
<type templateParameter="0"/>
@ -3276,6 +3531,26 @@
<function name="back" yields="item"/>
</access>
</container>
<container id="qtVector" startPattern="QVector &lt;" inherits="qtContainer" opLessAllowed="true">
<size>
<function name="resize" action="resize"/>
<function name="push_back" action="push"/>
<function name="push_front" action="push"/>
<function name="pop_back" action="pop"/>
<function name="pop_front" action="pop"/>
</size>
<access indexOperator="array-like">
<function name="at" yields="at_index"/>
<function name="front" yields="item"/>
<function name="first" yields="item"/>
<function name="back" yields="item"/>
<function name="last" yields="item"/>
<function name="data" yields="buffer"/>
<function name="shrink_to_fit" action="change-internal"/>
<function name="squeeze" action="change-internal"/>
<function name="reserve" action="change-internal"/>
</access>
</container>
<container id="qtString" startPattern="QString" endPattern="" inherits="qtContainer" opLessAllowed="true">
<type string="std-like"/>
<size>

View File

@ -9,6 +9,7 @@
#include <QObject>
#include <QString>
#include <QVector>
#include <QtPlugin>
#include <QFile>
#include <cstdio>
@ -30,6 +31,44 @@ int QString2()
return s.size();
}
void QVector1(QVector<int> 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<QString> qstringVector1{"one", "two"};
(void)qstringVector1[1];
QVector<QString> qstringVector2 = {"one", "two"};
(void)qstringVector2[1];
QVector<QString> 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