qt.cfg: Add configuration for QString

This commit is contained in:
Daniel Marjamäki 2017-04-18 18:04:27 +02:00
parent 094b7a706f
commit c229754a70
3 changed files with 60 additions and 0 deletions

View File

@ -88,6 +88,41 @@
<not-uninit/>
</arg>
</function>
<container id="qtContainer" opLessAllowed="false">
<type templateParameter="0"/>
<size>
<function name="append" action="push"/>
<function name="clear" action="clear"/>
<function name="count" yields="size"/>
<function name="erase" action="erase"/>
<function name="insert" action="insert"/>
<function name="isEmpty" yields="empty"/>
<function name="size" yields="size"/>
<function name="swap" action="change"/>
</size>
<access>
<function name="begin" yields="start-iterator"/>
<function name="cbegin" yields="start-iterator"/>
<function name="constBegin" yields="start-iterator"/>
<function name="end" yields="end-iterator"/>
<function name="cend" yields="end-iterator"/>
<function name="constEnd" yields="end-iterator"/>
</access>
</container>
<container id="qtString" startPattern="QString" endPattern="" inherits="qtContainer" opLessAllowed="true">
<type string="std-like"/>
<size>
<function name="resize" action="resize"/>
</size>
<access indexOperator="array-like">
<function name="at" yields="at_index"/>
<function name="front" yields="item"/>
<function name="back" yields="item"/>
</access>
</container>
<define name="Q_DECL_EXPORT" value=""/>
<define name="Q_DECL_IMPORT" value=""/>
<define name="Q_DECLARE_FLAGS(x,y)" value=""/>

21
test/cfg/qt.cpp Normal file
View File

@ -0,0 +1,21 @@
// Test library configuration for qt.cfg
//
// Usage:
// $ cppcheck --check-library --enable=information --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --library=qt test/cfg/qt.cpp
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//
class QString {
public:
int size();
char &operator[](int pos);
};
void QString1(QString s) {
for (int i = 0; i <= s.size(); ++i) {
// cppcheck-suppress stlOutOfBounds
s[i] = 'x';
}
}

View File

@ -27,6 +27,10 @@ ${CPPCHECK} ${CPPCHECK_OPT} --library=posix ${DIR}posix.c
${CC} ${CC_OPT} -D_GNU_SOURCE ${DIR}gnu.c
${CPPCHECK} ${CPPCHECK_OPT} --library=gnu ${DIR}gnu.c
# qt.cpp
${CXX} ${CXX_OPT} ${DIR}qt.cpp
${CPPCHECK} --enable=style --enable=information --inline-suppr --error-exitcode=1 --library=qt ${DIR}qt.cpp
# std.c
${CC} ${CC_OPT} ${DIR}std.c
${CPPCHECK} ${CPPCHECK_OPT} ${DIR}std.c