diff options
Diffstat (limited to 'clang/tools/clang-cc/Warnings.cpp')
-rw-r--r-- | clang/tools/clang-cc/Warnings.cpp | 66 |
1 files changed, 14 insertions, 52 deletions
diff --git a/clang/tools/clang-cc/Warnings.cpp b/clang/tools/clang-cc/Warnings.cpp index 818e7743d87..bab2ab7a140 100644 --- a/clang/tools/clang-cc/Warnings.cpp +++ b/clang/tools/clang-cc/Warnings.cpp @@ -65,21 +65,17 @@ static bool WarningOptionCompare(const WarningOption &LHS, } static void MapGroupMembers(const WarningOption *Group, diag::Mapping Mapping, - Diagnostic &Diags, - llvm::SmallVectorImpl<unsigned short> &ControlledDiags) { + Diagnostic &Diags) { // Option exists, poke all the members of its diagnostic set. if (const short *Member = Group->Members) { - for (; *Member != -1; ++Member) { + 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); + MapGroupMembers(&OptionTable[(unsigned char)*SubGroups], Mapping, Diags); } } @@ -87,13 +83,19 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags) { Diags.setSuppressSystemWarnings(true); // Default to -Wno-system-headers Diags.setIgnoreAllWarnings(OptNoWarnings); + // If -pedantic or -pedantic-errors was specified, then we want to map all + // extension diagnostics onto WARNING or ERROR unless the user has futz'd + // around with them explicitly. + if (OptPedanticErrors) + Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Error); + else if (OptPedantic) + Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Warn); + else + Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Ignore); + // FIXME: -fdiagnostics-show-option // FIXME: -Wfatal-errors / -Wfatal-errors=foo - /// ControlledDiags - Keep track of the options that the user explicitly - /// poked with -Wfoo, -Wno-foo, or -Werror=foo. - llvm::SmallVector<unsigned short, 256> ControlledDiags; - for (unsigned i = 0, e = OptWarnings.size(); i != e; ++i) { const std::string &Opt = OptWarnings[i]; const char *OptStart = &Opt[0]; @@ -152,47 +154,7 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags) { continue; } - MapGroupMembers(Found, Mapping, Diags, ControlledDiags); - } - - // If -pedantic or -pedantic-errors was specified, then we want to map all - // extension diagnostics onto WARNING or ERROR unless the user has futz'd - // around with them explicitly. - if (OptPedantic || OptPedanticErrors) { - // Sort the array of options that has been poked at directly so we can do - // efficient queries. - std::sort(ControlledDiags.begin(), ControlledDiags.end()); - - // Don't worry about iteration off the end down below. - ControlledDiags.push_back(diag::DIAG_UPPER_LIMIT); - - diag::Mapping Mapping = - OptPedanticErrors ? diag::MAP_ERROR : diag::MAP_WARNING; - - // Loop over all of the extension diagnostics. Unless they were explicitly - // controlled, reset their mapping to Mapping. We walk through the - // ControlledDiags in parallel with this walk, which is faster than - // repeatedly binary searching it. - // - llvm::SmallVectorImpl<unsigned short>::iterator ControlledDiagsIt = - ControlledDiags.begin(); - - // TODO: if it matters, we could make tblgen produce a list of just the - // extension diags to avoid skipping ones that don't matter. - for (unsigned short i = 0; i != diag::DIAG_UPPER_LIMIT; ++i) { - // If this diagnostic was controlled, ignore it. - if (i == *ControlledDiagsIt) { - ++ControlledDiagsIt; - while (i == *ControlledDiagsIt) // ControlledDiags can have dupes. - ++ControlledDiagsIt; - // Do not map this diagnostic ID#. - continue; - } - - // Okay, the user didn't control this ID. If it is an example, map it. - if (Diagnostic::isBuiltinExtensionDiag(i)) - Diags.setDiagnosticMapping(i, Mapping); - } + MapGroupMembers(Found, Mapping, Diags); } return false; |