forked from qt-creator/qt-creator
clang-tidy: Suppress clang warnings
Those warnings should be printed via the clang code model, which can be fine tuned to (de-)activate warnings. The clang-diagnostic-* warnings from clang-tidy are not shown in the dialog an thus can not be selectivly activated by the user. Change-Id: I80b2cad227a9fd8fa0de253c73c40abfa8076be6 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
Björn Schäpers
parent
3e2d224722
commit
8987996500
@@ -58,10 +58,10 @@ static QStringList tidyChecksArguments(const ClangDiagnosticConfig diagnosticCon
|
|||||||
const ClangDiagnosticConfig::TidyMode tidyMode = diagnosticConfig.clangTidyMode();
|
const ClangDiagnosticConfig::TidyMode tidyMode = diagnosticConfig.clangTidyMode();
|
||||||
// The argument "-config={}" stops stating/evaluating the .clang-tidy file.
|
// The argument "-config={}" stops stating/evaluating the .clang-tidy file.
|
||||||
if (tidyMode == ClangDiagnosticConfig::TidyMode::UseDefaultChecks)
|
if (tidyMode == ClangDiagnosticConfig::TidyMode::UseDefaultChecks)
|
||||||
return {"-config={}"};
|
return {"-config={}", "-checks=-clang-diagnostic-*"};
|
||||||
if (tidyMode == ClangDiagnosticConfig::TidyMode::UseCustomChecks)
|
if (tidyMode == ClangDiagnosticConfig::TidyMode::UseCustomChecks)
|
||||||
return {"-config={}", "-checks=" + diagnosticConfig.clangTidyChecks()};
|
return {"-config={}", "-checks=" + diagnosticConfig.clangTidyChecks() + ",-clang-diagnostic-*"};
|
||||||
return {"--warnings-as-errors=-*"};
|
return {"--warnings-as-errors=-*", "-check=-clang-diagnostic-*"};
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList clazyChecksArguments(const ClangDiagnosticConfig diagnosticConfig)
|
static QStringList clazyChecksArguments(const ClangDiagnosticConfig diagnosticConfig)
|
||||||
|
@@ -960,9 +960,6 @@ void ClangTool::filter()
|
|||||||
if (check.name.isEmpty()) {
|
if (check.name.isEmpty()) {
|
||||||
check.name = checkName;
|
check.name = checkName;
|
||||||
check.displayName = checkName;
|
check.displayName = checkName;
|
||||||
const QString clangDiagPrefix = "clang-diagnostic-";
|
|
||||||
if (check.displayName.startsWith(clangDiagPrefix))
|
|
||||||
check.displayName = QString("-W%1").arg(check.name.mid(clangDiagPrefix.size()));
|
|
||||||
check.count = 1;
|
check.count = 1;
|
||||||
check.isShown = filterOptions ? filterOptions->checks.contains(checkName) : true;
|
check.isShown = filterOptions ? filterOptions->checks.contains(checkName) : true;
|
||||||
check.hasFixit = check.hasFixit || item->diagnostic().hasFixits;
|
check.hasFixit = check.hasFixit || item->diagnostic().hasFixits;
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
// clang-tidy -export-fixes=clang.unused-parameter.yaml clang.unused-parameter.cpp -- -Wunused-parameter
|
|
||||||
#include "clang.unused-parameter.h"
|
|
||||||
|
|
||||||
void g(int g) {}
|
|
||||||
|
|
@@ -1 +0,0 @@
|
|||||||
void f(int i) {}
|
|
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
MainSourceFile: 'FILE_PATH'
|
|
||||||
Diagnostics:
|
|
||||||
- DiagnosticName: clang-diagnostic-unused-parameter
|
|
||||||
DiagnosticMessage:
|
|
||||||
Message: 'unused parameter ''g'''
|
|
||||||
FilePath: 'FILE_PATH'
|
|
||||||
FileOffset: 153
|
|
||||||
Replacements: []
|
|
||||||
...
|
|
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
MainSourceFile: 'FILE_PATH'
|
|
||||||
Diagnostics:
|
|
||||||
- DiagnosticName: clang-diagnostic-unused-parameter
|
|
||||||
DiagnosticMessage:
|
|
||||||
Message: 'unused parameter ''g'''
|
|
||||||
FilePath: 'FILE_PATH'
|
|
||||||
FileOffset: 156
|
|
||||||
Replacements: []
|
|
||||||
...
|
|
@@ -146,29 +146,6 @@ TEST_F(ReadExportedDiagnostics, AcceptDiagsFromFilePaths_None)
|
|||||||
ASSERT_THAT(diags, IsEmpty());
|
ASSERT_THAT(diags, IsEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diagnostics from clang passed through via clang-tidy
|
|
||||||
TEST_F(ReadExportedDiagnostics, Tidy_Clang)
|
|
||||||
{
|
|
||||||
const QString sourceFile = TESTDATA "clang.unused-parameter.cpp";
|
|
||||||
const QString yamlSuffix
|
|
||||||
= QLatin1String(Utils::HostOsInfo::isWindowsHost() ? "_win.yaml" : ".yaml");
|
|
||||||
const QString exportedFile = createFile(appendYamlSuffix(TESTDATA "clang.unused-parameter"),
|
|
||||||
sourceFile);
|
|
||||||
Diagnostic expectedDiag;
|
|
||||||
expectedDiag.name = "clang-diagnostic-unused-parameter";
|
|
||||||
expectedDiag.location = {sourceFile, 4, 12};
|
|
||||||
expectedDiag.description = "unused parameter 'g' [clang-diagnostic-unused-parameter]";
|
|
||||||
expectedDiag.type = "warning";
|
|
||||||
expectedDiag.hasFixits = false;
|
|
||||||
|
|
||||||
Diagnostics diags = readExportedDiagnostics(Utils::FilePath::fromString(exportedFile),
|
|
||||||
{},
|
|
||||||
&errorMessage);
|
|
||||||
|
|
||||||
ASSERT_TRUE(errorMessage.isEmpty());
|
|
||||||
ASSERT_THAT(diags, ElementsAre(expectedDiag));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Diagnostics from clang (static) analyzer passed through via clang-tidy
|
// Diagnostics from clang (static) analyzer passed through via clang-tidy
|
||||||
TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer)
|
TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user