Skip to content

Commit bbf5efd

Browse files
Fix #12368 FP constParameterReference with std::mutex (f'up to #5882) (#5898)
1 parent 59fde1e commit bbf5efd

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2475,7 +2475,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
24752475
}
24762476

24772477
if (const Variable* var = tok->variable()) {
2478-
if (tok == var->nameToken() && (!var->isReference() || var->isConst()) && (var->isStlType() || !var->isClass())) // const ref or passed to (copy) ctor
2478+
if (tok == var->nameToken() && (!var->isReference() || var->isConst()) && (!var->isClass() || (var->valueType() && var->valueType()->container))) // const ref or passed to (copy) ctor
24792479
return false;
24802480
}
24812481

test/cfg/qt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ void MacroTest3()
437437
QVERIFY2(2 >= 0, message.constData());
438438
}
439439

440+
// cppcheck-suppress constParameterReference
440441
void validCode(int * pIntPtr, QString & qstrArg, double d)
441442
{
442443
Q_UNUSED(d)

test/cfg/std.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <iterator>
3939
#include <map>
4040
#include <memory>
41+
#include <mutex>
4142
#include <numeric>
4243
#include <queue>
4344
#include <set>
@@ -4923,3 +4924,8 @@ std::string global_scope_std() // #12355
49234924
::std::stringstream ss;
49244925
return ss.str();
49254926
}
4927+
4928+
void unique_lock_const_ref(std::mutex& m)
4929+
{
4930+
std::unique_lock lock(m);
4931+
}

0 commit comments

Comments
 (0)