Skip to content
Open
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
30 changes: 30 additions & 0 deletions .selfcheck_suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,40 @@ missingIncludeSystem
checkersReport

# warnings in Qt generated code we cannot fix
funcArgNamesDifferent:*/moc_aboutdialog.cpp
funcArgNamesDifferent:*/moc_applicationdialog.cpp
funcArgNamesDifferent:*/moc_applicationlist.cpp
funcArgNamesDifferent:*/moc_checkthread.cpp
funcArgNamesDifferent:*/moc_codeeditor.cpp
funcArgNamesDifferent:*/moc_codeeditstylecontrols.cpp
funcArgNamesDifferent:*/moc_compliancereportdialog.cpp
funcArgNamesDifferent:*/moc_codeeditstyledialog.cpp
funcArgNamesDifferent:*/moc_fileviewdialog.cpp
funcArgNamesDifferent:*/moc_helpdialog.cpp
funcArgNamesDifferent:*/moc_libraryaddfunctiondialog.cpp
funcArgNamesDifferent:*/moc_librarydialog.cpp
funcArgNamesDifferent:*/moc_libraryeditargdialog.cpp
funcArgNamesDifferent:*/moc_mainwindow.cpp
funcArgNamesDifferent:*/moc_newsuppressiondialog.cpp
funcArgNamesDifferent:*/moc_platforms.cpp
funcArgNamesDifferent:*/moc_projectfile.cpp
funcArgNamesDifferent:*/moc_projectfiledialog.cpp
funcArgNamesDifferent:*/moc_resultstree.cpp
funcArgNamesDifferent:*/moc_resultsview.cpp
funcArgNamesDifferent:*/moc_scratchpad.cpp
funcArgNamesDifferent:*/moc_settingsdialog.cpp
funcArgNamesDifferent:*/moc_statsdialog.cpp
funcArgNamesDifferent:*/moc_testcppchecklibrarydata.cpp
funcArgNamesDifferent:*/moc_testfilelist.cpp
funcArgNamesDifferent:*/moc_testprojectfile.cpp
funcArgNamesDifferent:*/moc_testresultstree.cpp
funcArgNamesDifferent:*/moc_testtranslationhandler.cpp
funcArgNamesDifferent:*/moc_testxmlreportv2.cpp
funcArgNamesDifferent:*/moc_threaddetails.cpp
funcArgNamesDifferent:*/moc_threadhandler.cpp
funcArgNamesDifferent:*/moc_threadresult.cpp
funcArgNamesDifferent:*/moc_translationhandler.cpp
funcArgNamesDifferent:*/moc_txtreport.cpp
naming-varname:*/gui/ui_*.h
functionStatic:*/gui/ui_*.h

Expand Down Expand Up @@ -37,7 +65,9 @@ invalidPrintfArgType_sint:externals/tinyxml2/tinyxml2.h
naming-privateMemberVariable:externals/tinyxml2/tinyxml2.h
functionStatic:externals/tinyxml2/tinyxml2.cpp
funcArgNamesDifferent:externals/tinyxml2/tinyxml2.cpp
funcArgNamesDifferent:externals/tinyxml2/tinyxml2.h
nullPointerRedundantCheck:externals/tinyxml2/tinyxml2.cpp
knownConditionTrueFalse:externals/tinyxml2/tinyxml2.cpp
useStlAlgorithm:externals/simplecpp/simplecpp.cpp
funcArgNamesDifferent:externals/simplecpp/simplecpp.h
missingMemberCopy:externals/simplecpp/simplecpp.h
4 changes: 2 additions & 2 deletions gui/codeeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ class CodeEditor : public QPlainTextEdit {
void resizeEvent(QResizeEvent *event) override;

private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void updateLineNumberAreaWidth(int /*newBlockCount*/);
void highlightErrorLine();
void updateLineNumberArea(const QRect & /*rect*/, int /*dy*/);
void updateLineNumberArea(const QRect& rect, int dy);

private:
QString generateStyleString();
Expand Down
6 changes: 3 additions & 3 deletions gui/librarydialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ private slots:
void addFunction();
void changeFunction();
void editArg();
void editFunctionName(QListWidgetItem* /*item*/);
void filterFunctions(const QString& /*filter*/);
void editFunctionName(QListWidgetItem* item);
void filterFunctions(const QString& filter);
void selectFunction();
void sortFunctions(bool /*sort*/);
void sortFunctions(bool sort);

private:
Ui::LibraryDialog *mUi;
Expand Down
2 changes: 1 addition & 1 deletion gui/projectfiledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private slots:
/**
* @brief Edit suppression (double clicking on suppression)
*/
void editSuppression(const QModelIndex &index);
void editSuppression(const QModelIndex& /*index*/);

/**
* @brief Browse for misra file
Expand Down
2 changes: 1 addition & 1 deletion gui/threadresult.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ThreadResult : public QObject, public ErrorLogger {
/**
* ErrorLogger methods
*/
void reportOut(const std::string &outmsg, Color c = Color::Reset) override;
void reportOut(const std::string &outmsg, Color /*c*/ = Color::Reset) override;
void reportErr(const ErrorMessage &msg) override;
void reportMetric(const std::string &metric) override
{
Expand Down
2 changes: 1 addition & 1 deletion lib/checkclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class CPPCHECKLIB CheckClass : public Check {
void checkUnsafeClassRefMember();

/** @brief Parse current TU and extract file info */
Check::FileInfo *getFileInfo(const Tokenizer &tokenizer, const Settings &settings, const std::string& currentConfig) const override;
Check::FileInfo *getFileInfo(const Tokenizer &tokenizer, const Settings& /*settings*/, const std::string& currentConfig) const override;

Check::FileInfo * loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const override;

Expand Down
2 changes: 1 addition & 1 deletion lib/checkmemoryleak.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class CPPCHECKLIB CheckMemoryLeakStructMember : public Check, private CheckMemor

void checkStructVariable(const Variable* variable) const;

void getErrorMessages(ErrorLogger * errorLogger, const Settings * settings) const override;
void getErrorMessages(ErrorLogger* /*errorLogger*/, const Settings* /*settings*/) const override;

static std::string myName() {
return "Memory leaks (struct members)";
Expand Down
8 changes: 5 additions & 3 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4061,7 +4061,9 @@ void CheckOther::checkFuncArgNamesDifferent()
// check for different argument names
if (style && inconclusive) {
for (int j = 0; j < function->argCount(); ++j) {
if (declarations[j] && definitions[j] && declarations[j]->str() != definitions[j]->str())
const bool warn = (declarations[j] != nullptr) != (definitions[j] != nullptr) ||
(declarations[j] && definitions[j] && declarations[j]->str() != definitions[j]->str());
if (warn)
funcArgNamesDifferent(function->name(), j, declarations[j], definitions[j]);
}
}
Expand All @@ -4075,8 +4077,8 @@ void CheckOther::funcArgNamesDifferent(const std::string & functionName, nonneg
reportError(tokens, Severity::style, "funcArgNamesDifferent",
"$symbol:" + functionName + "\n"
"Function '$symbol' argument " + std::to_string(index + 1) + " names different: declaration '" +
(declaration ? declaration->str() : std::string("A")) + "' definition '" +
(definition ? definition->str() : std::string("B")) + "'.", CWE628, Certainty::inconclusive);
(declaration ? declaration->str() : "<unnamed>") + "' definition '" +
(definition ? definition->str() : "<unnamed>") + "'.", CWE628, Certainty::inconclusive);
}

void CheckOther::funcArgOrderDifferent(const std::string & functionName,
Expand Down
6 changes: 3 additions & 3 deletions lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ void CheckStl::invalidContainer()
errorPath.insert(errorPath.end(), info.errorPath.cbegin(), info.errorPath.cend());
errorPath.insert(errorPath.end(), r.errorPath.cbegin(), r.errorPath.cend());
if (v) {
invalidContainerError(info.tok, r.tok, v, std::move(errorPath));
invalidContainerError(info.tok, v, std::move(errorPath));
} else {
invalidContainerReferenceError(info.tok, r.tok, std::move(errorPath));
}
Expand All @@ -1252,7 +1252,7 @@ void CheckStl::invalidContainerLoopError(const Token* tok, const Token* loopTok,
reportError(std::move(errorPath), Severity::error, "invalidContainerLoop", msg, CWE664, Certainty::normal);
}

void CheckStl::invalidContainerError(const Token *tok, const Token * /*contTok*/, const ValueFlow::Value *val, ErrorPath errorPath)
void CheckStl::invalidContainerError(const Token *tok, const ValueFlow::Value *val, ErrorPath errorPath)
{
const bool inconclusive = val ? val->isInconclusive() : false;
if (val)
Expand Down Expand Up @@ -3487,7 +3487,7 @@ void CheckStl::getErrorMessages(ErrorLogger* errorLogger, const Settings* settin
c.iteratorsError(nullptr, "container1", "container2");
c.iteratorsError(nullptr, nullptr, "container");
c.invalidContainerLoopError(nullptr, nullptr, ErrorPath{});
c.invalidContainerError(nullptr, nullptr, nullptr, ErrorPath{});
c.invalidContainerError(nullptr, nullptr, ErrorPath{});
c.invalidContainerReferenceError(nullptr, nullptr, ErrorPath{});
c.mismatchingContainerIteratorError(nullptr, nullptr, nullptr);
c.mismatchingContainersError(nullptr, nullptr);
Expand Down
2 changes: 1 addition & 1 deletion lib/checkstl.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class CPPCHECKLIB CheckStl : public Check {
void sizeError(const Token* tok);
void redundantIfRemoveError(const Token* tok);
void invalidContainerLoopError(const Token* tok, const Token* loopTok, ErrorPath errorPath);
void invalidContainerError(const Token *tok, const Token * contTok, const ValueFlow::Value *val, ErrorPath errorPath);
void invalidContainerError(const Token *tok, const ValueFlow::Value *val, ErrorPath errorPath);
void invalidContainerReferenceError(const Token* tok, const Token* contTok, ErrorPath errorPath);

void uselessCallsReturnValueError(const Token* tok, const std::string& varname, const std::string& function);
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ class CPPCHECKLIB SymbolDatabase {
/* returns the opening { if tok points to enum */
static const Token* isEnumDefinition(const Token* tok);

static void getErrorMessages(ErrorLogger &errorLogger);
static void getErrorMessages(ErrorLogger& /*errorLogger*/);

// check if type has no side effects (no constructors and no members with constructors)
/** @todo false negative: check constructors for side effects */
Expand Down
2 changes: 1 addition & 1 deletion test/fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class TestFixture : public ErrorLogger {
std::ostringstream mOutput;
std::ostringstream mErrout;

void reportOut(const std::string &outmsg, Color c = Color::Reset) override;
void reportOut(const std::string &outmsg, Color /*c*/ = Color::Reset) override;
void reportErr(const ErrorMessage &msg) override;
void reportMetric(const std::string &metric) override
{
Expand Down
26 changes: 18 additions & 8 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ class TestOther : public TestFixture {

void varScope39() {
check("struct S {\n" // #12405
" void f(const std::string&) const;\n"
" void f(const std::string& s) const;\n"
" const int* g(std::string&) const;\n"
"};\n"
"void h(int);\n"
Expand Down Expand Up @@ -3621,7 +3621,7 @@ class TestOther : public TestFixture {
"class D\n"
"{\n"
"public:\n"
" explicit D(int&);\n"
" explicit D(int& i);\n"
"\n"
"private:\n"
" C c;\n"
Expand All @@ -3642,7 +3642,7 @@ class TestOther : public TestFixture {
"class D\n"
"{\n"
"public:\n"
" explicit D(int&) noexcept;\n"
" explicit D(int& i) noexcept;\n"
"\n"
"private:\n"
" C c;\n"
Expand All @@ -3662,7 +3662,7 @@ class TestOther : public TestFixture {
"class D\n"
"{\n"
"public:\n"
" explicit D(int&);\n"
" explicit D(int& i);\n"
"\n"
"private:\n"
" C c;\n"
Expand All @@ -3683,7 +3683,7 @@ class TestOther : public TestFixture {
"class D\n"
"{\n"
"public:\n"
" explicit D(int&);\n"
" explicit D(int& i);\n"
"\n"
"private:\n"
" C c;\n"
Expand All @@ -3704,7 +3704,7 @@ class TestOther : public TestFixture {
"class D\n"
"{\n"
"public:\n"
" explicit D(int&);\n"
" explicit D(int& i);\n"
"\n"
"private:\n"
" C c;\n"
Expand Down Expand Up @@ -6776,7 +6776,7 @@ class TestOther : public TestFixture {
" AMethodObject(double, double, double);\n"
"};\n"
"struct S {\n"
" static void A(double, double, double);\n"
" static void A(double a1, double a2, double a3);\n"
"};\n"
"void S::A(double const a1, double const a2, double const a3) {\n"
" AMethodObject(a1, a2, a3);\n"
Expand Down Expand Up @@ -8013,7 +8013,7 @@ class TestOther : public TestFixture {
"public:\n"
" double getScale() const { return m_range * m_zoom; }\n"
" void setZoom(double z) { m_zoom = z; }\n"
" void dostuff(int);\n"
" void dostuff(int x);\n"
"private:\n"
" double m_zoom;\n"
" double m_range;\n"
Expand Down Expand Up @@ -12769,6 +12769,16 @@ class TestOther : public TestFixture {
"[test.cpp:7:15] -> [test.cpp:8:15]: (style, inconclusive) Function 'h' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n",
errout_str());

check("void f(int a);\n" // #14632
"void f(int) {}\n"
"void g(int);\n"
"void g(int b) {}\n"
"void h(int);\n"
"void h(int) {}\n");
ASSERT_EQUALS(
"[test.cpp:1:12]: (style, inconclusive) Function 'f' argument 1 names different: declaration 'a' definition '<unnamed>'. [funcArgNamesDifferent]\n"
"[test.cpp:4:12]: (style, inconclusive) Function 'g' argument 1 names different: declaration '<unnamed>' definition 'b'. [funcArgNamesDifferent]\n",
errout_str());
}

void funcArgOrderDifferent() {
Expand Down
Loading