forked from qt-creator/qt-creator
ClangTools/CppTools: Code cosmetics
Mostly namespaces. Change-Id: Ife8bbcb128344cf56d444da8f9d76b1204b9fe34 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -69,10 +69,12 @@
|
||||
#include <QTextBlock>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace ClangCodeModel;
|
||||
using namespace ClangCodeModel::Internal;
|
||||
using namespace CppTools;
|
||||
using namespace LanguageClient;
|
||||
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
static ClangModelManagerSupport *m_instance = nullptr;
|
||||
|
||||
static CppTools::CppModelManager *cppModelManager()
|
||||
@@ -651,7 +653,7 @@ void ClangModelManagerSupport::onClangdSettingsChanged()
|
||||
}
|
||||
|
||||
ClangdClient * const fallbackClient = clientForProject(nullptr);
|
||||
const CppTools::ClangdSettings &settings = CppTools::ClangdSettings::instance();
|
||||
const ClangdSettings &settings = ClangdSettings::instance();
|
||||
const auto startNewFallbackClient = [this] {
|
||||
claimNonProjectSources(createClient(nullptr, {}));
|
||||
};
|
||||
@@ -743,3 +745,6 @@ CppTools::ModelManagerSupport::Ptr ClangModelManagerSupportProvider::createModel
|
||||
{
|
||||
return CppTools::ModelManagerSupport::Ptr(new ClangModelManagerSupport);
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // ClangCodeModel
|
||||
|
@@ -37,21 +37,21 @@
|
||||
|
||||
#include <QThread>
|
||||
|
||||
static const char clangTidyExecutableKey[] = "ClangTidyExecutable";
|
||||
static const char clazyStandaloneExecutableKey[] = "ClazyStandaloneExecutable";
|
||||
|
||||
static const char parallelJobsKey[] = "ParallelJobs";
|
||||
static const char buildBeforeAnalysisKey[] = "BuildBeforeAnalysis";
|
||||
static const char analyzeOpenFilesKey[] = "AnalyzeOpenFiles";
|
||||
static const char oldDiagnosticConfigIdKey[] = "diagnosticConfigId";
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
static Utils::Id defaultDiagnosticId()
|
||||
const char clangTidyExecutableKey[] = "ClangTidyExecutable";
|
||||
const char clazyStandaloneExecutableKey[] = "ClazyStandaloneExecutable";
|
||||
|
||||
const char parallelJobsKey[] = "ParallelJobs";
|
||||
const char buildBeforeAnalysisKey[] = "BuildBeforeAnalysis";
|
||||
const char analyzeOpenFilesKey[] = "AnalyzeOpenFiles";
|
||||
const char oldDiagnosticConfigIdKey[] = "diagnosticConfigId";
|
||||
|
||||
static Id defaultDiagnosticId()
|
||||
{
|
||||
return ClangTools::Constants::DIAG_CONFIG_TIDY_AND_CLAZY;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ RunSettings::RunSettings()
|
||||
|
||||
void RunSettings::fromMap(const QVariantMap &map, const QString &prefix)
|
||||
{
|
||||
m_diagnosticConfigId = Utils::Id::fromSetting(map.value(prefix + diagnosticConfigIdKey));
|
||||
m_diagnosticConfigId = Id::fromSetting(map.value(prefix + diagnosticConfigIdKey));
|
||||
m_parallelJobs = map.value(prefix + parallelJobsKey).toInt();
|
||||
m_buildBeforeAnalysis = map.value(prefix + buildBeforeAnalysisKey).toBool();
|
||||
m_analyzeOpenFiles = map.value(prefix + analyzeOpenFilesKey).toBool();
|
||||
@@ -78,7 +78,7 @@ void RunSettings::toMap(QVariantMap &map, const QString &prefix) const
|
||||
map.insert(prefix + analyzeOpenFilesKey, m_analyzeOpenFiles);
|
||||
}
|
||||
|
||||
Utils::Id RunSettings::diagnosticConfigId() const
|
||||
Id RunSettings::diagnosticConfigId() const
|
||||
{
|
||||
if (!diagnosticConfigsModel().hasConfigWithId(m_diagnosticConfigId))
|
||||
return defaultDiagnosticId();
|
||||
@@ -220,13 +220,12 @@ static QVersionNumber getVersionNumber(QVersionNumber &version, const FilePath &
|
||||
|
||||
QVersionNumber ClangToolsSettings::clangTidyVersion()
|
||||
{
|
||||
return getVersionNumber(instance()->m_clangTidyVersion,
|
||||
ClangTools::Internal::clangTidyExecutable());
|
||||
return getVersionNumber(instance()->m_clangTidyVersion, Internal::clangTidyExecutable());
|
||||
}
|
||||
|
||||
QVersionNumber ClangToolsSettings::clazyVersion()
|
||||
{
|
||||
return ClazyStandaloneInfo(ClangTools::Internal::clazyStandaloneExecutable()).version;
|
||||
return ClazyStandaloneInfo(Internal::clazyStandaloneExecutable()).version;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -41,8 +41,6 @@
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <cpptools/clangdiagnosticconfigsmodel.h>
|
||||
|
||||
using namespace CppTools;
|
||||
|
@@ -53,21 +53,25 @@
|
||||
|
||||
static Q_LOGGING_CATEGORY(LOG, "qtc.clangtools.cftr", QtWarningMsg)
|
||||
|
||||
using namespace Core;
|
||||
using namespace CppTools;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
DocumentClangToolRunner::DocumentClangToolRunner(Core::IDocument *document)
|
||||
DocumentClangToolRunner::DocumentClangToolRunner(IDocument *document)
|
||||
: QObject(document)
|
||||
, m_document(document)
|
||||
, m_temporaryDir("clangtools-single-XXXXXX")
|
||||
{
|
||||
using namespace CppTools;
|
||||
|
||||
m_runTimer.setInterval(500);
|
||||
m_runTimer.setSingleShot(true);
|
||||
|
||||
connect(m_document,
|
||||
&Core::IDocument::contentsChanged,
|
||||
&IDocument::contentsChanged,
|
||||
this,
|
||||
&DocumentClangToolRunner::scheduleRun);
|
||||
connect(CppModelManager::instance(),
|
||||
@@ -88,7 +92,7 @@ DocumentClangToolRunner::~DocumentClangToolRunner()
|
||||
qDeleteAll(m_marks);
|
||||
}
|
||||
|
||||
Utils::FilePath DocumentClangToolRunner::filePath() const
|
||||
FilePath DocumentClangToolRunner::filePath() const
|
||||
{
|
||||
return m_document->filePath();
|
||||
}
|
||||
@@ -123,10 +127,10 @@ void DocumentClangToolRunner::scheduleRun()
|
||||
m_runTimer.start();
|
||||
}
|
||||
|
||||
static ProjectExplorer::Project *findProject(const Utils::FilePath &file)
|
||||
static Project *findProject(const FilePath &file)
|
||||
{
|
||||
ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(file);
|
||||
return project ? project : ProjectExplorer::SessionManager::startupProject();
|
||||
Project *project = SessionManager::projectForFile(file);
|
||||
return project ? project : SessionManager::startupProject();
|
||||
}
|
||||
|
||||
static VirtualFileSystemOverlay &vfso()
|
||||
@@ -135,29 +139,28 @@ static VirtualFileSystemOverlay &vfso()
|
||||
return overlay;
|
||||
}
|
||||
|
||||
static FileInfo getFileInfo(const Utils::FilePath &file, ProjectExplorer::Project *project)
|
||||
static FileInfo getFileInfo(const FilePath &file, Project *project)
|
||||
{
|
||||
const CppTools::ProjectInfo::Ptr projectInfo
|
||||
= CppTools::CppModelManager::instance()->projectInfo(project);
|
||||
const ProjectInfo::Ptr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||
if (!projectInfo)
|
||||
return {};
|
||||
|
||||
FileInfo candidate;
|
||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo->projectParts()) {
|
||||
for (const ProjectPart::Ptr &projectPart : projectInfo->projectParts()) {
|
||||
QTC_ASSERT(projectPart, continue);
|
||||
|
||||
for (const CppTools::ProjectFile &projectFile : qAsConst(projectPart->files)) {
|
||||
QTC_ASSERT(projectFile.kind != CppTools::ProjectFile::Unclassified, continue);
|
||||
QTC_ASSERT(projectFile.kind != CppTools::ProjectFile::Unsupported, continue);
|
||||
if (projectFile.path == CppTools::CppModelManager::configurationFileName())
|
||||
for (const ProjectFile &projectFile : qAsConst(projectPart->files)) {
|
||||
QTC_ASSERT(projectFile.kind != ProjectFile::Unclassified, continue);
|
||||
QTC_ASSERT(projectFile.kind != ProjectFile::Unsupported, continue);
|
||||
if (projectFile.path == CppModelManager::configurationFileName())
|
||||
continue;
|
||||
const auto projectFilePath = Utils::FilePath::fromString(projectFile.path);
|
||||
const auto projectFilePath = FilePath::fromString(projectFile.path);
|
||||
if (file != projectFilePath)
|
||||
continue;
|
||||
if (!projectFile.active)
|
||||
continue;
|
||||
// found the best candidate, early return
|
||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Unknown)
|
||||
if (projectPart->buildTargetType != BuildTargetType::Unknown)
|
||||
return FileInfo(projectFilePath, projectFile.kind, projectPart);
|
||||
// found something but keep looking for better candidates
|
||||
if (candidate.projectPart.isNull())
|
||||
@@ -168,27 +171,27 @@ static FileInfo getFileInfo(const Utils::FilePath &file, ProjectExplorer::Projec
|
||||
return candidate;
|
||||
}
|
||||
|
||||
static Utils::Environment projectBuildEnvironment(ProjectExplorer::Project *project)
|
||||
static Environment projectBuildEnvironment(Project *project)
|
||||
{
|
||||
Utils::Environment env;
|
||||
if (ProjectExplorer::Target *target = project->activeTarget()) {
|
||||
if (ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
||||
Environment env;
|
||||
if (Target *target = project->activeTarget()) {
|
||||
if (BuildConfiguration *buildConfig = target->activeBuildConfiguration())
|
||||
env = buildConfig->environment();
|
||||
}
|
||||
if (env.size() == 0)
|
||||
env = Utils::Environment::systemEnvironment();
|
||||
env = Environment::systemEnvironment();
|
||||
return env;
|
||||
}
|
||||
|
||||
void DocumentClangToolRunner::run()
|
||||
{
|
||||
cancel();
|
||||
auto isEditorForCurrentDocument = [this](const Core::IEditor *editor) {
|
||||
auto isEditorForCurrentDocument = [this](const IEditor *editor) {
|
||||
return editor->document() == m_document;
|
||||
};
|
||||
if (Utils::anyOf(Core::EditorManager::visibleEditors(), isEditorForCurrentDocument)) {
|
||||
const Utils::FilePath filePath = m_document->filePath();
|
||||
if (ProjectExplorer::Project *project = findProject(filePath)) {
|
||||
if (Utils::anyOf(EditorManager::visibleEditors(), isEditorForCurrentDocument)) {
|
||||
const FilePath filePath = m_document->filePath();
|
||||
if (Project *project = findProject(filePath)) {
|
||||
m_fileInfo = getFileInfo(filePath, project);
|
||||
if (m_fileInfo.file.exists()) {
|
||||
const auto projectSettings = ClangToolsProjectSettings::getSettings(project);
|
||||
@@ -207,10 +210,10 @@ void DocumentClangToolRunner::run()
|
||||
if (runSettings.analyzeOpenFiles()) {
|
||||
vfso().update();
|
||||
|
||||
CppTools::ClangDiagnosticConfig config = diagnosticConfig(
|
||||
ClangDiagnosticConfig config = diagnosticConfig(
|
||||
runSettings.diagnosticConfigId());
|
||||
|
||||
Utils::Environment env = projectBuildEnvironment(project);
|
||||
Environment env = projectBuildEnvironment(project);
|
||||
if (config.isClangTidyEnabled()) {
|
||||
m_runnerCreators << [this, env, config]() {
|
||||
return createRunner<ClangTidyRunner>(config, env);
|
||||
@@ -231,10 +234,10 @@ void DocumentClangToolRunner::run()
|
||||
runNext();
|
||||
}
|
||||
|
||||
QPair<Utils::FilePath, QString> getClangIncludeDirAndVersion(ClangToolRunner *runner)
|
||||
QPair<FilePath, QString> getClangIncludeDirAndVersion(ClangToolRunner *runner)
|
||||
{
|
||||
static QMap<Utils::FilePath, QPair<Utils::FilePath, QString>> cache;
|
||||
const Utils::FilePath tool = runner->executable();
|
||||
static QMap<FilePath, QPair<FilePath, QString>> cache;
|
||||
const FilePath tool = runner->executable();
|
||||
auto it = cache.find(tool);
|
||||
if (it == cache.end())
|
||||
it = cache.insert(tool, getClangIncludeDirAndVersion(tool));
|
||||
@@ -253,7 +256,7 @@ void DocumentClangToolRunner::runNext()
|
||||
runNext();
|
||||
} else {
|
||||
AnalyzeUnit unit(m_fileInfo, clangIncludeDir, clangVersion);
|
||||
QTC_ASSERT(Utils::FilePath::fromString(unit.file).exists(), runNext(); return;);
|
||||
QTC_ASSERT(FilePath::fromString(unit.file).exists(), runNext(); return;);
|
||||
m_currentRunner->setVFSOverlay(vfso().overlayFilePath().toString());
|
||||
if (!m_currentRunner->run(unit.file, unit.arguments))
|
||||
runNext();
|
||||
@@ -271,10 +274,10 @@ static void updateLocation(Debugger::DiagnosticLocation &location)
|
||||
void DocumentClangToolRunner::onSuccess()
|
||||
{
|
||||
QString errorMessage;
|
||||
Utils::FilePath mappedPath = vfso().autoSavedFilePath(m_document);
|
||||
FilePath mappedPath = vfso().autoSavedFilePath(m_document);
|
||||
Diagnostics diagnostics = readExportedDiagnostics(
|
||||
Utils::FilePath::fromString(m_currentRunner->outputFilePath()),
|
||||
[&](const Utils::FilePath &path) { return path == mappedPath; },
|
||||
FilePath::fromString(m_currentRunner->outputFilePath()),
|
||||
[&](const FilePath &path) { return path == mappedPath; },
|
||||
&errorMessage);
|
||||
|
||||
for (Diagnostic &diag : diagnostics) {
|
||||
@@ -308,9 +311,9 @@ void DocumentClangToolRunner::onSuccess()
|
||||
TextEditor::RefactorMarker marker;
|
||||
marker.tooltip = diagnostic.description;
|
||||
QTextCursor cursor(doc->document());
|
||||
cursor.setPosition(Utils::Text::positionInText(doc->document(),
|
||||
diagnostic.location.line,
|
||||
diagnostic.location.column));
|
||||
cursor.setPosition(Text::positionInText(doc->document(),
|
||||
diagnostic.location.line,
|
||||
diagnostic.location.column));
|
||||
cursor.movePosition(QTextCursor::EndOfLine);
|
||||
marker.cursor = cursor;
|
||||
marker.type = Constants::CLANG_TOOL_FIXIT_AVAILABLE_MARKER_ID;
|
||||
@@ -365,7 +368,7 @@ bool DocumentClangToolRunner::isSuppressed(const Diagnostic &diagnostic) const
|
||||
auto equalsSuppressed = [this, &diagnostic](const SuppressedDiagnostic &suppressed) {
|
||||
if (suppressed.description != diagnostic.description)
|
||||
return false;
|
||||
Utils::FilePath filePath = suppressed.filePath;
|
||||
FilePath filePath = suppressed.filePath;
|
||||
if (filePath.toFileInfo().isRelative())
|
||||
filePath = m_lastProjectDirectory.pathAppended(filePath.toString());
|
||||
return filePath == diagnostic.location.filePath;
|
||||
@@ -373,7 +376,7 @@ bool DocumentClangToolRunner::isSuppressed(const Diagnostic &diagnostic) const
|
||||
return Utils::anyOf(m_suppressed, equalsSuppressed);
|
||||
}
|
||||
|
||||
const CppTools::ClangDiagnosticConfig DocumentClangToolRunner::getDiagnosticConfig(ProjectExplorer::Project *project)
|
||||
const ClangDiagnosticConfig DocumentClangToolRunner::getDiagnosticConfig(Project *project)
|
||||
{
|
||||
const auto projectSettings = ClangToolsProjectSettings::getSettings(project);
|
||||
m_projectSettingsUpdate = connect(projectSettings.data(),
|
||||
@@ -381,15 +384,15 @@ const CppTools::ClangDiagnosticConfig DocumentClangToolRunner::getDiagnosticConf
|
||||
this,
|
||||
&DocumentClangToolRunner::run);
|
||||
|
||||
const Utils::Id &id = projectSettings->useGlobalSettings()
|
||||
? ClangToolsSettings::instance()->runSettings().diagnosticConfigId()
|
||||
: projectSettings->runSettings().diagnosticConfigId();
|
||||
const Id id = projectSettings->useGlobalSettings()
|
||||
? ClangToolsSettings::instance()->runSettings().diagnosticConfigId()
|
||||
: projectSettings->runSettings().diagnosticConfigId();
|
||||
return diagnosticConfig(id);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ClangToolRunner *DocumentClangToolRunner::createRunner(const CppTools::ClangDiagnosticConfig &config,
|
||||
const Utils::Environment &env)
|
||||
ClangToolRunner *DocumentClangToolRunner::createRunner(const ClangDiagnosticConfig &config,
|
||||
const Environment &env)
|
||||
{
|
||||
auto runner = new T(config, this);
|
||||
runner->init(m_temporaryDir.path(), env);
|
||||
|
@@ -45,38 +45,39 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
static const char defineOption[] = "-D";
|
||||
static const char undefineOption[] = "-U";
|
||||
const char defineOption[] = "-D";
|
||||
const char undefineOption[] = "-U";
|
||||
|
||||
static const char includeUserPathOption[] = "-I";
|
||||
static const char includeUserPathOptionWindows[] = "/I";
|
||||
static const char includeSystemPathOption[] = "-isystem";
|
||||
const char includeUserPathOption[] = "-I";
|
||||
const char includeUserPathOptionWindows[] = "/I";
|
||||
const char includeSystemPathOption[] = "-isystem";
|
||||
|
||||
static const char includeFileOptionGcc[] = "-include";
|
||||
static const char includeFileOptionCl[] = "/FI";
|
||||
const char includeFileOptionGcc[] = "-include";
|
||||
const char includeFileOptionCl[] = "/FI";
|
||||
|
||||
static QByteArray macroOption(const ProjectExplorer::Macro ¯o)
|
||||
static QByteArray macroOption(const Macro ¯o)
|
||||
{
|
||||
switch (macro.type) {
|
||||
case ProjectExplorer::MacroType::Define:
|
||||
case MacroType::Define:
|
||||
return defineOption;
|
||||
case ProjectExplorer::MacroType::Undefine:
|
||||
case MacroType::Undefine:
|
||||
return undefineOption;
|
||||
default:
|
||||
return QByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
static QByteArray toDefineOption(const ProjectExplorer::Macro ¯o)
|
||||
static QByteArray toDefineOption(const Macro ¯o)
|
||||
{
|
||||
return macro.toKeyValue(macroOption(macro));
|
||||
}
|
||||
|
||||
static QString defineDirectiveToDefineOption(const ProjectExplorer::Macro ¯o)
|
||||
static QString defineDirectiveToDefineOption(const Macro ¯o)
|
||||
{
|
||||
const QByteArray option = toDefineOption(macro);
|
||||
return QString::fromUtf8(option);
|
||||
@@ -124,13 +125,11 @@ QStringList CompilerOptionsBuilder::build(ProjectFile::Kind fileKind,
|
||||
evaluateCompilerFlags();
|
||||
|
||||
if (fileKind == ProjectFile::CHeader || fileKind == ProjectFile::CSource) {
|
||||
QTC_ASSERT(m_projectPart.languageVersion <= Utils::LanguageVersion::LatestC,
|
||||
return QStringList(););
|
||||
QTC_ASSERT(m_projectPart.languageVersion <= LanguageVersion::LatestC, return {});
|
||||
}
|
||||
|
||||
if (fileKind == ProjectFile::CXXHeader || fileKind == ProjectFile::CXXSource) {
|
||||
QTC_ASSERT(m_projectPart.languageVersion > Utils::LanguageVersion::LatestC,
|
||||
return QStringList(););
|
||||
QTC_ASSERT(m_projectPart.languageVersion > LanguageVersion::LatestC, return {});
|
||||
}
|
||||
|
||||
addCompilerFlags();
|
||||
@@ -278,7 +277,7 @@ void CompilerOptionsBuilder::addMsvcExceptions()
|
||||
{
|
||||
if (!m_clStyle)
|
||||
return;
|
||||
if (Utils::anyOf(m_projectPart.toolChainMacros, [](const ProjectExplorer::Macro ¯o) {
|
||||
if (Utils::anyOf(m_projectPart.toolChainMacros, [](const Macro ¯o) {
|
||||
return macro.key == "_CPPUNWIND";
|
||||
})) {
|
||||
enableExceptions();
|
||||
@@ -291,7 +290,7 @@ void CompilerOptionsBuilder::enableExceptions()
|
||||
// This is most likely due to incomplete exception support of clang.
|
||||
// However, as we need exception support only in the frontend,
|
||||
// enabling them explicitly should be fine.
|
||||
if (m_projectPart.languageVersion > ::Utils::LanguageVersion::LatestC)
|
||||
if (m_projectPart.languageVersion > LanguageVersion::LatestC)
|
||||
add("-fcxx-exceptions");
|
||||
add("-fexceptions");
|
||||
}
|
||||
@@ -347,9 +346,6 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||
|
||||
filter.process();
|
||||
|
||||
using ProjectExplorer::HeaderPath;
|
||||
using ProjectExplorer::HeaderPathType;
|
||||
|
||||
for (const HeaderPath &headerPath : qAsConst(filter.userHeaderPaths))
|
||||
addIncludeDirOptionForPath(headerPath);
|
||||
for (const HeaderPath &headerPath : qAsConst(filter.systemHeaderPaths))
|
||||
@@ -410,11 +406,11 @@ void CompilerOptionsBuilder::addProjectMacros()
|
||||
addMacros(m_projectPart.projectMacros);
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilder::addMacros(const ProjectExplorer::Macros ¯os)
|
||||
void CompilerOptionsBuilder::addMacros(const Macros ¯os)
|
||||
{
|
||||
QStringList options;
|
||||
|
||||
for (const ProjectExplorer::Macro ¯o : macros) {
|
||||
for (const Macro ¯o : macros) {
|
||||
if (excludeDefineDirective(macro))
|
||||
continue;
|
||||
|
||||
@@ -447,8 +443,7 @@ void CompilerOptionsBuilder::updateFileLanguage(ProjectFile::Kind fileKind)
|
||||
return;
|
||||
}
|
||||
|
||||
const bool objcExt = m_projectPart.languageExtensions
|
||||
& Utils::LanguageExtension::ObjectiveC;
|
||||
const bool objcExt = m_projectPart.languageExtensions & LanguageExtension::ObjectiveC;
|
||||
const QStringList options = createLanguageOptionGcc(fileKind, objcExt);
|
||||
if (options.isEmpty())
|
||||
return;
|
||||
@@ -463,9 +458,6 @@ void CompilerOptionsBuilder::updateFileLanguage(ProjectFile::Kind fileKind)
|
||||
|
||||
void CompilerOptionsBuilder::addLanguageVersionAndExtensions()
|
||||
{
|
||||
using Utils::LanguageExtension;
|
||||
using Utils::LanguageVersion;
|
||||
|
||||
if (m_compilerFlags.isLanguageVersionSpecified)
|
||||
return;
|
||||
|
||||
@@ -493,7 +485,7 @@ void CompilerOptionsBuilder::addLanguageVersionAndExtensions()
|
||||
// Continue in case no cl-style option could be chosen.
|
||||
}
|
||||
|
||||
const Utils::LanguageExtensions languageExtensions = m_projectPart.languageExtensions;
|
||||
const LanguageExtensions languageExtensions = m_projectPart.languageExtensions;
|
||||
const bool gnuExtensions = languageExtensions & LanguageExtension::Gnu;
|
||||
|
||||
switch (m_projectPart.languageVersion) {
|
||||
@@ -542,9 +534,9 @@ static QByteArray toMsCompatibilityVersionFormat(const QByteArray &mscFullVer)
|
||||
+ mscFullVer.mid(2, 2);
|
||||
}
|
||||
|
||||
static QByteArray msCompatibilityVersionFromDefines(const ProjectExplorer::Macros ¯os)
|
||||
static QByteArray msCompatibilityVersionFromDefines(const Macros ¯os)
|
||||
{
|
||||
for (const ProjectExplorer::Macro ¯o : macros) {
|
||||
for (const Macro ¯o : macros) {
|
||||
if (macro.key == "_MSC_FULL_VER")
|
||||
return toMsCompatibilityVersionFormat(macro.value);
|
||||
}
|
||||
@@ -652,18 +644,18 @@ void CompilerOptionsBuilder::addDefineFunctionMacrosMsvc()
|
||||
}
|
||||
}
|
||||
|
||||
void CompilerOptionsBuilder::addIncludeDirOptionForPath(const ProjectExplorer::HeaderPath &path)
|
||||
void CompilerOptionsBuilder::addIncludeDirOptionForPath(const HeaderPath &path)
|
||||
{
|
||||
if (path.type == ProjectExplorer::HeaderPathType::Framework) {
|
||||
if (path.type == HeaderPathType::Framework) {
|
||||
QTC_ASSERT(!isClStyle(), return;);
|
||||
add({"-F", QDir::toNativeSeparators(path.path)});
|
||||
return;
|
||||
}
|
||||
|
||||
bool systemPath = false;
|
||||
if (path.type == ProjectExplorer::HeaderPathType::BuiltIn) {
|
||||
if (path.type == HeaderPathType::BuiltIn) {
|
||||
systemPath = true;
|
||||
} else if (path.type == ProjectExplorer::HeaderPathType::System) {
|
||||
} else if (path.type == HeaderPathType::System) {
|
||||
if (m_useSystemHeader == UseSystemHeader::Yes)
|
||||
systemPath = true;
|
||||
} else {
|
||||
@@ -682,7 +674,7 @@ void CompilerOptionsBuilder::addIncludeDirOptionForPath(const ProjectExplorer::H
|
||||
add({includeUserPathOption, QDir::toNativeSeparators(path.path)});
|
||||
}
|
||||
|
||||
bool CompilerOptionsBuilder::excludeDefineDirective(const ProjectExplorer::Macro ¯o) const
|
||||
bool CompilerOptionsBuilder::excludeDefineDirective(const Macro ¯o) const
|
||||
{
|
||||
// Avoid setting __cplusplus & co as this might conflict with other command line flags.
|
||||
// Clang should set __cplusplus based on -std= and -fms-compatibility-version version.
|
||||
@@ -726,7 +718,7 @@ bool CompilerOptionsBuilder::excludeDefineDirective(const ProjectExplorer::Macro
|
||||
|
||||
QStringList CompilerOptionsBuilder::wrappedQtHeadersIncludePath() const
|
||||
{
|
||||
if (m_projectPart.qtVersion == Utils::QtVersion::None)
|
||||
if (m_projectPart.qtVersion == QtVersion::None)
|
||||
return {};
|
||||
return {"wrappedQtHeaders", "wrappedQtHeaders/QtCore"};
|
||||
}
|
||||
@@ -782,7 +774,7 @@ void CompilerOptionsBuilder::evaluateCompilerFlags()
|
||||
qgetenv("QTC_CLANG_CMD_OPTIONS_BLACKLIST"))
|
||||
.split(';', Qt::SkipEmptyParts);
|
||||
|
||||
const Utils::Id &toolChain = m_projectPart.toolchainType;
|
||||
const Id toolChain = m_projectPart.toolchainType;
|
||||
bool containsDriverMode = false;
|
||||
bool skipNext = false;
|
||||
const QStringList allFlags = m_projectPart.compilerFlags + m_projectPart.extraCodeModelFlags;
|
||||
|
@@ -80,11 +80,11 @@ static FilePath fallbackClangdFilePath()
|
||||
return "clangd";
|
||||
}
|
||||
|
||||
static Utils::Id clangDiagnosticConfigIdFromSettings(QSettings *s)
|
||||
static Id clangDiagnosticConfigIdFromSettings(QSettings *s)
|
||||
{
|
||||
QTC_ASSERT(s->group() == QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP), return Utils::Id());
|
||||
QTC_ASSERT(s->group() == QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP), return Id());
|
||||
|
||||
return Utils::Id::fromSetting(
|
||||
return Id::fromSetting(
|
||||
s->value(clangDiagnosticConfigKey(), initialClangDiagnosticConfigId().toSetting()));
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ static ClangDiagnosticConfigs removedBuiltinConfigs()
|
||||
return configs;
|
||||
}
|
||||
|
||||
static ClangDiagnosticConfig convertToCustomConfig(const Utils::Id &id)
|
||||
static ClangDiagnosticConfig convertToCustomConfig(const Id &id)
|
||||
{
|
||||
const ClangDiagnosticConfig config
|
||||
= Utils::findOrDefault(removedBuiltinConfigs(), [id](const ClangDiagnosticConfig &config) {
|
||||
@@ -151,7 +151,7 @@ void CppCodeModelSettings::fromSettings(QSettings *s)
|
||||
|
||||
// Qt Creator 4.11 removes some built-in configs.
|
||||
bool write = false;
|
||||
const Utils::Id id = m_clangDiagnosticConfigId;
|
||||
const Id id = m_clangDiagnosticConfigId;
|
||||
if (id == "Builtin.Pedantic" || id == "Builtin.EverythingWithExceptions") {
|
||||
// If one of them was used, continue to use it, but convert it to a custom config.
|
||||
const ClangDiagnosticConfig customConfig = convertToCustomConfig(id);
|
||||
@@ -192,7 +192,7 @@ void CppCodeModelSettings::toSettings(QSettings *s)
|
||||
{
|
||||
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
|
||||
const ClangDiagnosticConfigs previousConfigs = diagnosticConfigsFromSettings(s);
|
||||
const Utils::Id previousConfigId = clangDiagnosticConfigIdFromSettings(s);
|
||||
const Id previousConfigId = clangDiagnosticConfigIdFromSettings(s);
|
||||
|
||||
diagnosticConfigsToSettings(s, m_clangCustomDiagnosticConfigs);
|
||||
|
||||
@@ -206,7 +206,7 @@ void CppCodeModelSettings::toSettings(QSettings *s)
|
||||
|
||||
s->endGroup();
|
||||
|
||||
QVector<Utils::Id> invalidated
|
||||
QVector<Id> invalidated
|
||||
= ClangDiagnosticConfigsModel::changedOrRemovedConfigs(previousConfigs,
|
||||
m_clangCustomDiagnosticConfigs);
|
||||
|
||||
@@ -218,19 +218,19 @@ void CppCodeModelSettings::toSettings(QSettings *s)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
Utils::Id CppCodeModelSettings::clangDiagnosticConfigId() const
|
||||
Id CppCodeModelSettings::clangDiagnosticConfigId() const
|
||||
{
|
||||
if (!diagnosticConfigsModel().hasConfigWithId(m_clangDiagnosticConfigId))
|
||||
return defaultClangDiagnosticConfigId();
|
||||
return m_clangDiagnosticConfigId;
|
||||
}
|
||||
|
||||
void CppCodeModelSettings::setClangDiagnosticConfigId(const Utils::Id &configId)
|
||||
void CppCodeModelSettings::setClangDiagnosticConfigId(const Id &configId)
|
||||
{
|
||||
m_clangDiagnosticConfigId = configId;
|
||||
}
|
||||
|
||||
Utils::Id CppCodeModelSettings::defaultClangDiagnosticConfigId()
|
||||
Id CppCodeModelSettings::defaultClangDiagnosticConfigId()
|
||||
{
|
||||
return initialClangDiagnosticConfigId();
|
||||
}
|
||||
@@ -310,7 +310,7 @@ ClangdSettings &ClangdSettings::instance()
|
||||
return settings;
|
||||
}
|
||||
|
||||
void ClangdSettings::setDefaultClangdPath(const Utils::FilePath &filePath)
|
||||
void ClangdSettings::setDefaultClangdPath(const FilePath &filePath)
|
||||
{
|
||||
g_defaultClangdFilePath = filePath;
|
||||
}
|
||||
@@ -343,7 +343,8 @@ void ClangdSettings::saveSettings()
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
void ClangdSettings::setUseClangd(bool use) { instance().m_data.useClangd = use; }
|
||||
void ClangdSettings::setClangdFilePath(const Utils::FilePath &filePath)
|
||||
|
||||
void ClangdSettings::setClangdFilePath(const FilePath &filePath)
|
||||
{
|
||||
instance().m_data.executableFilePath = filePath;
|
||||
}
|
||||
|
Reference in New Issue
Block a user