aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/3rdparty/python/bin/dmgbuild7
-rw-r--r--src/app/config-ui/commandlineparser.h2
-rw-r--r--src/app/config-ui/mainwindow.cpp44
-rw-r--r--src/app/config-ui/mainwindow.h4
-rw-r--r--src/app/config/configcommandlineparser.h2
-rw-r--r--src/app/qbs-create-project/createproject.h2
-rw-r--r--src/app/qbs-setup-android/android-setup.cpp30
-rw-r--r--src/app/qbs-setup-android/commandlineparser.h2
-rw-r--r--src/app/qbs-setup-qt/commandlineparser.h4
-rw-r--r--src/app/qbs-setup-toolchains/clangclprobe.cpp172
-rw-r--r--src/app/qbs-setup-toolchains/clangclprobe.h55
-rw-r--r--src/app/qbs-setup-toolchains/commandlineparser.h4
-rw-r--r--src/app/qbs-setup-toolchains/iarewprobe.cpp196
-rw-r--r--src/app/qbs-setup-toolchains/iarewprobe.h65
-rw-r--r--src/app/qbs-setup-toolchains/keilprobe.cpp191
-rw-r--r--src/app/qbs-setup-toolchains/keilprobe.h65
-rw-r--r--src/app/qbs-setup-toolchains/msvcprobe.cpp36
-rw-r--r--src/app/qbs-setup-toolchains/msvcprobe.h12
-rw-r--r--src/app/qbs-setup-toolchains/probe.cpp146
-rw-r--r--src/app/qbs-setup-toolchains/probe.h2
-rw-r--r--src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro12
-rw-r--r--src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs8
-rw-r--r--src/app/qbs-setup-toolchains/sdccprobe.cpp166
-rw-r--r--src/app/qbs-setup-toolchains/sdccprobe.h65
-rw-r--r--src/app/qbs-setup-toolchains/xcodeprobe.cpp98
-rw-r--r--src/app/qbs/commandlinefrontend.cpp4
-rw-r--r--src/app/qbs/commandlinefrontend.h18
-rw-r--r--src/app/qbs/qbstool.h4
-rw-r--r--src/app/shared/logging/consolelogger.h2
-rw-r--r--src/lib/corelib/api/internaljobs.cpp21
-rw-r--r--src/lib/corelib/api/internaljobs.h12
-rw-r--r--src/lib/corelib/api/jobs.h2
-rw-r--r--src/lib/corelib/api/project.cpp21
-rw-r--r--src/lib/corelib/api/projectdata.cpp127
-rw-r--r--src/lib/corelib/api/projectdata.h15
-rw-r--r--src/lib/corelib/api/projectdata_p.h43
-rw-r--r--src/lib/corelib/api/projectfileupdater.cpp2
-rw-r--r--src/lib/corelib/api/projectfileupdater.h1
-rw-r--r--src/lib/corelib/api/runenvironment.cpp22
-rw-r--r--src/lib/corelib/buildgraph/abstractcommandexecutor.cpp4
-rw-r--r--src/lib/corelib/buildgraph/abstractcommandexecutor.h2
-rw-r--r--src/lib/corelib/buildgraph/artifact.h2
-rw-r--r--src/lib/corelib/buildgraph/artifactcleaner.cpp14
-rw-r--r--src/lib/corelib/buildgraph/artifactcleaner.h6
-rw-r--r--src/lib/corelib/buildgraph/buildgraph.cpp9
-rw-r--r--src/lib/corelib/buildgraph/buildgraphloader.cpp11
-rw-r--r--src/lib/corelib/buildgraph/buildgraphloader.h6
-rw-r--r--src/lib/corelib/buildgraph/buildgraphvisitor.h1
-rw-r--r--src/lib/corelib/buildgraph/cycledetector.cpp7
-rw-r--r--src/lib/corelib/buildgraph/cycledetector.h2
-rw-r--r--src/lib/corelib/buildgraph/depscanner.cpp4
-rw-r--r--src/lib/corelib/buildgraph/depscanner.h2
-rw-r--r--src/lib/corelib/buildgraph/emptydirectoriesremover.cpp4
-rw-r--r--src/lib/corelib/buildgraph/emptydirectoriesremover.h2
-rw-r--r--src/lib/corelib/buildgraph/environmentscriptrunner.h2
-rw-r--r--src/lib/corelib/buildgraph/executor.cpp34
-rw-r--r--src/lib/corelib/buildgraph/executor.h16
-rw-r--r--src/lib/corelib/buildgraph/executorjob.h12
-rw-r--r--src/lib/corelib/buildgraph/filedependency.h2
-rw-r--r--src/lib/corelib/buildgraph/inputartifactscanner.cpp11
-rw-r--r--src/lib/corelib/buildgraph/inputartifactscanner.h2
-rw-r--r--src/lib/corelib/buildgraph/jscommandexecutor.cpp6
-rw-r--r--src/lib/corelib/buildgraph/jscommandexecutor.h2
-rw-r--r--src/lib/corelib/buildgraph/nodetreedumper.h2
-rw-r--r--src/lib/corelib/buildgraph/processcommandexecutor.cpp6
-rw-r--r--src/lib/corelib/buildgraph/productbuilddata.h2
-rw-r--r--src/lib/corelib/buildgraph/productinstaller.cpp16
-rw-r--r--src/lib/corelib/buildgraph/productinstaller.h6
-rw-r--r--src/lib/corelib/buildgraph/projectbuilddata.cpp19
-rw-r--r--src/lib/corelib/buildgraph/projectbuilddata.h17
-rw-r--r--src/lib/corelib/buildgraph/rawscanneddependency.h2
-rw-r--r--src/lib/corelib/buildgraph/requestedartifacts.cpp35
-rw-r--r--src/lib/corelib/buildgraph/rulegraph.h1
-rw-r--r--src/lib/corelib/buildgraph/rulenode.h2
-rw-r--r--src/lib/corelib/buildgraph/rulesapplicator.cpp32
-rw-r--r--src/lib/corelib/buildgraph/rulesapplicator.h8
-rw-r--r--src/lib/corelib/buildgraph/rulesevaluationcontext.cpp4
-rw-r--r--src/lib/corelib/buildgraph/rulesevaluationcontext.h2
-rw-r--r--src/lib/corelib/buildgraph/transformer.cpp3
-rw-r--r--src/lib/corelib/buildgraph/transformerchangetracking.cpp10
-rw-r--r--src/lib/corelib/generators/generatableprojectiterator.cpp4
-rw-r--r--src/lib/corelib/generators/generatableprojectiterator.h2
-rw-r--r--src/lib/corelib/generators/generator.cpp2
-rw-r--r--src/lib/corelib/generators/generator.h2
-rw-r--r--src/lib/corelib/jsextensions/binaryfile.cpp2
-rw-r--r--src/lib/corelib/jsextensions/environmentextension.cpp3
-rw-r--r--src/lib/corelib/jsextensions/process.cpp2
-rw-r--r--src/lib/corelib/jsextensions/propertylist.mm2
-rw-r--r--src/lib/corelib/jsextensions/textfile.cpp2
-rw-r--r--src/lib/corelib/jsextensions/utilitiesextension.cpp101
-rw-r--r--src/lib/corelib/language/astimportshandler.cpp6
-rw-r--r--src/lib/corelib/language/builtindeclarations.cpp3
-rw-r--r--src/lib/corelib/language/evaluationdata.h4
-rw-r--r--src/lib/corelib/language/identifiersearch.h2
-rw-r--r--src/lib/corelib/language/item.cpp3
-rw-r--r--src/lib/corelib/language/itemobserver.h1
-rw-r--r--src/lib/corelib/language/itempool.cpp4
-rw-r--r--src/lib/corelib/language/itempool.h5
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.cpp4
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.h2
-rw-r--r--src/lib/corelib/language/language.cpp4
-rw-r--r--src/lib/corelib/language/language.h26
-rw-r--r--src/lib/corelib/language/loader.cpp6
-rw-r--r--src/lib/corelib/language/loader.h2
-rw-r--r--src/lib/corelib/language/moduleloader.cpp24
-rw-r--r--src/lib/corelib/language/moduleloader.h28
-rw-r--r--src/lib/corelib/language/projectresolver.cpp18
-rw-r--r--src/lib/corelib/language/projectresolver.h22
-rw-r--r--src/lib/corelib/language/scriptengine.cpp12
-rw-r--r--src/lib/corelib/language/scriptengine.h7
-rw-r--r--src/lib/corelib/language/scriptimporter.cpp4
-rw-r--r--src/lib/corelib/language/value.cpp4
-rw-r--r--src/lib/corelib/language/value.h4
-rw-r--r--src/lib/corelib/logging/ilogsink.cpp3
-rw-r--r--src/lib/corelib/logging/logger.cpp3
-rw-r--r--src/lib/corelib/parser/qmljsast_p.h536
-rw-r--r--src/lib/corelib/parser/qmljsparser.cpp6
-rw-r--r--src/lib/corelib/parser/qmljsparser_p.h6
-rw-r--r--src/lib/corelib/tools/applecodesignutils.cpp6
-rw-r--r--src/lib/corelib/tools/buildgraphlocker.cpp4
-rw-r--r--src/lib/corelib/tools/buildgraphlocker.h2
-rw-r--r--src/lib/corelib/tools/codelocation.cpp4
-rw-r--r--src/lib/corelib/tools/executablefinder.cpp7
-rw-r--r--src/lib/corelib/tools/executablefinder.h4
-rw-r--r--src/lib/corelib/tools/fileinfo.cpp5
-rw-r--r--src/lib/corelib/tools/fileinfo.h2
-rw-r--r--src/lib/corelib/tools/filesaver.cpp4
-rw-r--r--src/lib/corelib/tools/filesaver.h2
-rw-r--r--src/lib/corelib/tools/filetime.h2
-rw-r--r--src/lib/corelib/tools/hostosinfo.h9
-rw-r--r--src/lib/corelib/tools/id.cpp10
-rw-r--r--src/lib/corelib/tools/joblimits.cpp3
-rw-r--r--src/lib/corelib/tools/jsliterals.cpp3
-rw-r--r--src/lib/corelib/tools/launcherinterface.cpp2
-rw-r--r--src/lib/corelib/tools/launcherinterface.h2
-rw-r--r--src/lib/corelib/tools/launcherpackets.h12
-rw-r--r--src/lib/corelib/tools/msvcinfo.cpp88
-rw-r--r--src/lib/corelib/tools/msvcinfo.h11
-rw-r--r--src/lib/corelib/tools/persistence.cpp4
-rw-r--r--src/lib/corelib/tools/persistence.h20
-rw-r--r--src/lib/corelib/tools/preferences.cpp16
-rw-r--r--src/lib/corelib/tools/preferences.h4
-rw-r--r--src/lib/corelib/tools/processresult_p.h6
-rw-r--r--src/lib/corelib/tools/qbsprocess.h2
-rw-r--r--src/lib/corelib/tools/qttools.h10
-rw-r--r--src/lib/corelib/tools/scripttools.h2
-rw-r--r--src/lib/corelib/tools/set.h8
-rw-r--r--src/lib/corelib/tools/settingscreator.cpp10
-rw-r--r--src/lib/corelib/tools/settingscreator.h2
-rw-r--r--src/lib/corelib/tools/settingsmodel.cpp6
-rw-r--r--src/lib/corelib/tools/settingsmodel.h2
-rw-r--r--src/lib/corelib/tools/setupprojectparameters.cpp4
-rw-r--r--src/lib/corelib/tools/setupprojectparameters.h2
-rw-r--r--src/lib/corelib/tools/shellutils.h2
-rw-r--r--src/lib/corelib/tools/vsenvironmentdetector.cpp25
-rw-r--r--src/lib/corelib/tools/vsenvironmentdetector.h3
-rw-r--r--src/libexec/qbs_processlauncher/launchersockethandler.cpp4
-rw-r--r--src/libexec/qbs_processlauncher/launchersockethandler.h4
-rw-r--r--src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp12
-rw-r--r--src/plugins/generator/makefilegenerator/makefilegenerator.cpp33
-rw-r--r--src/plugins/generator/visualstudio/io/msbuildprojectwriter.cpp2
-rw-r--r--src/plugins/generator/visualstudio/io/visualstudiosolutionwriter.cpp11
-rw-r--r--src/plugins/generator/visualstudio/msbuild/imsbuildgroup.h2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/imsbuildproperty.h2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/items/msbuildfileitem.h2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.cpp4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.h2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuildimport.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuilditem.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuilditemdefinitiongroup.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuilditemgroup.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuilditemmetadata.h2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuildproject.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuildproperty.h2
-rw-r--r--src/plugins/generator/visualstudio/msbuild/msbuildpropertygroup.h4
-rw-r--r--src/plugins/generator/visualstudio/msbuildfiltersproject.cpp10
-rw-r--r--src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp9
-rw-r--r--src/plugins/generator/visualstudio/msbuildtargetproject.cpp4
-rw-r--r--src/plugins/generator/visualstudio/msbuildtargetproject.h2
-rw-r--r--src/plugins/generator/visualstudio/solution/ivisualstudiosolutionproject.h2
-rw-r--r--src/plugins/generator/visualstudio/solution/visualstudiosolution.cpp4
-rw-r--r--src/plugins/generator/visualstudio/solution/visualstudiosolution.h2
-rw-r--r--src/plugins/generator/visualstudio/solution/visualstudiosolutionfileproject.h2
-rw-r--r--src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.h2
-rw-r--r--src/plugins/generator/visualstudio/visualstudiogenerator.cpp12
-rw-r--r--src/plugins/generator/visualstudio/visualstudiogenerator.h8
-rw-r--r--src/plugins/scanner/cpp/Lexer.h14
-rw-r--r--src/plugins/scanner/cpp/Token.h2
-rw-r--r--src/plugins/scanner/qt/qtscanner.cpp20
-rw-r--r--src/shared/json/json.cpp28
193 files changed, 2286 insertions, 1144 deletions
diff --git a/src/3rdparty/python/bin/dmgbuild b/src/3rdparty/python/bin/dmgbuild
index 113ae0998..4647448da 100755
--- a/src/3rdparty/python/bin/dmgbuild
+++ b/src/3rdparty/python/bin/dmgbuild
@@ -33,4 +33,9 @@ for d in args.defines:
v = v[1:-1]
defines[k] = v
-dmgbuild.build_dmg(args.filename, args.volume_name, args.settings, defines=defines, lookForHiDPI=args.lookForHiDPI)
+dmgbuild.build_dmg(
+ args.filename.decode('utf_8'),
+ args.volume_name.decode('utf_8'),
+ args.settings.decode('utf_8'),
+ defines=defines,
+ lookForHiDPI=args.lookForHiDPI)
diff --git a/src/app/config-ui/commandlineparser.h b/src/app/config-ui/commandlineparser.h
index dc43d33b3..b8ab1a9f0 100644
--- a/src/app/config-ui/commandlineparser.h
+++ b/src/app/config-ui/commandlineparser.h
@@ -59,7 +59,7 @@ private:
void assignOptionArgument(const QString &option, QString &argument);
[[noreturn]] void complainAboutExtraArguments();
- bool m_helpRequested;
+ bool m_helpRequested = false;
qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope;
QString m_settingsDir;
QStringList m_commandLine;
diff --git a/src/app/config-ui/mainwindow.cpp b/src/app/config-ui/mainwindow.cpp
index 13708366a..2bf7fad5e 100644
--- a/src/app/config-ui/mainwindow.cpp
+++ b/src/app/config-ui/mainwindow.cpp
@@ -49,9 +49,52 @@
#include <QtGui/qkeysequence.h>
#include <QtWidgets/qaction.h>
+#include <QtWidgets/qlineedit.h>
#include <QtWidgets/qmenu.h>
#include <QtWidgets/qmenubar.h>
#include <QtWidgets/qmessagebox.h>
+#include <QtWidgets/qstyleditemdelegate.h>
+
+namespace {
+
+class TrimValidator : public QValidator
+{
+public:
+ explicit TrimValidator(QObject *parent = nullptr) : QValidator(parent) {}
+
+public: // QValidator interface
+ State validate(QString &input, int &pos) const override
+ {
+ Q_UNUSED(pos);
+ if (input.startsWith(QLatin1Char(' ')) || input.endsWith(QLatin1Char(' ')))
+ return State::Intermediate;
+ return State::Acceptable;
+ }
+
+ void fixup(QString &input) const override
+ {
+ input = input.trimmed();
+ }
+};
+
+class SettingsItemDelegate: public QStyledItemDelegate
+{
+public:
+ explicit SettingsItemDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
+
+ QWidget *createEditor(QWidget *parent,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override
+ {
+ const auto editor = QStyledItemDelegate::createEditor(parent, option, index);
+ const auto lineEdit = qobject_cast<QLineEdit *>(editor);
+ if (lineEdit)
+ lineEdit->setValidator(new TrimValidator(lineEdit));
+ return editor;
+ }
+};
+
+} // namespace
MainWindow::MainWindow(const QString &settingsDir, qbs::Settings::Scope scope, QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
@@ -59,6 +102,7 @@ MainWindow::MainWindow(const QString &settingsDir, qbs::Settings::Scope scope, Q
ui->setupUi(this);
m_model = new qbs::SettingsModel(settingsDir, scope, this);
ui->treeView->setModel(m_model);
+ ui->treeView->setItemDelegate(new SettingsItemDelegate(ui->treeView));
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->treeView, &QTreeView::expanded, this, &MainWindow::adjustColumns);
connect(ui->treeView, &QWidget::customContextMenuRequested,
diff --git a/src/app/config-ui/mainwindow.h b/src/app/config-ui/mainwindow.h
index 567a183f1..b8a12d61f 100644
--- a/src/app/config-ui/mainwindow.h
+++ b/src/app/config-ui/mainwindow.h
@@ -57,9 +57,9 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(const QString &settingsDir, qbs::Settings::Scope scope,
QWidget *parent = nullptr);
- ~MainWindow();
+ ~MainWindow() override;
- bool eventFilter(QObject *watched, QEvent *event);
+ bool eventFilter(QObject *watched, QEvent *event) override;
private:
void adjustColumns();
diff --git a/src/app/config/configcommandlineparser.h b/src/app/config/configcommandlineparser.h
index 22f6906f9..b567134fd 100644
--- a/src/app/config/configcommandlineparser.h
+++ b/src/app/config/configcommandlineparser.h
@@ -73,7 +73,7 @@ private:
ConfigCommand m_command;
qbs::Settings::Scopes m_scope = qbs::Settings::allScopes();
- bool m_helpRequested;
+ bool m_helpRequested = false;
QString m_settingsDir;
QStringList m_commandLine;
};
diff --git a/src/app/qbs-create-project/createproject.h b/src/app/qbs-create-project/createproject.h
index 95df434d9..efc217b68 100644
--- a/src/app/qbs-create-project/createproject.h
+++ b/src/app/qbs-create-project/createproject.h
@@ -82,7 +82,7 @@ private:
std::vector<ProjectPtr> subProjects;
};
Project m_topLevelProject;
- ProjectStructure m_projectStructure;
+ ProjectStructure m_projectStructure = ProjectStructure::Flat;
QList<QRegExp> m_whiteList;
QList<QRegExp> m_blackList;
};
diff --git a/src/app/qbs-setup-android/android-setup.cpp b/src/app/qbs-setup-android/android-setup.cpp
index 4a3c8aef9..029628419 100644
--- a/src/app/qbs-setup-android/android-setup.cpp
+++ b/src/app/qbs-setup-android/android-setup.cpp
@@ -68,12 +68,6 @@ static QStringList expectedArchs()
QStringLiteral("x86"), QStringLiteral("x86_64")};
}
-
-static QString subProfileName(const QString &mainProfileName, const QString &arch)
-{
- return mainProfileName + QLatin1Char('-') + arch;
-}
-
void setupSdk(qbs::Settings *settings, const QString &profileName, const QString &sdkDirPath)
{
if (!QDir(sdkDirPath).exists()) {
@@ -145,8 +139,8 @@ static QtInfoPerArch getQtAndroidInfo(const QString &qtSdkDir)
QDirIterator dit(qtSdkDir, QStringList() << QStringLiteral("android_*"), QDir::Dirs);
while (dit.hasNext())
qtDirs << dit.next();
- for (auto it = qtDirs.cbegin(); it != qtDirs.cend(); ++it) {
- const QtAndroidInfo info = getInfoForQtDir(*it);
+ for (const auto &qtDir : qtDirs) {
+ const QtAndroidInfo info = getInfoForQtDir(qtDir);
if (info.isValid())
archs.insert(info.arch, info);
}
@@ -227,25 +221,7 @@ static void setupNdk(qbs::Settings *settings, const QString &profileName, const
const QtAndroidInfo qtAndroidInfo = infoPerArch.value(arch);
if (!qtAndroidInfo.isValid())
continue;
- const QString subProName = subProfileName(profileName, arch);
- const QString setupQtPath = qApp->applicationDirPath() + qls("/qbs-setup-qt");
- QProcess setupQt;
- setupQt.start(setupQtPath, QStringList({ qtAndroidInfo.qmakePath, subProName }));
- if (!setupQt.waitForStarted()) {
- throw ErrorInfo(Tr::tr("Setting up Qt profile failed: '%1' "
- "could not be started.").arg(setupQtPath));
- }
- if (!setupQt.waitForFinished()) {
- throw ErrorInfo(Tr::tr("Setting up Qt profile failed: Error running '%1' (%2)")
- .arg(setupQtPath, setupQt.errorString()));
- }
- if (setupQt.exitCode() != 0) {
- throw ErrorInfo(Tr::tr("Setting up Qt profile failed: '%1' returned with "
- "exit code %2.").arg(setupQtPath).arg(setupQt.exitCode()));
- }
- settings->sync();
- qbs::Internal::TemporaryProfile p(subProName, settings);
- qmakeFilePaths << p.p.value(qls("moduleProviders.Qt.qmakeFilePaths")).toStringList();
+ qmakeFilePaths << qtAndroidInfo.qmakePath;
platform = maximumPlatform(platform, qtAndroidInfo.platform);
}
if (!qmakeFilePaths.empty())
diff --git a/src/app/qbs-setup-android/commandlineparser.h b/src/app/qbs-setup-android/commandlineparser.h
index 729f28cb9..3ce3eeb40 100644
--- a/src/app/qbs-setup-android/commandlineparser.h
+++ b/src/app/qbs-setup-android/commandlineparser.h
@@ -63,7 +63,7 @@ private:
void assignOptionArgument(const QString &option, QString &argument);
[[noreturn]] void complainAboutExtraArguments();
- bool m_helpRequested;
+ bool m_helpRequested = false;
QString m_sdkDir;
QString m_ndkDir;
QString m_qtSdkDir;
diff --git a/src/app/qbs-setup-qt/commandlineparser.h b/src/app/qbs-setup-qt/commandlineparser.h
index a9ecb55c8..c766a9df2 100644
--- a/src/app/qbs-setup-qt/commandlineparser.h
+++ b/src/app/qbs-setup-qt/commandlineparser.h
@@ -63,8 +63,8 @@ private:
void assignOptionArgument(const QString &option, QString &argument);
[[noreturn]] void complainAboutExtraArguments();
- bool m_helpRequested;
- bool m_autoDetectionMode;
+ bool m_helpRequested = false;
+ bool m_autoDetectionMode = false;
qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope;
QString m_qmakePath;
QString m_profileName;
diff --git a/src/app/qbs-setup-toolchains/clangclprobe.cpp b/src/app/qbs-setup-toolchains/clangclprobe.cpp
new file mode 100644
index 000000000..89075c5e8
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/clangclprobe.cpp
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com)
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "clangclprobe.h"
+#include "msvcprobe.h"
+#include "probe.h"
+
+#include "../shared/logging/consolelogger.h"
+
+#include <logging/translator.h>
+#include <tools/hostosinfo.h>
+#include <tools/profile.h>
+#include <tools/qttools.h>
+#include <tools/settings.h>
+
+#include <QtCore/qdir.h>
+#include <QtCore/qfileinfo.h>
+
+using qbs::Settings;
+using qbs::Profile;
+using qbs::Internal::HostOsInfo;
+
+using qbs::Internal::Tr;
+
+namespace {
+
+QString getToolchainInstallPath(const QString &compilerFilePath)
+{
+ return QFileInfo(compilerFilePath).path(); // 1 level up
+}
+
+Profile createProfileHelper(
+ Settings *settings,
+ const QString &profileName,
+ const QString &toolchainInstallPath,
+ const QString &vcvarsallPath,
+ const QString &architecture)
+{
+ Profile profile(profileName, settings);
+ profile.removeProfile();
+ profile.setValue(QStringLiteral("qbs.architecture"), architecture);
+ profile.setValue(
+ QStringLiteral("qbs.toolchain"),
+ QStringList{QStringLiteral("clang-cl"), QStringLiteral("msvc")});
+ profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), toolchainInstallPath);
+ profile.setValue(QStringLiteral("cpp.vcvarsallPath"), vcvarsallPath);
+ qbsInfo() << Tr::tr("Profile '%1' created for '%2'.")
+ .arg(profile.name(), QDir::toNativeSeparators(toolchainInstallPath));
+ return profile;
+}
+
+std::vector<MSVCInstallInfo> compatibleMsvcs()
+{
+ auto msvcs = installedMSVCs();
+ auto filter = [](const MSVCInstallInfo &info)
+ {
+ const auto versions = info.version.split(QLatin1Char('.'));
+ if (versions.empty())
+ return true;
+ bool ok = false;
+ const int major = versions.at(0).toInt(&ok);
+ return !(ok && major >= 15); // support MSVC2017 and above
+ };
+ const auto it = std::remove_if(msvcs.begin(), msvcs.end(), filter);
+ msvcs.erase(it, msvcs.end());
+ for (const auto &msvc: msvcs) {
+ auto vcvarsallPath = msvc.findVcvarsallBat();
+ if (vcvarsallPath.isEmpty())
+ continue;
+ }
+ return msvcs;
+}
+
+QString findCompatibleVcsarsallBat()
+{
+ for (const auto &msvc: compatibleMsvcs()) {
+ const auto vcvarsallPath = msvc.findVcvarsallBat();
+ if (!vcvarsallPath.isEmpty())
+ return vcvarsallPath;
+ }
+ return {};
+}
+
+} // namespace
+
+void createClangClProfile(
+ const QString &profileName, const QString &compilerFilePath, Settings *settings)
+{
+ const auto compilerName = QStringLiteral("clang-cl");
+ const auto vcvarsallPath = findCompatibleVcsarsallBat();
+ if (vcvarsallPath.isEmpty()) {
+ qbsWarning()
+ << Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.")
+ .arg(compilerName);
+ return;
+ }
+
+ const auto toolchainInstallPath = getToolchainInstallPath(compilerFilePath);
+ const auto hostArch = QString::fromStdString(HostOsInfo::hostOSArchitecture());
+ createProfileHelper(settings, profileName, toolchainInstallPath, vcvarsallPath, hostArch);
+}
+
+/*!
+ \brief Creates a clang-cl profile based on auto-detected vsversion.
+ \internal
+*/
+void clangClProbe(Settings *settings, QList<Profile> &profiles)
+{
+ const auto compilerName = QStringLiteral("clang-cl");
+ qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName);
+ const auto compilerFilePath = findExecutable(HostOsInfo::appendExecutableSuffix(compilerName));
+ if (compilerFilePath.isEmpty()) {
+ qbsInfo() << Tr::tr("%1 was not found.").arg(compilerName);
+ return;
+ }
+
+ const auto vcvarsallPath = findCompatibleVcsarsallBat();
+ if (vcvarsallPath.isEmpty()) {
+ qbsWarning()
+ << Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.")
+ .arg(compilerName);
+ return;
+ }
+
+ const QString architectures[] = {
+ QStringLiteral("x86_64"),
+ QStringLiteral("x86")
+ };
+ const auto toolchainInstallPath = getToolchainInstallPath(compilerFilePath);
+ for (const auto &arch: architectures) {
+ const auto profileName = QStringLiteral("clang-cl-%1").arg(arch);
+ auto profile = createProfileHelper(
+ settings, profileName, toolchainInstallPath, vcvarsallPath, arch);
+ profiles.push_back(std::move(profile));
+ }
+}
diff --git a/src/app/qbs-setup-toolchains/clangclprobe.h b/src/app/qbs-setup-toolchains/clangclprobe.h
new file mode 100644
index 000000000..1e7724fbf
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/clangclprobe.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com)
+** Contact: http://www.qt.io/licensing
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CLANGCLPROBE_H
+#define CLANGCLPROBE_H
+
+#include <QtCore/qlist.h>
+
+namespace qbs {
+class Profile;
+class Settings;
+}
+
+void createClangClProfile(
+ const QString &profileName, const QString &compilerFilePath, qbs::Settings *settings);
+
+void clangClProbe(qbs::Settings *settings, QList<qbs::Profile> &profiles);
+
+#endif // CLANGCLPROBE_H
diff --git a/src/app/qbs-setup-toolchains/commandlineparser.h b/src/app/qbs-setup-toolchains/commandlineparser.h
index cb0949bf1..9d5b0c246 100644
--- a/src/app/qbs-setup-toolchains/commandlineparser.h
+++ b/src/app/qbs-setup-toolchains/commandlineparser.h
@@ -64,8 +64,8 @@ private:
void assignOptionArgument(const QString &option, QString &argument);
[[noreturn]] void complainAboutExtraArguments();
- bool m_helpRequested;
- bool m_autoDetectionMode;
+ bool m_helpRequested = false;
+ bool m_autoDetectionMode = false;
qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope;
QString m_compilerPath;
QString m_toolchainType;
diff --git a/src/app/qbs-setup-toolchains/iarewprobe.cpp b/src/app/qbs-setup-toolchains/iarewprobe.cpp
new file mode 100644
index 000000000..5d3785759
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/iarewprobe.cpp
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "probe.h"
+#include "iarewprobe.h"
+
+#include "../shared/logging/consolelogger.h"
+
+#include <logging/translator.h>
+
+#include <tools/hostosinfo.h>
+#include <tools/profile.h>
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qsettings.h>
+
+using namespace qbs;
+using Internal::Tr;
+using Internal::HostOsInfo;
+
+static QStringList knownIarCompilerNames()
+{
+ return {QStringLiteral("icc8051"), QStringLiteral("iccarm"), QStringLiteral("iccavr")};
+}
+
+static QString guessIarArchitecture(const QFileInfo &compiler)
+{
+ const auto baseName = compiler.baseName();
+ if (baseName == QLatin1String("icc8051"))
+ return QStringLiteral("mcs51");
+ if (baseName == QLatin1String("iccarm"))
+ return QStringLiteral("arm");
+ if (baseName == QLatin1String("iccavr"))
+ return QStringLiteral("avr");
+ return {};
+}
+
+static Profile createIarProfileHelper(const QFileInfo &compiler, Settings *settings,
+ QString profileName = QString())
+{
+ const QString architecture = guessIarArchitecture(compiler);
+
+ // In case the profile is auto-detected.
+ if (profileName.isEmpty())
+ profileName = QLatin1String("iar-") + architecture;
+
+ Profile profile(profileName, settings);
+ profile.setValue(QLatin1String("cpp.toolchainInstallPath"), compiler.absolutePath());
+ profile.setValue(QLatin1String("qbs.toolchainType"), QLatin1String("iar"));
+ if (!architecture.isEmpty())
+ profile.setValue(QLatin1String("qbs.architecture"), architecture);
+
+ qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg(
+ profile.name(), compiler.absoluteFilePath());
+ return profile;
+}
+
+static std::vector<IarInstallInfo> installedIarsFromPath()
+{
+ std::vector<IarInstallInfo> infos;
+ const auto compilerNames = knownIarCompilerNames();
+ for (const QString &compilerName : compilerNames) {
+ const QFileInfo iarPath(
+ findExecutable(
+ HostOsInfo::appendExecutableSuffix(compilerName)));
+ if (!iarPath.exists())
+ continue;
+ infos.push_back({iarPath.absoluteFilePath(), {}});
+ }
+ return infos;
+}
+
+static std::vector<IarInstallInfo> installedIarsFromRegistry()
+{
+ std::vector<IarInstallInfo> infos;
+
+ if (HostOsInfo::isWindowsHost()) {
+
+#ifdef Q_OS_WIN64
+ static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\IAR Systems\\Embedded Workbench";
+#else
+ static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\IAR Systems\\Embedded Workbench";
+#endif
+
+ // Dictionary for know toolchains.
+ static const struct Entry {
+ QString registryKey;
+ QString subExePath;
+ } knowToolchains[] = {
+ {QStringLiteral("EWARM"), QStringLiteral("\\arm\\bin\\iccarm.exe")},
+ {QStringLiteral("EWAVR"), QStringLiteral("\\avr\\bin\\iccavr.exe")},
+ {QStringLiteral("EW8051"), QStringLiteral("\\8051\\bin\\icc8051.exe")},
+ };
+
+ QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat);
+ const auto oneLevelGroups = registry.childGroups();
+ for (const QString &oneLevelKey : oneLevelGroups) {
+ registry.beginGroup(oneLevelKey);
+ const auto twoLevelGroups = registry.childGroups();
+ for (const Entry &entry : knowToolchains) {
+ if (twoLevelGroups.contains(entry.registryKey)) {
+ registry.beginGroup(entry.registryKey);
+ const auto threeLevelGroups = registry.childGroups();
+ for (const QString &threeLevelKey : threeLevelGroups) {
+ registry.beginGroup(threeLevelKey);
+ const QString rootPath = registry.value(
+ QStringLiteral("InstallPath")).toString();
+ if (!rootPath.isEmpty()) {
+ // Build full compiler path.
+ const QFileInfo iarPath(rootPath + entry.subExePath);
+ if (iarPath.exists()) {
+ // Note: threeLevelKey is a guessed toolchain version.
+ const QString version = threeLevelKey;
+ infos.push_back({iarPath.absoluteFilePath(), version});
+ }
+ }
+ registry.endGroup();
+ }
+ registry.endGroup();
+ }
+ }
+ registry.endGroup();
+ }
+
+ }
+
+ return infos;
+}
+
+bool isIarCompiler(const QString &compilerName)
+{
+ return Internal::any_of(knownIarCompilerNames(), [compilerName](
+ const QString &knownName) {
+ return compilerName.contains(knownName);
+ });
+}
+
+void createIarProfile(const QFileInfo &compiler, Settings *settings,
+ QString profileName)
+{
+ createIarProfileHelper(compiler, settings, profileName);
+}
+
+void iarProbe(Settings *settings, QList<Profile> &profiles)
+{
+ qbsInfo() << Tr::tr("Trying to detect IAR toolchains...");
+
+ std::vector<IarInstallInfo> allInfos = installedIarsFromRegistry();
+ const std::vector<IarInstallInfo> pathInfos = installedIarsFromPath();
+ allInfos.insert(std::end(allInfos), std::begin(pathInfos), std::end(pathInfos));
+
+ for (const IarInstallInfo &info : allInfos) {
+ const auto profile = createIarProfileHelper(info.compilerPath, settings);
+ profiles.push_back(profile);
+ }
+
+ if (allInfos.empty())
+ qbsInfo() << Tr::tr("No IAR toolchains found.");
+}
diff --git a/src/app/qbs-setup-toolchains/iarewprobe.h b/src/app/qbs-setup-toolchains/iarewprobe.h
new file mode 100644
index 000000000..b549eddb8
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/iarewprobe.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IAREWPROBE_H
+#define IAREWPROBE_H
+
+#include <QtCore/qlist.h>
+
+class QFileInfo;
+
+namespace qbs {
+class Profile;
+class Settings;
+}
+
+struct IarInstallInfo
+{
+ QString compilerPath;
+ QString version;
+};
+
+bool isIarCompiler(const QString &compilerName);
+
+void createIarProfile(const QFileInfo &compiler, qbs::Settings *settings,
+ QString profileName);
+
+void iarProbe(qbs::Settings *settings, QList<qbs::Profile> &profiles);
+
+#endif // IAREWPROBE_H
diff --git a/src/app/qbs-setup-toolchains/keilprobe.cpp b/src/app/qbs-setup-toolchains/keilprobe.cpp
new file mode 100644
index 000000000..dc327d2ee
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/keilprobe.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "probe.h"
+#include "keilprobe.h"
+
+#include "../shared/logging/consolelogger.h"
+
+#include <logging/translator.h>
+
+#include <tools/hostosinfo.h>
+#include <tools/profile.h>
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qsettings.h>
+
+using namespace qbs;
+using Internal::Tr;
+using Internal::HostOsInfo;
+
+static QStringList knownKeilCompilerNames()
+{
+ return {QStringLiteral("c51"), QStringLiteral("armcc")};
+}
+
+static QString guessKeilArchitecture(const QFileInfo &compiler)
+{
+ const auto baseName = compiler.baseName();
+ if (baseName == QLatin1String("c51"))
+ return QStringLiteral("mcs51");
+ if (baseName == QLatin1String("armcc"))
+ return QStringLiteral("arm");
+ return {};
+}
+
+static Profile createKeilProfileHelper(const QFileInfo &compiler, Settings *settings,
+ QString profileName = QString())
+{
+ const QString architecture = guessKeilArchitecture(compiler);
+
+ // In case the profile is auto-detected.
+ if (profileName.isEmpty())
+ profileName = QLatin1String("keil-") + architecture;
+
+ Profile profile(profileName, settings);
+ profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath());
+ profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("keil"));
+ if (!architecture.isEmpty())
+ profile.setValue(QStringLiteral("qbs.architecture"), architecture);
+
+ qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg(
+ profile.name(), compiler.absoluteFilePath());
+ return profile;
+}
+
+static std::vector<KeilInstallInfo> installedKeilsFromPath()
+{
+ std::vector<KeilInstallInfo> infos;
+ const auto compilerNames = knownKeilCompilerNames();
+ for (const QString &compilerName : compilerNames) {
+ const QFileInfo keilPath(
+ findExecutable(
+ HostOsInfo::appendExecutableSuffix(compilerName)));
+ if (!keilPath.exists())
+ continue;
+ infos.push_back({keilPath.absoluteFilePath(), {}});
+ }
+ return infos;
+}
+
+static std::vector<KeilInstallInfo> installedKeilsFromRegistry()
+{
+ std::vector<KeilInstallInfo> infos;
+
+ if (HostOsInfo::isWindowsHost()) {
+
+#ifdef Q_OS_WIN64
+ static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Keil\\Products";
+#else
+ static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Keil\\Products";
+#endif
+
+ // Dictionary for know toolchains.
+ static const struct Entry {
+ QString productKey;
+ QString subExePath;
+ } knowToolchains[] = {
+ {QStringLiteral("MDK"), QStringLiteral("\\ARMCC\\bin\\armcc.exe")},
+ {QStringLiteral("C51"), QStringLiteral("\\BIN\\c51.exe")},
+ };
+
+ QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat);
+ const auto productGroups = registry.childGroups();
+ for (const QString &productKey : productGroups) {
+ const auto entryEnd = std::end(knowToolchains);
+ const auto entryIt = std::find_if(std::begin(knowToolchains), entryEnd,
+ [productKey](const Entry &entry) {
+ return entry.productKey == productKey;
+ });
+ if (entryIt == entryEnd)
+ continue;
+
+ registry.beginGroup(productKey);
+ const QString rootPath = registry.value(QStringLiteral("Path"))
+ .toString();
+ if (!rootPath.isEmpty()) {
+ // Build full compiler path.
+ const QFileInfo keilPath(rootPath + entryIt->subExePath);
+ if (keilPath.exists()) {
+ QString version = registry.value(QStringLiteral("Version"))
+ .toString();
+ if (version.startsWith(QLatin1Char('V')))
+ version.remove(0, 1);
+ infos.push_back({keilPath.absoluteFilePath(), version});
+ }
+ }
+ registry.endGroup();
+ }
+
+ }
+
+ return infos;
+}
+
+bool isKeilCompiler(const QString &compilerName)
+{
+ return Internal::any_of(knownKeilCompilerNames(), [compilerName](
+ const QString &knownName) {
+ return compilerName.contains(knownName);
+ });
+}
+
+void createKeilProfile(const QFileInfo &compiler, Settings *settings,
+ QString profileName)
+{
+ createKeilProfileHelper(compiler, settings, profileName);
+}
+
+void keilProbe(Settings *settings, QList<Profile> &profiles)
+{
+ qbsInfo() << Tr::tr("Trying to detect KEIL toolchains...");
+
+ std::vector<KeilInstallInfo> allInfos = installedKeilsFromRegistry();
+ const std::vector<KeilInstallInfo> pathInfos = installedKeilsFromPath();
+ allInfos.insert(std::end(allInfos), std::begin(pathInfos), std::end(pathInfos));
+
+ for (const KeilInstallInfo &info : allInfos) {
+ const auto profile = createKeilProfileHelper(info.compilerPath, settings);
+ profiles.push_back(profile);
+ }
+
+ if (allInfos.empty())
+ qbsInfo() << Tr::tr("No KEIL toolchains found.");
+}
diff --git a/src/app/qbs-setup-toolchains/keilprobe.h b/src/app/qbs-setup-toolchains/keilprobe.h
new file mode 100644
index 000000000..ef7b76418
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/keilprobe.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef KEILPROBE_H
+#define KEILPROBE_H
+
+#include <QtCore/qlist.h>
+
+class QFileInfo;
+
+namespace qbs {
+class Profile;
+class Settings;
+}
+
+struct KeilInstallInfo
+{
+ QString compilerPath;
+ QString version;
+};
+
+bool isKeilCompiler(const QString &compilerName);
+
+void createKeilProfile(const QFileInfo &compiler, qbs::Settings *settings,
+ QString profileName);
+
+void keilProbe(qbs::Settings *settings, QList<qbs::Profile> &profiles);
+
+#endif // KEILPROBE_H
diff --git a/src/app/qbs-setup-toolchains/msvcprobe.cpp b/src/app/qbs-setup-toolchains/msvcprobe.cpp
index a6292d860..d0b60a7fe 100644
--- a/src/app/qbs-setup-toolchains/msvcprobe.cpp
+++ b/src/app/qbs-setup-toolchains/msvcprobe.cpp
@@ -160,12 +160,6 @@ static QString wow6432Key()
#endif
}
-struct MSVCInstallInfo
-{
- QString version;
- QString installDir;
-};
-
static QString vswhereFilePath()
{
static const std::vector<const char *> envVarCandidates{"ProgramFiles", "ProgramFiles(x86)"};
@@ -213,7 +207,8 @@ static std::vector<MSVCInstallInfo> retrieveInstancesFromVSWhere(ProductType pro
.arg(parseError.errorString());
return result;
}
- for (const QJsonValue &v : jsonOutput.array()) {
+ const auto jsonArray = jsonOutput.array();
+ for (const QJsonValue &v : jsonArray) {
const QJsonObject o = v.toObject();
MSVCInstallInfo info;
info.version = o.value(QStringLiteral("installationVersion")).toString();
@@ -287,7 +282,28 @@ static std::vector<MSVCInstallInfo> installedMSVCsFromRegistry()
return result;
}
-static std::vector<MSVC> installedMSVCs()
+QString MSVCInstallInfo::findVcvarsallBat() const
+{
+ static const auto vcvarsall2017 = QStringLiteral("VC/Auxiliary/Build/vcvarsall.bat");
+ // 2015, 2013 and 2012
+ static const auto vcvarsallOld = QStringLiteral("VC/vcvarsall.bat");
+ QDir dir(installDir);
+ if (dir.exists(vcvarsall2017))
+ return dir.absoluteFilePath(vcvarsall2017);
+ if (dir.exists(vcvarsallOld))
+ return dir.absoluteFilePath(vcvarsallOld);
+ return {};
+}
+
+std::vector<MSVCInstallInfo> installedMSVCs()
+{
+ const auto installInfos = installedMSVCsFromVsWhere();
+ if (installInfos.empty())
+ return installedMSVCsFromRegistry();
+ return installInfos;
+}
+
+static std::vector<MSVC> installedCompilers()
{
std::vector<MSVC> msvcs;
std::vector<MSVCInstallInfo> installInfos = installedMSVCsFromVsWhere();
@@ -384,7 +400,7 @@ void msvcProbe(Settings *settings, QList<Profile> &profiles)
// 2) Installed MSVCs
std::vector<MSVC> msvcs;
- const auto instMsvcs = installedMSVCs();
+ const auto instMsvcs = installedCompilers();
for (const MSVC &msvc : instMsvcs) {
if (msvc.internalVsVersion.majorVersion() < 15) {
// Check existence of various install scripts
@@ -451,7 +467,7 @@ void msvcProbe(Settings *settings, QList<Profile> &profiles)
void createMsvcProfile(const QString &profileName, const QString &compilerFilePath,
Settings *settings)
{
- MSVC msvc(compilerFilePath);
+ MSVC msvc(compilerFilePath, MSVC::architectureFromClPath(compilerFilePath));
msvc.init();
QList<Profile> dummy;
addMSVCPlatform(settings, dummy, profileName, &msvc);
diff --git a/src/app/qbs-setup-toolchains/msvcprobe.h b/src/app/qbs-setup-toolchains/msvcprobe.h
index 0fa209548..4fa2cde48 100644
--- a/src/app/qbs-setup-toolchains/msvcprobe.h
+++ b/src/app/qbs-setup-toolchains/msvcprobe.h
@@ -42,11 +42,23 @@
#include <QtCore/qlist.h>
+#include <vector>
+
namespace qbs {
class Profile;
class Settings;
}
+struct MSVCInstallInfo
+{
+ QString version;
+ QString installDir;
+
+ QString findVcvarsallBat() const;
+};
+
+std::vector<MSVCInstallInfo> installedMSVCs();
+
void createMsvcProfile(const QString &profileName, const QString &compilerFilePath,
qbs::Settings *settings);
diff --git a/src/app/qbs-setup-toolchains/probe.cpp b/src/app/qbs-setup-toolchains/probe.cpp
index e90bafec2..3fae20a6e 100644
--- a/src/app/qbs-setup-toolchains/probe.cpp
+++ b/src/app/qbs-setup-toolchains/probe.cpp
@@ -38,7 +38,11 @@
****************************************************************************/
#include "probe.h"
+#include "clangclprobe.h"
+#include "iarewprobe.h"
+#include "keilprobe.h"
#include "msvcprobe.h"
+#include "sdccprobe.h"
#include "xcodeprobe.h"
#include <logging/translator.h>
@@ -66,7 +70,7 @@ using Internal::Tr;
static QTextStream qStdout(stdout);
static QTextStream qStderr(stderr);
-static QString findExecutable(const QString &fileName)
+QString findExecutable(const QString &fileName)
{
QString fullFileName = fileName;
if (HostOsInfo::isWindowsHost()
@@ -107,34 +111,12 @@ static QStringList validMinGWMachines()
QStringLiteral("i586-mingw32msvc"), QStringLiteral("amd64-mingw32msvc")};
}
-static QStringList knownIarCompilerNames()
-{
- return {QStringLiteral("icc8051"), QStringLiteral("iccarm"), QStringLiteral("iccavr")};
-}
-
-static bool isIarCompiler(const QString &compilerName)
-{
- return Internal::any_of(knownIarCompilerNames(), [compilerName](const QString &knownName) {
- return compilerName.contains(knownName);
- });
-}
-
-static QStringList knownKeilCompilerNames()
-{
- return {QStringLiteral("c51"), QStringLiteral("armcc")};
-}
-
-static bool isKeilCompiler(const QString &compilerName)
-{
- return Internal::any_of(knownKeilCompilerNames(), [compilerName](const QString &knownName) {
- return compilerName.contains(knownName);
- });
-}
-
static QStringList toolchainTypeFromCompilerName(const QString &compilerName)
{
if (compilerName == QLatin1String("cl.exe"))
return canonicalToolchain(QStringLiteral("msvc"));
+ if (compilerName == QLatin1String("clang-cl.exe"))
+ return canonicalToolchain(QLatin1String("clang-cl"));
const auto types = { QStringLiteral("clang"), QStringLiteral("llvm"),
QStringLiteral("mingw"), QStringLiteral("gcc") };
for (const auto &type : types) {
@@ -147,6 +129,8 @@ static QStringList toolchainTypeFromCompilerName(const QString &compilerName)
return canonicalToolchain(QStringLiteral("iar"));
if (isKeilCompiler(compilerName))
return canonicalToolchain(QStringLiteral("keil"));
+ if (isSdccCompiler(compilerName))
+ return canonicalToolchain(QStringLiteral("sdcc"));
return {};
}
@@ -191,8 +175,10 @@ static void setCommonProperties(Profile &profile, const QString &compilerFilePat
class ToolPathSetup
{
public:
- ToolPathSetup(Profile *profile, const QString &path, const QString &toolchainPrefix)
- : m_profile(profile), m_compilerDirPath(path), m_toolchainPrefix(toolchainPrefix)
+ ToolPathSetup(Profile *profile, QString path, QString toolchainPrefix)
+ : m_profile(profile),
+ m_compilerDirPath(std::move(path)),
+ m_toolchainPrefix(std::move(toolchainPrefix))
{
}
@@ -262,70 +248,6 @@ static Profile createGccProfile(const QString &compilerFilePath, Settings *setti
return profile;
}
-static QString guessIarArchitecture(const QFileInfo &compiler)
-{
- const auto baseName = compiler.baseName();
- if (baseName == QLatin1String("icc8051"))
- return QStringLiteral("mcs51");
- if (baseName == QLatin1String("iccarm"))
- return QStringLiteral("arm");
- if (baseName == QLatin1String("iccavr"))
- return QStringLiteral("avr");
- return {};
-}
-
-static Profile createIarProfile(const QFileInfo &compiler, Settings *settings,
- QString profileName = QString())
-{
- const QString architecture = guessIarArchitecture(compiler);
-
- // In case the profile is auto-detected.
- if (profileName.isEmpty())
- profileName = QLatin1String("iar-") + architecture;
-
- Profile profile(profileName, settings);
- profile.setValue(QLatin1String("cpp.toolchainInstallPath"), compiler.absolutePath());
- profile.setValue(QLatin1String("qbs.toolchainType"), QLatin1String("iar"));
- if (!architecture.isEmpty())
- profile.setValue(QLatin1String("qbs.architecture"), architecture);
-
- qStdout << Tr::tr("Profile '%1' created for '%2'.").arg(
- profile.name(), compiler.absoluteFilePath())
- << endl;
- return profile;
-}
-
-static QString guessKeilArchitecture(const QFileInfo &compiler)
-{
- const auto baseName = compiler.baseName();
- if (baseName == QLatin1String("c51"))
- return QStringLiteral("mcs51");
- if (baseName == QLatin1String("armcc"))
- return QStringLiteral("arm");
- return {};
-}
-
-static Profile createKeilProfile(const QFileInfo &compiler, Settings *settings,
- QString profileName = QString())
-{
- const QString architecture = guessKeilArchitecture(compiler);
-
- // In case the profile is auto-detected.
- if (profileName.isEmpty())
- profileName = QLatin1String("keil-") + architecture;
-
- Profile profile(profileName, settings);
- profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath());
- profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("keil"));
- if (!architecture.isEmpty())
- profile.setValue(QStringLiteral("qbs.architecture"), architecture);
-
- qStdout << Tr::tr("Profile '%1' created for '%2'.").arg(
- profile.name(), compiler.absoluteFilePath())
- << endl;
- return profile;
-}
-
static void gccProbe(Settings *settings, QList<Profile> &profiles, const QString &compilerName)
{
qStdout << Tr::tr("Trying to detect %1...").arg(compilerName) << endl;
@@ -364,47 +286,12 @@ static void mingwProbe(Settings *settings, QList<Profile> &profiles)
}
}
-static void iarProbe(Settings *settings, QList<Profile> &profiles)
-{
- qStdout << Tr::tr("Trying to detect IAR toolchains...") << endl;
-
- bool isFound = false;
- for (const QString &compilerName : knownIarCompilerNames()) {
- const QString iarPath = findExecutable(HostOsInfo::appendExecutableSuffix(compilerName));
- if (!iarPath.isEmpty()) {
- const auto profile = createIarProfile(iarPath, settings);
- profiles.push_back(profile);
- isFound = true;
- }
- }
-
- if (!isFound)
- qStdout << Tr::tr("No IAR toolchains found.") << endl;
-}
-
-static void keilProbe(Settings *settings, QList<Profile> &profiles)
-{
- qStdout << Tr::tr("Trying to detect KEIL toolchains...") << endl;
-
- bool isFound = false;
- for (const QString &compilerName : knownKeilCompilerNames()) {
- const QString keilPath = findExecutable(HostOsInfo::appendExecutableSuffix(compilerName));
- if (!keilPath.isEmpty()) {
- const auto profile = createKeilProfile(keilPath, settings);
- profiles.push_back(profile);
- isFound = true;
- }
- }
-
- if (!isFound)
- qStdout << Tr::tr("No KEIL toolchains found.") << endl;
-}
-
void probe(Settings *settings)
{
QList<Profile> profiles;
if (HostOsInfo::isWindowsHost()) {
msvcProbe(settings, profiles);
+ clangClProbe(settings, profiles);
} else {
gccProbe(settings, profiles, QStringLiteral("gcc"));
gccProbe(settings, profiles, QStringLiteral("clang"));
@@ -417,6 +304,7 @@ void probe(Settings *settings)
mingwProbe(settings, profiles);
iarProbe(settings, profiles);
keilProbe(settings, profiles);
+ sdccProbe(settings, profiles);
if (profiles.empty()) {
qStderr << Tr::tr("Could not detect any toolchains. No profile created.") << endl;
@@ -447,12 +335,16 @@ void createProfile(const QString &profileName, const QString &toolchainType,
if (toolchainTypes.contains(QLatin1String("msvc")))
createMsvcProfile(profileName, compiler.absoluteFilePath(), settings);
+ else if (toolchainTypes.contains(QLatin1String("clang-cl")))
+ createClangClProfile(profileName, compiler.absoluteFilePath(), settings);
else if (toolchainTypes.contains(QLatin1String("gcc")))
createGccProfile(compiler.absoluteFilePath(), settings, toolchainTypes, profileName);
else if (toolchainTypes.contains(QLatin1String("iar")))
createIarProfile(compiler, settings, profileName);
else if (toolchainTypes.contains(QLatin1String("keil")))
createKeilProfile(compiler, settings, profileName);
+ else if (toolchainTypes.contains(QLatin1String("sdcc")))
+ createSdccProfile(compiler, settings, profileName);
else
throw qbs::ErrorInfo(Tr::tr("Cannot create profile: Unknown toolchain type."));
}
diff --git a/src/app/qbs-setup-toolchains/probe.h b/src/app/qbs-setup-toolchains/probe.h
index 5c8774ddb..510747ef7 100644
--- a/src/app/qbs-setup-toolchains/probe.h
+++ b/src/app/qbs-setup-toolchains/probe.h
@@ -48,6 +48,8 @@ QT_END_NAMESPACE
namespace qbs { class Settings; }
+QString findExecutable(const QString &fileName);
+
void createProfile(const QString &profileName, const QString &toolchainType,
const QString &compilerFilePath, qbs::Settings *settings);
diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro
index f395c5458..e83a9c716 100644
--- a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro
+++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro
@@ -3,17 +3,25 @@ include(../app.pri)
TARGET = qbs-setup-toolchains
HEADERS += \
+ clangclprobe.h \
commandlineparser.h \
+ iarewprobe.h \
+ keilprobe.h \
msvcprobe.h \
probe.h \
- xcodeprobe.h
+ sdccprobe.h \
+ xcodeprobe.h \
SOURCES += \
+ clangclprobe.cpp \
commandlineparser.cpp \
+ iarewprobe.cpp \
+ keilprobe.cpp \
main.cpp \
msvcprobe.cpp \
probe.cpp \
- xcodeprobe.cpp
+ sdccprobe.cpp \
+ xcodeprobe.cpp \
mingw {
RC_FILE = qbs-setup-toolchains.rc
diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs
index 1b7cb6526..fd3043a28 100644
--- a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs
+++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs
@@ -4,13 +4,21 @@ QbsApp {
name: "qbs-setup-toolchains"
cpp.dynamicLibraries: qbs.targetOS.contains("windows") ? base.concat("shell32") : base
files: [
+ "clangclprobe.cpp",
+ "clangclprobe.h",
"commandlineparser.cpp",
"commandlineparser.h",
+ "iarewprobe.cpp",
+ "iarewprobe.h",
+ "keilprobe.cpp",
+ "keilprobe.h",
"main.cpp",
"msvcprobe.cpp",
"msvcprobe.h",
"probe.cpp",
"probe.h",
+ "sdccprobe.cpp",
+ "sdccprobe.h",
"xcodeprobe.cpp",
"xcodeprobe.h",
]
diff --git a/src/app/qbs-setup-toolchains/sdccprobe.cpp b/src/app/qbs-setup-toolchains/sdccprobe.cpp
new file mode 100644
index 000000000..751e872ee
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/sdccprobe.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "probe.h"
+#include "sdccprobe.h"
+
+#include "../shared/logging/consolelogger.h"
+
+#include <logging/translator.h>
+
+#include <tools/hostosinfo.h>
+#include <tools/profile.h>
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qsettings.h>
+
+using namespace qbs;
+using Internal::Tr;
+using Internal::HostOsInfo;
+
+static QStringList knownSdccCompilerNames()
+{
+ return {QStringLiteral("sdcc")};
+}
+
+static QString guessSdccArchitecture(const QFileInfo &compiler)
+{
+ const auto baseName = compiler.baseName();
+ if (baseName == QLatin1String("sdcc"))
+ return QStringLiteral("mcs51");
+ return {};
+}
+
+static Profile createSdccProfileHelper(const QFileInfo &compiler, Settings *settings,
+ QString profileName = QString())
+{
+ const QString architecture = guessSdccArchitecture(compiler);
+
+ // In case the profile is auto-detected.
+ if (profileName.isEmpty())
+ profileName = QLatin1String("sdcc-") + architecture;
+
+ Profile profile(profileName, settings);
+ profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath());
+ profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("sdcc"));
+ if (!architecture.isEmpty())
+ profile.setValue(QStringLiteral("qbs.architecture"), architecture);
+
+ qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg(
+ profile.name(), compiler.absoluteFilePath());
+ return profile;
+}
+
+static std::vector<SdccInstallInfo> installedSdccsFromPath()
+{
+ std::vector<SdccInstallInfo> infos;
+ const auto compilerNames = knownSdccCompilerNames();
+ for (const QString &compilerName : compilerNames) {
+ const QFileInfo sdccPath(
+ findExecutable(
+ HostOsInfo::appendExecutableSuffix(compilerName)));
+ if (!sdccPath.exists())
+ continue;
+ infos.push_back({sdccPath.absoluteFilePath(), {}});
+ }
+ return infos;
+}
+
+static std::vector<SdccInstallInfo> installedSdccsFromRegistry()
+{
+ std::vector<SdccInstallInfo> infos;
+
+ if (HostOsInfo::isWindowsHost()) {
+
+#ifdef Q_OS_WIN64
+ static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\SDCC";
+#else
+ static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\SDCC";
+#endif
+
+ QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat);
+ QString rootPath = registry.value(QStringLiteral("Default")).toString();
+ if (!rootPath.isEmpty()) {
+ // Build full compiler path.
+ const QFileInfo sdccPath(rootPath + QLatin1String("\\bin\\sdcc.exe"));
+ if (sdccPath.exists()) {
+ // Build compiler version.
+ const QString version = QStringLiteral("%1.%2.%3").arg(
+ registry.value(QStringLiteral("VersionMajor")).toString(),
+ registry.value(QStringLiteral("VersionMinor")).toString(),
+ registry.value(QStringLiteral("VersionRevision")).toString());
+ infos.push_back({sdccPath.absoluteFilePath(), version});
+ }
+ }
+ }
+
+ return infos;
+}
+
+bool isSdccCompiler(const QString &compilerName)
+{
+ return Internal::any_of(knownSdccCompilerNames(), [compilerName](
+ const QString &knownName) {
+ return compilerName.contains(knownName);
+ });
+}
+
+void createSdccProfile(const QFileInfo &compiler, Settings *settings,
+ QString profileName)
+{
+ createSdccProfileHelper(compiler, settings, profileName);
+}
+
+void sdccProbe(Settings *settings, QList<Profile> &profiles)
+{
+ qbsInfo() << Tr::tr("Trying to detect SDCC toolchains...");
+
+ std::vector<SdccInstallInfo> allInfos = installedSdccsFromRegistry();
+ const std::vector<SdccInstallInfo> pathInfos = installedSdccsFromPath();
+ allInfos.insert(std::end(allInfos), std::begin(pathInfos), std::end(pathInfos));
+
+ for (const SdccInstallInfo &info : allInfos) {
+ const auto profile = createSdccProfileHelper(info.compilerPath, settings);
+ profiles.push_back(profile);
+ }
+
+ if (allInfos.empty())
+ qbsInfo() << Tr::tr("No SDCC toolchains found.");
+}
diff --git a/src/app/qbs-setup-toolchains/sdccprobe.h b/src/app/qbs-setup-toolchains/sdccprobe.h
new file mode 100644
index 000000000..3cb147e4f
--- /dev/null
+++ b/src/app/qbs-setup-toolchains/sdccprobe.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Denis Shienkov <denis.shienkov@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SDCCPROBE_H
+#define SDCCPROBE_H
+
+#include <QtCore/qlist.h>
+
+class QFileInfo;
+
+namespace qbs {
+class Profile;
+class Settings;
+}
+
+struct SdccInstallInfo
+{
+ QString compilerPath;
+ QString version;
+};
+
+bool isSdccCompiler(const QString &compilerName);
+
+void createSdccProfile(const QFileInfo &compiler, qbs::Settings *settings,
+ QString profileName);
+
+void sdccProbe(qbs::Settings *settings, QList<qbs::Profile> &profiles);
+
+#endif // SDCCPROBE_H
diff --git a/src/app/qbs-setup-toolchains/xcodeprobe.cpp b/src/app/qbs-setup-toolchains/xcodeprobe.cpp
index 227dc00f3..a0f6f80d1 100644
--- a/src/app/qbs-setup-toolchains/xcodeprobe.cpp
+++ b/src/app/qbs-setup-toolchains/xcodeprobe.cpp
@@ -59,12 +59,54 @@
using namespace qbs;
using Internal::Tr;
-namespace {
static const QString defaultDeveloperPath =
QStringLiteral("/Applications/Xcode.app/Contents/Developer");
static const std::regex defaultDeveloperPathRegex(
"^/Applications/Xcode([a-zA-Z0-9 _-]+)\\.app/Contents/Developer$");
+static QString targetOS(const QString &applePlatformName)
+{
+ if (applePlatformName == QStringLiteral("macosx"))
+ return QStringLiteral("macos");
+ if (applePlatformName == QStringLiteral("iphoneos"))
+ return QStringLiteral("ios");
+ if (applePlatformName == QStringLiteral("iphonesimulator"))
+ return QStringLiteral("ios-simulator");
+ if (applePlatformName == QStringLiteral("appletvos"))
+ return QStringLiteral("tvos");
+ if (applePlatformName == QStringLiteral("appletvsimulator"))
+ return QStringLiteral("tvos-simulator");
+ if (applePlatformName == QStringLiteral("watchos"))
+ return QStringLiteral("watchos");
+ if (applePlatformName == QStringLiteral("watchsimulator"))
+ return QStringLiteral("watchos-simulator");
+ return {};
+}
+
+static QStringList archList(const QString &applePlatformName)
+{
+ QStringList archs;
+ if (applePlatformName == QStringLiteral("macosx")
+ || applePlatformName == QStringLiteral("iphonesimulator")
+ || applePlatformName == QStringLiteral("appletvsimulator")
+ || applePlatformName == QStringLiteral("watchsimulator")) {
+ if (applePlatformName != QStringLiteral("appletvsimulator"))
+ archs << QStringLiteral("x86");
+ if (applePlatformName != QStringLiteral("watchsimulator"))
+ archs << QStringLiteral("x86_64");
+ } else if (applePlatformName == QStringLiteral("iphoneos")
+ || applePlatformName == QStringLiteral("appletvos")) {
+ if (applePlatformName != QStringLiteral("appletvos"))
+ archs << QStringLiteral("armv7a");
+ archs << QStringLiteral("arm64");
+ } else if (applePlatformName == QStringLiteral("watchos")) {
+ archs << QStringLiteral("armv7k");
+ }
+
+ return archs;
+}
+
+namespace {
class XcodeProbe
{
public:
@@ -117,54 +159,13 @@ void XcodeProbe::detectDeveloperPaths()
if (!launchServices.waitForFinished(-1) || launchServices.exitCode()) {
qbsInfo() << Tr::tr("Could not detect additional Xcode installations with /usr/bin/mdfind");
} else {
- for (const QString &path : QString::fromLocal8Bit(launchServices.readAllStandardOutput())
- .split(QLatin1Char('\n'), QString::SkipEmptyParts))
+ const auto paths = QString::fromLocal8Bit(launchServices.readAllStandardOutput())
+ .split(QLatin1Char('\n'), QString::SkipEmptyParts);
+ for (const QString &path : paths)
addDeveloperPath(path + QStringLiteral("/Contents/Developer"));
}
}
-static QString targetOS(const QString &applePlatformName)
-{
- if (applePlatformName == QStringLiteral("macosx"))
- return QStringLiteral("macos");
- if (applePlatformName == QStringLiteral("iphoneos"))
- return QStringLiteral("ios");
- if (applePlatformName == QStringLiteral("iphonesimulator"))
- return QStringLiteral("ios-simulator");
- if (applePlatformName == QStringLiteral("appletvos"))
- return QStringLiteral("tvos");
- if (applePlatformName == QStringLiteral("appletvsimulator"))
- return QStringLiteral("tvos-simulator");
- if (applePlatformName == QStringLiteral("watchos"))
- return QStringLiteral("watchos");
- if (applePlatformName == QStringLiteral("watchsimulator"))
- return QStringLiteral("watchos-simulator");
- return {};
-}
-
-static QStringList archList(const QString &applePlatformName)
-{
- QStringList archs;
- if (applePlatformName == QStringLiteral("macosx")
- || applePlatformName == QStringLiteral("iphonesimulator")
- || applePlatformName == QStringLiteral("appletvsimulator")
- || applePlatformName == QStringLiteral("watchsimulator")) {
- if (applePlatformName != QStringLiteral("appletvsimulator"))
- archs << QStringLiteral("x86");
- if (applePlatformName != QStringLiteral("watchsimulator"))
- archs << QStringLiteral("x86_64");
- } else if (applePlatformName == QStringLiteral("iphoneos")
- || applePlatformName == QStringLiteral("appletvos")) {
- if (applePlatformName != QStringLiteral("appletvos"))
- archs << QStringLiteral("armv7a");
- archs << QStringLiteral("arm64");
- } else if (applePlatformName == QStringLiteral("watchos")) {
- archs << QStringLiteral("armv7k");
- }
-
- return archs;
-}
-
void XcodeProbe::setupDefaultToolchains(const QString &devPath, const QString &xcodeName)
{
qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg(xcodeName).arg(devPath);
@@ -188,14 +189,15 @@ void XcodeProbe::setupDefaultToolchains(const QString &devPath, const QString &x
<< QStringLiteral("appletvsimulator")
<< QStringLiteral("watchos")
<< QStringLiteral("watchsimulator");
- for (const QString &platform : platforms) {
+ for (const QString &platform : qAsConst(platforms)) {
Profile platformProfile(xcodeName + QLatin1Char('-') + platform, settings);
platformProfile.removeProfile();
platformProfile.setBaseProfile(installationProfile.name());
platformProfile.setValue(QStringLiteral("qbs.targetPlatform"), targetOS(platform));
profiles.push_back(platformProfile);
- for (const QString &arch : archList(platform)) {
+ const auto architectures = archList(platform);
+ for (const QString &arch : architectures) {
Profile archProfile(xcodeName + QLatin1Char('-') + platform + QLatin1Char('-') + arch,
settings);
archProfile.removeProfile();
@@ -211,7 +213,7 @@ void XcodeProbe::detectAll()
{
int i = 1;
detectDeveloperPaths();
- for (const QString &developerPath : developerPaths) {
+ for (const QString &developerPath : qAsConst(developerPaths)) {
QString profileName = QStringLiteral("xcode");
if (developerPath != defaultDeveloperPath) {
const auto devPath = developerPath.toStdString();
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp
index 1a8e1757d..95c3c10bc 100644
--- a/src/app/qbs/commandlinefrontend.cpp
+++ b/src/app/qbs/commandlinefrontend.cpp
@@ -230,7 +230,7 @@ void CommandLineFrontend::handleJobFinished(bool success, AbstractJob *job)
return;
}
cancel();
- } else if (SetupProjectJob * const setupJob = qobject_cast<SetupProjectJob *>(job)) {
+ } else if (const auto setupJob = qobject_cast<SetupProjectJob * const>(job)) {
m_resolveJobs.removeOne(job);
m_projects.push_back(setupJob->project());
if (m_observer && resolvingMultipleProjects())
@@ -611,7 +611,7 @@ void CommandLineFrontend::connectBuildJob(AbstractJob *job)
{
connectJob(job);
- BuildJob *bjob = qobject_cast<BuildJob *>(job);
+ const auto bjob = qobject_cast<const BuildJob *>(job);
if (!bjob)
return;
diff --git a/src/app/qbs/commandlinefrontend.h b/src/app/qbs/commandlinefrontend.h
index 363e0b040..346b46166 100644
--- a/src/app/qbs/commandlinefrontend.h
+++ b/src/app/qbs/commandlinefrontend.h
@@ -67,7 +67,7 @@ class CommandLineFrontend : public QObject
public:
explicit CommandLineFrontend(const CommandLineParser &parser, Settings *settings,
QObject *parent = nullptr);
- ~CommandLineFrontend();
+ ~CommandLineFrontend() override;
void cancel();
void start();
@@ -106,21 +106,21 @@ private:
QString buildDirectory(const QString &profileName) const;
const CommandLineParser &m_parser;
- Settings * const m_settings;
+ Settings * const m_settings = nullptr;
QList<AbstractJob *> m_resolveJobs;
QList<AbstractJob *> m_buildJobs;
QList<Project> m_projects;
- ConsoleProgressObserver *m_observer;
+ ConsoleProgressObserver *m_observer = nullptr;
enum CancelStatus { CancelStatusNone, CancelStatusRequested, CancelStatusCanceling };
- CancelStatus m_cancelStatus;
- QTimer * const m_cancelTimer;
+ CancelStatus m_cancelStatus = CancelStatus::CancelStatusNone;
+ QTimer * const m_cancelTimer = nullptr;
- int m_buildEffortsNeeded;
- int m_buildEffortsRetrieved;
- int m_totalBuildEffort;
- int m_currentBuildEffort;
+ int m_buildEffortsNeeded = 0;
+ int m_buildEffortsRetrieved = 0;
+ int m_totalBuildEffort = 0;
+ int m_currentBuildEffort = 0;
QHash<AbstractJob *, int> m_buildEfforts;
std::shared_ptr<ProjectGenerator> m_generator;
};
diff --git a/src/app/qbs/qbstool.h b/src/app/qbs/qbstool.h
index c1d7f75d8..e6d230361 100644
--- a/src/app/qbs/qbstool.h
+++ b/src/app/qbs/qbstool.h
@@ -57,8 +57,8 @@ public:
int *exitCode = 0);
private:
- bool m_failedToStart;
- int m_exitCode;
+ bool m_failedToStart = false;
+ int m_exitCode = 0;
QString m_stdout;
QString m_stderr;
};
diff --git a/src/app/shared/logging/consolelogger.h b/src/app/shared/logging/consolelogger.h
index d362cfc29..db7a705f5 100644
--- a/src/app/shared/logging/consolelogger.h
+++ b/src/app/shared/logging/consolelogger.h
@@ -55,7 +55,7 @@ public:
void setEnabled(bool enabled) { m_enabled = enabled; }
private:
- void doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag);
+ void doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag) override;
void fprintfWrapper(TextColor color, FILE *file, const char *str, ...);
private:
diff --git a/src/lib/corelib/api/internaljobs.cpp b/src/lib/corelib/api/internaljobs.cpp
index f07927c71..5cd4bd439 100644
--- a/src/lib/corelib/api/internaljobs.cpp
+++ b/src/lib/corelib/api/internaljobs.cpp
@@ -70,8 +70,8 @@ namespace Internal {
class JobObserver : public ProgressObserver
{
public:
- JobObserver(InternalJob *job) : m_canceled(false), m_job(job), m_timedLogger(nullptr) { }
- ~JobObserver() { delete m_timedLogger; }
+ JobObserver(InternalJob *job) : m_job(job) { }
+ ~JobObserver() override { delete m_timedLogger; }
void cancel()
{
@@ -116,20 +116,20 @@ private:
return m_canceled;
}
- int m_value;
- int m_maximum;
+ int m_value = 0;
+ int m_maximum = 0;
mutable std::mutex m_cancelMutex;
- bool m_canceled;
- InternalJob * const m_job;
- TimedActivityLogger *m_timedLogger;
+ bool m_canceled = false;
+ InternalJob * const m_job = nullptr;
+ TimedActivityLogger *m_timedLogger = nullptr;
};
-InternalJob::InternalJob(const Logger &logger, QObject *parent)
+InternalJob::InternalJob(Logger logger, QObject *parent)
: QObject(parent)
, m_observer(new JobObserver(this))
, m_ownsObserver(true)
- , m_logger(logger)
+ , m_logger(std::move(logger))
, m_timed(false)
{
}
@@ -162,7 +162,8 @@ void InternalJob::storeBuildGraph(const TopLevelProjectPtr &project)
project->store(logger());
} catch (const ErrorInfo &error) {
ErrorInfo fullError = this->error();
- for (const ErrorItem &item : error.items())
+ const auto items = error.items();
+ for (const ErrorItem &item : items)
fullError.append(item);
setError(fullError);
}
diff --git a/src/lib/corelib/api/internaljobs.h b/src/lib/corelib/api/internaljobs.h
index 71e6615bf..58127eb05 100644
--- a/src/lib/corelib/api/internaljobs.h
+++ b/src/lib/corelib/api/internaljobs.h
@@ -68,7 +68,7 @@ class InternalJob : public QObject
Q_OBJECT
friend class JobObserver;
public:
- ~InternalJob();
+ ~InternalJob() override;
void cancel();
virtual void start() {}
@@ -80,7 +80,7 @@ public:
void shareObserverWith(InternalJob *otherJob);
protected:
- explicit InternalJob(const Logger &logger, QObject *parent = nullptr);
+ explicit InternalJob(Logger logger, QObject *parent = nullptr);
JobObserver *observer() const { return m_observer; }
void setTimed(bool timed) { m_timed = timed; }
@@ -106,7 +106,7 @@ class InternalJobThreadWrapper : public InternalJob
Q_OBJECT
public:
InternalJobThreadWrapper(InternalJob *synchronousJob, QObject *parent = nullptr);
- ~InternalJobThreadWrapper();
+ ~InternalJobThreadWrapper() override;
void start() override;
InternalJob *synchronousJob() const { return m_job; }
@@ -127,7 +127,7 @@ class InternalSetupProjectJob : public InternalJob
Q_OBJECT
public:
InternalSetupProjectJob(const Logger &logger);
- ~InternalSetupProjectJob();
+ ~InternalSetupProjectJob() override;
void init(const TopLevelProjectPtr &existingProject, const SetupProjectParameters &parameters);
void reportError(const ErrorInfo &error);
@@ -160,7 +160,7 @@ signals:
protected:
BuildGraphTouchingJob(const Logger &logger, QObject *parent = nullptr);
- ~BuildGraphTouchingJob();
+ ~BuildGraphTouchingJob() override;
void setup(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
bool dryRun);
@@ -211,7 +211,7 @@ class InternalInstallJob : public InternalJob
Q_OBJECT
public:
InternalInstallJob(const Logger &logger);
- ~InternalInstallJob();
+ ~InternalInstallJob() override;
void init(const TopLevelProjectPtr &project, const std::vector<ResolvedProductPtr> &products,
const InstallOptions &options);
diff --git a/src/lib/corelib/api/jobs.h b/src/lib/corelib/api/jobs.h
index f121cc403..36c6b7a80 100644
--- a/src/lib/corelib/api/jobs.h
+++ b/src/lib/corelib/api/jobs.h
@@ -66,7 +66,7 @@ class QBS_EXPORT AbstractJob : public QObject
{
Q_OBJECT
public:
- ~AbstractJob();
+ ~AbstractJob() override;
enum State { StateRunning, StateCanceling, StateFinished };
State state() const { return m_state; }
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp
index 42591ce2f..3ffd6b2e9 100644
--- a/src/lib/corelib/api/project.cpp
+++ b/src/lib/corelib/api/project.cpp
@@ -233,7 +233,8 @@ ResolvedProductPtr ProjectPrivate::internalProduct(const ProductData &product) c
ProductData ProjectPrivate::findProductData(const ProductData &product) const
{
- for (const ProductData &p : m_projectData.allProducts()) {
+ const auto products = m_projectData.allProducts();
+ for (const ProductData &p : products) {
if (p.name() == product.name()
&& p.profile() == product.profile()
&& p.multiplexConfigurationId() == product.multiplexConfigurationId()) {
@@ -246,7 +247,8 @@ ProductData ProjectPrivate::findProductData(const ProductData &product) const
QList<ProductData> ProjectPrivate::findProductsByName(const QString &name) const
{
QList<ProductData> list;
- for (const ProductData &p : m_projectData.allProducts()) {
+ const auto products = m_projectData.allProducts();
+ for (const ProductData &p : products) {
if (p.name() == name)
list.push_back(p);
}
@@ -255,7 +257,8 @@ QList<ProductData> ProjectPrivate::findProductsByName(const QString &name) const
GroupData ProjectPrivate::findGroupData(const ProductData &product, const QString &groupName) const
{
- for (const GroupData &g : product.groups()) {
+ const auto groups = product.groups();
+ for (const GroupData &g : groups) {
if (g.name() == groupName)
return g;
}
@@ -708,11 +711,14 @@ void ProjectPrivate::updateExternalCodeLocations(const ProjectData &project,
if (lineOffset == 0)
return;
updateLocationIfNecessary(project.d->location, changeLocation, lineOffset);
- for (const ProjectData &subProject : project.subProjects())
+ const auto subProjects = project.subProjects();
+ for (const ProjectData &subProject : subProjects)
updateExternalCodeLocations(subProject, changeLocation, lineOffset);
- for (const ProductData &product : project.products()) {
+ const auto products = project.products();
+ for (const ProductData &product : products) {
updateLocationIfNecessary(product.d->location, changeLocation, lineOffset);
- for (const GroupData &group : product.groups())
+ const auto groups = product.groups();
+ for (const GroupData &group : groups)
updateLocationIfNecessary(group.d->location, changeLocation, lineOffset);
}
}
@@ -788,7 +794,8 @@ ProjectTransformerData ProjectPrivate::transformerData()
if (!m_projectData.isValid())
retrieveProjectData(m_projectData, internalProject);
ProjectTransformerData projectTransformerData;
- for (const ProductData &productData : m_projectData.allProducts()) {
+ const auto allProducts = m_projectData.allProducts();
+ for (const ProductData &productData : allProducts) {
if (!productData.isEnabled())
continue;
const ResolvedProductConstPtr product = internalProduct(productData);
diff --git a/src/lib/corelib/api/projectdata.cpp b/src/lib/corelib/api/projectdata.cpp
index 0c3ba186d..56700b8be 100644
--- a/src/lib/corelib/api/projectdata.cpp
+++ b/src/lib/corelib/api/projectdata.cpp
@@ -63,19 +63,15 @@ GroupData::GroupData() : d(new Internal::GroupDataPrivate)
{
}
-GroupData::GroupData(const GroupData &other) : d(other.d)
-{
-}
+GroupData::GroupData(const GroupData &other) = default;
-GroupData &GroupData::operator=(const GroupData &other)
-{
- d = other.d;
- return *this;
-}
+GroupData::GroupData(GroupData &&) Q_DECL_NOEXCEPT = default;
-GroupData::~GroupData()
-{
-}
+GroupData &GroupData::operator=(const GroupData &other) = default;
+
+GroupData &GroupData::operator=(GroupData &&) Q_DECL_NOEXCEPT = default;
+
+GroupData::~GroupData() = default;
/*!
* \brief Returns true if and only if the Group holds data that was initialized by Qbs.
@@ -212,19 +208,15 @@ ArtifactData::ArtifactData() : d(new Internal::ArtifactDataPrivate)
{
}
-ArtifactData::ArtifactData(const ArtifactData &other) : d(other.d)
-{
-}
+ArtifactData::ArtifactData(const ArtifactData &other) = default;
-ArtifactData &ArtifactData::operator=(const ArtifactData &other)
-{
- d = other.d;
- return *this;
-}
+ArtifactData::ArtifactData(ArtifactData &&) Q_DECL_NOEXCEPT = default;
-ArtifactData::~ArtifactData()
-{
-}
+ArtifactData &ArtifactData::operator=(const ArtifactData &other) = default;
+
+ArtifactData &ArtifactData::operator=(ArtifactData &&) Q_DECL_NOEXCEPT = default;
+
+ArtifactData::~ArtifactData() = default;
/*!
* \brief Returns true if and only if this object holds data that was initialized by Qbs.
@@ -321,19 +313,15 @@ InstallData::InstallData() : d(new Internal::InstallDataPrivate)
{
}
-InstallData::InstallData(const InstallData &other) : d(other.d)
-{
-}
+InstallData::InstallData(const InstallData &other) = default;
-InstallData &InstallData::operator=(const InstallData &other)
-{
- d = other.d;
- return *this;
-}
+InstallData::InstallData(InstallData &&) Q_DECL_NOEXCEPT = default;
-InstallData::~InstallData()
-{
-}
+InstallData &InstallData::operator=(const InstallData &other) = default;
+
+InstallData &InstallData::operator=(InstallData &&) Q_DECL_NOEXCEPT = default;
+
+InstallData::~InstallData() = default;
/*!
* \brief Returns true if and only if this object holds data that was initialized by Qbs.
@@ -408,19 +396,15 @@ ProductData::ProductData() : d(new Internal::ProductDataPrivate)
{
}
-ProductData::ProductData(const ProductData &other) : d(other.d)
-{
-}
+ProductData::ProductData(const ProductData &other) = default;
-ProductData &ProductData::operator=(const ProductData &other)
-{
- d = other.d;
- return *this;
-}
+ProductData::ProductData(ProductData &&) Q_DECL_NOEXCEPT = default;
-ProductData::~ProductData()
-{
-}
+ProductData &ProductData::operator=(const ProductData &other) = default;
+
+ProductData &ProductData::operator=(ProductData &&) Q_DECL_NOEXCEPT = default;
+
+ProductData::~ProductData() = default;
/*!
* \brief Returns true if and only if the Product holds data that was initialized by Qbs.
@@ -538,13 +522,14 @@ QList<ArtifactData> ProductData::targetArtifacts() const
QList<ArtifactData> ProductData::installableArtifacts() const
{
QList<ArtifactData> artifacts;
- for (const GroupData &g : groups()) {
- for (const ArtifactData &a : g.allSourceArtifacts()) {
+ for (const GroupData &g : qAsConst(d->groups)) {
+ const auto sourceArtifacts = g.allSourceArtifacts();
+ for (const ArtifactData &a : sourceArtifacts) {
if (a.installData().isInstallable())
artifacts << a;
}
}
- for (const ArtifactData &a : generatedArtifacts()) {
+ for (const ArtifactData &a : qAsConst(d->generatedArtifacts)) {
if (a.installData().isInstallable())
artifacts << a;
}
@@ -560,7 +545,8 @@ QString ProductData::targetExecutable() const
QBS_ASSERT(isValid(), return {});
if (d->moduleProperties.getModuleProperty(QStringLiteral("bundle"),
QStringLiteral("isBundle")).toBool()) {
- for (const ArtifactData &ta : targetArtifacts()) {
+ const auto artifacts = targetArtifacts();
+ for (const ArtifactData &ta : artifacts) {
if (ta.fileTags().contains(QLatin1String("bundle.application-executable"))) {
if (ta.installData().isInstallable())
return ta.installData().localInstallFilePath();
@@ -568,7 +554,8 @@ QString ProductData::targetExecutable() const
}
}
}
- for (const ArtifactData &ta : targetArtifacts()) {
+ const auto artifacts = targetArtifacts();
+ for (const ArtifactData &ta : artifacts) {
if (ta.isExecutable()) {
if (ta.installData().isInstallable())
return ta.installData().localInstallFilePath();
@@ -678,19 +665,15 @@ ProjectData::ProjectData() : d(new Internal::ProjectDataPrivate)
{
}
-ProjectData::ProjectData(const ProjectData &other) : d(other.d)
-{
-}
+ProjectData::ProjectData(const ProjectData &other) = default;
-ProjectData &ProjectData::operator =(const ProjectData &other)
-{
- d = other.d;
- return *this;
-}
+ProjectData::ProjectData(ProjectData &&) Q_DECL_NOEXCEPT = default;
-ProjectData::~ProjectData()
-{
-}
+ProjectData &ProjectData::operator =(const ProjectData &other) = default;
+
+ProjectData &ProjectData::operator=(ProjectData &&) Q_DECL_NOEXCEPT = default;
+
+ProjectData::~ProjectData() = default;
/*!
* \brief Returns true if and only if the Project holds data that was initialized by Qbs.
@@ -758,7 +741,7 @@ QList<ProjectData> ProjectData::subProjects() const
QList<ProductData> ProjectData::allProducts() const
{
QList<ProductData> productList = products();
- for (const ProjectData &pd : subProjects())
+ for (const ProjectData &pd : qAsConst(d->subProjects))
productList << pd.allProducts();
return productList;
}
@@ -769,7 +752,8 @@ QList<ProductData> ProjectData::allProducts() const
QList<ArtifactData> ProjectData::installableArtifacts() const
{
QList<ArtifactData> artifacts;
- for (const ProductData &p : allProducts())
+ const auto products = allProducts();
+ for (const ProductData &p : products)
artifacts << p.installableArtifacts();
return artifacts;
}
@@ -804,31 +788,30 @@ bool operator<(const ProjectData &lhs, const ProjectData &rhs)
*/
PropertyMap::PropertyMap()
- : d(new Internal::PropertyMapPrivate)
+ : d(std::make_unique<Internal::PropertyMapPrivate>())
{
static Internal::PropertyMapPtr defaultInternalMap = Internal::PropertyMapInternal::create();
d->m_map = defaultInternalMap;
}
PropertyMap::PropertyMap(const PropertyMap &other)
- : d(new Internal::PropertyMapPrivate(*other.d))
+ : d(std::make_unique<Internal::PropertyMapPrivate>(*other.d))
{
}
-PropertyMap::~PropertyMap()
-{
- delete d;
-}
+PropertyMap::PropertyMap(PropertyMap &&other) Q_DECL_NOEXCEPT = default;
+
+PropertyMap::~PropertyMap() = default;
PropertyMap &PropertyMap::operator =(const PropertyMap &other)
{
- if (this != &other) {
- delete d;
- d = new Internal::PropertyMapPrivate(*other.d);
- }
+ if (this != &other)
+ d = std::make_unique<Internal::PropertyMapPrivate>(*other.d);
return *this;
}
+PropertyMap &PropertyMap::operator =(PropertyMap &&other) Q_DECL_NOEXCEPT = default;
+
/*!
* \brief Returns the names of all properties.
*/
diff --git a/src/lib/corelib/api/projectdata.h b/src/lib/corelib/api/projectdata.h
index 91bcf7d9d..3bd1c4540 100644
--- a/src/lib/corelib/api/projectdata.h
+++ b/src/lib/corelib/api/projectdata.h
@@ -48,6 +48,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qvariant.h>
+#include <memory>
#include <utility>
namespace qbs {
@@ -75,9 +76,11 @@ class QBS_EXPORT PropertyMap
public:
PropertyMap();
PropertyMap(const PropertyMap &other);
+ PropertyMap(PropertyMap &&other) Q_DECL_NOEXCEPT;
~PropertyMap();
PropertyMap &operator =(const PropertyMap &other);
+ PropertyMap &operator =(PropertyMap &&other) Q_DECL_NOEXCEPT;
QStringList allProperties() const;
QVariant getProperty(const QString &name) const;
@@ -90,7 +93,7 @@ public:
QString toString() const;
private:
- Internal::PropertyMapPrivate *d;
+ std::unique_ptr<Internal::PropertyMapPrivate> d;
};
class InstallData;
@@ -101,7 +104,9 @@ class QBS_EXPORT ArtifactData
public:
ArtifactData();
ArtifactData(const ArtifactData &other);
+ ArtifactData(ArtifactData &&) Q_DECL_NOEXCEPT;
ArtifactData &operator=(const ArtifactData &other);
+ ArtifactData &operator=(ArtifactData &&) Q_DECL_NOEXCEPT;
~ArtifactData();
bool isValid() const;
@@ -124,7 +129,9 @@ class QBS_EXPORT InstallData
public:
InstallData();
InstallData(const InstallData &other);
+ InstallData(InstallData &&) Q_DECL_NOEXCEPT;
InstallData &operator=(const InstallData &other);
+ InstallData &operator=(InstallData &&) Q_DECL_NOEXCEPT;
~InstallData();
bool isValid() const;
@@ -149,7 +156,9 @@ class QBS_EXPORT GroupData
public:
GroupData();
GroupData(const GroupData &other);
+ GroupData(GroupData &&) Q_DECL_NOEXCEPT;
GroupData &operator=(const GroupData &other);
+ GroupData &operator=(GroupData &&) Q_DECL_NOEXCEPT;
~GroupData();
bool isValid() const;
@@ -178,7 +187,9 @@ class QBS_EXPORT ProductData
public:
ProductData();
ProductData(const ProductData &other);
+ ProductData(ProductData &&) Q_DECL_NOEXCEPT;
ProductData &operator=(const ProductData &other);
+ ProductData &operator=(ProductData &&) Q_DECL_NOEXCEPT;
~ProductData();
bool isValid() const;
@@ -218,7 +229,9 @@ class QBS_EXPORT ProjectData
public:
ProjectData();
ProjectData(const ProjectData &other);
+ ProjectData(ProjectData &&) Q_DECL_NOEXCEPT;
ProjectData &operator=(const ProjectData &other);
+ ProjectData &operator=(ProjectData &&) Q_DECL_NOEXCEPT;
~ProjectData();
bool isValid() const;
diff --git a/src/lib/corelib/api/projectdata_p.h b/src/lib/corelib/api/projectdata_p.h
index 69b046b0c..834aeec23 100644
--- a/src/lib/corelib/api/projectdata_p.h
+++ b/src/lib/corelib/api/projectdata_p.h
@@ -50,61 +50,49 @@ namespace Internal {
class InstallDataPrivate : public QSharedData
{
public:
- InstallDataPrivate() : isValid(false) {}
-
QString installFilePath;
QString installRoot;
- bool isValid;
- bool isInstallable;
+ bool isValid = false;
+ bool isInstallable = false;
};
class ArtifactDataPrivate : public QSharedData
{
public:
- ArtifactDataPrivate() : isValid(false) {}
-
QString filePath;
QStringList fileTags;
PropertyMap properties;
InstallData installData;
- bool isValid;
- bool isGenerated;
- bool isTargetArtifact;
+ bool isValid = false;
+ bool isGenerated = false;
+ bool isTargetArtifact = false;
};
class GroupDataPrivate : public QSharedData
{
public:
- GroupDataPrivate() : isValid(false)
- { }
-
QString name;
QString prefix;
CodeLocation location;
QList<ArtifactData> sourceArtifacts;
QList<ArtifactData> sourceArtifactsFromWildcards;
PropertyMap properties;
- bool isEnabled;
- bool isValid;
+ bool isEnabled = false;
+ bool isValid = false;
};
class InstallableFilePrivate: public QSharedData
{
public:
- InstallableFilePrivate() : isValid(false) {}
-
QString sourceFilePath;
QString targetFilePath;
QStringList fileTags;
- bool isValid;
+ bool isValid = false;
};
class ProductDataPrivate : public QSharedData
{
public:
- ProductDataPrivate() : isValid(false)
- { }
-
QStringList type;
QStringList dependencies;
QString name;
@@ -117,22 +105,19 @@ public:
QVariantMap properties;
PropertyMap moduleProperties;
QList<ArtifactData> generatedArtifacts;
- bool isEnabled;
- bool isRunnable;
- bool isMultiplexed;
- bool isValid;
+ bool isEnabled = false;
+ bool isRunnable = false;
+ bool isMultiplexed = false;
+ bool isValid = false;
};
class ProjectDataPrivate : public QSharedData
{
public:
- ProjectDataPrivate() : isValid(false)
- { }
-
QString name;
CodeLocation location;
- bool enabled;
- bool isValid;
+ bool enabled = false;
+ bool isValid = false;
QList<ProductData> products;
QList<ProjectData> subProjects;
QString buildDir;
diff --git a/src/lib/corelib/api/projectfileupdater.cpp b/src/lib/corelib/api/projectfileupdater.cpp
index 944de7161..04f8e630f 100644
--- a/src/lib/corelib/api/projectfileupdater.cpp
+++ b/src/lib/corelib/api/projectfileupdater.cpp
@@ -119,6 +119,8 @@ ProjectFileUpdater::ProjectFileUpdater(const QString &projectFile) : m_projectFi
{
}
+ProjectFileUpdater::~ProjectFileUpdater() = default;
+
ProjectFileUpdater::LineEndingType ProjectFileUpdater::guessLineEndingType(const QByteArray &text)
{
char before = 0;
diff --git a/src/lib/corelib/api/projectfileupdater.h b/src/lib/corelib/api/projectfileupdater.h
index bc8de30eb..c0d46c747 100644
--- a/src/lib/corelib/api/projectfileupdater.h
+++ b/src/lib/corelib/api/projectfileupdater.h
@@ -54,6 +54,7 @@ namespace Internal {
class ProjectFileUpdater
{
public:
+ virtual ~ProjectFileUpdater();
void apply();
CodeLocation itemPosition() const { return m_itemPosition; }
diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp
index 989918207..df5b4337d 100644
--- a/src/lib/corelib/api/runenvironment.cpp
+++ b/src/lib/corelib/api/runenvironment.cpp
@@ -71,16 +71,16 @@ using namespace Internal;
class RunEnvironment::RunEnvironmentPrivate
{
public:
- RunEnvironmentPrivate(const ResolvedProductPtr &product, const TopLevelProjectConstPtr &project,
- const InstallOptions &installOptions, const QProcessEnvironment &environment,
- const QStringList &setupRunEnvConfig, Settings *settings, const Logger &logger)
- : resolvedProduct(product)
- , project(project)
- , installOptions(installOptions)
+ RunEnvironmentPrivate(ResolvedProductPtr product, TopLevelProjectConstPtr project,
+ InstallOptions installOptions, const QProcessEnvironment &environment,
+ QStringList setupRunEnvConfig, Settings *settings, Logger logger)
+ : resolvedProduct(std::move(product))
+ , project(std::move(project))
+ , installOptions(std::move(installOptions))
, environment(environment)
- , setupRunEnvConfig(setupRunEnvConfig)
+ , setupRunEnvConfig(std::move(setupRunEnvConfig))
, settings(settings)
- , logger(logger)
+ , logger(std::move(logger))
, evalContext(this->logger)
{
}
@@ -184,7 +184,8 @@ int RunEnvironment::doRunShell()
#if defined(Q_OS_LINUX)
clearenv();
#endif
- for (const QString &key : environment.keys())
+ const auto keys = environment.keys();
+ for (const QString &key : keys)
qputenv(key.toLocal8Bit().constData(), environment.value(key).toLocal8Bit());
QString command;
if (HostOsInfo::isWindowsHost()) {
@@ -260,7 +261,8 @@ static QString findMainIntent(const QString &aapt, const QString &apkFilePath)
<< QStringLiteral("badging")
<< apkFilePath);
if (aaptProcess.waitForFinished(-1)) {
- for (auto line : aaptProcess.readAllStandardOutput().split('\n')) {
+ const auto lines = aaptProcess.readAllStandardOutput().split('\n');
+ for (const auto &line : lines) {
if (line.startsWith(QByteArrayLiteral("package:")))
packageId = QString::fromStdString(readAaptBadgingAttribute(line.toStdString()));
else if (line.startsWith(QByteArrayLiteral("launchable-activity:")))
diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
index 4626c6a1a..1a1d51f11 100644
--- a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp
@@ -49,14 +49,14 @@
namespace qbs {
namespace Internal {
-AbstractCommandExecutor::AbstractCommandExecutor(const Logger &logger, QObject *parent)
+AbstractCommandExecutor::AbstractCommandExecutor(Logger logger, QObject *parent)
: QObject(parent)
, m_echoMode(defaultCommandEchoMode())
, m_command(nullptr)
, m_transformer(nullptr)
, m_mainThreadScriptEngine(nullptr)
, m_dryRun(false)
- , m_logger(logger)
+ , m_logger(std::move(logger))
{
}
diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.h b/src/lib/corelib/buildgraph/abstractcommandexecutor.h
index f140b5d82..60b2b40b2 100644
--- a/src/lib/corelib/buildgraph/abstractcommandexecutor.h
+++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.h
@@ -58,7 +58,7 @@ class AbstractCommandExecutor : public QObject
{
Q_OBJECT
public:
- explicit AbstractCommandExecutor(const Internal::Logger &logger, QObject *parent = nullptr);
+ explicit AbstractCommandExecutor(Internal::Logger logger, QObject *parent = nullptr);
void setMainThreadScriptEngine(ScriptEngine *engine) { m_mainThreadScriptEngine = engine; }
void setDryRunEnabled(bool enabled) { m_dryRun = enabled; }
diff --git a/src/lib/corelib/buildgraph/artifact.h b/src/lib/corelib/buildgraph/artifact.h
index 32527caf3..ee3acea59 100644
--- a/src/lib/corelib/buildgraph/artifact.h
+++ b/src/lib/corelib/buildgraph/artifact.h
@@ -72,7 +72,7 @@ class QBS_AUTOTEST_EXPORT Artifact : public FileResourceBase, public BuildGraphN
{
public:
Artifact();
- ~Artifact();
+ ~Artifact() override;
Type type() const override { return ArtifactNodeType; }
FileType fileType() const override { return FileTypeArtifact; }
diff --git a/src/lib/corelib/buildgraph/artifactcleaner.cpp b/src/lib/corelib/buildgraph/artifactcleaner.cpp
index 232591e10..000dfda02 100644
--- a/src/lib/corelib/buildgraph/artifactcleaner.cpp
+++ b/src/lib/corelib/buildgraph/artifactcleaner.cpp
@@ -1,3 +1,5 @@
+#include <utility>
+
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
@@ -98,12 +100,12 @@ static void removeArtifactFromDisk(Artifact *artifact, bool dryRun, const Logger
class CleanupVisitor : public ArtifactVisitor
{
public:
- CleanupVisitor(const CleanOptions &options, const ProgressObserver *observer,
- const Logger &logger)
+ CleanupVisitor(CleanOptions options, const ProgressObserver *observer,
+ Logger logger)
: ArtifactVisitor(Artifact::Generated)
- , m_options(options)
+ , m_options(std::move(options))
, m_observer(observer)
- , m_logger(logger)
+ , m_logger(std::move(logger))
, m_hasError(false)
{
}
@@ -154,8 +156,8 @@ private:
Set<QString> m_directories;
};
-ArtifactCleaner::ArtifactCleaner(const Logger &logger, ProgressObserver *observer)
- : m_logger(logger), m_observer(observer)
+ArtifactCleaner::ArtifactCleaner(Logger logger, ProgressObserver *observer)
+ : m_logger(std::move(logger)), m_observer(observer)
{
}
diff --git a/src/lib/corelib/buildgraph/artifactcleaner.h b/src/lib/corelib/buildgraph/artifactcleaner.h
index 4d8c86ea8..5112a75d6 100644
--- a/src/lib/corelib/buildgraph/artifactcleaner.h
+++ b/src/lib/corelib/buildgraph/artifactcleaner.h
@@ -53,7 +53,7 @@ class ProgressObserver;
class ArtifactCleaner
{
public:
- ArtifactCleaner(const Logger &logger, ProgressObserver *observer);
+ ArtifactCleaner(Logger logger, ProgressObserver *observer);
void cleanup(const TopLevelProjectPtr &project, const QList<ResolvedProductPtr> &products,
const CleanOptions &options);
@@ -62,8 +62,8 @@ private:
bool *isEmpty = nullptr);
Logger m_logger;
- bool m_hasError;
- ProgressObserver *m_observer;
+ bool m_hasError = false;
+ ProgressObserver *m_observer = nullptr;
};
} // namespace Internal
diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp
index 616658a18..283e8dc2a 100644
--- a/src/lib/corelib/buildgraph/buildgraph.cpp
+++ b/src/lib/corelib/buildgraph/buildgraph.cpp
@@ -572,13 +572,10 @@ Artifact *lookupArtifact(const ResolvedProductConstPtr &product,
const ProjectBuildData *projectBuildData, const QString &dirPath, const QString &fileName,
bool compareByName)
{
- const QList<FileResourceBase *> lookupResults
- = projectBuildData->lookupFiles(dirPath, fileName);
- for (QList<FileResourceBase *>::const_iterator it = lookupResults.constBegin();
- it != lookupResults.constEnd(); ++it) {
- if ((*it)->fileType() != FileResourceBase::FileTypeArtifact)
+ for (const auto &fileResource : projectBuildData->lookupFiles(dirPath, fileName)) {
+ if (fileResource->fileType() != FileResourceBase::FileTypeArtifact)
continue;
- auto artifact = static_cast<Artifact *>(*it);
+ const auto artifact = static_cast<Artifact *>(fileResource);
if (compareByName
? artifact->product->uniqueName() == product->uniqueName()
: artifact->product == product) {
diff --git a/src/lib/corelib/buildgraph/buildgraphloader.cpp b/src/lib/corelib/buildgraph/buildgraphloader.cpp
index fc0492ef3..bf6c30dcd 100644
--- a/src/lib/corelib/buildgraph/buildgraphloader.cpp
+++ b/src/lib/corelib/buildgraph/buildgraphloader.cpp
@@ -76,8 +76,8 @@
namespace qbs {
namespace Internal {
-BuildGraphLoader::BuildGraphLoader(const Logger &logger) :
- m_logger(logger)
+BuildGraphLoader::BuildGraphLoader(Logger logger) :
+ m_logger(std::move(logger))
{
}
@@ -438,11 +438,10 @@ void BuildGraphLoader::trackProjectChanges()
allNewlyResolvedProducts);
}
- for (auto it = m_changedSourcesByProduct.cbegin(); it != m_changedSourcesByProduct.cend();
- ++it) {
- const ResolvedProductPtr product = m_freshProductsByName.value(it->first);
+ for (const auto &kv : m_changedSourcesByProduct) {
+ const ResolvedProductPtr product = m_freshProductsByName.value(kv.first);
QBS_CHECK(!!product);
- for (const SourceArtifactConstPtr &sa : it->second)
+ for (const SourceArtifactConstPtr &sa : kv.second)
updateArtifactFromSourceArtifact(product, sa);
}
diff --git a/src/lib/corelib/buildgraph/buildgraphloader.h b/src/lib/corelib/buildgraph/buildgraphloader.h
index 94eb01c5d..9363b8358 100644
--- a/src/lib/corelib/buildgraph/buildgraphloader.h
+++ b/src/lib/corelib/buildgraph/buildgraphloader.h
@@ -72,7 +72,7 @@ public:
class BuildGraphLoader
{
public:
- BuildGraphLoader(const Logger &logger);
+ BuildGraphLoader(Logger logger);
~BuildGraphLoader();
BuildGraphLoadResult load(const TopLevelProjectPtr &existingProject,
@@ -141,8 +141,8 @@ private:
QStringList m_artifactsRemovedFromDisk;
std::unordered_map<QString, std::vector<SourceArtifactConstPtr>> m_changedSourcesByProduct;
Set<QString> m_productsWhoseArtifactsNeedUpdate;
- qint64 m_wildcardExpansionEffort;
- qint64 m_propertyComparisonEffort;
+ qint64 m_wildcardExpansionEffort = 0;
+ qint64 m_propertyComparisonEffort = 0;
// These must only be deleted at the end so we can still peek into the old look-up table.
QList<FileResourceBase *> m_objectsToDelete;
diff --git a/src/lib/corelib/buildgraph/buildgraphvisitor.h b/src/lib/corelib/buildgraph/buildgraphvisitor.h
index 216e16a8c..cc2dde792 100644
--- a/src/lib/corelib/buildgraph/buildgraphvisitor.h
+++ b/src/lib/corelib/buildgraph/buildgraphvisitor.h
@@ -55,6 +55,7 @@ class RuleNode;
class BuildGraphVisitor
{
public:
+ virtual ~BuildGraphVisitor() = default;
virtual bool visit(Artifact *) { return true; }
virtual void endVisit(Artifact *) { }
virtual bool visit(RuleNode *) { return true; }
diff --git a/src/lib/corelib/buildgraph/cycledetector.cpp b/src/lib/corelib/buildgraph/cycledetector.cpp
index 95afba87d..5daed55fd 100644
--- a/src/lib/corelib/buildgraph/cycledetector.cpp
+++ b/src/lib/corelib/buildgraph/cycledetector.cpp
@@ -51,8 +51,8 @@
namespace qbs {
namespace Internal {
-CycleDetector::CycleDetector(const Logger &logger)
- : m_parent(nullptr), m_logger(logger)
+CycleDetector::CycleDetector(Logger logger)
+ : m_parent(nullptr), m_logger(std::move(logger))
{
}
@@ -80,7 +80,8 @@ bool CycleDetector::visitNode(BuildGraphNode *node)
{
if (Q_UNLIKELY(m_nodesInCurrentPath.contains(node))) {
ErrorInfo error(Tr::tr("Cycle in build graph detected."));
- for (const BuildGraphNode * const n : cycle(node))
+ const auto nodes = cycle(node);
+ for (const BuildGraphNode * const n : nodes)
error.append(n->toString());
throw error;
}
diff --git a/src/lib/corelib/buildgraph/cycledetector.h b/src/lib/corelib/buildgraph/cycledetector.h
index fffe6ed2f..5bfb44ef8 100644
--- a/src/lib/corelib/buildgraph/cycledetector.h
+++ b/src/lib/corelib/buildgraph/cycledetector.h
@@ -52,7 +52,7 @@ class BuildGraphNode;
class QBS_AUTOTEST_EXPORT CycleDetector : private BuildGraphVisitor
{
public:
- CycleDetector(const Logger &logger);
+ CycleDetector(Logger logger);
void visitProject(const TopLevelProjectConstPtr &project);
void visitProduct(const ResolvedProductConstPtr &product);
diff --git a/src/lib/corelib/buildgraph/depscanner.cpp b/src/lib/corelib/buildgraph/depscanner.cpp
index a2a39e4b2..0bf644286 100644
--- a/src/lib/corelib/buildgraph/depscanner.cpp
+++ b/src/lib/corelib/buildgraph/depscanner.cpp
@@ -154,9 +154,9 @@ bool PluginDependencyScanner::areModulePropertiesCompatible(const PropertyMapCon
return true;
}
-UserDependencyScanner::UserDependencyScanner(const ResolvedScannerConstPtr &scanner,
+UserDependencyScanner::UserDependencyScanner(ResolvedScannerConstPtr scanner,
ScriptEngine *engine)
- : m_scanner(scanner),
+ : m_scanner(std::move(scanner)),
m_engine(engine),
m_product(nullptr)
{
diff --git a/src/lib/corelib/buildgraph/depscanner.h b/src/lib/corelib/buildgraph/depscanner.h
index b8f8721aa..ffc0b83de 100644
--- a/src/lib/corelib/buildgraph/depscanner.h
+++ b/src/lib/corelib/buildgraph/depscanner.h
@@ -102,7 +102,7 @@ private:
class UserDependencyScanner : public DependencyScanner
{
public:
- UserDependencyScanner(const ResolvedScannerConstPtr &scanner, ScriptEngine *engine);
+ UserDependencyScanner(ResolvedScannerConstPtr scanner, ScriptEngine *engine);
private:
QStringList collectSearchPaths(Artifact *artifact) override;
diff --git a/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp b/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp
index b3cc6c840..ebbcf67a7 100644
--- a/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp
+++ b/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp
@@ -49,8 +49,8 @@ namespace qbs {
namespace Internal {
EmptyDirectoriesRemover::EmptyDirectoriesRemover(const TopLevelProject *project,
- const Logger &logger)
- : m_project(project), m_logger(logger)
+ Logger logger)
+ : m_project(project), m_logger(std::move(logger))
{
}
diff --git a/src/lib/corelib/buildgraph/emptydirectoriesremover.h b/src/lib/corelib/buildgraph/emptydirectoriesremover.h
index 6ec42c627..7d73fb819 100644
--- a/src/lib/corelib/buildgraph/emptydirectoriesremover.h
+++ b/src/lib/corelib/buildgraph/emptydirectoriesremover.h
@@ -53,7 +53,7 @@ class TopLevelProject;
class EmptyDirectoriesRemover
{
public:
- EmptyDirectoriesRemover(const TopLevelProject *project, const Logger &logger);
+ EmptyDirectoriesRemover(const TopLevelProject *project, Logger logger);
void removeEmptyParentDirectories(const QStringList &artifactFilePaths);
void removeEmptyParentDirectories(const ArtifactSet &artifacts);
diff --git a/src/lib/corelib/buildgraph/environmentscriptrunner.h b/src/lib/corelib/buildgraph/environmentscriptrunner.h
index 344a764d0..221314798 100644
--- a/src/lib/corelib/buildgraph/environmentscriptrunner.h
+++ b/src/lib/corelib/buildgraph/environmentscriptrunner.h
@@ -69,7 +69,7 @@ private:
const QProcessEnvironment m_env;
QStringList m_runEnvConfig;
- enum EnvType { BuildEnv, RunEnv } m_envType;
+ enum EnvType { BuildEnv, RunEnv } m_envType = EnvType::BuildEnv;
};
} // namespace Internal
diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp
index 8f71e1ea3..de81ada20 100644
--- a/src/lib/corelib/buildgraph/executor.cpp
+++ b/src/lib/corelib/buildgraph/executor.cpp
@@ -86,10 +86,10 @@ bool Executor::ComparePriority::operator() (const BuildGraphNode *x, const Build
}
-Executor::Executor(const Logger &logger, QObject *parent)
+Executor::Executor(Logger logger, QObject *parent)
: QObject(parent)
, m_productInstaller(nullptr)
- , m_logger(logger)
+ , m_logger(std::move(logger))
, m_progressObserver(nullptr)
, m_state(ExecutorIdle)
, m_cancelationTimer(new QTimer(this))
@@ -105,7 +105,8 @@ Executor::~Executor()
// jobs must be destroyed before deleting the shared scan result cache
for (ExecutorJob *job : qAsConst(m_availableJobs))
delete job;
- for (ExecutorJob *job : m_processingJobs.keys())
+ const auto processingJobs = m_processingJobs.keys();
+ for (ExecutorJob *job : processingJobs)
delete job;
delete m_inputArtifactScanContext;
delete m_productInstaller;
@@ -180,7 +181,7 @@ void Executor::setProducts(const std::vector<ResolvedProductPtr> &productsToBuil
class ProductPrioritySetter
{
const std::vector<ResolvedProductPtr> &m_allProducts;
- unsigned int m_priority;
+ unsigned int m_priority = 0;
Set<ResolvedProductPtr> m_seenProducts;
public:
ProductPrioritySetter(const std::vector<ResolvedProductPtr> &allProducts) // TODO: Use only products to build?
@@ -242,8 +243,7 @@ void Executor::doBuild()
const QStringList &filesToConsider = m_buildOptions.filesToConsider();
if (!filesToConsider.empty()) {
for (const QString &fileToConsider : filesToConsider) {
- const QList<FileResourceBase *> &files
- = m_project->buildData->lookupFiles(fileToConsider);
+ const auto &files = m_project->buildData->lookupFiles(fileToConsider);
for (const FileResourceBase * const file : files) {
if (file->fileType() != FileResourceBase::FileTypeArtifact)
continue;
@@ -392,7 +392,7 @@ bool Executor::schedulingBlockedByJobLimit(const BuildGraphNode *node)
{
if (node->type() != BuildGraphNode::ArtifactNodeType)
return false;
- const Artifact * const artifact = static_cast<const Artifact *>(node);
+ const auto artifact = static_cast<const Artifact *>(node);
if (artifact->artifactType == Artifact::SourceFile)
return false;
@@ -412,7 +412,8 @@ bool Executor::schedulingBlockedByJobLimit(const BuildGraphNode *node)
// running transformers.
if (jobLimitIsExceeded(transformer))
return true;
- for (const ExecutorJob * const runningJob : m_processingJobs.keys()) {
+ const auto runningJobs = m_processingJobs.keys();
+ for (const ExecutorJob * const runningJob : runningJobs) {
if (!runningJob->jobPools().contains(jobPool))
continue;
const Transformer * const runningTransformer = runningJob->transformer();
@@ -684,7 +685,8 @@ bool Executor::transformerHasMatchingInputFiles(const TransformerConstPtr &trans
if (transformer->inputs.empty())
return true;
for (const Artifact * const input : qAsConst(transformer->inputs)) {
- for (const QString &filePath : m_buildOptions.filesToConsider()) {
+ const auto files = m_buildOptions.filesToConsider();
+ for (const QString &filePath : files) {
if (input->filePath() == filePath
|| input->fileTags().intersects(m_tagsNeededForFilesToConsider)) {
return true;
@@ -725,7 +727,8 @@ void Executor::cancelJobs()
return;
qCDebug(lcExec) << "Canceling all jobs.";
setState(ExecutorCanceling);
- for (ExecutorJob *job : m_processingJobs.keys())
+ const auto jobs = m_processingJobs.keys();
+ for (ExecutorJob *job : jobs)
job->cancel();
}
@@ -734,7 +737,7 @@ void Executor::setupProgressObserver()
if (!m_progressObserver)
return;
int totalEffort = 1; // For the effort after the last rule application;
- for (const ResolvedProductConstPtr &product : m_productsToBuild) {
+ for (const ResolvedProductConstPtr &product : qAsConst(m_productsToBuild)) {
QBS_CHECK(product->buildData);
const auto filtered = filterByType<RuleNode>(product->buildData->allNodes());
totalEffort += std::distance(filtered.begin(), filtered.end());
@@ -746,7 +749,7 @@ void Executor::doSanityChecks()
{
QBS_CHECK(m_project);
QBS_CHECK(!m_productsToBuild.empty());
- for (const ResolvedProductConstPtr &product : m_productsToBuild) {
+ for (const ResolvedProductConstPtr &product : qAsConst(m_productsToBuild)) {
QBS_CHECK(product->buildData);
QBS_CHECK(product->topLevelProject() == m_project.get());
}
@@ -754,7 +757,8 @@ void Executor::doSanityChecks()
void Executor::handleError(const ErrorInfo &error)
{
- for (const ErrorItem &ei : error.items())
+ const auto items = error.items();
+ for (const ErrorItem &ei : items)
m_error.append(ei);
if (m_processingJobs.empty())
finish();
@@ -833,7 +837,7 @@ void Executor::rescueOldBuildData(Artifact *artifact, bool *childrenAdded = null
childrenToConnect.push_back(child);
}
for (const QString &depPath : rad.fileDependencies) {
- const QList<FileResourceBase *> depList = m_project->buildData->lookupFiles(depPath);
+ const auto &depList = m_project->buildData->lookupFiles(depPath);
if (depList.empty()) {
canRescue = false;
qCDebug(lcBuildGraph) << "File dependency" << depPath
@@ -1079,7 +1083,7 @@ void Executor::checkForUnbuiltProducts()
{
if (m_buildOptions.executeRulesOnly())
return;
- QList<ResolvedProductPtr> unbuiltProducts;
+ std::vector<ResolvedProductPtr> unbuiltProducts;
for (const ResolvedProductPtr &product : m_productsToBuild) {
bool productBuilt = true;
for (BuildGraphNode *rootNode : qAsConst(product->buildData->rootNodes())) {
diff --git a/src/lib/corelib/buildgraph/executor.h b/src/lib/corelib/buildgraph/executor.h
index 003ba9a22..895e066a7 100644
--- a/src/lib/corelib/buildgraph/executor.h
+++ b/src/lib/corelib/buildgraph/executor.h
@@ -77,8 +77,8 @@ class Executor : public QObject, private BuildGraphVisitor
public:
void build();
- Executor(const Logger &logger, QObject *parent = nullptr);
- ~Executor();
+ Executor(Logger logger, QObject *parent = nullptr);
+ ~Executor() override;
void setProject(const TopLevelProjectPtr &project);
void setProducts(const std::vector<ResolvedProductPtr> &productsToBuild);
@@ -180,17 +180,17 @@ private:
Leaves m_leaves;
InputArtifactScannerContext *m_inputArtifactScanContext;
ErrorInfo m_error;
- bool m_explicitlyCanceled;
+ bool m_explicitlyCanceled = false;
FileTags m_activeFileTags;
FileTags m_tagsOfFilesToConsider;
FileTags m_tagsNeededForFilesToConsider;
QList<ResolvedProductPtr> m_productsOfFilesToConsider;
- QTimer * const m_cancelationTimer;
+ QTimer * const m_cancelationTimer = nullptr;
QStringList m_artifactsRemovedFromDisk;
- bool m_partialBuild;
- qint64 m_elapsedTimeRules;
- qint64 m_elapsedTimeScanners;
- qint64 m_elapsedTimeInstalling;
+ bool m_partialBuild = false;
+ qint64 m_elapsedTimeRules = 0;
+ qint64 m_elapsedTimeScanners = 0;
+ qint64 m_elapsedTimeInstalling = 0;
};
} // namespace Internal
diff --git a/src/lib/corelib/buildgraph/executorjob.h b/src/lib/corelib/buildgraph/executorjob.h
index e28d42f7f..bc8954072 100644
--- a/src/lib/corelib/buildgraph/executorjob.h
+++ b/src/lib/corelib/buildgraph/executorjob.h
@@ -66,7 +66,7 @@ class ExecutorJob : public QObject
Q_OBJECT
public:
ExecutorJob(const Logger &logger, QObject *parent);
- ~ExecutorJob();
+ ~ExecutorJob() override;
void setMainThreadScriptEngine(ScriptEngine *engine);
void setDryRun(bool enabled);
@@ -88,12 +88,12 @@ private:
void setFinished();
void reset();
- AbstractCommandExecutor *m_currentCommandExecutor;
- ProcessCommandExecutor *m_processCommandExecutor;
- JsCommandExecutor *m_jsCommandExecutor;
- Transformer *m_transformer;
+ AbstractCommandExecutor *m_currentCommandExecutor = nullptr;
+ ProcessCommandExecutor *m_processCommandExecutor = nullptr;
+ JsCommandExecutor *m_jsCommandExecutor = nullptr;
+ Transformer *m_transformer = nullptr;
Set<QString> m_jobPools;
- int m_currentCommandIdx;
+ int m_currentCommandIdx = 0;
ErrorInfo m_error;
};
diff --git a/src/lib/corelib/buildgraph/filedependency.h b/src/lib/corelib/buildgraph/filedependency.h
index b9a7caf57..802654e9f 100644
--- a/src/lib/corelib/buildgraph/filedependency.h
+++ b/src/lib/corelib/buildgraph/filedependency.h
@@ -85,7 +85,7 @@ class FileDependency : public FileResourceBase
{
public:
FileDependency();
- ~FileDependency();
+ ~FileDependency() override;
FileType fileType() const override { return FileTypeDependency; }
};
diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp
index 68f3b744b..c8b2cb779 100644
--- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp
+++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp
@@ -77,8 +77,9 @@ static void resolveDepencency(const RawScannedDependency &dependency,
FileDependency *fileDependencyArtifact = nullptr;
Artifact *dependencyInProduct = nullptr;
Artifact *dependencyInOtherProduct = nullptr;
- for (FileResourceBase *lookupResult : project->topLevelProject()
- ->buildData->lookupFiles(absDirPath, dependency.fileName())) {
+ const auto files = project->topLevelProject()
+ ->buildData->lookupFiles(absDirPath, dependency.fileName());
+ for (FileResourceBase *lookupResult : files) {
switch (lookupResult->fileType()) {
case FileResourceBase::FileTypeDependency:
fileDependencyArtifact = static_cast<FileDependency *>(lookupResult);
@@ -115,12 +116,12 @@ static void resolveDepencency(const RawScannedDependency &dependency,
}
InputArtifactScanner::InputArtifactScanner(Artifact *artifact, InputArtifactScannerContext *ctx,
- const Logger &logger)
+ Logger logger)
: m_artifact(artifact),
m_rawScanResults(artifact->product->topLevelProject()->buildData->rawScanResults),
m_context(ctx),
m_newDependencyAdded(false),
- m_logger(logger)
+ m_logger(std::move(logger))
{
}
@@ -274,7 +275,7 @@ void InputArtifactScanner::resolveScanResultDependencies(const Artifact *inputAr
}
// try include paths
- for (const QString &includePath : cache.searchPaths) {
+ for (const QString &includePath : qAsConst(cache.searchPaths)) {
resolveDepencency(dependency, inputArtifact->product.get(),
&resolvedDependency, includePath);
if (resolvedDependency.isValid())
diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.h b/src/lib/corelib/buildgraph/inputartifactscanner.h
index 92d5f516f..ac51af579 100644
--- a/src/lib/corelib/buildgraph/inputartifactscanner.h
+++ b/src/lib/corelib/buildgraph/inputartifactscanner.h
@@ -118,7 +118,7 @@ class InputArtifactScanner
{
public:
InputArtifactScanner(Artifact *artifact, InputArtifactScannerContext *ctx,
- const Logger &logger);
+ Logger logger);
void scan();
bool newDependencyAdded() const { return m_newDependencyAdded; }
diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.cpp b/src/lib/corelib/buildgraph/jscommandexecutor.cpp
index 4b7adb221..30970779c 100644
--- a/src/lib/corelib/buildgraph/jscommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/jscommandexecutor.cpp
@@ -62,7 +62,7 @@ namespace Internal {
struct JavaScriptCommandResult
{
- bool success;
+ bool success = false;
QString errorMessage;
CodeLocation errorLocation;
};
@@ -71,8 +71,8 @@ class JsCommandExecutorThreadObject : public QObject
{
Q_OBJECT
public:
- JsCommandExecutorThreadObject(const Logger &logger)
- : m_logger(logger)
+ JsCommandExecutorThreadObject(Logger logger)
+ : m_logger(std::move(logger))
, m_scriptEngine(nullptr)
{
}
diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.h b/src/lib/corelib/buildgraph/jscommandexecutor.h
index 207e18097..0170c5231 100644
--- a/src/lib/corelib/buildgraph/jscommandexecutor.h
+++ b/src/lib/corelib/buildgraph/jscommandexecutor.h
@@ -56,7 +56,7 @@ class JsCommandExecutor : public AbstractCommandExecutor
Q_OBJECT
public:
explicit JsCommandExecutor(const Logger &logger, QObject *parent = nullptr);
- ~JsCommandExecutor();
+ ~JsCommandExecutor() override;
signals:
void startRequested(const JavaScriptCommand *cmd, Transformer *transformer);
diff --git a/src/lib/corelib/buildgraph/nodetreedumper.h b/src/lib/corelib/buildgraph/nodetreedumper.h
index 3ad3ca592..4175ce727 100644
--- a/src/lib/corelib/buildgraph/nodetreedumper.h
+++ b/src/lib/corelib/buildgraph/nodetreedumper.h
@@ -74,7 +74,7 @@ private:
QIODevice &m_outDevice;
ResolvedProductPtr m_currentProduct;
NodeSet m_visited;
- unsigned int m_indentation;
+ unsigned int m_indentation = 0;
};
} // namespace Internal
diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
index 0818e1200..c34a734b4 100644
--- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp
+++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp
@@ -89,7 +89,8 @@ static QProcessEnvironment mergeEnvironments(const QProcessEnvironment &baseEnv,
QStringLiteral("DYLD_LIBRARY_PATH"),
QStringLiteral("DYLD_FRAMEWORK_PATH"),
};
- for (const QString &key : additionalEnv.keys()) {
+ const auto keys = additionalEnv.keys();
+ for (const QString &key : keys) {
QString newValue = additionalEnv.value(key);
if (pathListVariables.contains(key, HostOsInfo::fileNameCaseSensitivity())) {
const QString &oldValue = baseEnv.value(key);
@@ -108,7 +109,8 @@ void ProcessCommandExecutor::doSetup()
transformer()->product()->buildEnvironment)
.findExecutable(cmd->program(), cmd->workingDir());
cmd->clearRelevantEnvValues();
- for (const QString &key : cmd->relevantEnvVars())
+ const auto keys = cmd->relevantEnvVars();
+ for (const QString &key : keys)
cmd->addRelevantEnvValue(key, transformer()->product()->buildEnvironment.value(key));
m_commandEnvironment = mergeEnvironments(m_buildEnvironment, cmd->environment());
diff --git a/src/lib/corelib/buildgraph/productbuilddata.h b/src/lib/corelib/buildgraph/productbuilddata.h
index bcc500de8..a7660af27 100644
--- a/src/lib/corelib/buildgraph/productbuilddata.h
+++ b/src/lib/corelib/buildgraph/productbuilddata.h
@@ -106,7 +106,7 @@ private:
AllRescuableArtifactData m_rescuableArtifactData;
// Do not store, initialized in executor. Higher prioritized artifacts are built first.
- unsigned int m_buildPriority;
+ unsigned int m_buildPriority = 0;
ArtifactSetByFileTag m_artifactsByFileTag;
mutable std::mutex m_artifactsMapMutex;
diff --git a/src/lib/corelib/buildgraph/productinstaller.cpp b/src/lib/corelib/buildgraph/productinstaller.cpp
index cfd74c205..d4acc9ace 100644
--- a/src/lib/corelib/buildgraph/productinstaller.cpp
+++ b/src/lib/corelib/buildgraph/productinstaller.cpp
@@ -59,14 +59,14 @@
namespace qbs {
namespace Internal {
-ProductInstaller::ProductInstaller(const TopLevelProjectPtr &project,
- const std::vector<ResolvedProductPtr> &products, const InstallOptions &options,
- ProgressObserver *observer, const Logger &logger)
- : m_project(project),
- m_products(products),
- m_options(options),
+ProductInstaller::ProductInstaller(TopLevelProjectPtr project,
+ std::vector<ResolvedProductPtr> products, InstallOptions options,
+ ProgressObserver *observer, Logger logger)
+ : m_project(std::move(project)),
+ m_products(std::move(products)),
+ m_options(std::move(options)),
m_observer(observer),
- m_logger(logger)
+ m_logger(std::move(logger))
{
if (!m_options.installRoot().isEmpty()) {
QFileInfo installRootFileInfo(m_options.installRoot());
@@ -85,7 +85,7 @@ ProductInstaller::ProductInstaller(const TopLevelProjectPtr &project,
if (m_options.removeExistingInstallation())
throw ErrorInfo(Tr::tr("Refusing to remove sysroot."));
}
- initInstallRoot(project.get(), m_options);
+ initInstallRoot(m_project.get(), m_options);
}
void ProductInstaller::install()
diff --git a/src/lib/corelib/buildgraph/productinstaller.h b/src/lib/corelib/buildgraph/productinstaller.h
index 8379adb4c..09828cfe9 100644
--- a/src/lib/corelib/buildgraph/productinstaller.h
+++ b/src/lib/corelib/buildgraph/productinstaller.h
@@ -55,9 +55,9 @@ class ProgressObserver;
class ProductInstaller
{
public:
- ProductInstaller(const TopLevelProjectPtr &project,
- const std::vector<ResolvedProductPtr> &products,
- const InstallOptions &options, ProgressObserver *observer, const Logger &logger);
+ ProductInstaller(TopLevelProjectPtr project,
+ std::vector<ResolvedProductPtr> products,
+ InstallOptions options, ProgressObserver *observer, Logger logger);
void install();
static QString targetFilePath(const TopLevelProject *project, const QString &productSourceDir,
diff --git a/src/lib/corelib/buildgraph/projectbuilddata.cpp b/src/lib/corelib/buildgraph/projectbuilddata.cpp
index dcb10b45b..31012e23e 100644
--- a/src/lib/corelib/buildgraph/projectbuilddata.cpp
+++ b/src/lib/corelib/buildgraph/projectbuilddata.cpp
@@ -96,8 +96,7 @@ QString ProjectBuildData::deriveBuildGraphFilePath(const QString &buildDir, cons
void ProjectBuildData::insertIntoLookupTable(FileResourceBase *fileres)
{
- QList<FileResourceBase *> &lst
- = m_artifactLookupTable[fileres->fileName()][fileres->dirPath()];
+ auto &lst = m_artifactLookupTable[{fileres->fileName(), fileres->dirPath()}];
const auto * const artifact = fileres->fileType() == FileResourceBase::FileTypeArtifact
? static_cast<Artifact *>(fileres) : nullptr;
if (artifact && artifact->artifactType == Artifact::Generated) {
@@ -117,30 +116,32 @@ void ProjectBuildData::insertIntoLookupTable(FileResourceBase *fileres)
throw error;
}
}
- QBS_CHECK(!lst.contains(fileres));
+ QBS_CHECK(!contains(lst, fileres));
lst.push_back(fileres);
m_isDirty = true;
}
void ProjectBuildData::removeFromLookupTable(FileResourceBase *fileres)
{
- m_artifactLookupTable[fileres->fileName()][fileres->dirPath()].removeOne(fileres);
+ removeOne(m_artifactLookupTable[{fileres->fileName(), fileres->dirPath()}], fileres);
}
-QList<FileResourceBase *> ProjectBuildData::lookupFiles(const QString &filePath) const
+const std::vector<FileResourceBase *> &ProjectBuildData::lookupFiles(const QString &filePath) const
{
QString dirPath, fileName;
FileInfo::splitIntoDirectoryAndFileName(filePath, &dirPath, &fileName);
return lookupFiles(dirPath, fileName);
}
-QList<FileResourceBase *> ProjectBuildData::lookupFiles(const QString &dirPath,
+const std::vector<FileResourceBase *> &ProjectBuildData::lookupFiles(const QString &dirPath,
const QString &fileName) const
{
- return m_artifactLookupTable.value(fileName).value(dirPath);
+ static const std::vector<FileResourceBase *> emptyResult;
+ const auto it = m_artifactLookupTable.find({fileName, dirPath});
+ return it != m_artifactLookupTable.end() ? it->second : emptyResult;
}
-QList<FileResourceBase *> ProjectBuildData::lookupFiles(const Artifact *artifact) const
+const std::vector<FileResourceBase *> &ProjectBuildData::lookupFiles(const Artifact *artifact) const
{
return lookupFiles(artifact->dirPath(), artifact->fileName());
}
@@ -266,7 +267,7 @@ void ProjectBuildData::store(PersistentPool &pool)
}
-BuildDataResolver::BuildDataResolver(const Logger &logger) : m_logger(logger)
+BuildDataResolver::BuildDataResolver(Logger logger) : m_logger(std::move(logger))
{
}
diff --git a/src/lib/corelib/buildgraph/projectbuilddata.h b/src/lib/corelib/buildgraph/projectbuilddata.h
index 785a86cbb..930344435 100644
--- a/src/lib/corelib/buildgraph/projectbuilddata.h
+++ b/src/lib/corelib/buildgraph/projectbuilddata.h
@@ -45,13 +45,15 @@
#include <logging/logger.h>
#include <tools/persistence.h>
#include <tools/set.h>
+#include <tools/qttools.h>
-#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
#include <QtScript/qscriptvalue.h>
+#include <unordered_map>
+
namespace qbs {
namespace Internal {
class BuildGraphNode;
@@ -70,9 +72,9 @@ public:
void insertIntoLookupTable(FileResourceBase *fileres);
void removeFromLookupTable(FileResourceBase *fileres);
- QList<FileResourceBase *> lookupFiles(const QString &filePath) const;
- QList<FileResourceBase *> lookupFiles(const QString &dirPath, const QString &fileName) const;
- QList<FileResourceBase *> lookupFiles(const Artifact *artifact) const;
+ const std::vector<FileResourceBase *> &lookupFiles(const QString &filePath) const;
+ const std::vector<FileResourceBase *> &lookupFiles(const QString &dirPath, const QString &fileName) const;
+ const std::vector<FileResourceBase *> &lookupFiles(const Artifact *artifact) const;
void insertFileDependency(FileDependency *dependency);
void removeArtifactAndExclusiveDependents(Artifact *artifact, const Logger &logger,
bool removeFromProduct = true, ArtifactSet *removedArtifacts = nullptr);
@@ -99,9 +101,10 @@ private:
pool.serializationOp<opType>(fileDependencies, rawScanResults);
}
- using ResultsPerDirectory = QHash<QString, QList<FileResourceBase *>>;
- using ArtifactLookupTable = QHash<QString, ResultsPerDirectory>;
+ using ArtifactKey = std::pair<QString /*fileName*/, QString /*dirName*/>;
+ using ArtifactLookupTable = std::unordered_map<ArtifactKey, std::vector<FileResourceBase *>>;
ArtifactLookupTable m_artifactLookupTable;
+
bool m_doCleanupInDestructor = true;
bool m_isDirty = true;
};
@@ -110,7 +113,7 @@ private:
class BuildDataResolver
{
public:
- BuildDataResolver(const Logger &logger);
+ BuildDataResolver(Logger logger);
void resolveBuildData(const TopLevelProjectPtr &resolvedProject,
const RulesEvaluationContextPtr &evalContext);
void resolveProductBuildDataForExistingProject(const TopLevelProjectPtr &project,
diff --git a/src/lib/corelib/buildgraph/rawscanneddependency.h b/src/lib/corelib/buildgraph/rawscanneddependency.h
index e1cb5015c..4871bea62 100644
--- a/src/lib/corelib/buildgraph/rawscanneddependency.h
+++ b/src/lib/corelib/buildgraph/rawscanneddependency.h
@@ -72,7 +72,7 @@ private:
QString m_dirPath;
QString m_fileName;
- bool m_isClean;
+ bool m_isClean = 0;
};
bool operator==(const RawScannedDependency &d1, const RawScannedDependency &d2);
diff --git a/src/lib/corelib/buildgraph/requestedartifacts.cpp b/src/lib/corelib/buildgraph/requestedartifacts.cpp
index 7fbaf65f1..e4730d2f1 100644
--- a/src/lib/corelib/buildgraph/requestedartifacts.cpp
+++ b/src/lib/corelib/buildgraph/requestedartifacts.cpp
@@ -55,9 +55,8 @@ bool RequestedArtifacts::isUpToDate(const TopLevelProject *project) const
if (m_requestedArtifactsPerProduct.empty())
return true;
const std::vector<ResolvedProductPtr> &allProducts = project->allProducts();
- for (auto it = m_requestedArtifactsPerProduct.cbegin();
- it != m_requestedArtifactsPerProduct.cend(); ++it) {
- const QString &productName = it->first;
+ for (const auto &kv : m_requestedArtifactsPerProduct) {
+ const QString &productName = kv.first;
const auto findProduct = [productName](const ResolvedProductConstPtr &p) {
return p->uniqueName() == productName;
};
@@ -67,7 +66,7 @@ bool RequestedArtifacts::isUpToDate(const TopLevelProject *project) const
<< "does not exist anymore";
return false;
}
- if (!it->second.isUpToDate(productIt->get()))
+ if (!kv.second.isUpToDate(productIt->get()))
return false;
}
return true;
@@ -110,18 +109,14 @@ void RequestedArtifacts::setArtifactsEnumerated(const ResolvedProduct *product)
void RequestedArtifacts::unite(const RequestedArtifacts &other)
{
- for (auto it = other.m_requestedArtifactsPerProduct.begin();
- it != other.m_requestedArtifactsPerProduct.end(); ++it) {
- m_requestedArtifactsPerProduct[it->first].unite(it->second);
- }
+ for (const auto &kv : other.m_requestedArtifactsPerProduct)
+ m_requestedArtifactsPerProduct[kv.first].unite(kv.second);
}
void RequestedArtifacts::doSanityChecks() const
{
- for (auto it = m_requestedArtifactsPerProduct.cbegin();
- it != m_requestedArtifactsPerProduct.cend(); ++it) {
- it->second.doSanityChecks();
- }
+ for (const auto &kv : m_requestedArtifactsPerProduct)
+ kv.second.doSanityChecks();
}
void RequestedArtifacts::load(PersistentPool &pool)
@@ -147,17 +142,17 @@ bool RequestedArtifacts::RequestedArtifactsPerProduct::isUpToDate(
return true;
const ArtifactSetByFileTag currentArtifacts = product->buildData->artifactsByFileTag();
- for (auto reqIt = requestedTags.cbegin(); reqIt != requestedTags.cend(); ++reqIt) {
- const FileTag tag = FileTag(reqIt->first.toUtf8());
+ for (const auto &kv : requestedTags) {
+ const FileTag tag = FileTag(kv.first.toUtf8());
const auto currentIt = currentArtifacts.constFind(tag);
Set<QString> currentFilePathsForTag;
if (currentIt != currentArtifacts.constEnd()) {
for (const Artifact * const a : currentIt.value())
currentFilePathsForTag.insert(a->filePath());
}
- if (currentFilePathsForTag != reqIt->second) {
+ if (currentFilePathsForTag != kv.second) {
qCDebug(lcBuildGraph) << "artifacts map not up to date: requested artifact set for "
- "file tag" << reqIt->first << "in product"
+ "file tag" << kv.first << "in product"
<< product->uniqueName() << "differs from the current one";
return false;
}
@@ -185,14 +180,14 @@ void RequestedArtifacts::RequestedArtifactsPerProduct::unite(
return;
}
allTags = other.allTags;
- for (auto it = other.requestedTags.begin(); it != other.requestedTags.end(); ++it)
- requestedTags[it->first] = it->second;
+ for (const auto &kv : other.requestedTags)
+ requestedTags[kv.first] = kv.second;
}
void RequestedArtifacts::RequestedArtifactsPerProduct::doSanityChecks() const
{
- for (auto it = requestedTags.begin(); it != requestedTags.end(); ++it)
- QBS_CHECK(allTags.contains(it->first) || it->second.empty());
+ for (const auto &kv : requestedTags)
+ QBS_CHECK(allTags.contains(kv.first) || kv.second.empty());
}
void RequestedArtifacts::RequestedArtifactsPerProduct::load(PersistentPool &pool)
diff --git a/src/lib/corelib/buildgraph/rulegraph.h b/src/lib/corelib/buildgraph/rulegraph.h
index fe2fc4c3b..4ce5ecea8 100644
--- a/src/lib/corelib/buildgraph/rulegraph.h
+++ b/src/lib/corelib/buildgraph/rulegraph.h
@@ -56,6 +56,7 @@ namespace Internal {
class RuleGraphVisitor
{
public:
+ virtual ~RuleGraphVisitor() = default;
virtual void visit(const RuleConstPtr &parentRule, const RuleConstPtr &rule) = 0;
virtual void endVisit(const RuleConstPtr &rule) { Q_UNUSED(rule); }
};
diff --git a/src/lib/corelib/buildgraph/rulenode.h b/src/lib/corelib/buildgraph/rulenode.h
index 0585678ec..cfb2039d6 100644
--- a/src/lib/corelib/buildgraph/rulenode.h
+++ b/src/lib/corelib/buildgraph/rulenode.h
@@ -58,7 +58,7 @@ class RuleNode : public BuildGraphNode
{
public:
RuleNode();
- ~RuleNode();
+ ~RuleNode() override;
void setRule(const RuleConstPtr &rule) { m_rule = rule; }
const RuleConstPtr &rule() const { return m_rule; }
diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp
index 7ff64a9ef..16aa0c001 100644
--- a/src/lib/corelib/buildgraph/rulesapplicator.cpp
+++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp
@@ -1,3 +1,5 @@
+#include <utility>
+
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
@@ -76,15 +78,15 @@ namespace qbs {
namespace Internal {
RulesApplicator::RulesApplicator(
- const ResolvedProductPtr &product,
- const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
- const std::unordered_map<QString, const ResolvedProject *> &projectsByName,
- const Logger &logger)
- : m_product(product)
- , m_productsByName(productsByName)
- , m_projectsByName(projectsByName)
+ ResolvedProductPtr product,
+ std::unordered_map<QString, const ResolvedProduct *> productsByName,
+ std::unordered_map<QString, const ResolvedProject *> projectsByName,
+ Logger logger)
+ : m_product(std::move(product))
+ , m_productsByName(std::move(productsByName))
+ , m_projectsByName(std::move(projectsByName))
, m_mocScanner(nullptr)
- , m_logger(logger)
+ , m_logger(std::move(logger))
{
}
@@ -186,7 +188,7 @@ void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &p
qCDebug(lcBuildGraph) << "apply rule" << m_rule->toString()
<< toStringList(inputArtifacts).join(QLatin1String(",\n "));
- QList<std::pair<const RuleArtifact *, OutputArtifactInfo>> ruleArtifactArtifactMap;
+ std::vector<std::pair<const RuleArtifact *, OutputArtifactInfo>> ruleArtifactArtifactMap;
QList<Artifact *> outputArtifacts;
m_transformer = Transformer::create();
@@ -308,7 +310,7 @@ void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &p
|| m_oldTransformer->commands != m_transformer->commands
|| commandsNeedRerun(m_transformer.get(), m_product.get(), m_productsByName,
m_projectsByName)) {
- for (Artifact * const output : outputArtifacts) {
+ for (Artifact * const output : qAsConst(outputArtifacts)) {
output->clearTimestamp();
m_invalidatedArtifacts += output;
}
@@ -545,8 +547,8 @@ class ArtifactBindingsExtractor
{
struct Entry
{
- Entry(const QString &module, const QString &name, const QVariant &value)
- : module(module), name(name), value(value)
+ Entry(QString module, QString name, QVariant value)
+ : module(std::move(module)), name(std::move(name)), value(std::move(value))
{}
QString module;
@@ -558,9 +560,9 @@ class ArtifactBindingsExtractor
static Set<QString> getArtifactItemPropertyNames()
{
Set<QString> s;
- for (const PropertyDeclaration &pd :
- BuiltinDeclarations::instance().declarationsForType(
- ItemType::Artifact).properties()) {
+ const auto properties = BuiltinDeclarations::instance().declarationsForType(
+ ItemType::Artifact).properties();
+ for (const PropertyDeclaration &pd : properties) {
s.insert(pd.name());
}
s.insert(StringConstants::explicitlyDependsOnProperty());
diff --git a/src/lib/corelib/buildgraph/rulesapplicator.h b/src/lib/corelib/buildgraph/rulesapplicator.h
index f6fadb1ec..1160f3d09 100644
--- a/src/lib/corelib/buildgraph/rulesapplicator.h
+++ b/src/lib/corelib/buildgraph/rulesapplicator.h
@@ -62,10 +62,10 @@ class ScriptEngine;
class RulesApplicator
{
public:
- RulesApplicator(const ResolvedProductPtr &product,
- const std::unordered_map<QString, const ResolvedProduct *> &productsByName,
- const std::unordered_map<QString, const ResolvedProject *> &projectsByName,
- const Logger &logger);
+ RulesApplicator(ResolvedProductPtr product,
+ std::unordered_map<QString, const ResolvedProduct *> productsByName,
+ std::unordered_map<QString, const ResolvedProject *> projectsByName,
+ Logger logger);
~RulesApplicator();
const NodeSet &createdArtifacts() const { return m_createdArtifacts; }
diff --git a/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp b/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
index c81e40c4f..6ae230329 100644
--- a/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
+++ b/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp
@@ -53,8 +53,8 @@
namespace qbs {
namespace Internal {
-RulesEvaluationContext::RulesEvaluationContext(const Logger &logger)
- : m_logger(logger),
+RulesEvaluationContext::RulesEvaluationContext(Logger logger)
+ : m_logger(std::move(logger)),
m_engine(ScriptEngine::create(m_logger, EvalContext::RuleExecution)),
m_observer(nullptr),
m_initScopeCalls(0)
diff --git a/src/lib/corelib/buildgraph/rulesevaluationcontext.h b/src/lib/corelib/buildgraph/rulesevaluationcontext.h
index d3bf0e5bd..a5d81ce61 100644
--- a/src/lib/corelib/buildgraph/rulesevaluationcontext.h
+++ b/src/lib/corelib/buildgraph/rulesevaluationcontext.h
@@ -56,7 +56,7 @@ class ScriptEngine;
class RulesEvaluationContext
{
public:
- RulesEvaluationContext(const Logger &logger);
+ RulesEvaluationContext(Logger logger);
~RulesEvaluationContext();
class Scope
diff --git a/src/lib/corelib/buildgraph/transformer.cpp b/src/lib/corelib/buildgraph/transformer.cpp
index d737e908b..cc0b4c923 100644
--- a/src/lib/corelib/buildgraph/transformer.cpp
+++ b/src/lib/corelib/buildgraph/transformer.cpp
@@ -242,7 +242,8 @@ AbstractCommandPtr Transformer::createCommandFromScriptValue(const QScriptValue
if (className == StringConstants::commandType()) {
auto procCmd = static_cast<ProcessCommand *>(cmdBase.get());
procCmd->clearRelevantEnvValues();
- for (const QString &key : procCmd->relevantEnvVars())
+ const auto envVars = procCmd->relevantEnvVars();
+ for (const QString &key : envVars)
procCmd->addRelevantEnvValue(key, product()->buildEnvironment.value(key));
}
return cmdBase;
diff --git a/src/lib/corelib/buildgraph/transformerchangetracking.cpp b/src/lib/corelib/buildgraph/transformerchangetracking.cpp
index 08875b742..505f0cbba 100644
--- a/src/lib/corelib/buildgraph/transformerchangetracking.cpp
+++ b/src/lib/corelib/buildgraph/transformerchangetracking.cpp
@@ -209,8 +209,8 @@ bool TrafoChangeTracker::isExportedModuleUpToDate(const QString &productName,
bool TrafoChangeTracker::areExportedModulesUpToDate(
const std::unordered_map<QString, ExportedModule> exportedModules) const
{
- for (auto it = exportedModules.begin(); it != exportedModules.end(); ++it) {
- if (!isExportedModuleUpToDate(it->first, it->second))
+ for (const auto &kv : exportedModules) {
+ if (!isExportedModuleUpToDate(kv.first, kv.second))
return false;
}
return true;
@@ -226,8 +226,7 @@ const Artifact *TrafoChangeTracker::getArtifact(const QString &filePath,
const ResolvedProduct * const product = getProduct(productName);
if (!product)
return nullptr;
- const QList<FileResourceBase *> &candidates
- = product->topLevelProject()->buildData->lookupFiles(filePath);
+ const auto &candidates = product->topLevelProject()->buildData->lookupFiles(filePath);
const Artifact *artifact = nullptr;
for (const FileResourceBase * const candidate : candidates) {
if (candidate->fileType() == FileResourceBase::FileTypeArtifact) {
@@ -338,7 +337,8 @@ bool TrafoChangeTracker::commandsNeedRerun() const
if (c->type() != AbstractCommand::ProcessCommandType)
continue;
const ProcessCommandPtr &processCmd = std::static_pointer_cast<ProcessCommand>(c);
- for (const QString &var : processCmd->relevantEnvVars()) {
+ const auto envVars = processCmd->relevantEnvVars();
+ for (const QString &var : envVars) {
const QString &oldValue = processCmd->relevantEnvValue(var);
const QString &newValue = m_product->buildEnvironment.value(var);
if (oldValue != newValue) {
diff --git a/src/lib/corelib/generators/generatableprojectiterator.cpp b/src/lib/corelib/generators/generatableprojectiterator.cpp
index c6d990f02..7267662e8 100644
--- a/src/lib/corelib/generators/generatableprojectiterator.cpp
+++ b/src/lib/corelib/generators/generatableprojectiterator.cpp
@@ -41,8 +41,8 @@
namespace qbs {
-GeneratableProjectIterator::GeneratableProjectIterator(const GeneratableProject &project)
- : project(project)
+GeneratableProjectIterator::GeneratableProjectIterator(GeneratableProject project)
+ : project(std::move(project))
{
}
diff --git a/src/lib/corelib/generators/generatableprojectiterator.h b/src/lib/corelib/generators/generatableprojectiterator.h
index 793627512..993144ce3 100644
--- a/src/lib/corelib/generators/generatableprojectiterator.h
+++ b/src/lib/corelib/generators/generatableprojectiterator.h
@@ -49,7 +49,7 @@ class QBS_EXPORT GeneratableProjectIterator {
GeneratableProject project;
public:
- GeneratableProjectIterator(const GeneratableProject &project);
+ GeneratableProjectIterator(GeneratableProject project);
void accept(IGeneratableProjectVisitor *visitor);
private:
diff --git a/src/lib/corelib/generators/generator.cpp b/src/lib/corelib/generators/generator.cpp
index 24da95e41..90bebdcaa 100644
--- a/src/lib/corelib/generators/generator.cpp
+++ b/src/lib/corelib/generators/generator.cpp
@@ -213,7 +213,7 @@ const GeneratableProject ProjectGenerator::project() const
{
QMap<QString, ProjectData> rootProjects;
GeneratableProject proj;
- for (const auto &project : projects()) {
+ for (const auto &project : qAsConst(d->projects)) {
const QString configurationName = _configurationName(project);
rootProjects.insert(configurationName, project.projectData());
proj.projects.insert(configurationName, project);
diff --git a/src/lib/corelib/generators/generator.h b/src/lib/corelib/generators/generator.h
index 8d4e4f21b..775469f18 100644
--- a/src/lib/corelib/generators/generator.h
+++ b/src/lib/corelib/generators/generator.h
@@ -59,7 +59,7 @@ class QBS_EXPORT ProjectGenerator : public QObject
Q_OBJECT
Q_DISABLE_COPY(ProjectGenerator)
public:
- ~ProjectGenerator();
+ ~ProjectGenerator() override;
/*!
* Returns the name of the generator used to create the external build system files.
diff --git a/src/lib/corelib/jsextensions/binaryfile.cpp b/src/lib/corelib/jsextensions/binaryfile.cpp
index 92f07d88d..5f28f689b 100644
--- a/src/lib/corelib/jsextensions/binaryfile.cpp
+++ b/src/lib/corelib/jsextensions/binaryfile.cpp
@@ -67,7 +67,7 @@ public:
};
static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine);
- ~BinaryFile();
+ ~BinaryFile() override;
Q_INVOKABLE void close();
Q_INVOKABLE QString filePath();
diff --git a/src/lib/corelib/jsextensions/environmentextension.cpp b/src/lib/corelib/jsextensions/environmentextension.cpp
index 22c4f069b..cf17c938b 100644
--- a/src/lib/corelib/jsextensions/environmentextension.cpp
+++ b/src/lib/corelib/jsextensions/environmentextension.cpp
@@ -127,7 +127,8 @@ QScriptValue EnvironmentExtension::js_currentEnv(QScriptContext *context, QScrip
if (!procenv)
procenv = &env;
QScriptValue envObject = engine->newObject();
- for (const QString &key : procenv->keys()) {
+ const auto keys = procenv->keys();
+ for (const QString &key : keys) {
const QString keyName = HostOsInfo::isWindowsHost() ? key.toUpper() : key;
envObject.setProperty(keyName, QScriptValue(procenv->value(key)));
}
diff --git a/src/lib/corelib/jsextensions/process.cpp b/src/lib/corelib/jsextensions/process.cpp
index 5148f9468..064297a32 100644
--- a/src/lib/corelib/jsextensions/process.cpp
+++ b/src/lib/corelib/jsextensions/process.cpp
@@ -63,7 +63,7 @@ class Process : public QObject, public QScriptable, public ResourceAcquiringScri
public:
static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine);
Process(QScriptContext *context);
- ~Process();
+ ~Process() override;
Q_INVOKABLE QString getEnv(const QString &name);
Q_INVOKABLE void setEnv(const QString &name, const QString &value);
diff --git a/src/lib/corelib/jsextensions/propertylist.mm b/src/lib/corelib/jsextensions/propertylist.mm
index d73cd742d..6ac9d56c9 100644
--- a/src/lib/corelib/jsextensions/propertylist.mm
+++ b/src/lib/corelib/jsextensions/propertylist.mm
@@ -70,7 +70,7 @@ class PropertyList : public QObject, public QScriptable
public:
static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine);
PropertyList(QScriptContext *context);
- ~PropertyList();
+ ~PropertyList() override;
Q_INVOKABLE bool isEmpty() const;
Q_INVOKABLE void clear();
Q_INVOKABLE void readFromObject(const QScriptValue &value);
diff --git a/src/lib/corelib/jsextensions/textfile.cpp b/src/lib/corelib/jsextensions/textfile.cpp
index 51688677f..7c67f9019 100644
--- a/src/lib/corelib/jsextensions/textfile.cpp
+++ b/src/lib/corelib/jsextensions/textfile.cpp
@@ -68,7 +68,7 @@ public:
};
static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine);
- ~TextFile();
+ ~TextFile() override;
Q_INVOKABLE void close();
Q_INVOKABLE QString filePath();
diff --git a/src/lib/corelib/jsextensions/utilitiesextension.cpp b/src/lib/corelib/jsextensions/utilitiesextension.cpp
index 5abaccad9..b425bb4a2 100644
--- a/src/lib/corelib/jsextensions/utilitiesextension.cpp
+++ b/src/lib/corelib/jsextensions/utilitiesextension.cpp
@@ -109,6 +109,7 @@ public:
static QScriptValue js_certificateInfo(QScriptContext *context, QScriptEngine *engine);
static QScriptValue js_signingIdentities(QScriptContext *context, QScriptEngine *engine);
static QScriptValue js_msvcCompilerInfo(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue js_clangClCompilerInfo(QScriptContext *context, QScriptEngine *engine);
static QScriptValue js_versionCompare(QScriptContext *context, QScriptEngine *engine);
@@ -235,7 +236,7 @@ static inline QString escapedString(const Char *begin, int length, bool isUnicod
// Surrogate characters are category Cs (Other_Surrogate), so isPrintable = false for them
int runLength = 0;
while (p + runLength != end &&
- isPrintable(p[runLength]) && p[runLength] != '\\' && p[runLength] != '"')
+ QChar::isPrint(p[runLength]) && p[runLength] != '\\' && p[runLength] != '"')
++runLength;
if (runLength) {
out += QString(reinterpret_cast<const QChar *>(p), runLength);
@@ -287,7 +288,7 @@ static inline QString escapedString(const Char *begin, int length, bool isUnicod
if ((p + 1) != end && QChar::isLowSurrogate(p[1])) {
// properly-paired surrogates
uint ucs4 = QChar::surrogateToUcs4(*p, p[1]);
- if (isPrintable(ucs4)) {
+ if (QChar::isPrint(ucs4)) {
buf[0] = *p;
buf[1] = p[1];
buflen = 2;
@@ -455,6 +456,37 @@ QScriptValue UtilitiesExtension::js_signingIdentities(QScriptContext *context,
#endif
}
+#ifdef Q_OS_WIN
+static std::pair<QVariantMap /*result*/, QString /*error*/> msvcCompilerInfoHelper(
+ const QString &compilerFilePath,
+ MSVC::CompilerLanguage language,
+ const QString &vcvarsallPath,
+ const QString &arch)
+{
+ MSVC msvc(compilerFilePath, arch);
+ VsEnvironmentDetector envdetector(vcvarsallPath);
+ if (!envdetector.start(&msvc))
+ return { {}, QStringLiteral("Detecting the MSVC build environment failed: ")
+ + envdetector.errorString() };
+
+ try {
+ QVariantMap envMap;
+ for (const QString &key : msvc.environment.keys())
+ envMap.insert(key, msvc.environment.value(key));
+
+ return {
+ QVariantMap {
+ {QStringLiteral("buildEnvironment"), envMap},
+ {QStringLiteral("macros"), msvc.compilerDefines(compilerFilePath, language)},
+ },
+ {}
+ };
+ } catch (const qbs::ErrorInfo &info) {
+ return { {}, info.toString() };
+ }
+}
+#endif
+
QScriptValue UtilitiesExtension::js_msvcCompilerInfo(QScriptContext *context, QScriptEngine *engine)
{
#ifndef Q_OS_WIN
@@ -462,14 +494,12 @@ QScriptValue UtilitiesExtension::js_msvcCompilerInfo(QScriptContext *context, QS
return context->throwError(QScriptContext::UnknownError,
QStringLiteral("msvcCompilerInfo is not available on this platform"));
#else
- if (Q_UNLIKELY(context->argumentCount() < 1))
+ if (Q_UNLIKELY(context->argumentCount() < 2))
return context->throwError(QScriptContext::SyntaxError,
- QStringLiteral("msvcCompilerInfo expects at least 1 argument"));
+ QStringLiteral("msvcCompilerInfo expects 2 arguments"));
const QString compilerFilePath = context->argument(0).toString();
- const QString compilerLanguage = context->argumentCount() > 1
- ? context->argument(1).toString()
- : QString();
+ const QString compilerLanguage = context->argument(1).toString();
MSVC::CompilerLanguage language;
if (compilerLanguage == QStringLiteral("c"))
language = MSVC::CLanguage;
@@ -479,26 +509,45 @@ QScriptValue UtilitiesExtension::js_msvcCompilerInfo(QScriptContext *context, QS
return context->throwError(QScriptContext::TypeError,
QStringLiteral("msvcCompilerInfo expects \"c\" or \"cpp\" as its second argument"));
- MSVC msvc(compilerFilePath);
- VsEnvironmentDetector envdetector;
- if (!envdetector.start(&msvc))
- return context->throwError(QScriptContext::UnknownError,
- QStringLiteral("Detecting the MSVC build environment failed: ")
- + envdetector.errorString());
+ const auto result = msvcCompilerInfoHelper(
+ compilerFilePath, language, {}, MSVC::architectureFromClPath(compilerFilePath));
+ if (result.first.isEmpty())
+ return context->throwError(QScriptContext::UnknownError, result.second);
+ return engine->toScriptValue(result.first);
+#endif
+}
- try {
- QVariantMap envMap;
- for (const QString &key : msvc.environment.keys())
- envMap.insert(key, msvc.environment.value(key));
+QScriptValue UtilitiesExtension::js_clangClCompilerInfo(QScriptContext *context, QScriptEngine *engine)
+{
+#ifndef Q_OS_WIN
+ Q_UNUSED(engine);
+ return context->throwError(QScriptContext::UnknownError,
+ QStringLiteral("clangClCompilerInfo is not available on this platform"));
+#else
+ if (Q_UNLIKELY(context->argumentCount() < 4))
+ return context->throwError(QScriptContext::SyntaxError,
+ QStringLiteral("clangClCompilerInfo expects 4 arguments"));
- return engine->toScriptValue(QVariantMap {
- {QStringLiteral("buildEnvironment"), envMap},
- {QStringLiteral("macros"), msvc.compilerDefines(compilerFilePath, language)},
- });
- } catch (const qbs::ErrorInfo &info) {
- return context->throwError(QScriptContext::UnknownError,
- info.toString());
- }
+ const QString compilerFilePath = context->argument(0).toString();
+ QString arch = context->argument(1).toString();
+ QString vcvarsallPath = context->argument(2).toString();
+ const QString compilerLanguage = context->argumentCount() > 3
+ ? context->argument(3).toString()
+ : QString();
+ MSVC::CompilerLanguage language;
+ if (compilerLanguage == QStringLiteral("c"))
+ language = MSVC::CLanguage;
+ else if (compilerLanguage == StringConstants::cppLang())
+ language = MSVC::CPlusPlusLanguage;
+ else
+ return context->throwError(QScriptContext::TypeError,
+ QStringLiteral("clangClCompilerInfo expects \"c\" or \"cpp\" as its fourth argument"));
+
+ const auto result = msvcCompilerInfoHelper(
+ compilerFilePath, language, vcvarsallPath, arch);
+ if (result.first.isEmpty())
+ return context->throwError(QScriptContext::UnknownError, result.second);
+ return engine->toScriptValue(result.first);
#endif
}
@@ -800,6 +849,8 @@ void initializeJsExtensionUtilities(QScriptValue extensionObject)
engine->newFunction(UtilitiesExtension::js_signingIdentities, 0));
environmentObj.setProperty(QStringLiteral("msvcCompilerInfo"),
engine->newFunction(UtilitiesExtension::js_msvcCompilerInfo, 1));
+ environmentObj.setProperty(QStringLiteral("clangClCompilerInfo"),
+ engine->newFunction(UtilitiesExtension::js_clangClCompilerInfo, 1));
environmentObj.setProperty(QStringLiteral("versionCompare"),
engine->newFunction(UtilitiesExtension::js_versionCompare, 2));
environmentObj.setProperty(QStringLiteral("qmlTypeInfo"),
diff --git a/src/lib/corelib/language/astimportshandler.cpp b/src/lib/corelib/language/astimportshandler.cpp
index 960af4cda..d634af7e4 100644
--- a/src/lib/corelib/language/astimportshandler.cpp
+++ b/src/lib/corelib/language/astimportshandler.cpp
@@ -69,7 +69,8 @@ ASTImportsHandler::ASTImportsHandler(ItemReaderVisitorState &visitorState, Logge
void ASTImportsHandler::handleImports(const QbsQmlJS::AST::UiImportList *uiImportList)
{
- for (const QString &searchPath : m_file->searchPaths())
+ const auto searchPaths = m_file->searchPaths();
+ for (const QString &searchPath : searchPaths)
collectPrototypes(searchPath + QStringLiteral("/imports"), QString());
// files in the same directory are available as prototypes
@@ -191,7 +192,8 @@ void ASTImportsHandler::handleImport(const QbsQmlJS::AST::UiImport *import, bool
? QStringLiteral("qbs/base") : importUri.join(QDir::separator());
bool found = m_typeNameToFile.contains(importUri);
if (!found) {
- for (const QString &searchPath : m_file->searchPaths()) {
+ const auto searchPaths = m_file->searchPaths();
+ for (const QString &searchPath : searchPaths) {
const QFileInfo fi(FileInfo::resolvePath(
FileInfo::resolvePath(searchPath,
StringConstants::importsDir()),
diff --git a/src/lib/corelib/language/builtindeclarations.cpp b/src/lib/corelib/language/builtindeclarations.cpp
index ee1b2d56e..68355df51 100644
--- a/src/lib/corelib/language/builtindeclarations.cpp
+++ b/src/lib/corelib/language/builtindeclarations.cpp
@@ -150,7 +150,8 @@ QStringList BuiltinDeclarations::argumentNamesForScriptFunction(ItemType itemTyp
const QString &scriptName) const
{
const ItemDeclaration itemDecl = declarationsForType(itemType);
- for (const PropertyDeclaration &propDecl : itemDecl.properties()) {
+ const auto properties = itemDecl.properties();
+ for (const PropertyDeclaration &propDecl : properties) {
if (propDecl.name() == scriptName)
return propDecl.functionArgumentNames();
}
diff --git a/src/lib/corelib/language/evaluationdata.h b/src/lib/corelib/language/evaluationdata.h
index efd504a11..791b2f234 100644
--- a/src/lib/corelib/language/evaluationdata.h
+++ b/src/lib/corelib/language/evaluationdata.h
@@ -55,8 +55,8 @@ class Item;
class EvaluationData
{
public:
- Evaluator *evaluator;
- const Item *item;
+ Evaluator *evaluator = nullptr;
+ const Item *item = nullptr;
mutable QHash<QScriptString, QScriptValue> valueCache;
};
diff --git a/src/lib/corelib/language/identifiersearch.h b/src/lib/corelib/language/identifiersearch.h
index d9769266c..7d99c0f13 100644
--- a/src/lib/corelib/language/identifiersearch.h
+++ b/src/lib/corelib/language/identifiersearch.h
@@ -61,7 +61,7 @@ private:
bool visit(QbsQmlJS::AST::IdentifierExpression *e) override;
QMap<QString, bool *> m_requests;
- int m_numberOfFoundIds;
+ int m_numberOfFoundIds = 0;
};
} // namespace Internal
diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp
index 39dc39370..9f754bdd7 100644
--- a/src/lib/corelib/language/item.cpp
+++ b/src/lib/corelib/language/item.cpp
@@ -249,7 +249,8 @@ bool Item::isPresentModule() const
void Item::setupForBuiltinType(Logger &logger)
{
const BuiltinDeclarations &builtins = BuiltinDeclarations::instance();
- for (const PropertyDeclaration &pd : builtins.declarationsForType(type()).properties()) {
+ const auto properties = builtins.declarationsForType(type()).properties();
+ for (const PropertyDeclaration &pd : properties) {
m_propertyDeclarations.insert(pd.name(), pd);
const ValuePtr value = m_properties.value(pd.name());
if (!value) {
diff --git a/src/lib/corelib/language/itemobserver.h b/src/lib/corelib/language/itemobserver.h
index 82a3aed24..fca3a2d85 100644
--- a/src/lib/corelib/language/itemobserver.h
+++ b/src/lib/corelib/language/itemobserver.h
@@ -48,6 +48,7 @@ class Item;
class ItemObserver
{
public:
+ virtual ~ItemObserver() = default;
virtual void onItemPropertyChanged(Item *item) = 0;
};
diff --git a/src/lib/corelib/language/itempool.cpp b/src/lib/corelib/language/itempool.cpp
index 8ec6b63d1..3da8b947b 100644
--- a/src/lib/corelib/language/itempool.cpp
+++ b/src/lib/corelib/language/itempool.cpp
@@ -49,8 +49,8 @@ ItemPool::ItemPool()
ItemPool::~ItemPool()
{
- for (ItemVector::const_iterator it = m_items.cbegin(); it != m_items.cend(); ++it)
- (*it)->~Item();
+ for (Item *item : m_items)
+ item->~Item();
}
Item *ItemPool::allocateItem(const ItemType &type)
diff --git a/src/lib/corelib/language/itempool.h b/src/lib/corelib/language/itempool.h
index 8ee8562d7..ef4be7639 100644
--- a/src/lib/corelib/language/itempool.h
+++ b/src/lib/corelib/language/itempool.h
@@ -43,7 +43,7 @@
#include <parser/qmljsmemorypool_p.h>
#include <tools/qbs_export.h>
-#include <QtCore/qlist.h>
+#include <vector>
namespace qbs {
namespace Internal {
@@ -62,8 +62,7 @@ public:
private:
QbsQmlJS::MemoryPool m_pool;
- using ItemVector = QList<Item *>;
- ItemVector m_items;
+ std::vector<Item *> m_items;
};
} // namespace Internal
diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp
index 2ea306138..901772d16 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.cpp
+++ b/src/lib/corelib/language/itemreaderastvisitor.cpp
@@ -67,9 +67,9 @@ namespace qbs {
namespace Internal {
ItemReaderASTVisitor::ItemReaderASTVisitor(ItemReaderVisitorState &visitorState,
- const FileContextPtr &file, ItemPool *itemPool, Logger &logger)
+ FileContextPtr file, ItemPool *itemPool, Logger &logger)
: m_visitorState(visitorState)
- , m_file(file)
+ , m_file(std::move(file))
, m_itemPool(itemPool)
, m_logger(logger)
{
diff --git a/src/lib/corelib/language/itemreaderastvisitor.h b/src/lib/corelib/language/itemreaderastvisitor.h
index 4a0bedc91..963b78471 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.h
+++ b/src/lib/corelib/language/itemreaderastvisitor.h
@@ -60,7 +60,7 @@ class ItemReaderVisitorState;
class ItemReaderASTVisitor : public QbsQmlJS::AST::Visitor
{
public:
- ItemReaderASTVisitor(ItemReaderVisitorState &visitorState, const FileContextPtr &file,
+ ItemReaderASTVisitor(ItemReaderVisitorState &visitorState, FileContextPtr file,
ItemPool *itemPool, Logger &logger);
void checkItemTypes() { doCheckItemTypes(rootItem()); }
diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp
index f21f724f1..d888700c5 100644
--- a/src/lib/corelib/language/language.cpp
+++ b/src/lib/corelib/language/language.cpp
@@ -91,8 +91,8 @@ template<typename T> bool equals(const T *v1, const T *v2)
* \brief The \c FileTagger class maps 1:1 to the respective item in a qbs source file.
*/
-FileTagger::FileTagger(const QStringList &patterns, const FileTags &fileTags, int priority)
- : m_fileTags(fileTags), m_priority(priority)
+FileTagger::FileTagger(const QStringList &patterns, FileTags fileTags, int priority)
+ : m_fileTags(std::move(fileTags)), m_priority(priority)
{
setPatterns(patterns);
}
diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h
index 297fedf1c..65879dd56 100644
--- a/src/lib/corelib/language/language.h
+++ b/src/lib/corelib/language/language.h
@@ -98,7 +98,7 @@ public:
}
private:
- FileTagger(const QStringList &patterns, const FileTags &fileTags, int priority);
+ FileTagger(const QStringList &patterns, FileTags fileTags, int priority);
FileTagger() {}
void setPatterns(const QStringList &patterns);
@@ -162,7 +162,7 @@ private:
QVariantMap m_properties;
QVariantMap m_initialProperties;
std::vector<QString> m_importedFilesUsed;
- bool m_condition;
+ bool m_condition = false;
};
class RuleArtifact
@@ -280,14 +280,14 @@ public:
CodeLocation location;
QString name;
- bool enabled;
+ bool enabled = true;
QString prefix;
std::vector<SourceArtifactPtr> files;
std::unique_ptr<SourceWildCards> wildcards;
PropertyMapPtr properties;
FileTags fileTags;
QString targetOfModule;
- bool overrideTags;
+ bool overrideTags = false;
std::vector<SourceArtifactPtr> allFiles() const;
@@ -295,10 +295,6 @@ public:
void store(PersistentPool &pool);
private:
- ResolvedGroup()
- : enabled(true)
- {}
-
template<PersistentPool::OpType opType> void serializationOp(PersistentPool &pool)
{
pool.serializationOp<opType>(name, enabled, location, prefix, files, wildcards, properties,
@@ -370,7 +366,7 @@ public:
PrivateScriptFunction setupBuildEnvironmentScript;
PrivateScriptFunction setupRunEnvironmentScript;
ResolvedProduct *product = nullptr;
- bool isProduct;
+ bool isProduct = false;
static QStringList argumentNamesForSetupBuildEnv();
static QStringList argumentNamesForSetupRunEnv();
@@ -414,13 +410,13 @@ public:
FileTags inputsFromDependencies;
FileTags explicitlyDependsOn;
FileTags explicitlyDependsOnFromDependencies;
- bool multiplex;
- bool requiresInputs;
+ bool multiplex = false;
+ bool requiresInputs = false;
std::vector<RuleArtifactPtr> artifacts; // unused, if outputFileTags/outputArtifactsScript is non-empty
- bool alwaysRun;
+ bool alwaysRun = false;
// members that we don't need to save
- int ruleGraphId;
+ int ruleGraphId = -1;
static QStringList argumentNamesForOutputArtifacts();
static QStringList argumentNamesForPrepare();
@@ -440,7 +436,7 @@ public:
requiresInputs, alwaysRun, artifacts);
}
private:
- Rule() : multiplex(false), alwaysRun(false), ruleGraphId(-1) {}
+ Rule() = default;
};
bool operator==(const Rule &r1, const Rule &r2);
inline bool operator!=(const Rule &r1, const Rule &r2) { return !(r1 == r2); }
@@ -477,7 +473,7 @@ public:
}
QString fullName;
- PropertyDeclaration::Type type;
+ PropertyDeclaration::Type type = PropertyDeclaration::Type::UnknownType;
QString sourceCode;
bool isBuiltin = false;
};
diff --git a/src/lib/corelib/language/loader.cpp b/src/lib/corelib/language/loader.cpp
index e27ccca74..f248fbb1a 100644
--- a/src/lib/corelib/language/loader.cpp
+++ b/src/lib/corelib/language/loader.cpp
@@ -61,8 +61,8 @@
namespace qbs {
namespace Internal {
-Loader::Loader(ScriptEngine *engine, const Logger &logger)
- : m_logger(logger)
+Loader::Loader(ScriptEngine *engine, Logger logger)
+ : m_logger(std::move(logger))
, m_progressObserver(nullptr)
, m_engine(engine)
{
@@ -167,7 +167,7 @@ TopLevelProjectPtr Loader::loadProject(const SetupProjectParameters &_parameters
moduleLoader.setStoredProfiles(m_storedProfiles);
moduleLoader.setStoredModuleProviderInfo(m_storedModuleProviderInfo);
const ModuleLoaderResult loadResult = moduleLoader.load(parameters);
- ProjectResolver resolver(&evaluator, loadResult, parameters, m_logger);
+ ProjectResolver resolver(&evaluator, loadResult, std::move(parameters), m_logger);
resolver.setProgressObserver(m_progressObserver);
const TopLevelProjectPtr project = resolver.resolve();
project->lastStartResolveTime = resolveTime;
diff --git a/src/lib/corelib/language/loader.h b/src/lib/corelib/language/loader.h
index 48a0b6065..d172a74ed 100644
--- a/src/lib/corelib/language/loader.h
+++ b/src/lib/corelib/language/loader.h
@@ -57,7 +57,7 @@ class ScriptEngine;
class QBS_AUTOTEST_EXPORT Loader
{
public:
- Loader(ScriptEngine *engine, const Logger &logger);
+ Loader(ScriptEngine *engine, Logger logger);
void setProgressObserver(ProgressObserver *observer);
void setSearchPaths(const QStringList &searchPaths);
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index d7fb9b75d..67d60e05d 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -294,7 +294,8 @@ ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters &parameters)
m_probesEncountered = m_probesRun = m_probesCachedCurrent = m_probesCachedOld = 0;
m_settings.reset(new Settings(parameters.settingsDirectory()));
- for (const QString &key : m_parameters.overriddenValues().keys()) {
+ const auto keys = m_parameters.overriddenValues().keys();
+ for (const QString &key : keys) {
static const QStringList prefixes({ StringConstants::projectPrefix(),
QStringLiteral("projects"),
QStringLiteral("products"), QStringLiteral("modules"),
@@ -695,7 +696,7 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult,
if (child->type() == ItemType::Product)
multiplexedProducts << multiplexProductItem(&dummyProductContext, child);
}
- for (Item * const additionalProductItem : multiplexedProducts)
+ for (Item * const additionalProductItem : qAsConst(multiplexedProducts))
Item::addChild(projectItem, additionalProductItem);
resolveProbes(&dummyProductContext, projectItem);
@@ -2121,12 +2122,12 @@ void ModuleLoader::checkProductNamesInOverrides()
if (m_erroneousProducts.contains(productNameInOverride))
continue;
bool found = false;
- for (auto it = m_productsByName.cbegin(); it != m_productsByName.cend(); ++it) {
+ for (const auto &kv : m_productsByName) {
// In an override string such as "a.b.c:d, we cannot tell whether we have a product
// "a" and a module "b.c" or a product "a.b" and a module "c", so we need to take
// care not to emit false positives here.
- if (it->first == productNameInOverride
- || it->first.startsWith(productNameInOverride + StringConstants::dot())) {
+ if (kv.first == productNameInOverride
+ || kv.first.startsWith(productNameInOverride + StringConstants::dot())) {
found = true;
break;
}
@@ -2653,7 +2654,7 @@ void ModuleLoader::resolveDependsItem(DependsContext *dependsContext, Item *pare
profiles.push_back(QString());
}
for (const QString &profile : qAsConst(profiles)) {
- for (const QString &multiplexId : multiplexConfigurationIds) {
+ for (const QString &multiplexId : qAsConst(multiplexConfigurationIds)) {
ModuleLoaderResult::ProductInfo::Dependency dependency;
dependency.name = moduleName.toString();
dependency.profile = profile;
@@ -3405,7 +3406,8 @@ void ModuleLoader::instantiateModule(ProductContext *productContext, Item *expor
// create ids from from the prototype in the instance
if (modulePrototype->file()->idScope()) {
- for (Item * const itemWithId : collectItemsWithId(modulePrototype)) {
+ const auto items = collectItemsWithId(modulePrototype);
+ for (Item * const itemWithId : items) {
Item *idProto = itemWithId;
Item *idInstance = prototypeInstanceMap.value(idProto);
QBS_ASSERT(idInstance, continue);
@@ -4029,9 +4031,8 @@ void ModuleLoader::handleProductError(const ErrorInfo &error,
<< "in product" << productContext->name;
return;
}
- const auto &deps = productContext->productModuleDependencies;
- for (auto it = deps.cbegin(); it != deps.cend(); ++it) {
- const auto rangeForName = m_productsByName.equal_range(it->first);
+ for (const auto &kv : productContext->productModuleDependencies) {
+ const auto rangeForName = m_productsByName.equal_range(kv.first);
for (auto rangeIt = rangeForName.first; rangeIt != rangeForName.second; ++rangeIt) {
const ProductContext * const dep = rangeIt->second;
if (dep->info.delayedError.hasError()) {
@@ -4044,7 +4045,8 @@ void ModuleLoader::handleProductError(const ErrorInfo &error,
}
}
}
- for (const ErrorItem &ei : error.items())
+ const auto errorItems = error.items();
+ for (const ErrorItem &ei : errorItems)
productContext->info.delayedError.append(ei.description(), ei.codeLocation());
productContext->project->result->productInfos.insert(productContext->item,
productContext->info);
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index a8190596d..85a2467f2 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -175,7 +175,7 @@ private:
class ProductContext : public ContextBase
{
public:
- ProjectContext *project;
+ ProjectContext *project = nullptr;
ModuleLoaderResult::ProductInfo info;
QString profileName;
QString multiplexConfigurationId;
@@ -201,8 +201,8 @@ private:
class ProjectContext : public ContextBase
{
public:
- TopLevelProjectContext *topLevelProject;
- ModuleLoaderResult *result;
+ TopLevelProjectContext *topLevelProject = nullptr;
+ ModuleLoaderResult *result = nullptr;
std::vector<ProductContext> products;
std::vector<QStringList> searchPathsStack;
};
@@ -232,7 +232,7 @@ private:
public:
ProductContext *product = nullptr;
Item *exportingProductItem = nullptr;
- ProductDependencies *productDependencies;
+ ProductDependencies *productDependencies = nullptr;
};
void handleTopLevelProject(ModuleLoaderResult *loadResult, Item *projectItem,
@@ -457,16 +457,16 @@ private:
Version m_qbsVersion;
Item *m_tempScopeItem = nullptr;
- qint64 m_elapsedTimeProbes;
- qint64 m_elapsedTimePrepareProducts;
- qint64 m_elapsedTimeProductDependencies;
- qint64 m_elapsedTimeTransitiveDependencies;
- qint64 m_elapsedTimeHandleProducts;
- qint64 m_elapsedTimePropertyChecking;
- quint64 m_probesEncountered;
- quint64 m_probesRun;
- quint64 m_probesCachedCurrent;
- quint64 m_probesCachedOld;
+ qint64 m_elapsedTimeProbes = 0;
+ qint64 m_elapsedTimePrepareProducts = 0;
+ qint64 m_elapsedTimeProductDependencies = 0;
+ qint64 m_elapsedTimeTransitiveDependencies = 0;
+ qint64 m_elapsedTimeHandleProducts = 0;
+ qint64 m_elapsedTimePropertyChecking = 0;
+ quint64 m_probesEncountered = 0;
+ quint64 m_probesRun = 0;
+ quint64 m_probesCachedCurrent = 0;
+ quint64 m_probesCachedOld = 0;
Set<QString> m_projectNamesUsedInOverrides;
Set<QString> m_productNamesUsedInOverrides;
Set<QString> m_disabledProjects;
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index 0bbf8d37a..049472310 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -98,7 +98,7 @@ struct ProjectResolver::ProductContext
{
ResolvedProductPtr product;
QString buildDirectory;
- Item *item;
+ Item *item = nullptr;
using ArtifactPropertiesInfo = std::pair<ArtifactPropertiesPtr, std::vector<CodeLocation>>;
QHash<QStringList, ArtifactPropertiesInfo> artifactPropertiesPerFilter;
ProjectResolver::FileLocations sourceArtifactLocations;
@@ -114,14 +114,14 @@ struct ProjectResolver::ModuleContext
class CancelException { };
-ProjectResolver::ProjectResolver(Evaluator *evaluator, const ModuleLoaderResult &loadResult,
- const SetupProjectParameters &setupParameters, Logger &logger)
+ProjectResolver::ProjectResolver(Evaluator *evaluator, ModuleLoaderResult loadResult,
+ SetupProjectParameters setupParameters, Logger &logger)
: m_evaluator(evaluator)
, m_logger(logger)
, m_engine(m_evaluator->engine())
, m_progressObserver(nullptr)
- , m_setupParams(setupParameters)
- , m_loadResult(loadResult)
+ , m_setupParams(std::move(setupParameters))
+ , m_loadResult(std::move(loadResult))
{
QBS_CHECK(FileInfo::isAbsolute(m_setupParams.buildRoot()));
}
@@ -826,7 +826,7 @@ void ProjectResolver::resolveGroupFully(Item *item, ProjectResolver::ProjectCont
&m_productContext->sourceArtifactLocations, &fileError);
}
- for (const QString &fileName : files) {
+ for (const QString &fileName : qAsConst(files)) {
createSourceArtifact(m_productContext->product, fileName, group, false, filesLocation,
&m_productContext->sourceArtifactLocations, &fileError);
}
@@ -1022,7 +1022,8 @@ void ProjectResolver::setupExportedProperties(const Item *item, const QString &n
const ItemDeclaration itemDecl
= BuiltinDeclarations::instance().declarationsForType(item->type());
PropertyDeclaration propertyDecl;
- for (const PropertyDeclaration &decl : itemDecl.properties()) {
+ const auto itemProperties = itemDecl.properties();
+ for (const PropertyDeclaration &decl : itemProperties) {
if (decl.name() == it.key()) {
propertyDecl = decl;
exportedProperty.isBuiltin = true;
@@ -1109,7 +1110,8 @@ void ProjectResolver::resolveExport(Item *exportItem, ProjectContext *)
exportItem->file()->content());
}
}
- for (const QString &builtinImport: JsExtensions::extensionNames()) {
+ const auto builtInImports = JsExtensions::extensionNames();
+ for (const QString &builtinImport: builtInImports) {
if (usesImport(exportedModule, builtinImport))
exportedModule.importStatements << QStringLiteral("import qbs.") + builtinImport;
}
diff --git a/src/lib/corelib/language/projectresolver.h b/src/lib/corelib/language/projectresolver.h
index 0732b1c9b..428ba144d 100644
--- a/src/lib/corelib/language/projectresolver.h
+++ b/src/lib/corelib/language/projectresolver.h
@@ -67,8 +67,8 @@ class ScriptEngine;
class ProjectResolver
{
public:
- ProjectResolver(Evaluator *evaluator, const ModuleLoaderResult &loadResult,
- const SetupProjectParameters &setupParameters, Logger &logger);
+ ProjectResolver(Evaluator *evaluator, ModuleLoaderResult loadResult,
+ SetupProjectParameters setupParameters, Logger &logger);
~ProjectResolver();
void setProgressObserver(ProgressObserver *observer);
@@ -172,12 +172,12 @@ private:
void setupExportedProperties(const Item *item, const QString &namePrefix,
std::vector<ExportedProperty> &properties);
- Evaluator *m_evaluator;
+ Evaluator *m_evaluator = nullptr;
Logger &m_logger;
- ScriptEngine *m_engine;
- ProgressObserver *m_progressObserver;
- ProductContext *m_productContext;
- ModuleContext *m_moduleContext;
+ ScriptEngine *m_engine = nullptr;
+ ProgressObserver *m_progressObserver = nullptr;
+ ProductContext *m_productContext = nullptr;
+ ModuleContext *m_moduleContext = nullptr;
QMap<QString, ResolvedProductPtr> m_productsByName;
QHash<FileTag, QList<ResolvedProductPtr> > m_productsByType;
QHash<ResolvedProductPtr, Item *> m_productItemMap;
@@ -185,14 +185,14 @@ private:
mutable QHash<CodeLocation, ScriptFunctionPtr> m_scriptFunctionMap;
mutable QHash<std::pair<QStringRef, QStringList>, QString> m_scriptFunctions;
mutable QHash<QStringRef, QString> m_sourceCode;
- const SetupProjectParameters &m_setupParams;
+ const SetupProjectParameters m_setupParams;
ModuleLoaderResult m_loadResult;
Set<CodeLocation> m_groupLocationWarnings;
std::vector<std::pair<ResolvedProductPtr, Item *>> m_productExportInfo;
std::vector<ErrorInfo> m_queuedErrors;
- qint64 m_elapsedTimeModPropEval;
- qint64 m_elapsedTimeAllPropEval;
- qint64 m_elapsedTimeGroups;
+ qint64 m_elapsedTimeModPropEval = 0;
+ qint64 m_elapsedTimeAllPropEval = 0;
+ qint64 m_elapsedTimeGroups = 0;
typedef void (ProjectResolver::*ItemFuncPtr)(Item *item, ProjectContext *projectContext);
using ItemFuncMap = QMap<ItemType, ItemFuncPtr>;
diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp
index 1c6d0cb0d..7c531e764 100644
--- a/src/lib/corelib/language/scriptengine.cpp
+++ b/src/lib/corelib/language/scriptengine.cpp
@@ -609,8 +609,8 @@ Set<QString> ScriptEngine::imports() const
for (const QString &filePath : jsImport.filePaths)
filePaths << filePath;
}
- for (auto it = m_filePathsPerImport.cbegin(); it != m_filePathsPerImport.cend(); ++it) {
- for (const QString &fp : it->second)
+ for (const auto &kv : m_filePathsPerImport) {
+ for (const QString &fp : kv.second)
filePaths << fp;
}
return filePaths;
@@ -817,9 +817,11 @@ void ScriptEngine::uninstallImportFunctions()
globalObject().setProperty(requireString(), QScriptValue());
}
-ScriptEngine::PropertyCacheKey::PropertyCacheKey(const QString &moduleName,
- const QString &propertyName, const PropertyMapConstPtr &propertyMap)
- : m_moduleName(moduleName), m_propertyName(propertyName), m_propertyMap(propertyMap)
+ScriptEngine::PropertyCacheKey::PropertyCacheKey(QString moduleName,
+ QString propertyName, PropertyMapConstPtr propertyMap)
+ : m_moduleName(std::move(moduleName))
+ , m_propertyName(std::move(propertyName))
+ , m_propertyMap(std::move(propertyMap))
{
}
diff --git a/src/lib/corelib/language/scriptengine.h b/src/lib/corelib/language/scriptengine.h
index 89863189a..24e133dff 100644
--- a/src/lib/corelib/language/scriptengine.h
+++ b/src/lib/corelib/language/scriptengine.h
@@ -93,6 +93,7 @@ using DubiousContextList = std::vector<DubiousContext>;
class ResourceAcquiringScriptObject
{
public:
+ virtual ~ResourceAcquiringScriptObject() = default;
virtual void releaseResources() = 0;
};
@@ -104,7 +105,7 @@ class QBS_AUTOTEST_EXPORT ScriptEngine : public QScriptEngine
ScriptEngine(Logger &logger, EvalContext evalContext, QObject *parent = nullptr);
public:
static ScriptEngine *create(Logger &logger, EvalContext evalContext, QObject *parent = nullptr);
- ~ScriptEngine();
+ ~ScriptEngine() override;
Logger &logger() const { return m_logger; }
void import(const FileContextBaseConstPtr &fileCtx, QScriptValue &targetObject,
@@ -302,8 +303,8 @@ private:
class PropertyCacheKey
{
public:
- PropertyCacheKey(const QString &moduleName, const QString &propertyName,
- const PropertyMapConstPtr &propertyMap);
+ PropertyCacheKey(QString moduleName, QString propertyName,
+ PropertyMapConstPtr propertyMap);
private:
const QString m_moduleName;
const QString m_propertyName;
diff --git a/src/lib/corelib/language/scriptimporter.cpp b/src/lib/corelib/language/scriptimporter.cpp
index c5dc887b7..9c6d4d38e 100644
--- a/src/lib/corelib/language/scriptimporter.cpp
+++ b/src/lib/corelib/language/scriptimporter.cpp
@@ -109,8 +109,8 @@ private:
m_suffix += name;
}
- bool m_first;
- bool m_barrier;
+ bool m_first = false;
+ bool m_barrier = false;
QString m_suffix;
};
diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp
index 16cbbeeff..656f38874 100644
--- a/src/lib/corelib/language/value.cpp
+++ b/src/lib/corelib/language/value.cpp
@@ -183,9 +183,9 @@ ValuePtr ItemValue::clone() const
return create(m_item->clone(), createdByPropertiesBlock());
}
-VariantValue::VariantValue(const QVariant &v)
+VariantValue::VariantValue(QVariant v)
: Value(VariantValueType, false)
- , m_value(v)
+ , m_value(std::move(v))
{
}
diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h
index b9a869d73..f27406f2d 100644
--- a/src/lib/corelib/language/value.h
+++ b/src/lib/corelib/language/value.h
@@ -115,7 +115,7 @@ class JSSourceValue : public Value
public:
static JSSourceValuePtr QBS_AUTOTEST_EXPORT create(bool createdByPropertiesBlock = false);
- ~JSSourceValue();
+ ~JSSourceValue() override;
void apply(ValueHandler *handler) override { handler->handle(this); }
ValuePtr clone() const override;
@@ -207,7 +207,7 @@ private:
class VariantValue : public Value
{
- VariantValue(const QVariant &v);
+ VariantValue(QVariant v);
public:
static VariantValuePtr create(const QVariant &v = QVariant());
diff --git a/src/lib/corelib/logging/ilogsink.cpp b/src/lib/corelib/logging/ilogsink.cpp
index bc2f36e61..4eb930cbf 100644
--- a/src/lib/corelib/logging/ilogsink.cpp
+++ b/src/lib/corelib/logging/ilogsink.cpp
@@ -78,13 +78,12 @@ QString logLevelName(LoggerLevel level)
class ILogSink::ILogSinkPrivate
{
public:
- LoggerLevel logLevel;
+ LoggerLevel logLevel = defaultLogLevel();
std::mutex mutex;
};
ILogSink::ILogSink() : d(new ILogSinkPrivate)
{
- d->logLevel = defaultLogLevel();
}
ILogSink::~ILogSink()
diff --git a/src/lib/corelib/logging/logger.cpp b/src/lib/corelib/logging/logger.cpp
index c3b11094d..71ca6a96c 100644
--- a/src/lib/corelib/logging/logger.cpp
+++ b/src/lib/corelib/logging/logger.cpp
@@ -165,7 +165,8 @@ LogWriter operator<<(LogWriter w, const QVariant &variant)
QString str = QLatin1String(variant.typeName()) + QLatin1Char('(');
if (variant.type() == QVariant::List) {
bool firstLoop = true;
- for (const QVariant &item : variant.toList()) {
+ const auto list = variant.toList();
+ for (const QVariant &item : list) {
str += item.toString();
if (firstLoop)
firstLoop = false;
diff --git a/src/lib/corelib/parser/qmljsast_p.h b/src/lib/corelib/parser/qmljsast_p.h
index d7b627a4b..8c6f32140 100644
--- a/src/lib/corelib/parser/qmljsast_p.h
+++ b/src/lib/corelib/parser/qmljsast_p.h
@@ -247,7 +247,7 @@ class QML_PARSER_EXPORT ExpressionNode: public Node
public:
ExpressionNode() {}
- virtual ExpressionNode *expressionCast();
+ ExpressionNode *expressionCast() override;
};
class QML_PARSER_EXPORT Statement: public Node
@@ -255,7 +255,7 @@ class QML_PARSER_EXPORT Statement: public Node
public:
Statement() {}
- virtual Statement *statementCast();
+ Statement *statementCast() override;
};
class QML_PARSER_EXPORT NestedExpression: public ExpressionNode
@@ -267,12 +267,12 @@ public:
: expression(expression)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lparenToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rparenToken; }
// attributes
@@ -288,12 +288,12 @@ public:
ThisExpression() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return thisToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return thisToken; }
// attributes
@@ -308,12 +308,12 @@ public:
IdentifierExpression(const QStringRef &n):
name (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return identifierToken; }
// attributes
@@ -328,12 +328,12 @@ public:
NullExpression() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return nullToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return nullToken; }
// attributes
@@ -347,12 +347,12 @@ public:
TrueLiteral() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return trueToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return trueToken; }
// attributes
@@ -366,12 +366,12 @@ public:
FalseLiteral() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return falseToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return falseToken; }
// attributes
@@ -386,12 +386,12 @@ public:
NumericLiteral(double v):
value(v) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return literalToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return literalToken; }
// attributes:
@@ -407,12 +407,12 @@ public:
StringLiteral(const QStringRef &v):
value (v) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return literalToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return literalToken; }
// attributes:
@@ -428,12 +428,12 @@ public:
RegExpLiteral(const QStringRef &p, int f):
pattern (p), flags (f) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return literalToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return literalToken; }
// attributes:
@@ -459,12 +459,12 @@ public:
elements (elts), elision (e)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbracketToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
// attributes
@@ -486,12 +486,12 @@ public:
ObjectLiteral(PropertyNameAndValueList *plist):
properties (plist) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -515,12 +515,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return commaToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : commaToken; }
inline Elision *finish ()
@@ -559,16 +559,16 @@ public:
return front;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (elision)
return elision->firstSourceLocation();
return expression->firstSourceLocation();
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -589,10 +589,10 @@ public:
PropertyName() { kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return propertyNameToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return propertyNameToken; }
// attributes
@@ -616,12 +616,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return name->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -651,7 +651,7 @@ public:
IdentifierPropertyName(const QStringRef &n):
id (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
QStringRef id;
@@ -665,7 +665,7 @@ public:
StringLiteralPropertyName(const QStringRef &n):
id (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
QStringRef id;
@@ -679,7 +679,7 @@ public:
NumericLiteralPropertyName(double n):
id (n) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
double id;
@@ -694,12 +694,12 @@ public:
base (b), expression (e)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
// attributes
@@ -718,12 +718,12 @@ public:
base (b), name (n)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return identifierToken; }
// attributes
@@ -742,12 +742,12 @@ public:
base (b), arguments (a)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return newToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rparenToken; }
// attributes
@@ -766,12 +766,12 @@ public:
NewExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return newToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -788,12 +788,12 @@ public:
base (b), arguments (a)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rparenToken; }
// attributes
@@ -820,12 +820,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -853,12 +853,12 @@ public:
PostIncrementExpression(ExpressionNode *b):
base (b) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return incrementToken; }
// attributes
@@ -874,12 +874,12 @@ public:
PostDecrementExpression(ExpressionNode *b):
base (b) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return base->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return decrementToken; }
// attributes
@@ -895,12 +895,12 @@ public:
DeleteExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return deleteToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -916,12 +916,12 @@ public:
VoidExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return voidToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -937,12 +937,12 @@ public:
TypeOfExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return typeofToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -958,12 +958,12 @@ public:
PreIncrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return incrementToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -979,12 +979,12 @@ public:
PreDecrementExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return decrementToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1000,12 +1000,12 @@ public:
UnaryPlusExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return plusToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1021,12 +1021,12 @@ public:
UnaryMinusExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return minusToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1042,12 +1042,12 @@ public:
TildeExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return tildeToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1063,12 +1063,12 @@ public:
NotExpression(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return notToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression->lastSourceLocation(); }
// attributes
@@ -1085,14 +1085,14 @@ public:
left (l), op (o), right (r)
{ kind = K; }
- virtual BinaryExpression *binaryExpressionCast();
+ BinaryExpression *binaryExpressionCast() override;
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return left->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return right->lastSourceLocation(); }
// attributes
@@ -1111,12 +1111,12 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return ko->lastSourceLocation(); }
// attributes
@@ -1135,12 +1135,12 @@ public:
Expression(ExpressionNode *l, ExpressionNode *r):
left (l), right (r) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return left->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return right->lastSourceLocation(); }
// attributes
@@ -1157,12 +1157,12 @@ public:
Block(StatementList *slist):
statements (slist) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -1188,12 +1188,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return statement->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : statement->lastSourceLocation(); }
inline StatementList *finish ()
@@ -1217,12 +1217,12 @@ public:
declarations (vlist)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return declarationKindToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1240,12 +1240,12 @@ public:
name (n), expression (e), readOnly(false)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return expression ? expression->lastSourceLocation() : identifierToken; }
// attributes
@@ -1272,12 +1272,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return declaration->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (next)
return next->lastSourceLocation();
@@ -1309,12 +1309,12 @@ public:
EmptyStatement() { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return semicolonToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1329,12 +1329,12 @@ public:
ExpressionStatement(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return expression->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1351,12 +1351,12 @@ public:
expression (e), ok (t), ko (f)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return ifToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (ko)
return ko->lastSourceLocation();
@@ -1383,12 +1383,12 @@ public:
statement (stmt), expression (e)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return doToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1410,12 +1410,12 @@ public:
expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return whileToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1435,12 +1435,12 @@ public:
initialiser (i), condition (c), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1464,12 +1464,12 @@ public:
declarations (vlist), condition (c), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1494,12 +1494,12 @@ public:
initialiser (i), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1521,12 +1521,12 @@ public:
declaration (v), expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return forToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1548,12 +1548,12 @@ public:
ContinueStatement(const QStringRef &l = QStringRef()):
label (l) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return continueToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1571,12 +1571,12 @@ public:
BreakStatement(const QStringRef &l):
label (l) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return breakToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1594,12 +1594,12 @@ public:
ReturnStatement(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return returnToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1617,12 +1617,12 @@ public:
expression (e), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return withToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1642,12 +1642,12 @@ public:
clauses (c), defaultClause (d), moreClauses (r)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -1667,12 +1667,12 @@ public:
expression (e), block (b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return switchToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return block->rbraceToken; }
// attributes
@@ -1692,12 +1692,12 @@ public:
expression (e), statements (slist)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return caseToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statements ? statements->lastSourceLocation() : colonToken; }
// attributes
@@ -1724,12 +1724,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return clause->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : clause->lastSourceLocation(); }
inline CaseClauses *finish ()
@@ -1753,12 +1753,12 @@ public:
statements (slist)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return defaultToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statements ? statements->lastSourceLocation() : colonToken; }
// attributes
@@ -1776,12 +1776,12 @@ public:
label (l), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1799,12 +1799,12 @@ public:
ThrowStatement(ExpressionNode *e):
expression (e) { kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return throwToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -1822,12 +1822,12 @@ public:
name (n), statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return catchToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -1848,12 +1848,12 @@ public:
statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return finallyToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement ? statement->lastSourceLocation() : finallyToken; }
// attributes
@@ -1878,12 +1878,12 @@ public:
statement (stmt), catchExpression (c), finallyExpression (nullptr)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return tryToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (finallyExpression)
return finallyExpression->statement->rbraceToken;
@@ -1909,12 +1909,12 @@ public:
name (n), formals (f), body (b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return functionToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -1938,7 +1938,7 @@ public:
FunctionExpression(n, f, b)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
};
class QML_PARSER_EXPORT FormalParameterList: public Node
@@ -1958,12 +1958,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
inline FormalParameterList *finish ()
@@ -2006,12 +2006,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return element->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : element->lastSourceLocation(); }
inline SourceElements *finish ()
@@ -2035,12 +2035,12 @@ public:
elements (elts)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return elements ? elements->firstSourceLocation() : SourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return elements ? elements->lastSourceLocation() : SourceLocation(); }
// attributes
@@ -2056,12 +2056,12 @@ public:
elements (elts)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return elements ? elements->firstSourceLocation() : SourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return elements ? elements->lastSourceLocation() : SourceLocation(); }
// attributes
@@ -2077,12 +2077,12 @@ public:
declaration (f)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return declaration->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return declaration->lastSourceLocation(); }
// attributes
@@ -2098,12 +2098,12 @@ public:
statement (stmt)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return statement->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
// attributes
@@ -2118,12 +2118,12 @@ public:
DebuggerStatement()
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return debuggerToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -2155,12 +2155,12 @@ public:
return head;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
// attributes
@@ -2182,12 +2182,12 @@ public:
: importUri(uri)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return importToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
// attributes
@@ -2227,12 +2227,12 @@ public:
return head;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return import->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : import->lastSourceLocation(); }
// attributes
@@ -2243,10 +2243,10 @@ public:
class QML_PARSER_EXPORT UiObjectMember: public Node
{
public:
- virtual SourceLocation firstSourceLocation() const = 0;
- virtual SourceLocation lastSourceLocation() const = 0;
+ SourceLocation firstSourceLocation() const override = 0;
+ SourceLocation lastSourceLocation() const override = 0;
- virtual UiObjectMember *uiObjectMemberCast();
+ UiObjectMember *uiObjectMemberCast() override;
};
class QML_PARSER_EXPORT UiObjectMemberList: public Node
@@ -2266,12 +2266,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return member->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
UiObjectMemberList *finish()
@@ -2295,9 +2295,9 @@ public:
: imports(imports), members(members)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (imports)
return imports->firstSourceLocation();
@@ -2306,7 +2306,7 @@ public:
return SourceLocation();
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (members)
return members->lastSourceLocation();
@@ -2337,12 +2337,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return member->firstSourceLocation(); }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : member->lastSourceLocation(); }
UiArrayMemberList *finish()
@@ -2367,12 +2367,12 @@ public:
: members(members)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return lbraceToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbraceToken; }
// attributes
@@ -2398,12 +2398,12 @@ public:
previous->next = this;
}
- virtual void accept0(Visitor *) {}
+ void accept0(Visitor *) override {}
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return propertyTypeToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return next ? next->lastSourceLocation() : identifierToken; }
inline UiParameterList *finish ()
@@ -2438,9 +2438,9 @@ public:
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (defaultToken.isValid())
return defaultToken;
@@ -2450,7 +2450,7 @@ public:
return propertyToken;
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
if (binding)
return binding->lastSourceLocation();
@@ -2490,12 +2490,12 @@ public:
: qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer)
{ kind = K; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return qualifiedTypeNameId->identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return initializer->rbraceToken; }
// attributes
@@ -2512,27 +2512,27 @@ public:
: sourceElement(sourceElement)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
- if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
+ if (const auto funDecl = cast<const FunctionDeclaration *>(sourceElement))
return funDecl->firstSourceLocation();
- else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
+ else if (const auto varStmt = cast<const VariableStatement *>(sourceElement))
return varStmt->firstSourceLocation();
return SourceLocation();
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{
- if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement))
+ if (const auto funDecl = cast<const FunctionDeclaration *>(sourceElement))
return funDecl->lastSourceLocation();
- else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement))
+ else if (const auto varStmt = cast<const VariableStatement *>(sourceElement))
return varStmt->lastSourceLocation();
return SourceLocation();
}
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
@@ -2553,7 +2553,7 @@ public:
hasOnToken(false)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{
if (hasOnToken && qualifiedTypeNameId)
return qualifiedTypeNameId->identifierToken;
@@ -2561,10 +2561,10 @@ public:
return qualifiedId->identifierToken;
}
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return initializer->rbraceToken; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
@@ -2586,13 +2586,13 @@ public:
statement(statement)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return qualifiedId->identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return statement->lastSourceLocation(); }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
UiQualifiedId *qualifiedId;
@@ -2611,13 +2611,13 @@ public:
members(members)
{ kind = K; }
- virtual SourceLocation firstSourceLocation() const
+ SourceLocation firstSourceLocation() const override
{ return qualifiedId->identifierToken; }
- virtual SourceLocation lastSourceLocation() const
+ SourceLocation lastSourceLocation() const override
{ return rbracketToken; }
- virtual void accept0(Visitor *visitor);
+ void accept0(Visitor *visitor) override;
// attributes
UiQualifiedId *qualifiedId;
diff --git a/src/lib/corelib/parser/qmljsparser.cpp b/src/lib/corelib/parser/qmljsparser.cpp
index 71cff876d..6390c8a9d 100644
--- a/src/lib/corelib/parser/qmljsparser.cpp
+++ b/src/lib/corelib/parser/qmljsparser.cpp
@@ -114,13 +114,13 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
QVarLengthArray<AST::SourceLocation, 4> locations;
AST::ExpressionNode *it = expr;
- while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
+ while (const auto m = AST::cast<AST::FieldMemberExpression *>(it)) {
nameIds.append(m->name);
locations.append(m->identifierToken);
it = m->base;
}
- if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
+ if (const auto idExpr = AST::cast<AST::IdentifierExpression *>(it)) {
const auto q = new (pool) AST::UiQualifiedId(idExpr->name);
q->identifierToken = idExpr->identifierToken;
@@ -1150,7 +1150,7 @@ case 212: {
} break;
case 214: {
- AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression,
+ const auto node = new (pool) AST::BinaryExpression(sym(1).Expression,
QSOperator::And, sym(3).Expression);
node->operatorToken = loc(2);
sym(1).Node = node;
diff --git a/src/lib/corelib/parser/qmljsparser_p.h b/src/lib/corelib/parser/qmljsparser_p.h
index 05e22074b..c761bb25b 100644
--- a/src/lib/corelib/parser/qmljsparser_p.h
+++ b/src/lib/corelib/parser/qmljsparser_p.h
@@ -212,13 +212,13 @@ protected:
enum { TOKEN_BUFFER_SIZE = 3 };
struct SavedToken {
- int token;
- double dval;
+ int token = 0;
+ double dval = 0.0;
AST::SourceLocation loc;
QStringRef spell;
};
- double yylval;
+ double yylval = 0.0;
QStringRef yytokenspell;
AST::SourceLocation yylloc;
AST::SourceLocation yyprevlloc;
diff --git a/src/lib/corelib/tools/applecodesignutils.cpp b/src/lib/corelib/tools/applecodesignutils.cpp
index 67c4f5238..feae266bf 100644
--- a/src/lib/corelib/tools/applecodesignutils.cpp
+++ b/src/lib/corelib/tools/applecodesignutils.cpp
@@ -80,7 +80,8 @@ QVariantMap certificateInfo(const QByteArray &data)
// Also potentially useful, but these are for signing pkgs which aren't used here
// 1.2.840.113635.100.4.9 - 3rd Party Mac Developer Installer: <name>
// 1.2.840.113635.100.4.13 - Developer ID Installer: <name>
- for (const auto &extension : cert.extensions()) {
+ const auto extensions = cert.extensions();
+ for (const auto &extension : extensions) {
if (extension.name() == QStringLiteral("extendedKeyUsage")) {
if (!extension.value().toStringList().contains(QStringLiteral("Code Signing")))
return {};
@@ -89,7 +90,8 @@ QVariantMap certificateInfo(const QByteArray &data)
const auto subjectInfo = [](const QSslCertificate &cert) {
QVariantMap map;
- for (const auto &attr : cert.subjectInfoAttributes())
+ const auto attributes = cert.subjectInfoAttributes();
+ for (const auto &attr : attributes)
map.insert(QString::fromUtf8(attr), cert.subjectInfo(attr).front());
return map;
};
diff --git a/src/lib/corelib/tools/buildgraphlocker.cpp b/src/lib/corelib/tools/buildgraphlocker.cpp
index c166c6e2d..28a58e3f4 100644
--- a/src/lib/corelib/tools/buildgraphlocker.cpp
+++ b/src/lib/corelib/tools/buildgraphlocker.cpp
@@ -55,8 +55,8 @@
namespace qbs {
namespace Internal {
-DirectoryManager::DirectoryManager(const QString &dir, const Logger &logger)
- : m_dir(dir), m_logger(logger)
+DirectoryManager::DirectoryManager(QString dir, Logger logger)
+ : m_dir(std::move(dir)), m_logger(std::move(logger))
{
rememberCreatedDirectories();
}
diff --git a/src/lib/corelib/tools/buildgraphlocker.h b/src/lib/corelib/tools/buildgraphlocker.h
index 17d452130..f85fc0768 100644
--- a/src/lib/corelib/tools/buildgraphlocker.h
+++ b/src/lib/corelib/tools/buildgraphlocker.h
@@ -55,7 +55,7 @@ class ProgressObserver;
class DirectoryManager
{
public:
- DirectoryManager(const QString &dir, const Logger &logger);
+ DirectoryManager(QString dir, Logger logger);
~DirectoryManager();
QString dir() const { return m_dir; }
diff --git a/src/lib/corelib/tools/codelocation.cpp b/src/lib/corelib/tools/codelocation.cpp
index 57b577711..2c6ade3b0 100644
--- a/src/lib/corelib/tools/codelocation.cpp
+++ b/src/lib/corelib/tools/codelocation.cpp
@@ -68,8 +68,8 @@ public:
}
QString filePath;
- int line;
- int column;
+ int line = 0;
+ int column = 0;
};
CodeLocation::CodeLocation()
diff --git a/src/lib/corelib/tools/executablefinder.cpp b/src/lib/corelib/tools/executablefinder.cpp
index 7c5d1210e..4342c82f0 100644
--- a/src/lib/corelib/tools/executablefinder.cpp
+++ b/src/lib/corelib/tools/executablefinder.cpp
@@ -64,10 +64,9 @@ static QStringList populateExecutableSuffixes()
QStringList ExecutableFinder::m_executableSuffixes = populateExecutableSuffixes();
-ExecutableFinder::ExecutableFinder(const ResolvedProductPtr &m_product,
- const QProcessEnvironment &env)
- : m_product(m_product)
- , m_environment(env)
+ExecutableFinder::ExecutableFinder(ResolvedProductPtr product, QProcessEnvironment env)
+ : m_product(std::move(product))
+ , m_environment(std::move(env))
{
}
diff --git a/src/lib/corelib/tools/executablefinder.h b/src/lib/corelib/tools/executablefinder.h
index cb965b5d1..9467756fc 100644
--- a/src/lib/corelib/tools/executablefinder.h
+++ b/src/lib/corelib/tools/executablefinder.h
@@ -53,7 +53,7 @@ namespace Internal {
class ExecutableFinder
{
public:
- ExecutableFinder(const ResolvedProductPtr &product, const QProcessEnvironment &env);
+ ExecutableFinder(ResolvedProductPtr product, QProcessEnvironment env);
QString findExecutable(const QString &path, const QString &workingDirPath);
@@ -68,7 +68,7 @@ private:
void cacheFilePath(const QString &filePaht, const QString &filePath) const;
ResolvedProductPtr m_product;
- const QProcessEnvironment &m_environment;
+ const QProcessEnvironment m_environment;
};
} // namespace Internal
diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp
index cec6b2660..8b0eedc27 100644
--- a/src/lib/corelib/tools/fileinfo.cpp
+++ b/src/lib/corelib/tools/fileinfo.cpp
@@ -404,8 +404,9 @@ bool removeFileRecursion(const QFileInfo &f, QString *errorMessage)
const QDir dir(f.absoluteFilePath());
// QDir::System is needed for broken symlinks.
- for (const QFileInfo &fi : dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot
- | QDir::Hidden | QDir::System))
+ const auto fileInfos = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot
+ | QDir::Hidden | QDir::System);
+ for (const QFileInfo &fi : fileInfos)
removeFileRecursion(fi, errorMessage);
QDir parent = f.absoluteDir();
if (!parent.rmdir(f.fileName())) {
diff --git a/src/lib/corelib/tools/fileinfo.h b/src/lib/corelib/tools/fileinfo.h
index 723d83424..9813b69a7 100644
--- a/src/lib/corelib/tools/fileinfo.h
+++ b/src/lib/corelib/tools/fileinfo.h
@@ -96,7 +96,7 @@ private:
#else
# error unknown platform
#endif
- InternalStatType m_stat;
+ InternalStatType m_stat{};
};
bool removeFileRecursion(const QFileInfo &f, QString *errorMessage);
diff --git a/src/lib/corelib/tools/filesaver.cpp b/src/lib/corelib/tools/filesaver.cpp
index 0fd652657..5a0a68c1f 100644
--- a/src/lib/corelib/tools/filesaver.cpp
+++ b/src/lib/corelib/tools/filesaver.cpp
@@ -48,8 +48,8 @@
namespace qbs {
namespace Internal {
-FileSaver::FileSaver(const std::string &filePath, bool overwriteIfUnchanged)
- : m_filePath(filePath), m_overwriteIfUnchanged(overwriteIfUnchanged)
+FileSaver::FileSaver(std::string filePath, bool overwriteIfUnchanged)
+ : m_filePath(std::move(filePath)), m_overwriteIfUnchanged(overwriteIfUnchanged)
{
}
diff --git a/src/lib/corelib/tools/filesaver.h b/src/lib/corelib/tools/filesaver.h
index 275ad0f01..8b4c01669 100644
--- a/src/lib/corelib/tools/filesaver.h
+++ b/src/lib/corelib/tools/filesaver.h
@@ -55,7 +55,7 @@ namespace Internal {
*/
class QBS_EXPORT FileSaver {
public:
- FileSaver(const std::string &filePath, bool overwriteIfUnchanged = false);
+ FileSaver(std::string filePath, bool overwriteIfUnchanged = false);
std::ostream *device();
bool open();
diff --git a/src/lib/corelib/tools/filetime.h b/src/lib/corelib/tools/filetime.h
index 7daec6415..f9a15f794 100644
--- a/src/lib/corelib/tools/filetime.h
+++ b/src/lib/corelib/tools/filetime.h
@@ -115,7 +115,7 @@ public:
}
private:
- InternalType m_fileTime;
+ InternalType m_fileTime{};
};
} // namespace Internal
diff --git a/src/lib/corelib/tools/hostosinfo.h b/src/lib/corelib/tools/hostosinfo.h
index cae451638..d7f718c19 100644
--- a/src/lib/corelib/tools/hostosinfo.h
+++ b/src/lib/corelib/tools/hostosinfo.h
@@ -74,6 +74,7 @@ public:
enum HostOs { HostOsWindows, HostOsLinux, HostOsMacos, HostOsOtherUnix, HostOsOther };
static inline std::string hostOSIdentifier();
+ static inline std::string hostOSArchitecture();
static inline std::vector<std::string> hostOSIdentifiers();
static inline std::vector<std::string> canonicalOSIdentifiers(const std::string &os);
static inline HostOs hostOs();
@@ -177,6 +178,14 @@ std::string HostOsInfo::hostOSIdentifier()
#endif
}
+std::string HostOsInfo::hostOSArchitecture()
+{
+ const auto cpuArch = QSysInfo::currentCpuArchitecture();
+ if (cpuArch == QLatin1String("i386"))
+ return "x86";
+ return cpuArch.toStdString();
+}
+
std::vector<std::string> HostOsInfo::hostOSIdentifiers()
{
return canonicalOSIdentifiers(hostOSIdentifier());
diff --git a/src/lib/corelib/tools/id.cpp b/src/lib/corelib/tools/id.cpp
index 9d31d3776..6dd1147f2 100644
--- a/src/lib/corelib/tools/id.cpp
+++ b/src/lib/corelib/tools/id.cpp
@@ -69,9 +69,7 @@ namespace Internal {
class StringHolder
{
public:
- StringHolder()
- : n(0), str(nullptr)
- {}
+ StringHolder() = default;
StringHolder(const char *s, int length)
: n(length), str(s)
@@ -85,9 +83,9 @@ public:
h &= 0x0fffffff;
}
}
- int n;
- const char *str;
- uint h;
+ int n = 0;
+ const char *str = nullptr;
+ uint h = 0;
};
static bool operator==(const StringHolder &sh1, const StringHolder &sh2)
diff --git a/src/lib/corelib/tools/joblimits.cpp b/src/lib/corelib/tools/joblimits.cpp
index 3b1fde83d..912b15a65 100644
--- a/src/lib/corelib/tools/joblimits.cpp
+++ b/src/lib/corelib/tools/joblimits.cpp
@@ -118,8 +118,7 @@ JobLimits::~JobLimits() {}
void JobLimits::setJobLimit(const JobLimit &limit)
{
- for (std::size_t i = 0; i < d->jobLimits.size(); ++i) {
- JobLimit &currentLimit = d->jobLimits.at(i);
+ for (auto &currentLimit : d->jobLimits) {
if (currentLimit.pool() == limit.pool()) {
if (currentLimit.limit() != limit.limit())
currentLimit = limit;
diff --git a/src/lib/corelib/tools/jsliterals.cpp b/src/lib/corelib/tools/jsliterals.cpp
index bf9720493..74328006c 100644
--- a/src/lib/corelib/tools/jsliterals.cpp
+++ b/src/lib/corelib/tools/jsliterals.cpp
@@ -77,7 +77,8 @@ QString toJSLiteral(const QVariant &val)
return Internal::StringConstants::undefinedValue();
if (val.type() == QVariant::List || val.type() == QVariant::StringList) {
QString res;
- for (const QVariant &child : val.toList()) {
+ const auto list = val.toList();
+ for (const QVariant &child : list) {
if (res.length()) res.append(QLatin1String(", "));
res.append(toJSLiteral(child));
}
diff --git a/src/lib/corelib/tools/launcherinterface.cpp b/src/lib/corelib/tools/launcherinterface.cpp
index b16c8563c..f4e80c5e2 100644
--- a/src/lib/corelib/tools/launcherinterface.cpp
+++ b/src/lib/corelib/tools/launcherinterface.cpp
@@ -67,7 +67,7 @@ private:
void setupChildProcess() override
{
#ifdef Q_OS_UNIX
- const pid_t pid = static_cast<pid_t>(processId());
+ const auto pid = static_cast<pid_t>(processId());
setpgid(pid, pid);
#endif
}
diff --git a/src/lib/corelib/tools/launcherinterface.h b/src/lib/corelib/tools/launcherinterface.h
index c497e7415..f3aca9bf4 100644
--- a/src/lib/corelib/tools/launcherinterface.h
+++ b/src/lib/corelib/tools/launcherinterface.h
@@ -57,7 +57,7 @@ class LauncherInterface : public QObject
Q_OBJECT
public:
static LauncherInterface &instance();
- ~LauncherInterface();
+ ~LauncherInterface() override;
static void startLauncher() { instance().doStart(); }
static void stopLauncher() { instance().doStop(); }
diff --git a/src/lib/corelib/tools/launcherpackets.h b/src/lib/corelib/tools/launcherpackets.h
index 0988761e7..4306718fd 100644
--- a/src/lib/corelib/tools/launcherpackets.h
+++ b/src/lib/corelib/tools/launcherpackets.h
@@ -73,8 +73,8 @@ public:
private:
QDataStream m_stream;
- LauncherPacketType m_type;
- quintptr m_token;
+ LauncherPacketType m_type = LauncherPacketType::Shutdown;
+ quintptr m_token = 0;
QByteArray m_packetData;
int m_sizeOfNextPacket = -1;
};
@@ -95,7 +95,7 @@ public:
void deserialize(const QByteArray &data);
const LauncherPacketType type;
- const quintptr token;
+ const quintptr token = 0;
protected:
LauncherPacket(LauncherPacketType type, quintptr token) : type(type), token(token) { }
@@ -161,9 +161,9 @@ public:
QString errorString;
QByteArray stdOut;
QByteArray stdErr;
- QProcess::ExitStatus exitStatus;
- QProcess::ProcessError error;
- int exitCode;
+ QProcess::ExitStatus exitStatus = QProcess::ExitStatus::NormalExit;
+ QProcess::ProcessError error = QProcess::ProcessError::UnknownError;
+ int exitCode = 0;
private:
void doSerialize(QDataStream &stream) const override;
diff --git a/src/lib/corelib/tools/msvcinfo.cpp b/src/lib/corelib/tools/msvcinfo.cpp
index f51ba8ba2..cffec85b2 100644
--- a/src/lib/corelib/tools/msvcinfo.cpp
+++ b/src/lib/corelib/tools/msvcinfo.cpp
@@ -70,7 +70,8 @@ public:
TemporaryEnvChanger(const QProcessEnvironment &envChanges) : m_locker(envMutex)
{
QProcessEnvironment currentEnv = QProcessEnvironment::systemEnvironment();
- for (const QString &key : envChanges.keys()) {
+ const auto keys = envChanges.keys();
+ for (const QString &key : keys) {
m_changesToRestore.insert(key, currentEnv.value(key));
qputenv(qPrintable(key), qPrintable(envChanges.value(key)));
}
@@ -78,7 +79,8 @@ public:
~TemporaryEnvChanger()
{
- for (const QString &key : m_changesToRestore.keys())
+ const auto keys = m_changesToRestore.keys();
+ for (const QString &key : keys)
qputenv(qPrintable(key), qPrintable(m_changesToRestore.value(key)));
}
@@ -119,7 +121,7 @@ static QByteArray runProcess(const QString &exeFilePath, const QStringList &args
class DummyFile {
public:
- DummyFile(const QString &fp) : filePath(fp) { }
+ DummyFile(QString fp) : filePath(std::move(fp)) { }
~DummyFile() { QFile::remove(filePath); }
const QString filePath;
};
@@ -196,11 +198,88 @@ static QVariantMap getMsvcDefines(const QString &compilerFilePath,
#endif
}
+/*!
+ \internal
+ clang-cl does not support gcc and msvc ways to dump a macros, so we have to use original
+ clang.exe directly
+*/
+static QVariantMap getClangClDefines(
+ const QString &compilerFilePath,
+ const QProcessEnvironment &compilerEnv,
+ MSVC::CompilerLanguage language)
+{
+#ifdef Q_OS_WIN
+ QFileInfo clInfo(compilerFilePath);
+ QFileInfo clangInfo(clInfo.absolutePath() + QLatin1String("/clang.exe"));
+ if (!clangInfo.exists())
+ throw ErrorInfo(QStringLiteral("%1 does not exist").arg(clangInfo.absoluteFilePath()));
+
+ QString languageSwitch;
+ switch (language) {
+ case MSVC::CLanguage:
+ languageSwitch = QStringLiteral("c");
+ break;
+ case MSVC::CPlusPlusLanguage:
+ languageSwitch = QStringLiteral("c++");
+ break;
+ }
+ QStringList args = {
+ QStringLiteral("-dM"),
+ QStringLiteral("-E"),
+ QStringLiteral("-x"),
+ languageSwitch,
+ QStringLiteral("NUL"),
+ };
+ const auto lines = QString::fromLocal8Bit(
+ runProcess(
+ clangInfo.absoluteFilePath(),
+ args,
+ compilerEnv,
+ true)).split(QLatin1Char('\n'));
+ QVariantMap result;
+ for (const auto &line: lines) {
+ static const auto defineString = QLatin1String("#define ");
+ if (!line.startsWith(defineString)) {
+ throw ErrorInfo(QStringLiteral("Unexpected compiler frontend output: ")
+ + lines.join(QLatin1Char('\n')));
+ }
+ QStringView view(line.data() + defineString.size());
+ const auto it = std::find(view.begin(), view.end(), QLatin1Char(' '));
+ if (it == view.end()) {
+ throw ErrorInfo(QStringLiteral("Unexpected compiler frontend output: ")
+ + lines.join(QLatin1Char('\n')));
+ }
+ QStringView key(view.begin(), it);
+ QStringView value(it + 1, view.end());
+ result.insert(key.toString(), value.isEmpty() ? QVariant() : QVariant(value.toString()));
+ }
+ return result;
+#else
+ Q_UNUSED(compilerFilePath);
+ Q_UNUSED(compilerEnv);
+ Q_UNUSED(language);
+ return {};
+#endif
+}
+
void MSVC::init()
{
determineCompilerVersion();
}
+/*!
+ \internal
+ Returns the architecture detected from the compiler path.
+*/
+QString MSVC::architectureFromClPath(const QString &clPath)
+{
+ const auto parentDir = QFileInfo(clPath).absolutePath();
+ const auto parentDirName = QFileInfo(parentDir).fileName().toLower();
+ if (parentDirName == QLatin1String("bin"))
+ return QStringLiteral("x86");
+ return parentDirName;
+}
+
QString MSVC::binPathForArchitecture(const QString &arch) const
{
QString archSubDir;
@@ -220,6 +299,9 @@ QString MSVC::clPathForArchitecture(const QString &arch) const
QVariantMap MSVC::compilerDefines(const QString &compilerFilePath,
MSVC::CompilerLanguage language) const
{
+ const auto compilerName = QFileInfo(compilerFilePath).fileName().toLower();
+ if (compilerName == QLatin1String("clang-cl.exe"))
+ return getClangClDefines(compilerFilePath, environment, language);
return getMsvcDefines(compilerFilePath, environment, language);
}
diff --git a/src/lib/corelib/tools/msvcinfo.h b/src/lib/corelib/tools/msvcinfo.h
index 61a19dc4f..b5cf04e84 100644
--- a/src/lib/corelib/tools/msvcinfo.h
+++ b/src/lib/corelib/tools/msvcinfo.h
@@ -77,20 +77,19 @@ public:
MSVC() { }
- MSVC(const QString &clPath)
+ MSVC(const QString &clPath, QString arch):
+ architecture(std::move(arch))
{
QDir parentDir = QFileInfo(clPath).dir();
binPath = parentDir.absolutePath();
QString parentDirName = parentDir.dirName().toLower();
- if (parentDirName == QLatin1String("bin"))
- parentDirName = QStringLiteral("x86");
- else
+ if (parentDirName != QLatin1String("bin"))
parentDir.cdUp();
- architecture = parentDirName;
vcInstallPath = parentDir.path();
}
QBS_EXPORT void init();
+ QBS_EXPORT static QString architectureFromClPath(const QString &clPath);
QBS_EXPORT QString binPathForArchitecture(const QString &arch) const;
QBS_EXPORT QString clPathForArchitecture(const QString &arch) const;
QBS_EXPORT QVariantMap compilerDefines(const QString &compilerFilePath,
@@ -103,7 +102,7 @@ private:
class WinSDK : public MSVC
{
public:
- bool isDefault;
+ bool isDefault = false;
WinSDK()
{
diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp
index dfa7fb683..3b69926f6 100644
--- a/src/lib/corelib/tools/persistence.cpp
+++ b/src/lib/corelib/tools/persistence.cpp
@@ -150,7 +150,7 @@ void PersistentPool::closeStream()
void PersistentPool::storeVariant(const QVariant &variant)
{
- const quint32 type = static_cast<quint32>(variant.type());
+ const auto type = static_cast<quint32>(variant.type());
m_stream << type;
switch (type) {
case QMetaType::QString:
@@ -172,7 +172,7 @@ void PersistentPool::storeVariant(const QVariant &variant)
QVariant PersistentPool::loadVariant()
{
- const quint32 type = load<quint32>();
+ const auto type = load<quint32>();
QVariant value;
switch (type) {
case QMetaType::QString:
diff --git a/src/lib/corelib/tools/persistence.h b/src/lib/corelib/tools/persistence.h
index 6be0ae8e4..4bda59f7c 100644
--- a/src/lib/corelib/tools/persistence.h
+++ b/src/lib/corelib/tools/persistence.h
@@ -171,18 +171,18 @@ private:
HeadData m_headData;
std::vector<void *> m_loadedRaw;
std::vector<std::shared_ptr<void>> m_loaded;
- QHash<const void*, int> m_storageIndices;
- PersistentObjectId m_lastStoredObjectId;
+ std::unordered_map<const void*, int> m_storageIndices;
+ PersistentObjectId m_lastStoredObjectId = 0;
std::vector<QString> m_stringStorage;
QHash<QString, int> m_inverseStringStorage;
- PersistentObjectId m_lastStoredStringId;
+ PersistentObjectId m_lastStoredStringId = 0;
std::vector<QProcessEnvironment> m_envStorage;
QHash<QProcessEnvironment, int> m_inverseEnvStorage;
- PersistentObjectId m_lastStoredEnvId;
+ PersistentObjectId m_lastStoredEnvId = 0;
std::vector<QStringList> m_stringListStorage;
QHash<QStringList, int> m_inverseStringListStorage;
- PersistentObjectId m_lastStoredStringListId;
+ PersistentObjectId m_lastStoredStringListId = 0;
Logger &m_logger;
template<typename T, typename Enable>
@@ -198,14 +198,14 @@ template<typename T> inline void PersistentPool::storeSharedObject(const T *obje
return;
}
const void * const addr = uniqueAddress(object);
- PersistentObjectId id = m_storageIndices.value(addr, -1);
- if (id < 0) {
- id = m_lastStoredObjectId++;
- m_storageIndices.insert(addr, id);
+ const auto found = m_storageIndices.find(addr);
+ if (found == m_storageIndices.end()) {
+ PersistentObjectId id = m_lastStoredObjectId++;
+ m_storageIndices[addr] = id;
m_stream << id;
store(*object);
} else {
- m_stream << id;
+ m_stream << found->second;
}
}
diff --git a/src/lib/corelib/tools/preferences.cpp b/src/lib/corelib/tools/preferences.cpp
index ca3fe8378..4db271758 100644
--- a/src/lib/corelib/tools/preferences.cpp
+++ b/src/lib/corelib/tools/preferences.cpp
@@ -1,3 +1,5 @@
+#include <utility>
+
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
@@ -51,13 +53,13 @@ namespace qbs {
* If a non-empty \c profileName is given, the profile's preferences take precedence over global
* ones. Otherwise, the global preferences are used.
*/
-Preferences::Preferences(Settings *settings, const QString &profileName)
- : m_settings(settings), m_profile(profileName)
+Preferences::Preferences(Settings *settings, QString profileName)
+ : m_settings(settings), m_profile(std::move(profileName))
{
}
-Preferences::Preferences(Settings *settings, const QVariantMap &profileContents)
- : m_settings(settings), m_profileContents(profileContents)
+Preferences::Preferences(Settings *settings, QVariantMap profileContents)
+ : m_settings(settings), m_profileContents(std::move(profileContents))
{
}
@@ -131,14 +133,16 @@ JobLimits Preferences::jobLimits() const
{
const QString prefix = QStringLiteral("preferences.jobLimit");
JobLimits limits;
- for (const QString &key : m_settings->allKeysWithPrefix(prefix, Settings::allScopes())) {
+ const auto keys = m_settings->allKeysWithPrefix(prefix, Settings::allScopes());
+ for (const QString &key : keys) {
limits.setJobLimit(key, m_settings->value(prefix + QLatin1Char('.') + key,
Settings::allScopes()).toInt());
}
const QString fullPrefix = prefix + QLatin1Char('.');
if (!m_profile.isEmpty()) {
Profile p(m_profile, m_settings, m_profileContents);
- for (const QString &key : p.allKeys(Profile::KeySelectionRecursive)) {
+ const auto keys = p.allKeys(Profile::KeySelectionRecursive);
+ for (const QString &key : keys) {
if (!key.startsWith(fullPrefix))
continue;
const QString jobPool = key.mid(fullPrefix.size());
diff --git a/src/lib/corelib/tools/preferences.h b/src/lib/corelib/tools/preferences.h
index 661b39d7f..2824ebf2c 100644
--- a/src/lib/corelib/tools/preferences.h
+++ b/src/lib/corelib/tools/preferences.h
@@ -54,8 +54,8 @@ class Settings;
class QBS_EXPORT Preferences
{
public:
- explicit Preferences(Settings *settings, const QString &profileName = QString());
- Preferences(Settings *settings, const QVariantMap &profileContents);
+ explicit Preferences(Settings *settings, QString profileName = QString());
+ Preferences(Settings *settings, QVariantMap profileContents);
bool useColoredOutput() const;
int jobs() const;
diff --git a/src/lib/corelib/tools/processresult_p.h b/src/lib/corelib/tools/processresult_p.h
index 141dd9301..69ccb8598 100644
--- a/src/lib/corelib/tools/processresult_p.h
+++ b/src/lib/corelib/tools/processresult_p.h
@@ -48,14 +48,14 @@ namespace Internal {
class ProcessResultPrivate : public QSharedData
{
public:
- bool success;
+ bool success = false;
QString executableFilePath;
QStringList arguments;
QString workingDirectory;
- QProcess::ProcessError error;
- int exitCode;
+ QProcess::ProcessError error = QProcess::ProcessError::UnknownError;
+ int exitCode = 0;
QStringList stdOut;
QStringList stdErr;
};
diff --git a/src/lib/corelib/tools/qbsprocess.h b/src/lib/corelib/tools/qbsprocess.h
index 07f344e8a..2181818f0 100644
--- a/src/lib/corelib/tools/qbsprocess.h
+++ b/src/lib/corelib/tools/qbsprocess.h
@@ -95,7 +95,7 @@ private:
QString m_errorString;
QProcess::ProcessError m_error = QProcess::UnknownError;
QProcess::ProcessState m_state = QProcess::NotRunning;
- int m_exitCode;
+ int m_exitCode = 0;
int m_connectionAttempts = 0;
bool m_socketError = false;
};
diff --git a/src/lib/corelib/tools/qttools.h b/src/lib/corelib/tools/qttools.h
index 2252c12d3..4cb39527e 100644
--- a/src/lib/corelib/tools/qttools.h
+++ b/src/lib/corelib/tools/qttools.h
@@ -53,7 +53,15 @@ namespace std {
template<> struct hash<QString> {
std::size_t operator()(const QString &s) const { return qHash(s); }
};
-}
+
+template<typename T1, typename T2> struct hash<std::pair<T1, T2>>
+{
+ size_t operator()(const pair<T1, T2> &x) const
+ {
+ return std::hash<T1>()(x.first) ^ std::hash<T2>()(x.second);
+ }
+};
+} // namespace std
QT_BEGIN_NAMESPACE
uint qHash(const QStringList &list);
diff --git a/src/lib/corelib/tools/scripttools.h b/src/lib/corelib/tools/scripttools.h
index 2d8f54204..4a258b98f 100644
--- a/src/lib/corelib/tools/scripttools.h
+++ b/src/lib/corelib/tools/scripttools.h
@@ -76,7 +76,7 @@ void attachPointerTo(QScriptValue &scriptValue, T *ptr)
template <class T>
T *attachedPointer(const QScriptValue &scriptValue)
{
- const quintptr ptr = scriptValue.data().toVariant().value<quintptr>();
+ const auto ptr = scriptValue.data().toVariant().value<quintptr>();
return reinterpret_cast<T *>(ptr);
}
diff --git a/src/lib/corelib/tools/set.h b/src/lib/corelib/tools/set.h
index 322074b0d..eb3bf6632 100644
--- a/src/lib/corelib/tools/set.h
+++ b/src/lib/corelib/tools/set.h
@@ -179,8 +179,8 @@ template<typename T> Set<T>::Set(const std::initializer_list<T> &list) : m_data(
template<typename T> Set<T> &Set<T>::intersect(const Set<T> &other)
{
- iterator it = begin();
- const_iterator otherIt = other.cbegin();
+ auto it = begin();
+ auto otherIt = other.cbegin();
while (it != end()) {
if (otherIt == other.cend()) {
m_data.erase(it, end());
@@ -207,8 +207,8 @@ template<typename T> std::pair<typename Set<T>::iterator, bool> Set<T>::insert(c
template<typename T> bool Set<T>::contains(const Set<T> &other) const
{
- const_iterator it = cbegin();
- const_iterator otherIt = other.cbegin();
+ auto it = cbegin();
+ auto otherIt = other.cbegin();
while (otherIt != other.cend()) {
if (it == cend() || *otherIt < *it)
return false;
diff --git a/src/lib/corelib/tools/settingscreator.cpp b/src/lib/corelib/tools/settingscreator.cpp
index 8479a67dc..eaaf2802c 100644
--- a/src/lib/corelib/tools/settingscreator.cpp
+++ b/src/lib/corelib/tools/settingscreator.cpp
@@ -1,3 +1,5 @@
+#include <utility>
+
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
@@ -56,8 +58,9 @@ static QSettings::Format format()
}
-SettingsCreator::SettingsCreator(const QString &baseDir)
- : m_settingsBaseDir(baseDir), m_qbsVersion(Version::fromString(QLatin1String(QBS_VERSION)))
+SettingsCreator::SettingsCreator(QString baseDir)
+ : m_settingsBaseDir(std::move(baseDir))
+ , m_qbsVersion(Version::fromString(QLatin1String(QBS_VERSION)))
{
}
@@ -102,7 +105,8 @@ void SettingsCreator::migrate()
// that's only preferences.qbsSearchPaths as written by libqtprofilesetup, but we don't want
// to hardcode that here.
m_settings.reset(new QSettings(m_newSettingsFilePath, format()));
- for (const QString &key : m_settings->allKeys()) {
+ const auto allKeys = m_settings->allKeys();
+ for (const QString &key : allKeys) {
QVariant v = m_settings->value(key);
if (v.type() == QVariant::String) {
QString s = v.toString();
diff --git a/src/lib/corelib/tools/settingscreator.h b/src/lib/corelib/tools/settingscreator.h
index 6bc2a5cb7..39da80a7f 100644
--- a/src/lib/corelib/tools/settingscreator.h
+++ b/src/lib/corelib/tools/settingscreator.h
@@ -56,7 +56,7 @@ namespace Internal {
class SettingsCreator
{
public:
- SettingsCreator(const QString &baseDir);
+ SettingsCreator(QString baseDir);
QSettings *getQSettings();
diff --git a/src/lib/corelib/tools/settingsmodel.cpp b/src/lib/corelib/tools/settingsmodel.cpp
index 4a90773eb..d67f1da5c 100644
--- a/src/lib/corelib/tools/settingsmodel.cpp
+++ b/src/lib/corelib/tools/settingsmodel.cpp
@@ -327,7 +327,8 @@ void SettingsModel::SettingsModelPrivate::readSettings()
{
qDeleteAll(rootNode.children);
rootNode.children.clear();
- for (const QString &topLevelKey : settings->directChildren(QString(), scope()))
+ const auto topLevelKeys = settings->directChildren(QString(), scope());
+ for (const QString &topLevelKey : topLevelKeys)
addNodeFromSettings(&rootNode, topLevelKey);
for (QVariantMap::ConstIterator it = additionalProperties.constBegin();
it != additionalProperties.constEnd(); ++it) {
@@ -353,7 +354,8 @@ void SettingsModel::SettingsModelPrivate::addNodeFromSettings(Node *parentNode,
= fullyQualifiedName.mid(fullyQualifiedName.lastIndexOf(QLatin1Char('.')) + 1);
Node * const node = createNode(parentNode, nodeName);
node->value = settingsValueToRepresentation(settings->value(fullyQualifiedName, scope()));
- for (const QString &childKey : settings->directChildren(fullyQualifiedName, scope()))
+ const auto childKeys = settings->directChildren(fullyQualifiedName, scope());
+ for (const QString &childKey : childKeys)
addNodeFromSettings(node, fullyQualifiedName + QLatin1Char('.') + childKey);
dirty = true;
}
diff --git a/src/lib/corelib/tools/settingsmodel.h b/src/lib/corelib/tools/settingsmodel.h
index 27936ba52..1bd59737c 100644
--- a/src/lib/corelib/tools/settingsmodel.h
+++ b/src/lib/corelib/tools/settingsmodel.h
@@ -53,7 +53,7 @@ class QBS_EXPORT SettingsModel : public QAbstractItemModel
Q_OBJECT
public:
SettingsModel(const QString &settingsDir, Settings::Scope scope, QObject *parent = nullptr);
- ~SettingsModel();
+ ~SettingsModel() override;
int keyColumn() const { return 0; }
int valueColumn() const { return 1; }
diff --git a/src/lib/corelib/tools/setupprojectparameters.cpp b/src/lib/corelib/tools/setupprojectparameters.cpp
index 6b13570d7..6d817c8f3 100644
--- a/src/lib/corelib/tools/setupprojectparameters.cpp
+++ b/src/lib/corelib/tools/setupprojectparameters.cpp
@@ -109,6 +109,8 @@ SetupProjectParameters::SetupProjectParameters(const SetupProjectParameters &oth
{
}
+SetupProjectParameters::SetupProjectParameters(SetupProjectParameters &&other) Q_DECL_NOEXCEPT = default;
+
SetupProjectParameters::~SetupProjectParameters()
{
}
@@ -119,6 +121,8 @@ SetupProjectParameters &SetupProjectParameters::operator=(const SetupProjectPara
return *this;
}
+SetupProjectParameters &SetupProjectParameters::operator=(SetupProjectParameters &&other) Q_DECL_NOEXCEPT = default;
+
/*!
* \brief Returns the name of the top-level profile for building the project.
*/
diff --git a/src/lib/corelib/tools/setupprojectparameters.h b/src/lib/corelib/tools/setupprojectparameters.h
index c462ca212..cf3b200cb 100644
--- a/src/lib/corelib/tools/setupprojectparameters.h
+++ b/src/lib/corelib/tools/setupprojectparameters.h
@@ -65,9 +65,11 @@ class QBS_EXPORT SetupProjectParameters
public:
SetupProjectParameters();
SetupProjectParameters(const SetupProjectParameters &other);
+ SetupProjectParameters(SetupProjectParameters &&other) Q_DECL_NOEXCEPT;
~SetupProjectParameters();
SetupProjectParameters &operator=(const SetupProjectParameters &other);
+ SetupProjectParameters &operator=(SetupProjectParameters &&other) Q_DECL_NOEXCEPT;
QString topLevelProfile() const;
void setTopLevelProfile(const QString &profile);
diff --git a/src/lib/corelib/tools/shellutils.h b/src/lib/corelib/tools/shellutils.h
index c148db4b8..6f1d82afb 100644
--- a/src/lib/corelib/tools/shellutils.h
+++ b/src/lib/corelib/tools/shellutils.h
@@ -83,7 +83,7 @@ private:
bool shouldQuote = true;
};
- bool m_isRawProgram;
+ bool m_isRawProgram = false;
QString m_program;
std::vector<Argument> m_arguments;
};
diff --git a/src/lib/corelib/tools/vsenvironmentdetector.cpp b/src/lib/corelib/tools/vsenvironmentdetector.cpp
index b91a8ff74..90f6b8921 100644
--- a/src/lib/corelib/tools/vsenvironmentdetector.cpp
+++ b/src/lib/corelib/tools/vsenvironmentdetector.cpp
@@ -69,8 +69,9 @@ static QString windowsSystem32Path()
return {};
}
-VsEnvironmentDetector::VsEnvironmentDetector()
+VsEnvironmentDetector::VsEnvironmentDetector(QString vcvarsallPath)
: m_windowsSystemDirPath(windowsSystem32Path())
+ , m_vcvarsallPath(std::move(vcvarsallPath))
{
}
@@ -137,7 +138,15 @@ QString VsEnvironmentDetector::findVcVarsAllBat(const MSVC &msvc,
bool VsEnvironmentDetector::startDetection(const std::vector<MSVC *> &compatibleMSVCs)
{
std::vector<QString> searchedPaths;
- const QString vcvarsallbat = findVcVarsAllBat(**compatibleMSVCs.begin(), searchedPaths);
+
+ if (!m_vcvarsallPath.isEmpty() && !QFileInfo::exists(m_vcvarsallPath)) {
+ m_errorString = Tr::tr("%1 does not exist.").arg(m_vcvarsallPath);
+ return false;
+ }
+
+ const auto vcvarsallbat = !m_vcvarsallPath.isEmpty()
+ ? m_vcvarsallPath
+ : findVcVarsAllBat(**compatibleMSVCs.begin(), searchedPaths);
if (vcvarsallbat.isEmpty()) {
if (!searchedPaths.empty()) {
m_errorString = Tr::tr(
@@ -201,9 +210,12 @@ static QString vcArchitecture(const MSVC *msvc)
if (msvc->architecture == StringConstants::x86_64Arch())
vcArch = StringConstants::amd64Arch();
- for (const QString &hostPrefix :
- QStringList({StringConstants::x86Arch(), QStringLiteral("amd64_"),
- QStringLiteral("x86_")})) {
+ const QString hostPrefixes[] = {
+ StringConstants::x86Arch(),
+ QStringLiteral("amd64_"),
+ QStringLiteral("x86_")
+ };
+ for (const QString &hostPrefix : hostPrefixes) {
if (QFile::exists(msvc->clPathForArchitecture(hostPrefix + vcArch))) {
vcArch.prepend(hostPrefix);
break;
@@ -237,7 +249,8 @@ void VsEnvironmentDetector::parseBatOutput(const QByteArray &output, std::vector
{
QString arch;
QProcessEnvironment *targetEnv = nullptr;
- for (QByteArray line : output.split('\n')) {
+ const auto lines = output.split('\n');
+ for (QByteArray line : lines) {
line = line.trimmed();
if (line.isEmpty())
continue;
diff --git a/src/lib/corelib/tools/vsenvironmentdetector.h b/src/lib/corelib/tools/vsenvironmentdetector.h
index 1970273ee..7fa152cb6 100644
--- a/src/lib/corelib/tools/vsenvironmentdetector.h
+++ b/src/lib/corelib/tools/vsenvironmentdetector.h
@@ -57,7 +57,7 @@ class MSVC;
class QBS_EXPORT VsEnvironmentDetector
{
public:
- VsEnvironmentDetector();
+ explicit VsEnvironmentDetector(QString vcvarsallPath = QString());
bool start(MSVC *msvc);
bool start(std::vector<MSVC *> msvcs);
@@ -70,6 +70,7 @@ private:
void parseBatOutput(const QByteArray &output, std::vector<MSVC *> msvcs);
const QString m_windowsSystemDirPath;
+ const QString m_vcvarsallPath;
QString m_errorString;
};
diff --git a/src/libexec/qbs_processlauncher/launchersockethandler.cpp b/src/libexec/qbs_processlauncher/launchersockethandler.cpp
index a6f7843ec..53bd81a9a 100644
--- a/src/libexec/qbs_processlauncher/launchersockethandler.cpp
+++ b/src/libexec/qbs_processlauncher/launchersockethandler.cpp
@@ -97,9 +97,9 @@ private:
enum class StopState { Inactive, Terminating, Killing } m_stopState = StopState::Inactive;
};
-LauncherSocketHandler::LauncherSocketHandler(const QString &serverPath, QObject *parent)
+LauncherSocketHandler::LauncherSocketHandler(QString serverPath, QObject *parent)
: QObject(parent),
- m_serverPath(serverPath),
+ m_serverPath(std::move(serverPath)),
m_socket(new QLocalSocket(this))
{
m_packetParser.setDevice(m_socket);
diff --git a/src/libexec/qbs_processlauncher/launchersockethandler.h b/src/libexec/qbs_processlauncher/launchersockethandler.h
index e96c02e13..b2d571870 100644
--- a/src/libexec/qbs_processlauncher/launchersockethandler.h
+++ b/src/libexec/qbs_processlauncher/launchersockethandler.h
@@ -58,8 +58,8 @@ class LauncherSocketHandler : public QObject
{
Q_OBJECT
public:
- explicit LauncherSocketHandler(const QString &socketPath, QObject *parent = nullptr);
- ~LauncherSocketHandler();
+ explicit LauncherSocketHandler(QString socketPath, QObject *parent = nullptr);
+ ~LauncherSocketHandler() override;
void start();
diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp b/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp
index 0f94f2b2b..bc13ec480 100644
--- a/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp
+++ b/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp
@@ -69,14 +69,18 @@ QString ClangCompilationDatabaseGenerator::generatorName() const
void ClangCompilationDatabaseGenerator::generate()
{
- for (const Project &theProject : project().projects.values()) {
+ const auto projects = project().projects.values();
+ for (const Project &theProject : projects) {
QJsonArray database;
const ProjectData projectData = theProject.projectData();
const QString buildDir = projectData.buildDirectory();
- for (const ProductData &productData : projectData.allProducts()) {
- for (const GroupData &groupData : productData.groups()) {
- for (const ArtifactData &sourceArtifact : groupData.allSourceArtifacts()) {
+ const auto products = projectData.allProducts();
+ for (const ProductData &productData : products) {
+ const auto groups = productData.groups();
+ for (const GroupData &groupData : groups) {
+ const auto sourceArtifacts = groupData.allSourceArtifacts();
+ for (const ArtifactData &sourceArtifact : sourceArtifacts) {
if (!hasValidInputFileTag(sourceArtifact.fileTags()))
continue;
diff --git a/src/plugins/generator/makefilegenerator/makefilegenerator.cpp b/src/plugins/generator/makefilegenerator/makefilegenerator.cpp
index f186b5244..24aff5a33 100644
--- a/src/plugins/generator/makefilegenerator/makefilegenerator.cpp
+++ b/src/plugins/generator/makefilegenerator/makefilegenerator.cpp
@@ -156,7 +156,8 @@ static QString removeCommand()
void qbs::MakefileGenerator::generate()
{
- for (const Project &theProject : project().projects.values()) {
+ const auto projects = project().projects.values();
+ for (const Project &theProject : projects) {
const QString makefileFilePath = theProject.projectData().buildDirectory()
+ QLatin1String("/Makefile");
QFile makefile(makefileFilePath);
@@ -241,16 +242,19 @@ void qbs::MakefileGenerator::generate()
allDefaultTargets.push_back(productTarget);
allTargets.push_back(productTarget);
stream << productTarget << ':';
- for (const ArtifactData &ta : productData.targetArtifacts())
+ const auto targetArtifacts = productData.targetArtifacts();
+ for (const ArtifactData &ta : targetArtifacts)
stream << ' ' << transformedOutputFilePath(ta);
stream << '\n';
for (const TransformerData &transformerData : productTransformerData) {
stream << transformedOutputFilePath(transformerData.outputs().constFirst()) << ":";
- for (const ArtifactData &input : transformerData.inputs())
+ const auto inputs = transformerData.inputs();
+ for (const ArtifactData &input : inputs)
stream << ' ' << transformedArtifactFilePath(input);
stream << '\n';
Set<QString> createdDirs;
- for (const ArtifactData &output : transformerData.outputs()) {
+ const auto outputs = transformerData.outputs();
+ for (const ArtifactData &output : outputs) {
const QString outputDir = QFileInfo(output.filePath()).path();
if (createdDirs.insert(outputDir).second)
stream << "\t" << mkdirCmdLine(QDir::toNativeSeparators(
@@ -258,7 +262,8 @@ void qbs::MakefileGenerator::generate()
<< '\n';
}
bool processCommandEncountered = false;
- for (const RuleCommand &command : transformerData.commands()) {
+ const auto commands = transformerData.commands();
+ for (const RuleCommand &command : commands) {
if (command.type() == RuleCommand::JavaScriptCommandType) {
jsCommandsEncountered = true;
continue;
@@ -268,7 +273,8 @@ void qbs::MakefileGenerator::generate()
quote(bruteForcePathReplace(command.executable(), srcDir,
buildDir, installRoot)));
// TODO: Optionally use environment?
- for (const QString &arg : command.arguments()) {
+ const auto args = command.arguments();
+ for (const QString &arg : args) {
stream << ' '
<< quote(bruteForcePathReplace(arg, srcDir, buildDir, installRoot));
}
@@ -279,13 +285,15 @@ void qbs::MakefileGenerator::generate()
<< transformedOutputFilePath(transformerData.outputs().at(i-1)) << '\n';
}
if (!processCommandEncountered && builtByDefault) {
- for (const ArtifactData &output : transformerData.outputs())
+ const auto outputs = transformerData.outputs();
+ for (const ArtifactData &output : outputs)
filesCreatedByJsCommands.push_back(output.filePath());
}
}
stream << "install-" << productTarget << ": " << productTarget << '\n';
Set<QString> createdDirs;
- for (const ArtifactData &artifact : productData.installableArtifacts()) {
+ const auto installableArtifacts = productData.installableArtifacts();
+ for (const ArtifactData &artifact : installableArtifacts) {
const QString &outputDir = artifact.installData().localInstallDir();
if (outputDir.contains(QLatin1Char(' '))) {
logger().qbsWarning() << Tr::tr("Skipping installation of '%1', because "
@@ -311,7 +319,8 @@ void qbs::MakefileGenerator::generate()
<< transformedInputFilePath << ' ' << transformedOutputDir << '\n';
}
stream << "clean-" << productTarget << ":\n";
- for (const ArtifactData &artifact : productData.generatedArtifacts()) {
+ const auto generatedArtifacts = productData.generatedArtifacts();
+ for (const ArtifactData &artifact : generatedArtifacts) {
const QFileInfo fileInfo(artifact.filePath());
const QString transformedFilePath = QDir::toNativeSeparators(
prefixifiedBuildDirPath(fileInfo.path())
@@ -324,15 +333,15 @@ void qbs::MakefileGenerator::generate()
}
stream << "all:";
- for (const QString &target : allDefaultTargets)
+ for (const QString &target : qAsConst(allDefaultTargets))
stream << ' ' << target;
stream << '\n';
stream << "install:";
- for (const QString &target : allDefaultTargets)
+ for (const QString &target : qAsConst(allDefaultTargets))
stream << ' ' << "install-" << target;
stream << '\n';
stream << "clean:";
- for (const QString &target : allTargets)
+ for (const QString &target : qAsConst(allTargets))
stream << ' ' << "clean-" << target;
stream << '\n';
if (!filesCreatedByJsCommands.empty()) {
diff --git a/src/plugins/generator/visualstudio/io/msbuildprojectwriter.cpp b/src/plugins/generator/visualstudio/io/msbuildprojectwriter.cpp
index c5684e5ba..634bb2381 100644
--- a/src/plugins/generator/visualstudio/io/msbuildprojectwriter.cpp
+++ b/src/plugins/generator/visualstudio/io/msbuildprojectwriter.cpp
@@ -51,7 +51,7 @@ static const QString kMSBuildSchemaURI =
class MSBuildProjectWriterPrivate : public IMSBuildNodeVisitor
{
public:
- std::ostream *device;
+ std::ostream *device = nullptr;
QByteArray buffer;
std::unique_ptr<QXmlStreamWriter> writer;
diff --git a/src/plugins/generator/visualstudio/io/visualstudiosolutionwriter.cpp b/src/plugins/generator/visualstudio/io/visualstudiosolutionwriter.cpp
index 4c0495316..e980249d6 100644
--- a/src/plugins/generator/visualstudio/io/visualstudiosolutionwriter.cpp
+++ b/src/plugins/generator/visualstudio/io/visualstudiosolutionwriter.cpp
@@ -54,7 +54,7 @@ using namespace Internal;
class VisualStudioSolutionWriterPrivate
{
public:
- std::ostream *device;
+ std::ostream *device = nullptr;
std::string baseDir;
};
@@ -87,7 +87,8 @@ bool VisualStudioSolutionWriter::write(const VisualStudioSolution *solution)
<< solution->versionInfo().version().majorVersion()
<< u8"\n";
- for (const auto &project : solution->fileProjects()) {
+ const auto fileProjects = solution->fileProjects();
+ for (const auto &project : fileProjects) {
auto projectFilePath = project->filePath().toStdString();
// Try to make the project file path relative to the
@@ -126,7 +127,8 @@ bool VisualStudioSolutionWriter::write(const VisualStudioSolution *solution)
out << u8"EndProject\n";
}
- for (const auto &project : solution->folderProjects()) {
+ const auto folderProjects = solution->folderProjects();
+ for (const auto &project : folderProjects) {
out << u8"Project(\""
<< project->projectTypeGuid().toString().toStdString()
<< u8"\") = \""
@@ -142,7 +144,8 @@ bool VisualStudioSolutionWriter::write(const VisualStudioSolution *solution)
out << u8"Global\n";
- for (const auto &globalSection : solution->globalSections()) {
+ const auto globalSections = solution->globalSections();
+ for (const auto &globalSection : globalSections) {
out << u8"\tGlobalSection("
<< globalSection->name().toStdString()
<< u8") = "
diff --git a/src/plugins/generator/visualstudio/msbuild/imsbuildgroup.h b/src/plugins/generator/visualstudio/msbuild/imsbuildgroup.h
index 848c855ef..3d9115643 100644
--- a/src/plugins/generator/visualstudio/msbuild/imsbuildgroup.h
+++ b/src/plugins/generator/visualstudio/msbuild/imsbuildgroup.h
@@ -45,7 +45,7 @@ class IMSBuildGroup : public QObject
Q_OBJECT
public:
explicit IMSBuildGroup(MSBuildProject *parent = nullptr);
- virtual ~IMSBuildGroup();
+ ~IMSBuildGroup() override;
QString condition() const;
void setCondition(const QString &condition);
diff --git a/src/plugins/generator/visualstudio/msbuild/imsbuildproperty.h b/src/plugins/generator/visualstudio/msbuild/imsbuildproperty.h
index 2e9405dfa..13f26f070 100644
--- a/src/plugins/generator/visualstudio/msbuild/imsbuildproperty.h
+++ b/src/plugins/generator/visualstudio/msbuild/imsbuildproperty.h
@@ -47,7 +47,7 @@ protected:
explicit IMSBuildProperty(QObject *parent = nullptr);
public:
- virtual ~IMSBuildProperty();
+ ~IMSBuildProperty() override;
QString condition() const;
void setCondition(const QString &condition);
diff --git a/src/plugins/generator/visualstudio/msbuild/items/msbuildfileitem.h b/src/plugins/generator/visualstudio/msbuild/items/msbuildfileitem.h
index df1fc8201..f34ac119a 100644
--- a/src/plugins/generator/visualstudio/msbuild/items/msbuildfileitem.h
+++ b/src/plugins/generator/visualstudio/msbuild/items/msbuildfileitem.h
@@ -40,7 +40,7 @@ class MSBuildFileItemPrivate;
class MSBuildFileItem : public MSBuildItem
{
public:
- virtual ~MSBuildFileItem();
+ ~MSBuildFileItem() override;
QString filePath() const;
void setFilePath(const QString &filePath);
diff --git a/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.cpp b/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.cpp
index 3a5d98a98..f7c506651 100644
--- a/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.cpp
+++ b/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.cpp
@@ -44,8 +44,8 @@ public:
QList<QString> extensions;
bool parseFiles = true;
bool sourceControlFiles = true;
- MSBuildItemMetadata *identifierMetadata;
- MSBuildItemMetadata *extensionsMetadata;
+ MSBuildItemMetadata *identifierMetadata = nullptr;
+ MSBuildItemMetadata *extensionsMetadata = nullptr;
};
MSBuildFilter::MSBuildFilter(IMSBuildItemGroup *parent)
diff --git a/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.h b/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.h
index 59be8d5fe..fb977f1cc 100644
--- a/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.h
+++ b/src/plugins/generator/visualstudio/msbuild/items/msbuildfilter.h
@@ -45,7 +45,7 @@ public:
explicit MSBuildFilter(IMSBuildItemGroup *parent = nullptr);
MSBuildFilter(const QString &name, const QList<QString> &extensions,
IMSBuildItemGroup *parent = nullptr);
- ~MSBuildFilter();
+ ~MSBuildFilter() override;
QUuid identifier() const;
void setIdentifier(const QUuid &identifier);
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildimport.h b/src/plugins/generator/visualstudio/msbuild/msbuildimport.h
index a6e4c4488..65f9bc056 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuildimport.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuildimport.h
@@ -53,7 +53,7 @@ class MSBuildImport : public QObject, public IMSBuildNode
public:
explicit MSBuildImport(MSBuildProject *parent);
explicit MSBuildImport(MSBuildImportGroup *parent);
- virtual ~MSBuildImport();
+ ~MSBuildImport() override;
QString project() const;
void setProject(const QString &project);
@@ -61,7 +61,7 @@ public:
QString condition() const;
void setCondition(const QString &condition);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
private:
std::unique_ptr<MSBuildImportPrivate> d;
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp b/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp
index 56c48049e..73e1922db 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp
+++ b/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp
@@ -66,7 +66,7 @@ void MSBuildImportGroup::accept(IMSBuildNodeVisitor *visitor) const
visitor->visitStart(this);
for (const auto &child : children()) {
- if (const MSBuildImport *import = qobject_cast<const MSBuildImport *>(child))
+ if (const auto import = qobject_cast<const MSBuildImport *>(child))
import->accept(visitor);
}
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.h b/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.h
index 829f5dd08..a21cb5a54 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.h
@@ -50,12 +50,12 @@ class MSBuildImportGroup : public IMSBuildGroup, public IMSBuildNode
Q_DISABLE_COPY(MSBuildImportGroup)
public:
explicit MSBuildImportGroup(MSBuildProject *parent = nullptr);
- virtual ~MSBuildImportGroup();
+ ~MSBuildImportGroup() override;
QString label() const;
void setLabel(const QString &label);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
private:
std::unique_ptr<MSBuildImportGroupPrivate> d;
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp b/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp
index 9a2ffb734..b11b62295 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp
+++ b/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp
@@ -85,7 +85,7 @@ void MSBuildItem::accept(IMSBuildNodeVisitor *visitor) const
visitor->visitStart(this);
for (const auto &child : children()) {
- if (MSBuildItemMetadata *itemMetadata = qobject_cast<MSBuildItemMetadata *>(child))
+ if (const auto itemMetadata = qobject_cast<const MSBuildItemMetadata *>(child))
itemMetadata->accept(visitor);
}
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuilditem.h b/src/plugins/generator/visualstudio/msbuild/msbuilditem.h
index 48c07f9e7..d01a357a2 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuilditem.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuilditem.h
@@ -53,7 +53,7 @@ class MSBuildItem : public QObject, public IMSBuildNode
Q_OBJECT
public:
explicit MSBuildItem(const QString &name, IMSBuildItemGroup *parent = nullptr);
- virtual ~MSBuildItem();
+ ~MSBuildItem() override;
QString name() const;
void setName(const QString &name);
@@ -63,7 +63,7 @@ public:
void appendProperty(const QString &name, const QVariant &value);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
private:
std::unique_ptr<MSBuildItemPrivate> d;
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuilditemdefinitiongroup.h b/src/plugins/generator/visualstudio/msbuild/msbuilditemdefinitiongroup.h
index 4fb95c4c6..3c324699d 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuilditemdefinitiongroup.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuilditemdefinitiongroup.h
@@ -49,9 +49,9 @@ class MSBuildItemDefinitionGroup : public IMSBuildItemGroup, public IMSBuildNode
Q_OBJECT
public:
explicit MSBuildItemDefinitionGroup(MSBuildProject *parent = nullptr);
- ~MSBuildItemDefinitionGroup();
+ ~MSBuildItemDefinitionGroup() override;
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
};
} // namespace qbs
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuilditemgroup.h b/src/plugins/generator/visualstudio/msbuild/msbuilditemgroup.h
index a77e55e57..bbbdb0e69 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuilditemgroup.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuilditemgroup.h
@@ -52,12 +52,12 @@ class MSBuildItemGroup : public IMSBuildItemGroup, public IMSBuildNode
Q_DISABLE_COPY(MSBuildItemGroup)
public:
explicit MSBuildItemGroup(MSBuildProject *parent = nullptr);
- ~MSBuildItemGroup();
+ ~MSBuildItemGroup() override;
QString label() const;
void setLabel(const QString &label);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
private:
std::unique_ptr<MSBuildItemGroupPrivate> d;
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuilditemmetadata.h b/src/plugins/generator/visualstudio/msbuild/msbuilditemmetadata.h
index f1768b286..09da2649c 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuilditemmetadata.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuilditemmetadata.h
@@ -52,7 +52,7 @@ public:
MSBuildItemMetadata(const QString &name, const QVariant &value = QVariant(),
MSBuildItem *parent = nullptr);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
};
} // namespace qbs
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildproject.h b/src/plugins/generator/visualstudio/msbuild/msbuildproject.h
index 820c0ecbd..5281f615d 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuildproject.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuildproject.h
@@ -51,7 +51,7 @@ class MSBuildProject : public QObject, public IMSBuildNode
Q_DISABLE_COPY(MSBuildProject)
public:
explicit MSBuildProject(QObject *parent = nullptr);
- ~MSBuildProject();
+ ~MSBuildProject() override;
QString defaultTargets() const;
void setDefaultTargets(const QString &defaultTargets);
@@ -59,7 +59,7 @@ public:
QString toolsVersion() const;
void setToolsVersion(const QString &toolsVersion);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
private:
std::unique_ptr<MSBuildProjectPrivate> d;
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildproperty.h b/src/plugins/generator/visualstudio/msbuild/msbuildproperty.h
index f1382406c..de2c52394 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuildproperty.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuildproperty.h
@@ -51,7 +51,7 @@ public:
MSBuildProperty(const QString &name, const QVariant &value = QVariant(),
MSBuildPropertyGroup *parent = nullptr);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
};
} // namespace qbs
diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildpropertygroup.h b/src/plugins/generator/visualstudio/msbuild/msbuildpropertygroup.h
index c3289457c..60bdb008e 100644
--- a/src/plugins/generator/visualstudio/msbuild/msbuildpropertygroup.h
+++ b/src/plugins/generator/visualstudio/msbuild/msbuildpropertygroup.h
@@ -50,14 +50,14 @@ class MSBuildPropertyGroup : public IMSBuildGroup, public IMSBuildNode
Q_DISABLE_COPY(MSBuildPropertyGroup)
public:
explicit MSBuildPropertyGroup(MSBuildProject *parent = nullptr);
- ~MSBuildPropertyGroup();
+ ~MSBuildPropertyGroup() override;
QString label() const;
void setLabel(const QString &label);
void appendProperty(const QString &name, const QVariant &value);
- void accept(IMSBuildNodeVisitor *visitor) const;
+ void accept(IMSBuildNodeVisitor *visitor) const override;
private:
std::unique_ptr<MSBuildPropertyGroupPrivate> d;
diff --git a/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp b/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp
index 7d633ca44..1cd2573c3 100644
--- a/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp
+++ b/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp
@@ -45,8 +45,6 @@
namespace qbs {
-namespace {
-
static QStringList sourceFileExtensions()
{
return {QStringLiteral("c"), QStringLiteral("C"), QStringLiteral("cpp"),
@@ -91,8 +89,6 @@ static bool matchesFilter(const MSBuildFilter *filter, const QString &filePath)
return filter->extensions().contains(QFileInfo(filePath).completeSuffix());
}
-}
-
MSBuildFiltersProject::MSBuildFiltersProject(const GeneratableProductData &product,
QObject *parent)
: MSBuildProject(parent)
@@ -110,8 +106,10 @@ MSBuildFiltersProject::MSBuildFiltersProject(const GeneratableProductData &produ
}
Internal::Set<QString> allFiles;
- for (const auto &productData : product.data.values()) {
- for (const auto &groupData : productData.groups())
+ const auto productDatas = product.data.values();
+ for (const auto &productData : productDatas) {
+ const auto groups = productData.groups();
+ for (const auto &groupData : groups)
if (groupData.isEnabled())
allFiles.unite(Internal::Set<QString>::fromList(groupData.allFilePaths()));
}
diff --git a/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp b/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp
index ed41dfb33..2d679ceb1 100644
--- a/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp
+++ b/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp
@@ -176,7 +176,8 @@ void MSBuildQbsProductProject::addConfiguration(const GeneratableProject &projec
.runEnvironment();
if (!env.isEmpty()) {
const auto systemEnv = QProcessEnvironment::systemEnvironment();
- for (const auto &key : systemEnv.keys()) {
+ const auto keys = systemEnv.keys();
+ for (const auto &key : keys) {
if (!env.contains(key))
continue;
@@ -364,8 +365,10 @@ void MSBuildQbsProductProject::addFiles(const GeneratableProject &project,
QMapIterator<QString, qbs::ProductData> productDataIt(product.data);
while (productDataIt.hasNext()) {
productDataIt.next();
- for (const auto &group : productDataIt.value().groups()) {
- for (const auto &sourceArtifact : group.allSourceArtifacts()) {
+ const auto groups = productDataIt.value().groups();
+ for (const auto &group : groups) {
+ const auto sourceArtifacts = group.allSourceArtifacts();
+ for (const auto &sourceArtifact : sourceArtifacts) {
const auto filePath = sourceArtifact.filePath();
if (sourceFileNodes.find(filePath) == sourceFileNodes.end()) {
sourceFileNodes.insert({
diff --git a/src/plugins/generator/visualstudio/msbuildtargetproject.cpp b/src/plugins/generator/visualstudio/msbuildtargetproject.cpp
index 08315cc08..154f8dccc 100644
--- a/src/plugins/generator/visualstudio/msbuildtargetproject.cpp
+++ b/src/plugins/generator/visualstudio/msbuildtargetproject.cpp
@@ -46,8 +46,8 @@ class MSBuildTargetProjectPrivate
public:
MSBuildTargetProjectPrivate(const Internal::VisualStudioVersionInfo &versionInfo)
: versionInfo(versionInfo) {}
- MSBuildPropertyGroup *globalsPropertyGroup;
- MSBuildProperty *projectGuidProperty;
+ MSBuildPropertyGroup *globalsPropertyGroup = nullptr;
+ MSBuildProperty *projectGuidProperty = nullptr;
const Internal::VisualStudioVersionInfo &versionInfo;
};
diff --git a/src/plugins/generator/visualstudio/msbuildtargetproject.h b/src/plugins/generator/visualstudio/msbuildtargetproject.h
index 647f0dc91..496441a88 100644
--- a/src/plugins/generator/visualstudio/msbuildtargetproject.h
+++ b/src/plugins/generator/visualstudio/msbuildtargetproject.h
@@ -53,7 +53,7 @@ protected:
VisualStudioGenerator *parent = nullptr);
public:
- ~MSBuildTargetProject();
+ ~MSBuildTargetProject() override;
const Internal::VisualStudioVersionInfo &versionInfo() const;
diff --git a/src/plugins/generator/visualstudio/solution/ivisualstudiosolutionproject.h b/src/plugins/generator/visualstudio/solution/ivisualstudiosolutionproject.h
index b53f39ee1..6f8574aed 100644
--- a/src/plugins/generator/visualstudio/solution/ivisualstudiosolutionproject.h
+++ b/src/plugins/generator/visualstudio/solution/ivisualstudiosolutionproject.h
@@ -48,7 +48,7 @@ protected:
explicit IVisualStudioSolutionProject(QObject *parent = nullptr);
public:
- virtual ~IVisualStudioSolutionProject();
+ ~IVisualStudioSolutionProject() override;
virtual QUuid projectTypeGuid() const = 0;
diff --git a/src/plugins/generator/visualstudio/solution/visualstudiosolution.cpp b/src/plugins/generator/visualstudio/solution/visualstudiosolution.cpp
index fbd6a3848..c09ef1f4f 100644
--- a/src/plugins/generator/visualstudio/solution/visualstudiosolution.cpp
+++ b/src/plugins/generator/visualstudio/solution/visualstudiosolution.cpp
@@ -74,7 +74,7 @@ QList<IVisualStudioSolutionProject *> VisualStudioSolution::projects() const
QList<VisualStudioSolutionFileProject *> VisualStudioSolution::fileProjects() const
{
QList<VisualStudioSolutionFileProject *> list;
- for (const auto &project : d->projects)
+ for (const auto &project : qAsConst(d->projects))
if (auto fileProject = qobject_cast<VisualStudioSolutionFileProject *>(project))
list.push_back(fileProject);
return list;
@@ -83,7 +83,7 @@ QList<VisualStudioSolutionFileProject *> VisualStudioSolution::fileProjects() co
QList<VisualStudioSolutionFolderProject *> VisualStudioSolution::folderProjects() const
{
QList<VisualStudioSolutionFolderProject *> list;
- for (const auto &project : d->projects)
+ for (const auto &project : qAsConst(d->projects))
if (auto folderProject = qobject_cast<VisualStudioSolutionFolderProject *>(project))
list.push_back(folderProject);
return list;
diff --git a/src/plugins/generator/visualstudio/solution/visualstudiosolution.h b/src/plugins/generator/visualstudio/solution/visualstudiosolution.h
index 67fcbbe01..ba304c00c 100644
--- a/src/plugins/generator/visualstudio/solution/visualstudiosolution.h
+++ b/src/plugins/generator/visualstudio/solution/visualstudiosolution.h
@@ -55,7 +55,7 @@ class VisualStudioSolution : public QObject
public:
explicit VisualStudioSolution(const Internal::VisualStudioVersionInfo &versionInfo,
QObject *parent = nullptr);
- ~VisualStudioSolution();
+ ~VisualStudioSolution() override;
Internal::VisualStudioVersionInfo versionInfo() const;
diff --git a/src/plugins/generator/visualstudio/solution/visualstudiosolutionfileproject.h b/src/plugins/generator/visualstudio/solution/visualstudiosolutionfileproject.h
index 22848b8fb..2039146b6 100644
--- a/src/plugins/generator/visualstudio/solution/visualstudiosolutionfileproject.h
+++ b/src/plugins/generator/visualstudio/solution/visualstudiosolutionfileproject.h
@@ -45,7 +45,7 @@ class VisualStudioSolutionFileProject : public IVisualStudioSolutionProject
Q_OBJECT
public:
explicit VisualStudioSolutionFileProject(const QString &filePath, QObject *parent = nullptr);
- ~VisualStudioSolutionFileProject();
+ ~VisualStudioSolutionFileProject() override;
QString name() const override;
diff --git a/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.h b/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.h
index 3cc8a8702..6d383e7d4 100644
--- a/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.h
+++ b/src/plugins/generator/visualstudio/solution/visualstudiosolutionglobalsection.h
@@ -45,7 +45,7 @@ class VisualStudioSolutionGlobalSection : public QObject
Q_DISABLE_COPY(VisualStudioSolutionGlobalSection)
public:
explicit VisualStudioSolutionGlobalSection(const QString &name, QObject *parent = nullptr);
- ~VisualStudioSolutionGlobalSection();
+ ~VisualStudioSolutionGlobalSection() override;
QString name() const;
void setName(const QString &name);
diff --git a/src/plugins/generator/visualstudio/visualstudiogenerator.cpp b/src/plugins/generator/visualstudio/visualstudiogenerator.cpp
index 47f0363a6..ace55b6e6 100644
--- a/src/plugins/generator/visualstudio/visualstudiogenerator.cpp
+++ b/src/plugins/generator/visualstudio/visualstudiogenerator.cpp
@@ -130,7 +130,8 @@ public:
const GeneratableProductData &productData) override {
Q_UNUSED(project);
Q_UNUSED(projectData);
- for (const auto &dep : productData.dependencies()) {
+ const auto dependencies = productData.dependencies();
+ for (const auto &dep : dependencies) {
generator->d->solution->addDependency(
generator->d->solutionProjects.value(productData.name()),
generator->d->solutionProjects.value(dep));
@@ -143,8 +144,8 @@ public:
}
private:
- VisualStudioGenerator *generator;
- VisualStudioSolutionGlobalSection *nestedProjects;
+ VisualStudioGenerator *generator = nullptr;
+ VisualStudioSolutionGlobalSection *nestedProjects = nullptr;
};
VisualStudioGenerator::VisualStudioGenerator(const VisualStudioVersionInfo &versionInfo)
@@ -190,7 +191,7 @@ void VisualStudioGenerator::addPropertySheets(const GeneratableProject &project)
void VisualStudioGenerator::addPropertySheets(
const std::shared_ptr<MSBuildTargetProject> &targetProject)
{
- for (const auto &pair : d->propertySheetNames) {
+ for (const auto &pair : qAsConst(d->propertySheetNames)) {
targetProject->appendPropertySheet(
QStringLiteral("$(SolutionDir)\\") + pair.first, pair.second);
}
@@ -221,7 +222,8 @@ static void addDefaultGlobalSections(const GeneratableProject &topLevelProject,
QStringLiteral("ProjectConfigurationPlatforms"), solution);
solution->appendGlobalSection(projectConfigurationPlatformsSection);
projectConfigurationPlatformsSection->setPost(true);
- for (const auto project : solution->projects()) {
+ const auto projects = solution->projects();
+ for (const auto project : projects) {
for (const auto &qbsProject : topLevelProject.projects) {
projectConfigurationPlatformsSection->appendProperty(
QStringLiteral("%1.%2.ActiveCfg")
diff --git a/src/plugins/generator/visualstudio/visualstudiogenerator.h b/src/plugins/generator/visualstudio/visualstudiogenerator.h
index 898ae0b9c..e104ca427 100644
--- a/src/plugins/generator/visualstudio/visualstudiogenerator.h
+++ b/src/plugins/generator/visualstudio/visualstudiogenerator.h
@@ -57,15 +57,15 @@ class VisualStudioGenerator : public ProjectGenerator, private IGeneratableProje
friend class SolutionDependenciesVisitor;
public:
explicit VisualStudioGenerator(const Internal::VisualStudioVersionInfo &versionInfo);
- ~VisualStudioGenerator();
+ ~VisualStudioGenerator() override;
QString generatorName() const override;
void generate() override;
private:
- virtual void visitProject(const GeneratableProject &project) override;
- virtual void visitProjectData(const GeneratableProject &project,
+ void visitProject(const GeneratableProject &project) override;
+ void visitProjectData(const GeneratableProject &project,
const GeneratableProjectData &projectData) override;
- virtual void visitProduct(const GeneratableProject &project,
+ void visitProduct(const GeneratableProject &project,
const GeneratableProjectData &projectData,
const GeneratableProductData &productData) override;
diff --git a/src/plugins/scanner/cpp/Lexer.h b/src/plugins/scanner/cpp/Lexer.h
index 2b843a14a..1cf829ebb 100644
--- a/src/plugins/scanner/cpp/Lexer.h
+++ b/src/plugins/scanner/cpp/Lexer.h
@@ -145,17 +145,17 @@ private:
unsigned _objCEnabled: 1;
};
- const char *_firstChar;
- const char *_currentChar;
- const char *_lastChar;
- const char *_tokenStart;
- unsigned char _yychar;
- int _state;
+ const char *_firstChar = nullptr;
+ const char *_currentChar = nullptr;
+ const char *_lastChar = nullptr;
+ const char *_tokenStart = nullptr;
+ unsigned char _yychar = 0;
+ int _state = 0;
union {
unsigned _flags;
Flags f;
};
- unsigned _currentLine;
+ unsigned _currentLine = 0;
};
} // end of namespace CPlusPlus
diff --git a/src/plugins/scanner/cpp/Token.h b/src/plugins/scanner/cpp/Token.h
index 286c71a48..846aa5a12 100644
--- a/src/plugins/scanner/cpp/Token.h
+++ b/src/plugins/scanner/cpp/Token.h
@@ -353,7 +353,7 @@ public:
Flags f;
};
- unsigned offset;
+ unsigned offset = 0;
union {
void *ptr;
diff --git a/src/plugins/scanner/qt/qtscanner.cpp b/src/plugins/scanner/qt/qtscanner.cpp
index 51faadab3..40d062e1f 100644
--- a/src/plugins/scanner/qt/qtscanner.cpp
+++ b/src/plugins/scanner/qt/qtscanner.cpp
@@ -68,24 +68,16 @@
struct OpaqQrc
{
#ifdef Q_OS_UNIX
- int fd;
- int mapl;
+ int fd = 0;
+ int mapl = 0;
#else
- QFile *file;
+ QFile *file = nullptr;
#endif
- char *map;
- QXmlStreamReader *xml;
+ char *map = nullptr;
+ QXmlStreamReader *xml = nullptr;
QByteArray current;
- OpaqQrc()
-#ifdef Q_OS_UNIX
- : fd (0),
-#else
- : file(nullptr),
-#endif
- map(nullptr),
- xml(nullptr)
- {}
+ OpaqQrc() = default;
~OpaqQrc()
{
diff --git a/src/shared/json/json.cpp b/src/shared/json/json.cpp
index 82b7467c8..3a838a177 100644
--- a/src/shared/json/json.cpp
+++ b/src/shared/json/json.cpp
@@ -542,7 +542,7 @@ public:
}
char *raw = (char *)malloc(size);
memcpy(raw + sizeof(Header), b, b->size);
- Header *h = (Header *)raw;
+ const auto h = (Header *)raw;
h->tag = JsonDocument::BinaryFormatTag;
h->version = 1;
const auto d = new Data(raw, size);
@@ -1251,8 +1251,8 @@ JsonArray::JsonArray()
JsonArray::JsonArray(std::initializer_list<JsonValue> args)
: d(nullptr), a(nullptr)
{
- for (auto i = args.begin(); i != args.end(); ++i)
- append(*i);
+ for (const auto &arg : args)
+ append(arg);
}
/*!
@@ -2284,8 +2284,8 @@ JsonObject::JsonObject()
JsonObject::JsonObject(std::initializer_list<std::pair<std::string, JsonValue> > args)
: d(nullptr), o(nullptr)
{
- for (auto i = args.begin(); i != args.end(); ++i)
- insert(i->first, i->second);
+ for (const auto &arg : args)
+ insert(arg.first, arg.second);
}
/*!
@@ -3521,7 +3521,7 @@ bool JsonDocument::isArray() const
if (!d)
return false;
- Internal::Header *h = (Internal::Header *)d->rawData;
+ const auto h = (Internal::Header *)d->rawData;
return h->root()->isArray();
}
@@ -3535,7 +3535,7 @@ bool JsonDocument::isObject() const
if (!d)
return false;
- Internal::Header *h = (Internal::Header *)d->rawData;
+ const auto h = (Internal::Header *)d->rawData;
return h->root()->isObject();
}
@@ -3731,7 +3731,7 @@ static std::string escapedString(const std::string &in)
static void valueToJson(const Base *b, const Value &v, std::string &json, int indent, bool compact)
{
- JsonValue::Type type = (JsonValue::Type)(uint32_t)v.type;
+ const auto type = (JsonValue::Type)(uint32_t)v.type;
switch (type) {
case JsonValue::Bool:
json += v.toBoolean() ? "true" : "false";
@@ -4013,7 +4013,7 @@ JsonDocument Parser::parse(JsonParseError *error)
data = (char *)malloc(dataLength);
// fill in Header data
- Header *h = (Header *)data;
+ const auto h = (Header *)data;
h->tag = JsonDocument::BinaryFormatTag;
h->version = 1u;
@@ -4065,7 +4065,7 @@ error:
void Parser::ParsedObject::insert(uint32_t offset)
{
- const Entry *newEntry = reinterpret_cast<const Entry *>(parser->data + objectPosition + offset);
+ const auto newEntry = reinterpret_cast<const Entry *>(parser->data + objectPosition + offset);
size_t min = 0;
size_t n = offsets.size();
while (n > 0) {
@@ -4133,7 +4133,7 @@ bool Parser::parseObject()
memcpy(data + table, &*parsedObject.offsets.begin(), tableSize);
}
- Object *o = (Object *)(data + objectOffset);
+ const auto o = (Object *)(data + objectOffset);
o->tableOffset = table - objectOffset;
o->size = current - objectOffset;
o->is_object = true;
@@ -4166,7 +4166,7 @@ bool Parser::parseMember(int baseOffset)
return false;
// finalize the entry
- Entry *e = (Entry *)(data + entryOffset);
+ const auto e = (Entry *)(data + entryOffset);
e->value = val;
END;
@@ -4224,7 +4224,7 @@ bool Parser::parseArray()
memcpy(data + table, values.data(), tableSize);
}
- Array *a = (Array *)(data + arrayOffset);
+ const auto a = (Array *)(data + arrayOffset);
a->tableOffset = table - arrayOffset;
a->size = current - arrayOffset;
a->is_object = false;
@@ -4632,7 +4632,7 @@ void Data::compact()
int size = sizeof(Base) + reserve + base->length*sizeof(offset);
int alloc = sizeof(Header) + size;
- Header *h = (Header *) malloc(alloc);
+ const auto h = (Header *) malloc(alloc);
h->tag = JsonDocument::BinaryFormatTag;
h->version = 1;
Base *b = h->root();