[libclang] Allow skipping warnings from all included files
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.
Differential Revision: https://reviews.llvm.org/D48116
llvm-svn: 363067
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index ad3dc70..63bae07 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -443,10 +443,14 @@
if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForIndexing))
setThreadBackgroundPriority();
- bool CaptureDiagnostics = !Logger::isLoggingEnabled();
+ CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::All;
+ if (TU_options & CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles)
+ CaptureDiagnostics = CaptureDiagsKind::AllWithoutNonErrorsFromIncludes;
+ if (Logger::isLoggingEnabled())
+ CaptureDiagnostics = CaptureDiagsKind::None;
CaptureDiagnosticConsumer *CaptureDiag = nullptr;
- if (CaptureDiagnostics)
+ if (CaptureDiagnostics != CaptureDiagsKind::None)
CaptureDiag = new CaptureDiagnosticConsumer();
// Configure the diagnostics.