forked from qt-creator/qt-creator
CppTools: Add convenience functions to ClangDiagnosticConfig
Change-Id: Iebf01e1ab71dc3500cc6e492c525735f300272ca Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -258,10 +258,10 @@ QList<RunnerCreator> ClangToolRunWorker::runnerCreators()
|
|||||||
{
|
{
|
||||||
QList<RunnerCreator> creators;
|
QList<RunnerCreator> creators;
|
||||||
|
|
||||||
if (m_diagnosticConfig.clangTidyChecks() != "-*")
|
if (m_diagnosticConfig.isClangTidyEnabled())
|
||||||
creators << [this]() { return createRunner<ClangTidyRunner>(); };
|
creators << [this]() { return createRunner<ClangTidyRunner>(); };
|
||||||
|
|
||||||
if (!m_diagnosticConfig.clazyChecks().isEmpty()) {
|
if (m_diagnosticConfig.isClazyEnabled()) {
|
||||||
if (!qEnvironmentVariable("QTC_USE_CLAZY_STANDALONE_PATH").isEmpty())
|
if (!qEnvironmentVariable("QTC_USE_CLAZY_STANDALONE_PATH").isEmpty())
|
||||||
creators << [this]() { return createRunner<ClazyStandaloneRunner>(); };
|
creators << [this]() { return createRunner<ClazyStandaloneRunner>(); };
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ ClangDiagnosticConfigs importDiagnosticConfigsFromCodeModel()
|
|||||||
ClangDiagnosticConfigs clangOnlyConfigs;
|
ClangDiagnosticConfigs clangOnlyConfigs;
|
||||||
std::tie(tidyClazyConfigs, clangOnlyConfigs)
|
std::tie(tidyClazyConfigs, clangOnlyConfigs)
|
||||||
= Utils::partition(configs, [](const ClangDiagnosticConfig &config) {
|
= Utils::partition(configs, [](const ClangDiagnosticConfig &config) {
|
||||||
return !config.clazyChecks().isEmpty() || config.clangTidyChecks() != "-*";
|
return config.isClazyEnabled() || config.isClangTidyEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!tidyClazyConfigs.isEmpty()) {
|
if (!tidyClazyConfigs.isEmpty()) {
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ void ClangDiagnosticConfig::setClangTidyChecks(const QString &checks)
|
|||||||
m_clangTidyChecks = checks;
|
m_clangTidyChecks = checks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClangDiagnosticConfig::isClangTidyEnabled() const
|
||||||
|
{
|
||||||
|
return m_clangTidyMode != TidyMode::UseCustomChecks || clangTidyChecks() != "-*";
|
||||||
|
}
|
||||||
|
|
||||||
QString ClangDiagnosticConfig::clazyChecks() const
|
QString ClangDiagnosticConfig::clazyChecks() const
|
||||||
{
|
{
|
||||||
return m_clazyChecks;
|
return m_clazyChecks;
|
||||||
@@ -140,6 +145,11 @@ void ClangDiagnosticConfig::setClazyChecks(const QString &checks)
|
|||||||
m_clazyChecks = checks;
|
m_clazyChecks = checks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClangDiagnosticConfig::isClazyEnabled() const
|
||||||
|
{
|
||||||
|
return m_clazyMode != ClazyMode::UseCustomChecks || !m_clazyChecks.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
static QString convertToNewClazyChecksFormat(const QString &checks)
|
static QString convertToNewClazyChecksFormat(const QString &checks)
|
||||||
{
|
{
|
||||||
// Before Qt Creator 4.9 valid values for checks were: "", "levelN".
|
// Before Qt Creator 4.9 valid values for checks were: "", "levelN".
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public:
|
|||||||
QString clangTidyChecks() const;
|
QString clangTidyChecks() const;
|
||||||
void setClangTidyChecks(const QString &checks);
|
void setClangTidyChecks(const QString &checks);
|
||||||
|
|
||||||
|
bool isClangTidyEnabled() const;
|
||||||
|
|
||||||
// Clazy
|
// Clazy
|
||||||
enum class ClazyMode
|
enum class ClazyMode
|
||||||
{
|
{
|
||||||
@@ -83,6 +85,8 @@ public:
|
|||||||
QString clazyChecks() const;
|
QString clazyChecks() const;
|
||||||
void setClazyChecks(const QString &checks);
|
void setClazyChecks(const QString &checks);
|
||||||
|
|
||||||
|
bool isClazyEnabled() const;
|
||||||
|
|
||||||
bool operator==(const ClangDiagnosticConfig &other) const;
|
bool operator==(const ClangDiagnosticConfig &other) const;
|
||||||
bool operator!=(const ClangDiagnosticConfig &other) const;
|
bool operator!=(const ClangDiagnosticConfig &other) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user