]> granicus.if.org Git - clang/commitdiff
In r149662, setDiagnosticMapping was modified to not allow warnings mapped to
authorChad Rosier <mcrosier@apple.com>
Tue, 7 Feb 2012 19:55:45 +0000 (19:55 +0000)
committerChad Rosier <mcrosier@apple.com>
Tue, 7 Feb 2012 19:55:45 +0000 (19:55 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150001 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h
lib/Basic/Diagnostic.cpp

index e5dff5ad099ea1a0e05e787f425bbdbdf405e715..b9815125c36c0f776251ceed711bd38f42020d9d 100644 (file)
@@ -464,12 +464,20 @@ public:
   bool setDiagnosticGroupMapping(StringRef Group, diag::Mapping Map,
                                  SourceLocation Loc = SourceLocation());
 
+  /// \brief Set the warning-as-error flag for the given diagnostic. This
+  /// function always only operates on the current diagnostic state.
+  void setDiagnosticWarningAsError(diag::kind Diag, bool Enabled);
+
   /// \brief Set the warning-as-error flag for the given diagnostic group. This
   /// function always only operates on the current diagnostic state.
   ///
   /// \returns True if the given group is unknown, false otherwise.
   bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled);
 
+  /// \brief Set the error-as-fatal flag for the given diagnostic. This function
+  /// always only operates on the current diagnostic state.
+  void setDiagnosticErrorAsFatal(diag::kind Diag, bool Enabled);
+
   /// \brief Set the error-as-fatal flag for the given diagnostic group. This
   /// function always only operates on the current diagnostic state.
   ///
index 790524644708d98a8238ab91d5b99f486bb5cef1..268b024c7e0e29e0b1eb88da8a48092bd26613ca 100644 (file)
@@ -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