diff options
author | Manuel Klimek <klimek@google.com> | 2016-03-01 10:56:19 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2016-03-01 10:56:19 +0000 |
commit | 016c024ca4798796480af7ecae6758e95600550f (patch) | |
tree | e599961bf87585bea4ae6ded81756f747efc4a40 /clang/lib/Basic | |
parent | 255689c3ad4feb4af32aea0a50ab881f472a66e9 (diff) | |
download | bcm5719-llvm-016c024ca4798796480af7ecae6758e95600550f.tar.gz bcm5719-llvm-016c024ca4798796480af7ecae6758e95600550f.zip |
Optionally demote fatal errors to non-fatal errors.
This behavior is enabled when the new CXTranslationUnit_KeepGoing
option is passed to clang_parseTranslationUnit{,2}. It is geared
towards use by IDEs and similar consumers of the clang-c API where
fatal errors may arise when parsing incomplete code mid-edit, or
when include paths are not properly configured yet. In such situations
one still wants to get as much information as possible about a TU.
Previously, the semantic analysis would not instantiate templates
or report additional fatal errors after the first fatal error was
encountered.
Fixes PR24268.
Patch by Milian Wolff.
llvm-svn: 262318
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 1 | ||||
-rw-r--r-- | clang/lib/Basic/DiagnosticIDs.cpp | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 7cf7305827f..f10d156743b 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -68,6 +68,7 @@ DiagnosticsEngine::DiagnosticsEngine( WarningsAsErrors = false; EnableAllWarnings = false; ErrorsAsFatal = false; + FatalsAsError = false; SuppressSystemWarnings = false; SuppressAllDiagnostics = false; ElideType = true; diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp index a34c7fecb53..efc3f94c959 100644 --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -462,6 +462,12 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, Result = diag::Severity::Fatal; } + // If explicitly requested, map fatal errors to errors. + if (Result == diag::Severity::Fatal) { + if (Diag.FatalsAsError) + Result = diag::Severity::Error; + } + // Custom diagnostics always are emitted in system headers. bool ShowInSystemHeader = !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader; |