enabled and mitigated `modernize-use-equals-default` clang-tidy warnings / removed unnecessary default destructors (#5335)

This commit is contained in:
Oliver Stöneberg 2023-08-16 17:13:36 +02:00 committed by GitHub
parent 6a263ba026
commit 84a9b3a5f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 18 additions and 80 deletions

View File

@ -45,7 +45,6 @@ Checks: >
-modernize-replace-auto-ptr, -modernize-replace-auto-ptr,
-modernize-return-braced-init-list, -modernize-return-braced-init-list,
-modernize-use-auto, -modernize-use-auto,
-modernize-use-equals-default,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,
-performance-avoid-endl, -performance-avoid-endl,
-performance-inefficient-string-concatenation, -performance-inefficient-string-concatenation,

View File

@ -63,7 +63,6 @@ This does not appear to be useful as it is reported on very common code.
It was decided not to apply these. It was decided not to apply these.
`modernize-use-equals-default`<br/>
`modernize-loop-convert`<br/> `modernize-loop-convert`<br/>
These might change the behavior of code which might not be intended (need to file an upstream issue) These might change the behavior of code which might not be intended (need to file an upstream issue)

View File

@ -31,9 +31,6 @@ Executor::Executor(const std::map<std::string, std::size_t> &files, const Settin
: mFiles(files), mSettings(settings), mSuppressions(suppressions), mErrorLogger(errorLogger) : mFiles(files), mSettings(settings), mSuppressions(suppressions), mErrorLogger(errorLogger)
{} {}
Executor::~Executor()
{}
bool Executor::hasToLog(const ErrorMessage &msg) bool Executor::hasToLog(const ErrorMessage &msg)
{ {
if (!mSuppressions.isSuppressed(msg)) if (!mSuppressions.isSuppressed(msg))

View File

@ -40,7 +40,7 @@ class Suppressions;
class Executor { class Executor {
public: public:
Executor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); Executor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
virtual ~Executor(); virtual ~Executor() = default;
Executor(const Executor &) = delete; Executor(const Executor &) = delete;
void operator=(const Executor &) = delete; void operator=(const Executor &) = delete;

View File

@ -67,9 +67,6 @@ ProcessExecutor::ProcessExecutor(const std::map<std::string, std::size_t> &files
assert(mSettings.jobs > 1); assert(mSettings.jobs > 1);
} }
ProcessExecutor::~ProcessExecutor()
{}
class PipeWriter : public ErrorLogger { class PipeWriter : public ErrorLogger {
public: public:
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'}; enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'};

View File

@ -40,7 +40,6 @@ class ProcessExecutor : public Executor {
public: public:
ProcessExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); ProcessExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
ProcessExecutor(const ProcessExecutor &) = delete; ProcessExecutor(const ProcessExecutor &) = delete;
~ProcessExecutor() override;
void operator=(const ProcessExecutor &) = delete; void operator=(const ProcessExecutor &) = delete;
unsigned int check() override; unsigned int check() override;

View File

@ -37,9 +37,6 @@ SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::map<std::string, s
assert(mSettings.jobs == 1); assert(mSettings.jobs == 1);
} }
SingleExecutor::~SingleExecutor()
{}
// TODO: markup handling is not performed with multiple jobs // TODO: markup handling is not performed with multiple jobs
unsigned int SingleExecutor::check() unsigned int SingleExecutor::check()
{ {

View File

@ -35,7 +35,6 @@ class SingleExecutor : public Executor
public: public:
SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); SingleExecutor(CppCheck &cppcheck, const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
SingleExecutor(const SingleExecutor &) = delete; SingleExecutor(const SingleExecutor &) = delete;
~SingleExecutor() override;
void operator=(const SingleExecutor &) = delete; void operator=(const SingleExecutor &) = delete;
unsigned int check() override; unsigned int check() override;

View File

@ -46,9 +46,6 @@ ThreadExecutor::ThreadExecutor(const std::map<std::string, std::size_t> &files,
assert(mSettings.jobs > 1); assert(mSettings.jobs > 1);
} }
ThreadExecutor::~ThreadExecutor()
{}
class SyncLogForwarder : public ErrorLogger class SyncLogForwarder : public ErrorLogger
{ {
public: public:

View File

@ -40,7 +40,6 @@ class ThreadExecutor : public Executor {
public: public:
ThreadExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger); ThreadExecutor(const std::map<std::string, std::size_t> &files, const Settings &settings, Suppressions &suppressions, ErrorLogger &errorLogger);
ThreadExecutor(const ThreadExecutor &) = delete; ThreadExecutor(const ThreadExecutor &) = delete;
~ThreadExecutor() override;
void operator=(const ThreadExecutor &) = delete; void operator=(const ThreadExecutor &) = delete;
unsigned int check() override; unsigned int check() override;

View File

@ -42,7 +42,7 @@
*/ */
class Application { class Application {
public: public:
Application() {} Application() = default;
Application(QString name, QString path, QString params); Application(QString name, QString path, QString params);
/** /**

View File

@ -86,14 +86,7 @@ static bool executeCommand(std::string exe, std::vector<std::string> args, std::
CheckThread::CheckThread(ThreadResult &result) : CheckThread::CheckThread(ThreadResult &result) :
mResult(result), mResult(result),
mCppcheck(result, true, executeCommand) mCppcheck(result, true, executeCommand)
{ {}
//ctor
}
CheckThread::~CheckThread()
{
//dtor
}
void CheckThread::check(const Settings &settings) void CheckThread::check(const Settings &settings)
{ {

View File

@ -46,7 +46,6 @@ class CheckThread : public QThread {
Q_OBJECT Q_OBJECT
public: public:
explicit CheckThread(ThreadResult &result); explicit CheckThread(ThreadResult &result);
~CheckThread() override;
/** /**
* @brief Set settings for cppcheck * @brief Set settings for cppcheck

View File

@ -35,7 +35,6 @@ class SelectColorButton : public QPushButton {
Q_OBJECT Q_OBJECT
public: public:
explicit SelectColorButton(QWidget* parent); explicit SelectColorButton(QWidget* parent);
~SelectColorButton() override {}
void setColor(const QColor& color); void setColor(const QColor& color);
const QColor& getColor(); const QColor& getColor();
@ -57,7 +56,6 @@ class SelectFontWeightCombo : public QComboBox {
Q_OBJECT Q_OBJECT
public: public:
explicit SelectFontWeightCombo(QWidget* parent); explicit SelectFontWeightCombo(QWidget* parent);
~SelectFontWeightCombo() override {}
void setWeight(const QFont::Weight& weight); void setWeight(const QFont::Weight& weight);
const QFont::Weight& getWeight(); const QFont::Weight& getWeight();

View File

@ -42,7 +42,6 @@ class StyleEditDialog : public QDialog {
public: public:
explicit StyleEditDialog(const CodeEditorStyle& newStyle, explicit StyleEditDialog(const CodeEditorStyle& newStyle,
QWidget *parent = nullptr); QWidget *parent = nullptr);
~StyleEditDialog() override {}
CodeEditorStyle getStyle(); CodeEditorStyle getStyle();

View File

@ -35,9 +35,6 @@
const unsigned int CppcheckLibraryData::Function::Arg::ANY = ~0U; const unsigned int CppcheckLibraryData::Function::Arg::ANY = ~0U;
const unsigned int CppcheckLibraryData::Function::Arg::VARIADIC = ~1U; const unsigned int CppcheckLibraryData::Function::Arg::VARIADIC = ~1U;
CppcheckLibraryData::CppcheckLibraryData()
{}
static std::string unhandledElement(const QXmlStreamReader &xmlReader) static std::string unhandledElement(const QXmlStreamReader &xmlReader)
{ {
throw std::runtime_error(QObject::tr("line %1: Unhandled element %2").arg(xmlReader.lineNumber()).arg(xmlReader.name().toString()).toStdString()); throw std::runtime_error(QObject::tr("line %1: Unhandled element %2").arg(xmlReader.lineNumber()).arg(xmlReader.name().toString()).toStdString());

View File

@ -30,7 +30,7 @@ class QIODevice;
class CppcheckLibraryData { class CppcheckLibraryData {
public: public:
CppcheckLibraryData(); CppcheckLibraryData() = default;
struct Container { struct Container {
QString id; QString id;

View File

@ -30,9 +30,6 @@ CsvReport::CsvReport(const QString &filename) :
Report(filename) Report(filename)
{} {}
CsvReport::~CsvReport()
{}
bool CsvReport::create() bool CsvReport::create()
{ {
if (Report::create()) { if (Report::create()) {

View File

@ -39,7 +39,6 @@ class ErrorItem;
class CsvReport : public Report { class CsvReport : public Report {
public: public:
explicit CsvReport(const QString &filename); explicit CsvReport(const QString &filename);
~CsvReport() override;
/** /**
* @brief Create the report (file). * @brief Create the report (file).

View File

@ -27,9 +27,6 @@ PrintableReport::PrintableReport() :
Report(QString()) Report(QString())
{} {}
PrintableReport::~PrintableReport()
{}
bool PrintableReport::create() bool PrintableReport::create()
{ {
return true; return true;

View File

@ -36,7 +36,6 @@ class ErrorItem;
class PrintableReport : public Report { class PrintableReport : public Report {
public: public:
PrintableReport(); PrintableReport();
~PrintableReport() override;
/** /**
* @brief Create the report (file). * @brief Create the report (file).

View File

@ -91,9 +91,6 @@ ResultsTree::ResultsTree(QWidget * parent) :
connect(this, &ResultsTree::doubleClicked, this, &ResultsTree::quickStartApplication); connect(this, &ResultsTree::doubleClicked, this, &ResultsTree::quickStartApplication);
} }
ResultsTree::~ResultsTree()
{}
void ResultsTree::keyPressEvent(QKeyEvent *event) void ResultsTree::keyPressEvent(QKeyEvent *event)
{ {
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {

View File

@ -53,7 +53,7 @@ class ResultsTree : public QTreeView {
Q_OBJECT Q_OBJECT
public: public:
explicit ResultsTree(QWidget * parent = nullptr); explicit ResultsTree(QWidget * parent = nullptr);
~ResultsTree() override;
void initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler); void initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler);
/** /**

View File

@ -40,8 +40,8 @@ const char Settings::SafeChecks::XmlExternalFunctions[] = "external-functions";
const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions"; const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions";
const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables"; const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables";
Settings::Settings() : maxCtuDepth(10) {} Settings::Settings() : maxCtuDepth(10) {}
cppcheck::Platform::Platform() {} cppcheck::Platform::Platform() = default;
ImportProject::ImportProject() {} ImportProject::ImportProject() = default;
bool ImportProject::sourceFileExists(const std::string & /*file*/) { bool ImportProject::sourceFileExists(const std::string & /*file*/) {
return true; return true;
} }

View File

@ -28,11 +28,6 @@
#include <QFile> #include <QFile>
#include <QMutexLocker> #include <QMutexLocker>
ThreadResult::~ThreadResult()
{
//dtor
}
void ThreadResult::reportOut(const std::string &outmsg, Color /*c*/) void ThreadResult::reportOut(const std::string &outmsg, Color /*c*/)
{ {
emit log(QString::fromStdString(outmsg)); emit log(QString::fromStdString(outmsg));

View File

@ -46,7 +46,6 @@ class ThreadResult : public QObject, public ErrorLogger {
Q_OBJECT Q_OBJECT
public: public:
ThreadResult() = default; ThreadResult() = default;
~ThreadResult() override;
/** /**
* @brief Get next unprocessed file * @brief Get next unprocessed file

View File

@ -62,9 +62,6 @@ TranslationHandler::TranslationHandler(QObject *parent) :
addTranslation("Swedish", "cppcheck_sv"); addTranslation("Swedish", "cppcheck_sv");
} }
TranslationHandler::~TranslationHandler()
{}
bool TranslationHandler::setLanguage(const QString &code) bool TranslationHandler::setLanguage(const QString &code)
{ {
bool failure = false; bool failure = false;

View File

@ -63,7 +63,6 @@ class TranslationHandler : QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit TranslationHandler(QObject *parent = nullptr); explicit TranslationHandler(QObject *parent = nullptr);
~TranslationHandler() override;
/** /**
* @brief Get a list of available translations. * @brief Get a list of available translations.

View File

@ -29,9 +29,6 @@ TxtReport::TxtReport(const QString &filename) :
Report(filename) Report(filename)
{} {}
TxtReport::~TxtReport()
{}
bool TxtReport::create() bool TxtReport::create()
{ {
if (Report::create()) { if (Report::create()) {

View File

@ -40,7 +40,6 @@ class TxtReport : public Report {
public: public:
explicit TxtReport(const QString &filename); explicit TxtReport(const QString &filename);
~TxtReport() override;
/** /**
* @brief Create the report (file). * @brief Create the report (file).

View File

@ -184,7 +184,7 @@ struct Analyzer {
virtual bool invalid() const { virtual bool invalid() const {
return false; return false;
} }
virtual ~Analyzer() {} virtual ~Analyzer() = default;
Analyzer(const Analyzer&) = default; Analyzer(const Analyzer&) = default;
protected: protected:
Analyzer() = default; Analyzer() = default;

View File

@ -100,8 +100,8 @@ public:
/** Base class used for whole-program analysis */ /** Base class used for whole-program analysis */
class CPPCHECKLIB FileInfo { class CPPCHECKLIB FileInfo {
public: public:
FileInfo() {} FileInfo() = default;
virtual ~FileInfo() {} virtual ~FileInfo() = default;
virtual std::string toString() const { virtual std::string toString() const {
return std::string(); return std::string();
} }

View File

@ -82,7 +82,7 @@ namespace CTU {
: callId(std::move(callId)), callArgNr(callArgNr), callFunctionName(std::move(callFunctionName)), location(std::move(loc)) : callId(std::move(callId)), callArgNr(callArgNr), callFunctionName(std::move(callFunctionName)), location(std::move(loc))
{} {}
CallBase(const Tokenizer *tokenizer, const Token *callToken); CallBase(const Tokenizer *tokenizer, const Token *callToken);
virtual ~CallBase() {} virtual ~CallBase() = default;
CallBase(const CallBase&) = default; CallBase(const CallBase&) = default;
std::string callId; std::string callId;
int callArgNr{}; int callArgNr{};

View File

@ -219,8 +219,8 @@ private:
*/ */
class CPPCHECKLIB ErrorLogger { class CPPCHECKLIB ErrorLogger {
public: public:
ErrorLogger() {} ErrorLogger() = default;
virtual ~ErrorLogger() {} virtual ~ErrorLogger() = default;
/** /**
* Information about progress is directed here. * Information about progress is directed here.

View File

@ -33,7 +33,7 @@ template<class T> class ValuePtr;
struct InferModel { struct InferModel {
virtual bool match(const ValueFlow::Value& value) const = 0; virtual bool match(const ValueFlow::Value& value) const = 0;
virtual ValueFlow::Value yield(MathLib::bigint value) const = 0; virtual ValueFlow::Value yield(MathLib::bigint value) const = 0;
virtual ~InferModel() {} virtual ~InferModel() = default;
InferModel(const InferModel&) = default; InferModel(const InferModel&) = default;
protected: protected:
InferModel() = default; InferModel() = default;

View File

@ -284,9 +284,6 @@ TemplateSimplifier::TemplateSimplifier(Tokenizer &tokenizer)
mErrorLogger(mTokenizer.mErrorLogger) mErrorLogger(mTokenizer.mErrorLogger)
{} {}
TemplateSimplifier::~TemplateSimplifier()
{}
void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates() void TemplateSimplifier::checkComplicatedSyntaxErrorsInTemplates()
{ {
// check for more complicated syntax errors when using templates.. // check for more complicated syntax errors when using templates..

View File

@ -48,7 +48,6 @@ class CPPCHECKLIB TemplateSimplifier {
public: public:
explicit TemplateSimplifier(Tokenizer &tokenizer); explicit TemplateSimplifier(Tokenizer &tokenizer);
~TemplateSimplifier();
std::string dump() const { std::string dump() const {
return mDump; return mDump;

View File

@ -37,7 +37,7 @@ enum class SHOWTIME_MODES {
class CPPCHECKLIB TimerResultsIntf { class CPPCHECKLIB TimerResultsIntf {
public: public:
virtual ~TimerResultsIntf() {} virtual ~TimerResultsIntf() = default;
virtual void addResults(const std::string& str, std::clock_t clocks) = 0; virtual void addResults(const std::string& str, std::clock_t clocks) = 0;
}; };
@ -54,7 +54,7 @@ struct TimerResultsData {
class CPPCHECKLIB TimerResults : public TimerResultsIntf { class CPPCHECKLIB TimerResults : public TimerResultsIntf {
public: public:
TimerResults() {} TimerResults() = default;
void showResults(SHOWTIME_MODES mode) const; void showResults(SHOWTIME_MODES mode) const;
void addResults(const std::string& str, std::clock_t clocks) override; void addResults(const std::string& str, std::clock_t clocks) override;

View File

@ -6676,7 +6676,7 @@ struct ConditionHandler {
} }
}); });
} }
virtual ~ConditionHandler() {} virtual ~ConditionHandler() = default;
ConditionHandler(const ConditionHandler&) = default; ConditionHandler(const ConditionHandler&) = default;
protected: protected:
ConditionHandler() = default; ConditionHandler() = default;
@ -9291,7 +9291,7 @@ struct ValueFlowPass {
virtual void run(const ValueFlowState& state) const = 0; virtual void run(const ValueFlowState& state) const = 0;
// Returns true if pass needs C++ // Returns true if pass needs C++
virtual bool cpp() const = 0; virtual bool cpp() const = 0;
virtual ~ValueFlowPass() noexcept {} virtual ~ValueFlowPass() noexcept = default;
}; };
struct ValueFlowPassRunner { struct ValueFlowPassRunner {

View File

@ -97,7 +97,6 @@ public:
operator bool() const NOEXCEPT { operator bool() const NOEXCEPT {
return !!mPtr; return !!mPtr;
} }
~ValuePtr() {}
private: private:
std::shared_ptr<T> mPtr; std::shared_ptr<T> mPtr;

View File

@ -241,7 +241,6 @@ public:
const std::string classname; const std::string classname;
explicit TestFixture(const char * const _name); explicit TestFixture(const char * const _name);
~TestFixture() override {}
static std::size_t runTests(const options& args); static std::size_t runTests(const options& args);
}; };