Merge remote-tracking branch 'origin/5.0'

Conflicts:
	src/plugins/clangtools/clangtoolssettings.cpp
	src/plugins/clangtools/executableinfo.cpp
	src/plugins/clangtools/executableinfo.h

Change-Id: Id8caf63e3e594792467d3447870086bd2d8f73b9
This commit is contained in:
Eike Ziller
2021-09-13 15:36:51 +02:00
98 changed files with 1321 additions and 445 deletions

View File

@@ -225,7 +225,7 @@ QVersionNumber ClangToolsSettings::clangTidyVersion()
QVersionNumber ClangToolsSettings::clazyVersion()
{
return ClazyStandaloneInfo(Internal::clazyStandaloneExecutable()).version;
return ClazyStandaloneInfo::getInfo(Internal::clazyStandaloneExecutable()).version;
}
} // namespace Internal

View File

@@ -353,7 +353,7 @@ QString clazyDocUrl(const QString &check)
{
QVersionNumber version = ClangToolsSettings::clazyVersion();
if (!version.isNull())
version = QVersionNumber(version.majorVersion(), version.minorVersion(), 0);
version = QVersionNumber(version.majorVersion(), version.minorVersion());
const QString versionString = version.isNull() ? "master" : version.toString();
static const char urlTemplate[]
= "https://github.com/KDE/clazy/blob/%1/docs/checks/README-%2.md";

View File

@@ -1140,7 +1140,7 @@ QString removeClangTidyCheck(const QString &checks, const QString &check)
QString removeClazyCheck(const QString &checks, const QString &check)
{
const ClazyStandaloneInfo clazyInfo(clazyStandaloneExecutable());
const ClazyStandaloneInfo clazyInfo = ClazyStandaloneInfo::getInfo(clazyStandaloneExecutable());
ClazyChecksTreeModel model(clazyInfo.supportedChecks);
model.enableChecks(checks.split(',', Qt::SkipEmptyParts));
const QModelIndex index = model.indexForName(check.mid(QString("clazy-").length()));
@@ -1190,7 +1190,8 @@ void disableChecks(const QList<Diagnostic> &diagnostics)
if (diag.name.startsWith("clazy-")) {
if (config.clazyMode() == ClangDiagnosticConfig::ClazyMode::UseDefaultChecks) {
config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks);
const ClazyStandaloneInfo clazyInfo(clazyStandaloneExecutable());
const ClazyStandaloneInfo clazyInfo
= ClazyStandaloneInfo::getInfo(clazyStandaloneExecutable());
config.setClazyChecks(clazyInfo.defaultChecks.join(','));
}
config.setClazyChecks(removeClazyCheck(config.clazyChecks(), diag.name));

View File

@@ -163,6 +163,22 @@ ClangTidyInfo::ClangTidyInfo(const FilePath &executablePath)
, supportedChecks(queryClangTidyChecks(executablePath, "-checks=*"))
{}
ClazyStandaloneInfo ClazyStandaloneInfo::getInfo(const FilePath &executablePath)
{
const QDateTime timeStamp = executablePath.lastModified();
const auto it = cache.find(executablePath);
if (it == cache.end()) {
const ClazyStandaloneInfo info(executablePath);
cache.insert(executablePath, qMakePair(timeStamp, info));
return info;
}
if (it->first != timeStamp) {
it->first = timeStamp;
it->second = ClazyStandaloneInfo::getInfo(executablePath);
}
return it->second;
}
ClazyStandaloneInfo::ClazyStandaloneInfo(const FilePath &executablePath)
: defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
, supportedChecks(querySupportedClazyChecks(executablePath))
@@ -228,5 +244,7 @@ QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolP
return qMakePair(dynamicResourceDir + "/include", dynamicVersion);
}
QHash<Utils::FilePath, QPair<QDateTime, ClazyStandaloneInfo>> ClazyStandaloneInfo::cache;
} // namespace Internal
} // namespace ClangTools

View File

@@ -27,6 +27,8 @@
#include <utils/filepath.h>
#include <QDateTime>
#include <QHash>
#include <QPair>
#include <QStringList>
#include <QVector>
@@ -60,11 +62,16 @@ using ClazyChecks = QVector<ClazyCheck>;
class ClazyStandaloneInfo
{
public:
ClazyStandaloneInfo(const Utils::FilePath &executablePath);
static ClazyStandaloneInfo getInfo(const Utils::FilePath &executablePath);
QVersionNumber version;
QStringList defaultChecks;
ClazyChecks supportedChecks;
private:
ClazyStandaloneInfo(const Utils::FilePath &executablePath);
static QHash<Utils::FilePath, QPair<QDateTime, ClazyStandaloneInfo>> cache;
};
} // namespace Internal

View File

@@ -82,7 +82,7 @@ static CppEditor::ClangDiagnosticConfigsWidget *createEditWidget(
return new DiagnosticConfigsWidget(configs,
configToSelect,
ClangTidyInfo(clangTidyPath),
ClazyStandaloneInfo(clazyStandalonePath));
ClazyStandaloneInfo::getInfo(clazyStandalonePath));
}
void RunSettingsWidget::fromSettings(const RunSettings &s)