summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2018-06-13 09:48:32 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-06-21 09:30:56 +0000
commitcc84b351940f2aa9177d0cb83e827be06f219d8f (patch)
tree3b8be0e17d167a86853cae7ab990d3c49b2e2032 /lib
parent43ac160b1aa4d98ad07f1e8dde5e445593dc8d91 (diff)
[libclang] Allow skipping warnings from all included files
------------------------------------------------------------------ * https://reviews.llvm.org/D48116 ------------------------------------------------------------------ Depending on the included files and the used warning flags, e.g. - Weverything, a huge number of warnings can be reported for included files. As processing that many diagnostics comes with a performance impact and not all clients are interested in those diagnostics, add a flag to skip them. Change-Id: Ia738a9382b43d210046bff68b3be8cb9dd89206f Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/Diagnostic.cpp1
-rw-r--r--lib/Basic/DiagnosticIDs.cpp8
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 26baa838f8..dd15c83e5b 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -70,6 +70,7 @@ DiagnosticsEngine::DiagnosticsEngine(IntrusiveRefCntPtr<DiagnosticIDs> diags,
AllExtensionsSilenced = 0;
SuppressAfterFatalError = true;
SuppressAllDiagnostics = false;
+ SuppressNonErrorsFromIncludedFiles = false;
ElideType = true;
PrintTemplateTree = false;
ShowColors = false;
diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp
index c4c425d9eb..ab7802651d 100644
--- a/lib/Basic/DiagnosticIDs.cpp
+++ b/lib/Basic/DiagnosticIDs.cpp
@@ -477,6 +477,14 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
Result = diag::Severity::Fatal;
}
+ // If requested, ignore warnings from all headers.
+ if (Diag.SuppressNonErrorsFromIncludedFiles &&
+ Result <= diag::Severity::Warning && Loc.isValid() &&
+ !Diag.getSourceManager().isInMainFile(
+ Diag.getSourceManager().getExpansionLoc(Loc))) {
+ return diag::Severity::Ignored;
+ }
+
// Custom diagnostics always are emitted in system headers.
bool ShowInSystemHeader =
!GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader;