forked from qt-creator/qt-creator
ClangTools: Cache information about the clazy executable
Fixes: QTCREATORBUG-26237 Change-Id: I43203d58b8ed278664427e3b4112a7c7848354b9 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -227,7 +227,7 @@ QVersionNumber ClangToolsSettings::clangTidyVersion()
|
|||||||
|
|
||||||
QVersionNumber ClangToolsSettings::clazyVersion()
|
QVersionNumber ClangToolsSettings::clazyVersion()
|
||||||
{
|
{
|
||||||
return ClazyStandaloneInfo(ClangTools::Internal::clazyStandaloneExecutable()).version;
|
return ClazyStandaloneInfo::getInfo(ClangTools::Internal::clazyStandaloneExecutable()).version;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -1140,7 +1140,7 @@ QString removeClangTidyCheck(const QString &checks, const QString &check)
|
|||||||
|
|
||||||
QString removeClazyCheck(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);
|
ClazyChecksTreeModel model(clazyInfo.supportedChecks);
|
||||||
model.enableChecks(checks.split(',', Qt::SkipEmptyParts));
|
model.enableChecks(checks.split(',', Qt::SkipEmptyParts));
|
||||||
const QModelIndex index = model.indexForName(check.mid(QString("clazy-").length()));
|
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 (diag.name.startsWith("clazy-")) {
|
||||||
if (config.clazyMode() == ClangDiagnosticConfig::ClazyMode::UseDefaultChecks) {
|
if (config.clazyMode() == ClangDiagnosticConfig::ClazyMode::UseDefaultChecks) {
|
||||||
config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks);
|
config.setClazyMode(ClangDiagnosticConfig::ClazyMode::UseCustomChecks);
|
||||||
const ClazyStandaloneInfo clazyInfo(clazyStandaloneExecutable());
|
const ClazyStandaloneInfo clazyInfo
|
||||||
|
= ClazyStandaloneInfo::getInfo(clazyStandaloneExecutable());
|
||||||
config.setClazyChecks(clazyInfo.defaultChecks.join(','));
|
config.setClazyChecks(clazyInfo.defaultChecks.join(','));
|
||||||
}
|
}
|
||||||
config.setClazyChecks(removeClazyCheck(config.clazyChecks(), diag.name));
|
config.setClazyChecks(removeClazyCheck(config.clazyChecks(), diag.name));
|
||||||
|
|||||||
@@ -163,6 +163,23 @@ ClangTidyInfo::ClangTidyInfo(const QString &executablePath)
|
|||||||
, supportedChecks(queryClangTidyChecks(executablePath, "-checks=*"))
|
, supportedChecks(queryClangTidyChecks(executablePath, "-checks=*"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
ClazyStandaloneInfo ClazyStandaloneInfo::getInfo(const QString &_executablePath)
|
||||||
|
{
|
||||||
|
const FilePath executablePath = FilePath::fromString(_executablePath);
|
||||||
|
const QDateTime timeStamp = executablePath.lastModified();
|
||||||
|
const auto it = cache.find(executablePath);
|
||||||
|
if (it == cache.end()) {
|
||||||
|
const ClazyStandaloneInfo info(executablePath.toString());
|
||||||
|
cache.insert(executablePath, qMakePair(timeStamp, info));
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
if (it->first != timeStamp) {
|
||||||
|
it->first = timeStamp;
|
||||||
|
it->second = ClazyStandaloneInfo(executablePath.toString());
|
||||||
|
}
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
ClazyStandaloneInfo::ClazyStandaloneInfo(const QString &executablePath)
|
ClazyStandaloneInfo::ClazyStandaloneInfo(const QString &executablePath)
|
||||||
: defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
|
: defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
|
||||||
, supportedChecks(querySupportedClazyChecks(executablePath))
|
, supportedChecks(querySupportedClazyChecks(executablePath))
|
||||||
@@ -229,5 +246,7 @@ QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolP
|
|||||||
return qMakePair(dynamicResourceDir + "/include", dynamicVersion);
|
return qMakePair(dynamicResourceDir + "/include", dynamicVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHash<Utils::FilePath, QPair<QDateTime, ClazyStandaloneInfo>> ClazyStandaloneInfo::cache;
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ClangTools
|
} // namespace ClangTools
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QHash>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
@@ -60,11 +62,16 @@ using ClazyChecks = QVector<ClazyCheck>;
|
|||||||
class ClazyStandaloneInfo
|
class ClazyStandaloneInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClazyStandaloneInfo(const QString &executablePath);
|
static ClazyStandaloneInfo getInfo(const QString &executablePath);
|
||||||
|
|
||||||
QVersionNumber version;
|
QVersionNumber version;
|
||||||
QStringList defaultChecks;
|
QStringList defaultChecks;
|
||||||
ClazyChecks supportedChecks;
|
ClazyChecks supportedChecks;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ClazyStandaloneInfo(const QString &executablePath);
|
||||||
|
|
||||||
|
static QHash<Utils::FilePath, QPair<QDateTime, ClazyStandaloneInfo>> cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ static CppTools::ClangDiagnosticConfigsWidget *createEditWidget(
|
|||||||
return new DiagnosticConfigsWidget(configs,
|
return new DiagnosticConfigsWidget(configs,
|
||||||
configToSelect,
|
configToSelect,
|
||||||
ClangTidyInfo(clangTidyPath),
|
ClangTidyInfo(clangTidyPath),
|
||||||
ClazyStandaloneInfo(clazyStandalonePath));
|
ClazyStandaloneInfo::getInfo(clazyStandalonePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunSettingsWidget::fromSettings(const RunSettings &s)
|
void RunSettingsWidget::fromSettings(const RunSettings &s)
|
||||||
|
|||||||
Reference in New Issue
Block a user