ClangTools: Modernize

modernize-use-nullptr
modernize-use-override
modernize-use-equals-default

Change-Id: I14a840c6f2972f57763cdfd4bb4483df1ec261d4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Alessandro Portale
2018-11-04 22:30:54 +01:00
parent 5001927425
commit c4b07bf730
17 changed files with 30 additions and 29 deletions

View File

@@ -363,7 +363,7 @@ SelectableFilesDialog::SelectableFilesDialog(const ProjectInfo &projectInfo,
}); });
} }
SelectableFilesDialog::~SelectableFilesDialog() {} SelectableFilesDialog::~SelectableFilesDialog() = default;
FileInfos SelectableFilesDialog::filteredFileInfos() const FileInfos SelectableFilesDialog::filteredFileInfos() const
{ {

View File

@@ -47,7 +47,7 @@ ClangTidyClazyRunControl::ClangTidyClazyRunControl(
ClangToolRunner *ClangTidyClazyRunControl::createRunner() ClangToolRunner *ClangTidyClazyRunControl::createRunner()
{ {
QTC_ASSERT(!m_clangExecutable.isEmpty(), return 0); QTC_ASSERT(!m_clangExecutable.isEmpty(), return nullptr);
auto runner = new ClangTidyClazyRunner(m_diagnosticConfig, auto runner = new ClangTidyClazyRunner(m_diagnosticConfig,
m_clangExecutable, m_clangExecutable,

View File

@@ -44,7 +44,7 @@ class ClangTool : public QObject
public: public:
ClangTool(const QString &name); ClangTool(const QString &name);
virtual ~ClangTool(); ~ClangTool() override;
virtual void startTool(bool askUserForFileSelection) = 0; virtual void startTool(bool askUserForFileSelection) = 0;

View File

@@ -354,7 +354,7 @@ void ClangToolRunControl::stop()
QSetIterator<ClangToolRunner *> i(m_runners); QSetIterator<ClangToolRunner *> i(m_runners);
while (i.hasNext()) { while (i.hasNext()) {
ClangToolRunner *runner = i.next(); ClangToolRunner *runner = i.next();
QObject::disconnect(runner, 0, this, 0); QObject::disconnect(runner, nullptr, this, nullptr);
delete runner; delete runner;
} }
m_runners.clear(); m_runners.clear();

View File

@@ -50,7 +50,7 @@ struct AnalyzeUnit {
QString file; QString file;
QStringList arguments; // without file itself and "-o somePath" QStringList arguments; // without file itself and "-o somePath"
}; };
typedef QList<AnalyzeUnit> AnalyzeUnits; using AnalyzeUnits = QList<AnalyzeUnit>;
class ClangToolRunControl : public ProjectExplorer::RunWorker class ClangToolRunControl : public ProjectExplorer::RunWorker
{ {

View File

@@ -45,7 +45,7 @@ public:
const Utils::Environment &environment, const Utils::Environment &environment,
const QString &name, const QString &name,
QObject *parent = nullptr); QObject *parent = nullptr);
virtual ~ClangToolRunner(); ~ClangToolRunner() override;
// compilerOptions is expected to contain everything except: // compilerOptions is expected to contain everything except:
// (1) filePath, that is the file to analyze // (1) filePath, that is the file to analyze

View File

@@ -38,8 +38,8 @@ class ClangToolsBasicSettings : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ClangToolsBasicSettings(QWidget *parent = 0); explicit ClangToolsBasicSettings(QWidget *parent = nullptr);
~ClangToolsBasicSettings(); ~ClangToolsBasicSettings() override;
Ui::ClangToolsBasicSettings *ui(); Ui::ClangToolsBasicSettings *ui();
private: private:

View File

@@ -44,7 +44,7 @@ class ClangToolsConfigWidget : public QWidget
public: public:
ClangToolsConfigWidget(ClangToolsSettings *settings, QWidget *parent = nullptr); ClangToolsConfigWidget(ClangToolsSettings *settings, QWidget *parent = nullptr);
~ClangToolsConfigWidget(); ~ClangToolsConfigWidget() override;
private: private:
std::unique_ptr<Ui::ClangToolsConfigWidget> m_ui; std::unique_ptr<Ui::ClangToolsConfigWidget> m_ui;
ClangToolsSettings *m_settings; ClangToolsSettings *m_settings;

View File

@@ -87,7 +87,7 @@ int ClangToolsDiagnosticModel::diagnosticsCount() const
static QString createDiagnosticToolTipString(const Diagnostic &diagnostic) static QString createDiagnosticToolTipString(const Diagnostic &diagnostic)
{ {
typedef QPair<QString, QString> StringPair; using StringPair = QPair<QString, QString>;
QList<StringPair> lines; QList<StringPair> lines;
if (!diagnostic.category.isEmpty()) { if (!diagnostic.category.isEmpty()) {
@@ -140,7 +140,7 @@ static QString createExplainingStepToolTipString(const ExplainingStep &step)
if (step.message == step.extendedMessage) if (step.message == step.extendedMessage)
return createFullLocationString(step.location); return createFullLocationString(step.location);
typedef QPair<QString, QString> StringPair; using StringPair = QPair<QString, QString>;
QList<StringPair> lines; QList<StringPair> lines;
if (!step.message.isEmpty()) { if (!step.message.isEmpty()) {

View File

@@ -115,7 +115,7 @@ public:
ProjectExplorer::Project *project() const { return m_project; } ProjectExplorer::Project *project() const { return m_project; }
private: private:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
void handleSuppressedDiagnosticsChanged(); void handleSuppressedDiagnosticsChanged();
QPointer<ProjectExplorer::Project> m_project; QPointer<ProjectExplorer::Project> m_project;

View File

@@ -47,7 +47,7 @@ class ClickableFixItHeader : public QHeaderView
Q_OBJECT Q_OBJECT
public: public:
ClickableFixItHeader(Qt::Orientation orientation, QWidget *parent = 0) ClickableFixItHeader(Qt::Orientation orientation, QWidget *parent = nullptr)
: QHeaderView(orientation, parent) : QHeaderView(orientation, parent)
{ {
} }
@@ -58,7 +58,7 @@ public:
} }
protected: protected:
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override
{ {
painter->save(); painter->save();
QHeaderView::paintSection(painter, rect, logicalIndex); QHeaderView::paintSection(painter, rect, logicalIndex);
@@ -72,7 +72,7 @@ protected:
} }
} }
void mousePressEvent(QMouseEvent *event) void mousePressEvent(QMouseEvent *event) override
{ {
if (event->localPos().x() > sectionPosition(DiagnosticView::FixItColumn)) { if (event->localPos().x() > sectionPosition(DiagnosticView::FixItColumn)) {
state = (state != QStyle::State_On) ? QStyle::State_On : QStyle::State_Off; state = (state != QStyle::State_On) ? QStyle::State_On : QStyle::State_Off;

View File

@@ -35,7 +35,7 @@ class DiagnosticView : public Debugger::DetailedErrorView
Q_OBJECT Q_OBJECT
public: public:
DiagnosticView(QWidget *parent = 0); DiagnosticView(QWidget *parent = nullptr);
enum ExtraColumn { enum ExtraColumn {
FixItColumn = LocationColumn + 1, FixItColumn = LocationColumn + 1,
@@ -46,7 +46,7 @@ public:
private: private:
void suppressCurrentDiagnostic(); void suppressCurrentDiagnostic();
QList<QAction *> customActions() const; QList<QAction *> customActions() const override;
bool eventFilter(QObject *watched, QEvent *event) override; bool eventFilter(QObject *watched, QEvent *event) override;
void setModel(QAbstractItemModel *model) override; void setModel(QAbstractItemModel *model) override;

View File

@@ -82,19 +82,19 @@ public:
setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
} }
QWidget *widget() QWidget *widget() override
{ {
if (!m_widget) if (!m_widget)
m_widget = new ClangToolsConfigWidget(ClangToolsSettings::instance()); m_widget = new ClangToolsConfigWidget(ClangToolsSettings::instance());
return m_widget; return m_widget;
} }
void apply() void apply() override
{ {
ClangToolsSettings::instance()->writeSettings(); ClangToolsSettings::instance()->writeSettings();
} }
void finish() void finish() override
{ {
delete m_widget; delete m_widget;
} }

View File

@@ -65,7 +65,7 @@ inline bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnosti
&& d1.uniquifier == d2.uniquifier; && d1.uniquifier == d2.uniquifier;
} }
typedef QList<SuppressedDiagnostic> SuppressedDiagnosticsList; using SuppressedDiagnosticsList = QList<SuppressedDiagnostic>;
class ClangToolsProjectSettings : public QObject class ClangToolsProjectSettings : public QObject
{ {

View File

@@ -39,7 +39,7 @@ class SuppressedDiagnosticsModel : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
public: public:
SuppressedDiagnosticsModel(QObject *parent = 0) : QAbstractTableModel(parent) { } SuppressedDiagnosticsModel(QObject *parent = nullptr) : QAbstractTableModel(parent) { }
void setDiagnostics(const SuppressedDiagnosticsList &diagnostics); void setDiagnostics(const SuppressedDiagnosticsList &diagnostics);
SuppressedDiagnostic diagnosticAt(int i) const; SuppressedDiagnostic diagnosticAt(int i) const;
@@ -47,10 +47,11 @@ public:
private: private:
enum Columns { ColumnFile, ColumnContext, ColumnDescription, ColumnLast = ColumnDescription }; enum Columns { ColumnFile, ColumnContext, ColumnDescription, ColumnLast = ColumnDescription };
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex & = QModelIndex()) const { return ColumnLast + 1; } int columnCount(const QModelIndex & = QModelIndex()) const override { return ColumnLast + 1; }
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QVariant headerData(int section, Qt::Orientation orientation,
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
SuppressedDiagnosticsList m_diagnostics; SuppressedDiagnosticsList m_diagnostics;
}; };

View File

@@ -40,8 +40,8 @@ class ProjectSettingsWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent = 0); explicit ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent = nullptr);
~ProjectSettingsWidget(); ~ProjectSettingsWidget() override;
private: private:
void updateButtonStates(); void updateButtonStates();

View File

@@ -37,7 +37,7 @@ class ClangToolsUnitTests : public QObject
Q_OBJECT Q_OBJECT
public: public:
ClangToolsUnitTests() {} ClangToolsUnitTests() = default;
private slots: private slots:
void initTestCase(); void initTestCase();