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:
Christian Kandeler
2021-09-08 12:08:55 +02:00
parent 2d77922856
commit bf275331dd
5 changed files with 32 additions and 5 deletions

View File

@@ -163,6 +163,23 @@ ClangTidyInfo::ClangTidyInfo(const QString &executablePath)
, 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)
: defaultChecks(queryClangTidyChecks(executablePath, {})) // Yup, behaves as clang-tidy.
, supportedChecks(querySupportedClazyChecks(executablePath))
@@ -229,5 +246,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