qt.cfg: Add container configuration for QStack (inherits from QVector) (#2102)

This commit is contained in:
Sebastian 2019-08-20 20:37:52 +02:00 committed by GitHub
parent 4b231c53a4
commit 2c673bd380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 119 additions and 27 deletions

View File

@ -3328,10 +3328,11 @@
<const/>
</function>
<!-- QVector https://doc.qt.io/qt-5/qvector.html -->
<!-- QStack inherits from QVector https://doc.qt.io/qt-5/qstack.html -->
<!-- void QVector::append(const T &value) -->
<!-- void QVector::append(T &&value) -->
<!-- void QVector::append(const QVector<T> &value) -->
<function name="QVector::append">
<function name="QVector::append,QStack::append">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
@ -3340,7 +3341,7 @@
</arg>
</function>
<!-- const T &QVector::at(int i) const -->
<function name="QVector::at">
<function name="QVector::at,QStack::at">
<noreturn>false</noreturn>
<use-retval/>
<leak-ignore/>
@ -3351,12 +3352,12 @@
</arg>
</function>
<!-- void QVector::clear() -->
<function name="QVector::clear">
<function name="QVector::clear,QStack::clear">
<noreturn>false</noreturn>
<returnValue type="void"/>
</function>
<!-- bool QVector::contains(const T &value) const -->
<function name="QVector::contains">
<function name="QVector::contains,QStack::contains">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
@ -3368,7 +3369,7 @@
</function>
<!-- int QVector::count(const T &value) const -->
<!-- int QVector::count() const -->
<function name="QVector::count">
<function name="QVector::count,QStack::count">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
@ -3380,19 +3381,19 @@
</function>
<!-- T *QVector::data() -->
<!-- const T *QVector::data() const -->
<function name="QVector::data">
<function name="QVector::data,QStack::data">
<noreturn>false</noreturn>
<use-retval/>
</function>
<!-- bool QVector::empty() const -->
<function name="QVector::empty">
<function name="QVector::empty,QStack::empty">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<const/>
</function>
<!-- bool QVector::endsWith(const T &value) const -->
<function name="QVector::endsWith">
<function name="QVector::endsWith,QStack::endsWith">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
@ -3402,7 +3403,7 @@
</arg>
</function>
<!-- QVector<T> &QVector::fill(const T &value, int size = ...) -->
<function name="QVector::fill">
<function name="QVector::fill,QStack::fill">
<noreturn>false</noreturn>
<arg nr="1" direction="in">
<not-uninit/>
@ -3413,7 +3414,7 @@
</arg>
</function>
<!-- int QVector::indexOf(const T &value, int from = ...) const -->
<function name="QVector::indexOf">
<function name="QVector::indexOf,QStack::indexOf">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
@ -3429,7 +3430,7 @@
</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">
<function name="QVector::insert,QStack::insert">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -3443,14 +3444,14 @@
</arg>
</function>
<!-- bool QVector::isEmpty() const -->
<function name="QVector::isEmpty">
<function name="QVector::isEmpty,QStack::isEmpty">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
<const/>
</function>
<!-- int QVector::lastIndexOf(const T &value, int from = ...) const -->
<function name="QVector::lastIndexOf">
<function name="QVector::lastIndexOf,QStack::lastIndexOf">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
@ -3465,7 +3466,7 @@
</arg>
</function>
<!-- int QVector::length() const -->
<function name="QVector::length">
<function name="QVector::length,QStack::length">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
@ -3473,7 +3474,7 @@
</function>
<!-- void QVector::push_back(const T &value) -->
<!-- void QVector::push_back(T &&value) -->
<function name="QVector::push_back">
<function name="QVector::push_back,QStack::push_back">
<noreturn>false</noreturn>
<returnValue type="void"/>
<leak-ignore/>
@ -3483,7 +3484,7 @@
</function>
<!-- void QVector::remove(int i) -->
<!-- void QVector::remove(int i, int count) -->
<function name="QVector::remove">
<function name="QVector::remove,QStack::remove">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
@ -3496,7 +3497,7 @@
</arg>
</function>
<!-- int QVector::removeAll(const T &t) -->
<function name="QVector::removeAll">
<function name="QVector::removeAll,QStack::removeAll">
<noreturn>false</noreturn>
<returnValue type="int"/>
<arg nr="1" direction="in">
@ -3504,7 +3505,7 @@
</arg>
</function>
<!-- void QVector::removeAt(int i) -->
<function name="QVector::removeAt">
<function name="QVector::removeAt,QStack::removeAt">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
@ -3512,7 +3513,7 @@
</arg>
</function>
<!-- void QVector::replace(int i, const T &value) -->
<function name="QVector::replace">
<function name="QVector::replace,QStack::replace">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
@ -3524,7 +3525,7 @@
</arg>
</function>
<!-- void QVector::reserve(int size) -->
<function name="QVector::reserve">
<function name="QVector::reserve,QStack::reserve">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
@ -3532,27 +3533,27 @@
</arg>
</function>
<!-- void QVector::resize(int size) -->
<function name="QVector::resize">
<function name="QVector::resize,QStack::resize">
<noreturn>false</noreturn>
<returnValue type="false"/>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int QVector::size() const -->
<function name="QVector::size">
<function name="QVector::size,QStack::size">
<noreturn>false</noreturn>
<returnValue type="int"/>
<use-retval/>
<const/>
</function>
<!-- void QVector::squeeze() -->
<function name="QVector::squeeze">
<function name="QVector::squeeze,QStack::squeeze">
<noreturn>false</noreturn>
<returnValue type="void"/>
</function>
<!-- bool QVector::startsWith(const T &value) const -->
<function name="QVector::startsWith">
<function name="QVector::startsWith,QStack::startsWith">
<noreturn>false</noreturn>
<returnValue type="bool"/>
<use-retval/>
@ -3563,14 +3564,14 @@
</arg>
</function>
<!-- void QVector::swap(QVector<T> &other) -->
<function name="QVector::swap">
<function name="QVector::swap,QStack::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">
<function name="QVector::value,QStack::value">
<noreturn>false</noreturn>
<use-retval/>
<const/>
@ -3582,6 +3583,25 @@
<not-uninit/>
</arg>
</function>
<!-- QStack https://doc.qt.io/qt-5/qstack.html -->
<!-- T QStack::pop() -->
<function name="QStack::pop">
<noreturn>false</noreturn>
</function>
<!-- void QStack::push(const T &t) -->
<function name="QStack::push">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1" direction="in">
<not-uninit/>
</arg>
</function>
<!-- T &QStack::top() -->
<!-- const T &QStack::top() const -->
<function name="QStack::top">
<noreturn>false</noreturn>
<use-retval/>
</function>
<!-- QByteArray https://doc.qt.io/qt-5/qbytearray.html -->
<!-- char QByteArray::at(int i) const -->
<function name="QByteArray::at">
@ -3765,6 +3785,15 @@
<function name="crend" yields="end-iterator"/>
</access>
</container>
<container id="qtStack" startPattern="QStack &lt;" inherits="qtVector">
<size>
<function name="push" action="push"/>
<function name="pop" action="pop"/>
</size>
<access indexOperator="array-like">
<function name="top" yields="item"/>
</access>
</container>
<container id="qtString" startPattern="QString" endPattern="" inherits="qtContainer" opLessAllowed="true" itEndPattern=":: iterator|const_iterator|reverse_iterator|const_reverse_iterator">
<type string="std-like"/>
<size>

View File

@ -10,6 +10,7 @@
#include <QObject>
#include <QString>
#include <QVector>
#include <QStack>
#include <QByteArray>
#include <QList>
#include <QLinkedList>
@ -280,6 +281,68 @@ QVector<int>::iterator QVector2()
return it;
}
void QStack1(QStack<int> intStackArg)
{
for (int i = 0; i <= intStackArg.size(); ++i) {
// cppcheck-suppress stlOutOfBounds
intStackArg[i] = 1;
}
// cppcheck-suppress containerOutOfBoundsIndexExpression
intStackArg[intStackArg.length()] = 5;
// cppcheck-suppress containerOutOfBoundsIndexExpression
intStackArg[intStackArg.count()] = 10;
// cppcheck-suppress containerOutOfBoundsIndexExpression
printf("val: %d\n", intStackArg[intStackArg.size()]);
QStack<QString> qstringStack1;
qstringStack1.push("one");
qstringStack1.push("two");
(void)qstringStack1[1];
QStack<QString> qstringStack2;
qstringStack2 << "one" << "two";
// FIXME: The following containerOutOfBounds suppression is wrong #9242
// Please remove the suppression as soon as this is fixed
// cppcheck-suppress containerOutOfBounds
(void)qstringStack2[1];
// cppcheck-suppress ignoredReturnValue
qstringStack2.startsWith("one");
// cppcheck-suppress ignoredReturnValue
qstringStack2.endsWith("one");
// cppcheck-suppress ignoredReturnValue
qstringStack2.count();
// cppcheck-suppress ignoredReturnValue
qstringStack2.length();
// cppcheck-suppress ignoredReturnValue
qstringStack2.size();
// cppcheck-suppress ignoredReturnValue
qstringStack2.at(5);
// cppcheck-suppress invalidFunctionArg
(void)qstringStack2.at(-5);
}
QStack<int>::iterator QStack2()
{
QStack<int> qstack1;
QStack<int> qstack2;
// cppcheck-suppress iterators2
for (QStack<int>::iterator it = qstack1.begin(); it != qstack2.end(); ++it)
{}
QStack<int>::iterator it = qstack1.begin();
// TODO cppcheck-suppress returnDanglingLifetime
return it;
}
void QStack3()
{
QStack<int> intStack;
intStack.push(1);
// cppcheck-suppress ignoredReturnValue
intStack.top();
intStack.pop();
}
// Verify that Qt macros do not result in syntax errors, false positives or other issues.
class MacroTest1: public QObject {
Q_OBJECT