[cfe-commits] r69250 - /cfe/trunk/tools/clang-cc/Warnings.cpp

Chris Lattner sabre at nondot.org
Wed Apr 15 17:53:56 PDT 2009


Author: lattner
Date: Wed Apr 15 19:53:55 2009
New Revision: 69250

URL: http://llvm.org/viewvc/llvm-project?rev=69250&view=rev
Log:
when tblgen fills in all the subgroup info, clang is ready for it.
This depends on r69249 of llvm.

Modified:
    cfe/trunk/tools/clang-cc/Warnings.cpp

Modified: cfe/trunk/tools/clang-cc/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Warnings.cpp?rev=69250&r1=69249&r2=69250&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/Warnings.cpp (original)
+++ cfe/trunk/tools/clang-cc/Warnings.cpp Wed Apr 15 19:53:55 2009
@@ -18,10 +18,7 @@
 //
 // Each warning option controls any number of actual warnings.
 // Given a warning option 'foo', the following are valid:
-//
-// -Wfoo         -> alias of -Wfoo=warn
-// -Wno-foo      -> alias of -Wfoo=ignore
-// -Werror=foo   -> alias of -Wfoo=error
+//    -Wfoo, -Wno-foo, -Werror=foo
 //
 #include "clang-cc.h"
 #include "clang/Basic/Diagnostic.h"
@@ -44,8 +41,9 @@
 static llvm::cl::opt<bool> OptNoWarnings("w");
 
 struct WarningOption {
-  const char *Name;
+  const char  *Name;
   const short *Members;
+  const char  *SubGroups;
 };
 
 #define GET_DIAG_ARRAYS
@@ -66,6 +64,25 @@
   return strcmp(LHS.Name, RHS.Name) < 0;
 }
 
+static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping,
+                            Diagnostic &Diags,
+                       llvm::SmallVectorImpl<unsigned short> &ControlledDiags) {
+  // Option exists, poke all the members of its diagnostic set.
+  if (const short *Member = Group->Members) {
+    for (; *Member != -1; ++Member) {
+      Diags.setDiagnosticMapping(*Member, Mapping);
+      ControlledDiags.push_back(*Member);
+    }
+  }
+
+  // Enable/disable all subgroups along with this one.
+  if (const char *SubGroups = Group->SubGroups) {
+    for (; *SubGroups != (char)-1; ++SubGroups)
+      MapGroupMembers(&OptionTable[(unsigned char)*SubGroups], Mapping,
+                      Diags, ControlledDiags);
+  }
+}
+
 bool clang::ProcessWarningOptions(Diagnostic &Diags) {
   Diags.setSuppressSystemWarnings(true);  // Default to -Wno-system-headers
   Diags.setIgnoreAllWarnings(OptNoWarnings);
@@ -125,7 +142,7 @@
       OptStart = Specifier;
     }
     
-    WarningOption Key = { OptStart, 0 };
+    WarningOption Key = { OptStart, 0, 0 };
     const WarningOption *Found =
       std::lower_bound(OptionTable, OptionTable + OptionTableSize, Key,
                        WarningOptionCompare);
@@ -135,11 +152,7 @@
       continue;
     }
     
-    // Option exists, poke all the members of its diagnostic set.
-    for (const short *Member = Found->Members; *Member != -1; ++Member) {
-      Diags.setDiagnosticMapping(*Member, Mapping);
-      ControlledDiags.push_back(*Member);
-    }
+    MapGroupMembers(Found, Mapping, Diags, ControlledDiags);
   }
 
   // If -pedantic or -pedantic-errors was specified, then we want to map all





More information about the cfe-commits mailing list