forked from qt-creator/qt-creator
ClangTools: Proliferate use of FilePath
Change-Id: I3eb16546a729ab01c10e37572adac9aef83f5cd4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -141,8 +141,7 @@ ClangModelManagerSupport::ClangModelManagerSupport()
|
||||
claimNonProjectSources(fallbackClient);
|
||||
});
|
||||
|
||||
CppTools::ClangdSettings::setDefaultClangdPath(Utils::FilePath::fromString(
|
||||
Core::ICore::clangdExecutable(CLANG_BINDIR)));
|
||||
CppTools::ClangdSettings::setDefaultClangdPath(Core::ICore::clangdExecutable(CLANG_BINDIR));
|
||||
connect(&CppTools::ClangdSettings::instance(), &CppTools::ClangdSettings::changed,
|
||||
this, &ClangModelManagerSupport::onClangdSettingsChanged);
|
||||
CppTools::CppCodeModelSettings *settings = CppTools::codeModelSettings();
|
||||
|
@@ -76,7 +76,7 @@ public:
|
||||
UseLanguageDefines::No,
|
||||
useBuildSystemWarnings,
|
||||
QString(CLANG_VERSION),
|
||||
QString(CLANG_INCLUDE_DIR))
|
||||
FilePath(CLANG_INCLUDE_DIR))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -896,12 +896,12 @@ static CheckResult canAnalyze()
|
||||
{
|
||||
const ClangDiagnosticConfig config = diagnosticConfig(runSettings().diagnosticConfigId());
|
||||
|
||||
if (config.isClangTidyEnabled() && !isFileExecutable(clangTidyExecutable())) {
|
||||
if (config.isClangTidyEnabled() && !clangTidyExecutable().isExecutableFile()) {
|
||||
return {CheckResult::InvalidTidyExecutable,
|
||||
ClangTool::tr("Set a valid Clang-Tidy executable.")};
|
||||
}
|
||||
|
||||
if (config.isClazyEnabled() && !isFileExecutable(clazyStandaloneExecutable())) {
|
||||
if (config.isClazyEnabled() && !clazyStandaloneExecutable().isExecutableFile()) {
|
||||
return {CheckResult::InvalidClazyExecutable,
|
||||
ClangTool::tr("Set a valid Clazy-Standalone executable.")};
|
||||
}
|
||||
|
@@ -125,7 +125,7 @@ AnalyzeUnit::AnalyzeUnit(const FileInfo &fileInfo,
|
||||
UseLanguageDefines::No,
|
||||
UseBuildSystemWarnings::No,
|
||||
clangVersion,
|
||||
clangIncludeDir.toString());
|
||||
clangIncludeDir);
|
||||
file = fileInfo.file.toString();
|
||||
arguments = extraClangToolsPrependOptions();
|
||||
arguments.append(optionsBuilder.build(fileInfo.kind, CppTools::getPchUsage()));
|
||||
|
@@ -101,11 +101,11 @@ QStringList ClangToolRunner::mainToolArguments() const
|
||||
|
||||
bool ClangToolRunner::supportsVFSOverlay() const
|
||||
{
|
||||
static QMap<QString, bool> vfsCapabilities;
|
||||
static QMap<FilePath, bool> vfsCapabilities;
|
||||
auto it = vfsCapabilities.find(m_executable);
|
||||
if (it == vfsCapabilities.end()) {
|
||||
QtcProcess p;
|
||||
p.setCommand({FilePath::fromString(m_executable), {"--help"}});
|
||||
p.setCommand({m_executable, {"--help"}});
|
||||
p.runBlocking();
|
||||
it = vfsCapabilities.insert(m_executable, p.allOutput().contains("vfsoverlay"));
|
||||
}
|
||||
@@ -137,7 +137,7 @@ bool ClangToolRunner::run(const QString &fileToAnalyze, const QStringList &compi
|
||||
|
||||
m_outputFilePath = createOutputFilePath(m_outputDirPath, fileToAnalyze);
|
||||
QTC_ASSERT(!m_outputFilePath.isEmpty(), return false);
|
||||
m_commandLine = {FilePath::fromString(m_executable), m_argsCreator(compilerOptions)};
|
||||
m_commandLine = {m_executable, m_argsCreator(compilerOptions)};
|
||||
|
||||
qCDebug(LOG).noquote() << "Starting" << m_commandLine.toUserOutput();
|
||||
m_process->setCommand(m_commandLine);
|
||||
|
@@ -46,13 +46,13 @@ public:
|
||||
|
||||
void init(const Utils::FilePath &outputDirPath, const Utils::Environment &environment);
|
||||
void setName(const QString &name) { m_name = name; }
|
||||
void setExecutable(const QString &executable) { m_executable = executable; }
|
||||
void setExecutable(const Utils::FilePath &executable) { m_executable = executable; }
|
||||
void setArgsCreator(const ArgsCreator &argsCreator) { m_argsCreator = argsCreator; }
|
||||
void setOutputFileFormat(const OutputFileFormat &format) { m_outputFileFormat = format; }
|
||||
void setVFSOverlay(const QString overlayFilePath) { m_overlayFilePath = overlayFilePath; }
|
||||
|
||||
QString name() const { return m_name; }
|
||||
QString executable() const { return m_executable; }
|
||||
Utils::FilePath executable() const { return m_executable; }
|
||||
OutputFileFormat outputFileFormat() const { return m_outputFileFormat; }
|
||||
QString fileToAnalyze() const { return m_fileToAnalyze; }
|
||||
QString outputFilePath() const { return m_outputFilePath; }
|
||||
@@ -83,7 +83,7 @@ private:
|
||||
Utils::QtcProcess *m_process = nullptr;
|
||||
|
||||
QString m_name;
|
||||
QString m_executable;
|
||||
Utils::FilePath m_executable;
|
||||
ArgsCreator m_argsCreator;
|
||||
OutputFileFormat m_outputFileFormat = OutputFileFormat::Yaml;
|
||||
|
||||
|
@@ -46,6 +46,7 @@ static const char analyzeOpenFilesKey[] = "AnalyzeOpenFiles";
|
||||
static const char oldDiagnosticConfigIdKey[] = "diagnosticConfigId";
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
@@ -151,8 +152,8 @@ void ClangToolsSettings::readSettings()
|
||||
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(Constants::SETTINGS_ID);
|
||||
m_clangTidyExecutable = s->value(clangTidyExecutableKey).toString();
|
||||
m_clazyStandaloneExecutable = s->value(clazyStandaloneExecutableKey).toString();
|
||||
m_clangTidyExecutable = FilePath::fromVariant(s->value(clangTidyExecutableKey));
|
||||
m_clazyStandaloneExecutable = FilePath::fromVariant(s->value(clazyStandaloneExecutableKey));
|
||||
m_diagnosticConfigs.append(diagnosticConfigsFromSettings(s));
|
||||
|
||||
QVariantMap map;
|
||||
@@ -184,8 +185,8 @@ void ClangToolsSettings::writeSettings()
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(Constants::SETTINGS_ID);
|
||||
|
||||
s->setValue(clangTidyExecutableKey, m_clangTidyExecutable);
|
||||
s->setValue(clazyStandaloneExecutableKey, m_clazyStandaloneExecutable);
|
||||
s->setValue(clangTidyExecutableKey, m_clangTidyExecutable.toVariant());
|
||||
s->setValue(clazyStandaloneExecutableKey, m_clazyStandaloneExecutable.toVariant());
|
||||
diagnosticConfigsToSettings(s, m_diagnosticConfigs);
|
||||
|
||||
QVariantMap map;
|
||||
@@ -198,24 +199,22 @@ void ClangToolsSettings::writeSettings()
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ClangToolsSettings::setClangTidyExecutable(const QString &path)
|
||||
void ClangToolsSettings::setClangTidyExecutable(const FilePath &path)
|
||||
{
|
||||
m_clangTidyExecutable = path;
|
||||
m_clangTidyVersion = {};
|
||||
}
|
||||
|
||||
void ClangTools::Internal::ClangToolsSettings::setClazyStandaloneExecutable(const QString &path)
|
||||
void ClangToolsSettings::setClazyStandaloneExecutable(const FilePath &path)
|
||||
{
|
||||
m_clazyStandaloneExecutable = path;
|
||||
m_clazyVersion = {};
|
||||
}
|
||||
|
||||
static QVersionNumber getVersionNumber(QVersionNumber &version, const QString &toolFilePath)
|
||||
static QVersionNumber getVersionNumber(QVersionNumber &version, const FilePath &toolFilePath)
|
||||
{
|
||||
if (version.isNull() && !toolFilePath.isEmpty()) {
|
||||
version = QVersionNumber::fromString(queryVersion(Utils::FilePath::fromString(toolFilePath),
|
||||
QueryFailMode::Silent));
|
||||
};
|
||||
if (version.isNull() && !toolFilePath.isEmpty())
|
||||
version = QVersionNumber::fromString(queryVersion(toolFilePath, QueryFailMode::Silent));
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@@ -77,11 +77,11 @@ public:
|
||||
static ClangToolsSettings *instance();
|
||||
void writeSettings();
|
||||
|
||||
QString clangTidyExecutable() const { return m_clangTidyExecutable; }
|
||||
void setClangTidyExecutable(const QString &path);
|
||||
Utils::FilePath clangTidyExecutable() const { return m_clangTidyExecutable; }
|
||||
void setClangTidyExecutable(const Utils::FilePath &path);
|
||||
|
||||
QString clazyStandaloneExecutable() const { return m_clazyStandaloneExecutable; }
|
||||
void setClazyStandaloneExecutable(const QString &path);
|
||||
Utils::FilePath clazyStandaloneExecutable() const { return m_clazyStandaloneExecutable; }
|
||||
void setClazyStandaloneExecutable(const Utils::FilePath &path);
|
||||
|
||||
CppTools::ClangDiagnosticConfigs diagnosticConfigs() const { return m_diagnosticConfigs; }
|
||||
void setDiagnosticConfigs(const CppTools::ClangDiagnosticConfigs &configs)
|
||||
@@ -101,8 +101,8 @@ private:
|
||||
void readSettings();
|
||||
|
||||
// Executables
|
||||
QString m_clangTidyExecutable;
|
||||
QString m_clazyStandaloneExecutable;
|
||||
Utils::FilePath m_clangTidyExecutable;
|
||||
Utils::FilePath m_clazyStandaloneExecutable;
|
||||
|
||||
// Diagnostic Configs
|
||||
CppTools::ClangDiagnosticConfigs m_diagnosticConfigs;
|
||||
|
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
@@ -45,6 +46,7 @@
|
||||
#include <cpptools/clangdiagnosticconfigsmodel.h>
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
@@ -170,46 +172,36 @@ void showHintAboutBuildBeforeAnalysis()
|
||||
"ClangToolsDisablingBuildBeforeAnalysisHint");
|
||||
}
|
||||
|
||||
bool isFileExecutable(const QString &filePath)
|
||||
FilePath shippedClangTidyExecutable()
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
return false;
|
||||
|
||||
const QFileInfo fileInfo(filePath);
|
||||
return fileInfo.exists() && fileInfo.isFile() && fileInfo.isExecutable();
|
||||
}
|
||||
|
||||
QString shippedClangTidyExecutable()
|
||||
{
|
||||
const QString shippedExecutable = Core::ICore::clangTidyExecutable(CLANG_BINDIR);
|
||||
if (isFileExecutable(shippedExecutable))
|
||||
const FilePath shippedExecutable = Core::ICore::clangTidyExecutable(CLANG_BINDIR);
|
||||
if (shippedExecutable.isExecutableFile())
|
||||
return shippedExecutable;
|
||||
return {};
|
||||
}
|
||||
|
||||
QString shippedClazyStandaloneExecutable()
|
||||
FilePath shippedClazyStandaloneExecutable()
|
||||
{
|
||||
const QString shippedExecutable = Core::ICore::clazyStandaloneExecutable(CLANG_BINDIR);
|
||||
if (isFileExecutable(shippedExecutable))
|
||||
const FilePath shippedExecutable = Core::ICore::clazyStandaloneExecutable(CLANG_BINDIR);
|
||||
if (shippedExecutable.isExecutableFile())
|
||||
return shippedExecutable;
|
||||
return {};
|
||||
}
|
||||
|
||||
QString fullPath(const QString &executable)
|
||||
FilePath fullPath(const FilePath &executable)
|
||||
{
|
||||
const QString hostExeSuffix = QLatin1String(QTC_HOST_EXE_SUFFIX);
|
||||
const Qt::CaseSensitivity caseSensitivity = Utils::HostOsInfo::fileNameCaseSensitivity();
|
||||
|
||||
QString candidate = executable;
|
||||
const bool hasSuffix = candidate.endsWith(hostExeSuffix, caseSensitivity);
|
||||
FilePath candidate = executable;
|
||||
const bool hasSuffix = candidate.toString().endsWith(hostExeSuffix, caseSensitivity);
|
||||
|
||||
const QFileInfo fileInfo = QFileInfo(candidate);
|
||||
if (fileInfo.isAbsolute()) {
|
||||
if (candidate.isAbsolutePath()) {
|
||||
if (!hasSuffix)
|
||||
candidate.append(hostExeSuffix);
|
||||
candidate = candidate.withExecutableSuffix();
|
||||
} else {
|
||||
const Utils::Environment environment = Utils::Environment::systemEnvironment();
|
||||
const QString expandedPath = environment.searchInPath(candidate).toString();
|
||||
const Environment environment = Environment::systemEnvironment();
|
||||
const FilePath expandedPath = environment.searchInPath(candidate.toString());
|
||||
if (!expandedPath.isEmpty())
|
||||
candidate = expandedPath;
|
||||
}
|
||||
@@ -217,18 +209,18 @@ QString fullPath(const QString &executable)
|
||||
return candidate;
|
||||
}
|
||||
|
||||
static QString findValidExecutable(const QStringList &candidates)
|
||||
static FilePath findValidExecutable(const FilePaths &candidates)
|
||||
{
|
||||
for (const QString &candidate : candidates) {
|
||||
const QString expandedPath = fullPath(candidate);
|
||||
if (isFileExecutable(expandedPath))
|
||||
for (const FilePath &candidate : candidates) {
|
||||
const FilePath expandedPath = fullPath(candidate);
|
||||
if (expandedPath.isExecutableFile())
|
||||
return expandedPath;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QString clangTidyFallbackExecutable()
|
||||
FilePath clangTidyFallbackExecutable()
|
||||
{
|
||||
return findValidExecutable({
|
||||
shippedClangTidyExecutable(),
|
||||
@@ -236,15 +228,15 @@ QString clangTidyFallbackExecutable()
|
||||
});
|
||||
}
|
||||
|
||||
QString clangTidyExecutable()
|
||||
FilePath clangTidyExecutable()
|
||||
{
|
||||
const QString fromSettings = ClangToolsSettings::instance()->clangTidyExecutable();
|
||||
const FilePath fromSettings = ClangToolsSettings::instance()->clangTidyExecutable();
|
||||
if (!fromSettings.isEmpty())
|
||||
return fullPath(fromSettings);
|
||||
return clangTidyFallbackExecutable();
|
||||
}
|
||||
|
||||
QString clazyStandaloneFallbackExecutable()
|
||||
FilePath clazyStandaloneFallbackExecutable()
|
||||
{
|
||||
return findValidExecutable({
|
||||
shippedClazyStandaloneExecutable(),
|
||||
@@ -252,9 +244,9 @@ QString clazyStandaloneFallbackExecutable()
|
||||
});
|
||||
}
|
||||
|
||||
QString clazyStandaloneExecutable()
|
||||
FilePath clazyStandaloneExecutable()
|
||||
{
|
||||
const QString fromSettings = ClangToolsSettings::instance()->clazyStandaloneExecutable();
|
||||
const FilePath fromSettings = ClangToolsSettings::instance()->clazyStandaloneExecutable();
|
||||
if (!fromSettings.isEmpty())
|
||||
return fullPath(fromSettings);
|
||||
return clazyStandaloneFallbackExecutable();
|
||||
|
@@ -32,12 +32,9 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CppTools { class ClangDiagnosticConfigsModel; }
|
||||
namespace Debugger { class DiagnosticLocation; }
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
@@ -68,17 +65,15 @@ QString createFullLocationString(const Debugger::DiagnosticLocation &location);
|
||||
QString hintAboutBuildBeforeAnalysis();
|
||||
void showHintAboutBuildBeforeAnalysis();
|
||||
|
||||
bool isFileExecutable(const QString &filePath);
|
||||
Utils::FilePath shippedClazyStandaloneExecutable();
|
||||
Utils::FilePath clazyStandaloneExecutable();
|
||||
Utils::FilePath clazyStandaloneFallbackExecutable();
|
||||
|
||||
QString shippedClazyStandaloneExecutable();
|
||||
QString clazyStandaloneExecutable();
|
||||
QString clazyStandaloneFallbackExecutable();
|
||||
Utils::FilePath shippedClangTidyExecutable();
|
||||
Utils::FilePath clangTidyExecutable();
|
||||
Utils::FilePath clangTidyFallbackExecutable();
|
||||
|
||||
QString shippedClangTidyExecutable();
|
||||
QString clangTidyExecutable();
|
||||
QString clangTidyFallbackExecutable();
|
||||
|
||||
QString fullPath(const QString &executable);
|
||||
Utils::FilePath fullPath(const Utils::FilePath &executable);
|
||||
|
||||
QString documentationUrl(const QString &checkName);
|
||||
|
||||
|
@@ -234,7 +234,7 @@ void DocumentClangToolRunner::run()
|
||||
QPair<Utils::FilePath, QString> getClangIncludeDirAndVersion(ClangToolRunner *runner)
|
||||
{
|
||||
static QMap<Utils::FilePath, QPair<Utils::FilePath, QString>> cache;
|
||||
const Utils::FilePath tool = Utils::FilePath::fromString(runner->executable());
|
||||
const Utils::FilePath tool = runner->executable();
|
||||
auto it = cache.find(tool);
|
||||
if (it == cache.end())
|
||||
it = cache.insert(tool, getClangIncludeDirAndVersion(tool));
|
||||
|
@@ -158,17 +158,16 @@ static ClazyChecks querySupportedClazyChecks(const FilePath &executablePath)
|
||||
return infos;
|
||||
}
|
||||
|
||||
ClangTidyInfo::ClangTidyInfo(const QString &executablePath)
|
||||
: defaultChecks(queryClangTidyChecks(FilePath::fromString(executablePath), {}))
|
||||
, supportedChecks(queryClangTidyChecks(FilePath::fromString(executablePath), "-checks=*"))
|
||||
ClangTidyInfo::ClangTidyInfo(const FilePath &executablePath)
|
||||
: defaultChecks(queryClangTidyChecks(executablePath, {}))
|
||||
, supportedChecks(queryClangTidyChecks(executablePath, "-checks=*"))
|
||||
{}
|
||||
|
||||
ClazyStandaloneInfo::ClazyStandaloneInfo(const QString &executablePath)
|
||||
: defaultChecks(queryClangTidyChecks(FilePath::fromString(executablePath), {})) // Yup, behaves as clang-tidy.
|
||||
, supportedChecks(querySupportedClazyChecks(FilePath::fromString(executablePath)))
|
||||
ClazyStandaloneInfo::ClazyStandaloneInfo(const FilePath &executablePath)
|
||||
: defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
|
||||
, supportedChecks(querySupportedClazyChecks(executablePath))
|
||||
{
|
||||
QString output = runExecutable(CommandLine(FilePath::fromString(executablePath), {"--version"}),
|
||||
QueryFailMode::Silent);
|
||||
QString output = runExecutable({executablePath, {"--version"}}, QueryFailMode::Silent);
|
||||
QTextStream stream(&output);
|
||||
while (!stream.atEnd()) {
|
||||
// It's just "clazy version " right now, but let's be prepared for someone adding a colon
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QPair>
|
||||
#include <QStringList>
|
||||
@@ -43,7 +43,7 @@ QString queryVersion(const Utils::FilePath &clangToolPath, QueryFailMode failMod
|
||||
class ClangTidyInfo
|
||||
{
|
||||
public:
|
||||
ClangTidyInfo(const QString &executablePath);
|
||||
ClangTidyInfo(const Utils::FilePath &executablePath);
|
||||
QStringList defaultChecks;
|
||||
QStringList supportedChecks;
|
||||
};
|
||||
@@ -60,7 +60,7 @@ using ClazyChecks = QVector<ClazyCheck>;
|
||||
class ClazyStandaloneInfo
|
||||
{
|
||||
public:
|
||||
ClazyStandaloneInfo(const QString &executablePath);
|
||||
ClazyStandaloneInfo(const Utils::FilePath &executablePath);
|
||||
|
||||
QVersionNumber version;
|
||||
QStringList defaultChecks;
|
||||
|
@@ -36,6 +36,8 @@
|
||||
|
||||
#include <QThread>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
@@ -60,8 +62,8 @@ static CppTools::ClangDiagnosticConfigsWidget *createEditWidget(
|
||||
const CppTools::ClangDiagnosticConfigs &configs, const Utils::Id &configToSelect)
|
||||
{
|
||||
// Determine executable paths
|
||||
QString clangTidyPath;
|
||||
QString clazyStandalonePath;
|
||||
FilePath clangTidyPath;
|
||||
FilePath clazyStandalonePath;
|
||||
if (auto settingsWidget = SettingsWidget::instance()) {
|
||||
// Global settings case; executables might not yet applied to settings
|
||||
clangTidyPath = settingsWidget->clangTidyPath();
|
||||
|
@@ -37,20 +37,22 @@
|
||||
|
||||
#include <utils/optional.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
static SettingsWidget *m_instance = nullptr;
|
||||
|
||||
static void setupPathChooser(Utils::PathChooser *const chooser,
|
||||
static void setupPathChooser(PathChooser *const chooser,
|
||||
const QString &promptDiaglogTitle,
|
||||
const QString &placeHolderText,
|
||||
const QString &pathFromSettings,
|
||||
const FilePath &pathFromSettings,
|
||||
const QString &historyCompleterId)
|
||||
{
|
||||
chooser->setPromptDialogTitle(promptDiaglogTitle);
|
||||
chooser->setDefaultValue(placeHolderText);
|
||||
chooser->setPath(pathFromSettings);
|
||||
chooser->setFilePath(pathFromSettings);
|
||||
chooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
chooser->setHistoryCompleter(historyCompleterId);
|
||||
}
|
||||
@@ -71,8 +73,8 @@ SettingsWidget::SettingsWidget()
|
||||
// Group box "Executables"
|
||||
//
|
||||
|
||||
QString placeHolderText = shippedClangTidyExecutable();
|
||||
QString path = m_settings->clangTidyExecutable();
|
||||
QString placeHolderText = shippedClangTidyExecutable().toUserOutput();
|
||||
FilePath path = m_settings->clangTidyExecutable();
|
||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||
path = Constants::CLANG_TIDY_EXECUTABLE_NAME;
|
||||
setupPathChooser(m_ui->clangTidyPathChooser,
|
||||
@@ -81,7 +83,7 @@ SettingsWidget::SettingsWidget()
|
||||
path,
|
||||
"ClangTools.ClangTidyExecutable.History");
|
||||
|
||||
placeHolderText = shippedClazyStandaloneExecutable();
|
||||
placeHolderText = shippedClazyStandaloneExecutable().toUserOutput();
|
||||
path = m_settings->clazyStandaloneExecutable();
|
||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||
path = Constants::CLAZY_STANDALONE_EXECUTABLE_NAME;
|
||||
@@ -101,8 +103,8 @@ SettingsWidget::SettingsWidget()
|
||||
void SettingsWidget::apply()
|
||||
{
|
||||
// Executables
|
||||
m_settings->setClangTidyExecutable(m_ui->clangTidyPathChooser->rawPath());
|
||||
m_settings->setClazyStandaloneExecutable(m_ui->clazyStandalonePathChooser->rawPath());
|
||||
m_settings->setClangTidyExecutable(clangTidyPath());
|
||||
m_settings->setClazyStandaloneExecutable(clazyStandalonePath());
|
||||
|
||||
// Run options
|
||||
m_settings->setRunSettings(m_ui->runSettingsWidget->toSettings());
|
||||
@@ -120,14 +122,14 @@ SettingsWidget::~SettingsWidget()
|
||||
m_instance = nullptr;
|
||||
}
|
||||
|
||||
QString SettingsWidget::clangTidyPath() const
|
||||
FilePath SettingsWidget::clangTidyPath() const
|
||||
{
|
||||
return m_ui->clangTidyPathChooser->rawPath();
|
||||
return m_ui->clangTidyPathChooser->rawFilePath();
|
||||
}
|
||||
|
||||
QString SettingsWidget::clazyStandalonePath() const
|
||||
FilePath SettingsWidget::clazyStandalonePath() const
|
||||
{
|
||||
return m_ui->clazyStandalonePathChooser->rawPath();
|
||||
return m_ui->clazyStandalonePathChooser->rawFilePath();
|
||||
}
|
||||
|
||||
// ClangToolsOptionsPage
|
||||
|
@@ -31,6 +31,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
@@ -46,8 +48,8 @@ public:
|
||||
SettingsWidget();
|
||||
~SettingsWidget() override;
|
||||
|
||||
QString clangTidyPath() const;
|
||||
QString clazyStandalonePath() const;
|
||||
Utils::FilePath clangTidyPath() const;
|
||||
Utils::FilePath clazyStandalonePath() const;
|
||||
|
||||
private:
|
||||
void apply() final;
|
||||
|
@@ -522,31 +522,31 @@ static QString clangIncludePath(const QString &clangVersion)
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QString ICore::clangIncludeDirectory(const QString &clangVersion,
|
||||
const QString &clangFallbackIncludeDir)
|
||||
FilePath ICore::clangIncludeDirectory(const QString &clangVersion,
|
||||
const FilePath &clangFallbackIncludeDir)
|
||||
{
|
||||
FilePath dir = libexecPath("clang" + clangIncludePath(clangVersion));
|
||||
if (!dir.exists() || !dir.pathAppended("stdint.h").exists())
|
||||
dir = FilePath::fromString(clangFallbackIncludeDir);
|
||||
return dir.canonicalPath().toUserOutput();
|
||||
dir = clangFallbackIncludeDir;
|
||||
return dir.canonicalPath();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
static QString clangBinary(const QString &binaryBaseName, const QString &clangBinDirectory)
|
||||
static FilePath clangBinary(const QString &binaryBaseName, const FilePath &clangBinDirectory)
|
||||
{
|
||||
const QString hostExeSuffix(QTC_HOST_EXE_SUFFIX);
|
||||
FilePath executable = ICore::libexecPath("clang/bin") / binaryBaseName + hostExeSuffix;
|
||||
FilePath executable =
|
||||
ICore::libexecPath("clang/bin").pathAppended(binaryBaseName).withExecutableSuffix();
|
||||
if (!executable.exists())
|
||||
executable = FilePath::fromString(clangBinDirectory) / binaryBaseName + hostExeSuffix;
|
||||
return executable.canonicalPath().toUserOutput();
|
||||
executable = clangBinDirectory.pathAppended(binaryBaseName).withExecutableSuffix();
|
||||
return executable.canonicalPath();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QString ICore::clangExecutable(const QString &clangBinDirectory)
|
||||
FilePath ICore::clangExecutable(const FilePath &clangBinDirectory)
|
||||
{
|
||||
return clangBinary("clang", clangBinDirectory);
|
||||
}
|
||||
@@ -554,7 +554,7 @@ QString ICore::clangExecutable(const QString &clangBinDirectory)
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QString ICore::clangdExecutable(const QString &clangBinDirectory)
|
||||
FilePath ICore::clangdExecutable(const FilePath &clangBinDirectory)
|
||||
{
|
||||
return clangBinary("clangd", clangBinDirectory);
|
||||
}
|
||||
@@ -562,7 +562,7 @@ QString ICore::clangdExecutable(const QString &clangBinDirectory)
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QString ICore::clangTidyExecutable(const QString &clangBinDirectory)
|
||||
FilePath ICore::clangTidyExecutable(const FilePath &clangBinDirectory)
|
||||
{
|
||||
return clangBinary("clang-tidy", clangBinDirectory);
|
||||
}
|
||||
@@ -570,7 +570,7 @@ QString ICore::clangTidyExecutable(const QString &clangBinDirectory)
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QString ICore::clazyStandaloneExecutable(const QString &clangBinDirectory)
|
||||
FilePath ICore::clazyStandaloneExecutable(const FilePath &clangBinDirectory)
|
||||
{
|
||||
return clangBinary("clazy-standalone", clangBinDirectory);
|
||||
}
|
||||
|
@@ -164,12 +164,12 @@ public:
|
||||
static void setupScreenShooter(const QString &name, QWidget *w, const QRect &rc = QRect());
|
||||
static QString pluginPath();
|
||||
static QString userPluginPath();
|
||||
static QString clangExecutable(const QString &clangBinDirectory);
|
||||
static QString clangdExecutable(const QString &clangBinDirectory);
|
||||
static QString clangTidyExecutable(const QString &clangBinDirectory);
|
||||
static QString clazyStandaloneExecutable(const QString &clangBinDirectory);
|
||||
static QString clangIncludeDirectory(const QString &clangVersion,
|
||||
const QString &clangFallbackIncludeDir);
|
||||
static Utils::FilePath clangExecutable(const Utils::FilePath &clangBinDirectory);
|
||||
static Utils::FilePath clangdExecutable(const Utils::FilePath &clangBinDirectory);
|
||||
static Utils::FilePath clangTidyExecutable(const Utils::FilePath &clangBinDirectory);
|
||||
static Utils::FilePath clazyStandaloneExecutable(const Utils::FilePath &clangBinDirectory);
|
||||
static Utils::FilePath clangIncludeDirectory(const QString &clangVersion,
|
||||
const Utils::FilePath &clangFallbackIncludeDir);
|
||||
static QString buildCompatibilityString();
|
||||
static QStatusBar *statusBar();
|
||||
|
||||
|
@@ -45,6 +45,8 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
static const char defineOption[] = "-D";
|
||||
@@ -104,7 +106,7 @@ CompilerOptionsBuilder::CompilerOptionsBuilder(const ProjectPart &projectPart,
|
||||
UseLanguageDefines useLanguageDefines,
|
||||
UseBuildSystemWarnings useBuildSystemWarnings,
|
||||
const QString &clangVersion,
|
||||
const QString &clangIncludeDirectory)
|
||||
const FilePath &clangIncludeDirectory)
|
||||
: m_projectPart(projectPart)
|
||||
, m_useSystemHeader(useSystemHeader)
|
||||
, m_useTweakedHeaderPaths(useTweakedHeaderPaths)
|
||||
|
@@ -50,8 +50,8 @@ public:
|
||||
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::No,
|
||||
UseLanguageDefines useLanguageDefines = UseLanguageDefines::No,
|
||||
UseBuildSystemWarnings useBuildSystemWarnings = UseBuildSystemWarnings::No,
|
||||
const QString &clangVersion = QString(),
|
||||
const QString &clangIncludeDirectory = QString());
|
||||
const QString &clangVersion = {},
|
||||
const Utils::FilePath &clangIncludeDirectory = {});
|
||||
|
||||
QStringList build(ProjectFile::Kind fileKind, UsePrecompiledHeaders usePrecompiledHeaders);
|
||||
QStringList options() const { return m_options; }
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
const UseBuildSystemWarnings m_useBuildSystemWarnings;
|
||||
|
||||
const QString m_clangVersion;
|
||||
const QString m_clangIncludeDirectory;
|
||||
const Utils::FilePath m_clangIncludeDirectory;
|
||||
|
||||
struct {
|
||||
QStringList flags;
|
||||
|
@@ -36,11 +36,10 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace CppTools {
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
using ProjectExplorer::HeaderPath;
|
||||
using ProjectExplorer::HeaderPaths;
|
||||
using ProjectExplorer::HeaderPathType;
|
||||
namespace CppTools {
|
||||
|
||||
void HeaderPathFilter::process()
|
||||
{
|
||||
@@ -104,7 +103,7 @@ void HeaderPathFilter::filterHeaderPath(const ProjectExplorer::HeaderPath &heade
|
||||
|
||||
namespace {
|
||||
|
||||
QString clangIncludeDirectory(const QString &clangVersion, const QString &clangFallbackIncludeDir)
|
||||
FilePath clangIncludeDirectory(const QString &clangVersion, const FilePath &clangFallbackIncludeDir)
|
||||
{
|
||||
#ifndef UNIT_TESTS
|
||||
return Core::ICore::clangIncludeDirectory(clangVersion, clangFallbackIncludeDir);
|
||||
@@ -158,9 +157,9 @@ void HeaderPathFilter::tweakHeaderPaths()
|
||||
auto split = resourceIterator(builtInHeaderPaths);
|
||||
|
||||
if (!clangVersion.isEmpty()) {
|
||||
const QString clangIncludePath
|
||||
const FilePath clangIncludePath
|
||||
= clangIncludeDirectory(clangVersion, clangFallbackIncludeDirectory);
|
||||
builtInHeaderPaths.insert(split, HeaderPath{clangIncludePath, HeaderPathType::BuiltIn});
|
||||
builtInHeaderPaths.insert(split, HeaderPath{clangIncludePath.toString(), HeaderPathType::BuiltIn});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,14 +28,17 @@
|
||||
#include "compileroptionsbuilder.h"
|
||||
#include "projectpart.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT HeaderPathFilter
|
||||
{
|
||||
public:
|
||||
HeaderPathFilter(const ProjectPart &projectPart,
|
||||
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes,
|
||||
const QString &clangVersion = {},
|
||||
const QString &clangIncludeDirectory = {},
|
||||
const Utils::FilePath &clangIncludeDirectory = {},
|
||||
const QString &projectDirectory = {},
|
||||
const QString &buildDirectory = {})
|
||||
: projectPart{projectPart}
|
||||
@@ -67,7 +70,7 @@ public:
|
||||
ProjectExplorer::HeaderPaths userHeaderPaths;
|
||||
const ProjectPart &projectPart;
|
||||
const QString clangVersion;
|
||||
const QString clangFallbackIncludeDirectory;
|
||||
const Utils::FilePath clangFallbackIncludeDirectory;
|
||||
const QString projectDirectory;
|
||||
const QString buildDirectory;
|
||||
const UseTweakedHeaderPaths useTweakedHeaderPaths;
|
||||
|
@@ -37,7 +37,7 @@
|
||||
#include <cplusplus/Token.h>
|
||||
|
||||
#include <utils/cpplanguage_details.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QString>
|
||||
|
@@ -1640,10 +1640,9 @@ QList<ToolChain *> ClangToolChainFactory::autoDetect(const QList<ToolChain *> &a
|
||||
Constants::CLANG_TOOLCHAIN_TYPEID, alreadyKnown, device));
|
||||
known.append(tcs);
|
||||
|
||||
const FilePath compilerPath = FilePath::fromString(Core::ICore::clangExecutable(CLANG_BINDIR));
|
||||
const FilePath compilerPath = Core::ICore::clangExecutable(CLANG_BINDIR);
|
||||
if (!compilerPath.isEmpty()) {
|
||||
const FilePath clang = compilerPath.parentDir().pathAppended(
|
||||
HostOsInfo::withExecutableSuffix("clang"));
|
||||
const FilePath clang = compilerPath.parentDir().pathAppended("clang").withExecutableSuffix();
|
||||
tcs.append(autoDetectToolchains(clang.toString(), DetectVariants::No,
|
||||
Constants::C_LANGUAGE_ID, Constants::CLANG_TOOLCHAIN_TYPEID,
|
||||
tcs, device));
|
||||
|
@@ -1985,13 +1985,11 @@ QList<ToolChain *> ClangClToolChainFactory::autoDetect(const QList<ToolChain *>
|
||||
QList<ToolChain *> results;
|
||||
QList<ToolChain *> known = alreadyKnown;
|
||||
|
||||
QString qtCreatorsClang = Core::ICore::clangExecutable(CLANG_BINDIR);
|
||||
FilePath qtCreatorsClang = Core::ICore::clangExecutable(CLANG_BINDIR);
|
||||
if (!qtCreatorsClang.isEmpty()) {
|
||||
qtCreatorsClang = Utils::FilePath::fromString(qtCreatorsClang)
|
||||
.parentDir()
|
||||
.pathAppended("clang-cl.exe")
|
||||
.toString();
|
||||
results.append(detectClangClToolChainInPath(qtCreatorsClang, alreadyKnown, "", true));
|
||||
qtCreatorsClang = qtCreatorsClang.parentDir().pathAppended("clang-cl.exe");
|
||||
results.append(detectClangClToolChainInPath(qtCreatorsClang.toString(),
|
||||
alreadyKnown, "", true));
|
||||
known.append(results);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user