Skip to content

Fix #13902 FP constParameterPointer with QHash::insert() #7566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cfg/qt.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3293,7 +3293,7 @@
<returnValue type="bool"/>
<use-retval/>
<const/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
</arg>
</function>
Expand All @@ -3304,7 +3304,7 @@
<returnValue type="int"/>
<use-retval/>
<const/>
<arg nr="1" direction="in" default="">
<arg nr="1" default="">
<not-uninit/>
</arg>
</function>
Expand All @@ -3320,18 +3320,18 @@
<function name="QHash::find">
<noreturn>false</noreturn>
<use-retval/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
</arg>
</function>
<!-- QHash::iterator QHash::insert(const Key &key, const T &value) -->
<function name="QHash::insert">
<noreturn>false</noreturn>
<returnValue type="QHash::iterator"/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2" direction="in">
<arg nr="2">
<not-uninit/>
</arg>
</function>
Expand Down Expand Up @@ -3368,10 +3368,10 @@
<noreturn>false</noreturn>
<use-retval/>
<const/>
<arg nr="1" direction="in">
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2" direction="in" default="">
<arg nr="2" default="">
<not-uninit/>
</arg>
</function>
Expand All @@ -3381,7 +3381,7 @@
<noreturn>false</noreturn>
<use-retval/>
<const/>
<arg nr="1" direction="in" default="">
<arg nr="1" default="">
<not-uninit/>
</arg>
</function>
Expand Down Expand Up @@ -5259,7 +5259,7 @@
<function name="crend" yields="end-iterator"/>
</access>
</container>
<container id="qtMap" startPattern="QMap|QMultiMap &lt;" inherits="qtContainer">
<container id="qtMap" startPattern="QMap|QMultiMap|QHash &lt;" inherits="qtContainer">
<type templateParameter="1" associative="std-like"/>
<rangeItemRecordType>
<member name="first" templateParameter="0"/>
Expand Down
23 changes: 22 additions & 1 deletion test/cfg/qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,27 @@ void constVariablePointer_QVector(QVector<int*>& qv, int* p)
qv.push_back(p); // #12661
}

void constParameterPointer_QHash_insert(QHash<int*, int*>& qh, int* k, int* v)
{
qh.insert(k, v); // #13902
}

bool constParameterPointer_QHash_find(const QHash<int*, int*>& qh, int* k)
{
auto it = qh.find(k);
return it != qh.end();
}

bool constParameterPointer_QHash_contains(const QHash<int*, int*>& qh, int* k)
{
return qh.contains(k);
}

int constParameterPointer_QHash_count(const QHash<int*, int*>& qh, int* k)
{
return qh.count(k);
}

const QString& unassignedVariable_static_QString() // #12935
{
static QString qs;
Expand All @@ -825,4 +846,4 @@ namespace {

// cppcheck-suppress functionStatic
void TestUnusedFunction::doStuff() {} // Should not warn here with unusedFunction
}
}
Loading