summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2016-01-25 16:38:28 +0100
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2016-02-25 13:31:15 +0000
commitb2397b6b4faeca5e768bc68a3346fff9d04704f7 (patch)
tree46c2e5d4c969bd1b82dd59ff32294887e2ef9e83 /src/plugins/clangcodemodel
parent817f12fddd7a96333b695ec981d30e1bf6abc810 (diff)
downloadqt-creator-b2397b6b4faeca5e768bc68a3346fff9d04704f7.tar.gz
Clang: Ignore certain warnings in header files
We already had this workarounded, but it got lost in the refactorings. Task-number: QTCREATORBUG-12067 Change-Id: Ie01f9d41f25d17d1b595204748634bc87ef44378 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/clangcodemodel')
-rw-r--r--src/plugins/clangcodemodel/clangdiagnosticfilter.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticfilter.cpp b/src/plugins/clangcodemodel/clangdiagnosticfilter.cpp
index 133b691525..ecd1edf0e5 100644
--- a/src/plugins/clangcodemodel/clangdiagnosticfilter.cpp
+++ b/src/plugins/clangcodemodel/clangdiagnosticfilter.cpp
@@ -25,6 +25,10 @@
#include "clangdiagnosticfilter.h"
+#include <cpptools/cppprojectfile.h>
+
+#include <utf8stringvector.h>
+
namespace {
bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity)
@@ -41,6 +45,17 @@ bool isWarningOrNote(ClangBackEnd::DiagnosticSeverity severity)
Q_UNREACHABLE();
}
+bool isBlackListedDiagnostic(const ClangBackEnd::DiagnosticContainer &diagnostic,
+ bool isHeaderFile)
+{
+ static const Utf8StringVector blackList {
+ Utf8StringLiteral("warning: #pragma once in main file"),
+ Utf8StringLiteral("warning: #include_next in primary source file")
+ };
+
+ return isHeaderFile && blackList.contains(diagnostic.text());
+}
+
template <class Condition>
QVector<ClangBackEnd::DiagnosticContainer>
filterDiagnostics(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
@@ -76,8 +91,13 @@ namespace Internal {
void ClangDiagnosticFilter::filterDocumentRelatedWarnings(
const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics)
{
- const auto isLocalWarning = [this] (const ClangBackEnd::DiagnosticContainer &diagnostic) {
+ using namespace CppTools;
+ const bool isHeaderFile = ProjectFile::isHeader(ProjectFile::classify(m_filePath));
+
+ const auto isLocalWarning = [this, isHeaderFile]
+ (const ClangBackEnd::DiagnosticContainer &diagnostic) {
return isWarningOrNote(diagnostic.severity())
+ && !isBlackListedDiagnostic(diagnostic, isHeaderFile)
&& diagnostic.location().filePath() == m_filePath;
};