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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user