From: Chris Lattner Date: Thu, 16 Apr 2009 00:53:55 +0000 (+0000) Subject: when tblgen fills in all the subgroup info, clang is ready for it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ac3af96a162a0d01331e1a32b03d081be49d19b;p=clang when tblgen fills in all the subgroup info, clang is ready for it. This depends on r69249 of llvm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69250 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/clang-cc/Warnings.cpp b/tools/clang-cc/Warnings.cpp index f3b12da127..ccaa6533e1 100644 --- a/tools/clang-cc/Warnings.cpp +++ b/tools/clang-cc/Warnings.cpp @@ -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 OptPedanticErrors("pedantic-errors"); static llvm::cl::opt OptNoWarnings("w"); struct WarningOption { - const char *Name; + const char *Name; const short *Members; + const char *SubGroups; }; #define GET_DIAG_ARRAYS @@ -66,6 +64,25 @@ static bool WarningOptionCompare(const WarningOption &LHS, return strcmp(LHS.Name, RHS.Name) < 0; } +static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping, + Diagnostic &Diags, + llvm::SmallVectorImpl &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 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags) { 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 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags) { 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