diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-02-07 19:55:45 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-02-07 19:55:45 +0000 |
commit | 4c17fa7620e44f5491d277b156b94bc1bfc35b3c (patch) | |
tree | 52c8f06c979ac208c4deef6f387281dcff978e6c /clang/lib/Basic | |
parent | 09d20eefaa5d0dcdd17db45e4065a23396dcb574 (diff) | |
download | bcm5719-llvm-4c17fa7620e44f5491d277b156b94bc1bfc35b3c.tar.gz bcm5719-llvm-4c17fa7620e44f5491d277b156b94bc1bfc35b3c.zip |
In r149662, setDiagnosticMapping was modified to not allow warnings mapped to
MAP_ERROR to be remapped to MAP_WARNING. These new APIs are being added to
allow the diagnostic mapping's "no Werror" bit to be set, and potentially
downgrade anything already mapped to be a warning.
llvm-svn: 150001
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 79052464470..268b024c7e0 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -243,6 +243,24 @@ bool DiagnosticsEngine::setDiagnosticGroupMapping( return false; } +void DiagnosticsEngine::setDiagnosticWarningAsError(diag::kind Diag, + bool Enabled) { + // If we are enabling this feature, just set the diagnostic mappings to map to + // errors. + if (Enabled) + setDiagnosticMapping(Diag, diag::MAP_ERROR, SourceLocation()); + + // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and + // potentially downgrade anything already mapped to be a warning. + DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo(Diag); + + if (Info.getMapping() == diag::MAP_ERROR || + Info.getMapping() == diag::MAP_FATAL) + Info.setMapping(diag::MAP_WARNING); + + Info.setNoWarningAsError(true); +} + bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled) { // If we are enabling this feature, just set the diagnostic mappings to map to @@ -273,6 +291,23 @@ bool DiagnosticsEngine::setDiagnosticGroupWarningAsError(StringRef Group, return false; } +void DiagnosticsEngine::setDiagnosticErrorAsFatal(diag::kind Diag, + bool Enabled) { + // If we are enabling this feature, just set the diagnostic mappings to map to + // errors. + if (Enabled) + setDiagnosticMapping(Diag, diag::MAP_FATAL, SourceLocation()); + + // Otherwise, we want to set the diagnostic mapping's "no Werror" bit, and + // potentially downgrade anything already mapped to be a warning. + DiagnosticMappingInfo &Info = GetCurDiagState()->getOrAddMappingInfo(Diag); + + if (Info.getMapping() == diag::MAP_FATAL) + Info.setMapping(diag::MAP_ERROR); + + Info.setNoErrorAsFatal(true); +} + bool DiagnosticsEngine::setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled) { // If we are enabling this feature, just set the diagnostic mappings to map to |