From: Eli Friedman Date: Tue, 19 May 2009 01:17:04 +0000 (+0000) Subject: Move the warning options from Warnings.cpp to clang-cc.cpp. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0eeb86e5123530de78ea5b0b2136e512bf24b939;p=clang Move the warning options from Warnings.cpp to clang-cc.cpp. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72089 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/clang-cc/Warnings.cpp b/tools/clang-cc/Warnings.cpp index c3a6b2132a..b3e21e1052 100644 --- a/tools/clang-cc/Warnings.cpp +++ b/tools/clang-cc/Warnings.cpp @@ -30,34 +30,27 @@ #include using namespace clang; -// This gets all -W options, including -Werror, -W[no-]system-headers, etc. The -// driver has stripped off -Wa,foo etc. The driver has also translated -W to -// -Wextra, so we don't need to worry about it. -static llvm::cl::list -OptWarnings("W", llvm::cl::Prefix, llvm::cl::ValueOptional); - -static llvm::cl::opt OptPedantic("pedantic"); -static llvm::cl::opt OptPedanticErrors("pedantic-errors"); -static llvm::cl::opt OptNoWarnings("w"); - -bool clang::ProcessWarningOptions(Diagnostic &Diags) { +bool clang::ProcessWarningOptions(Diagnostic &Diags, + std::vector &Warnings, + bool Pedantic, bool PedanticErrors, + bool NoWarnings) { Diags.setSuppressSystemWarnings(true); // Default to -Wno-system-headers - Diags.setIgnoreAllWarnings(OptNoWarnings); + Diags.setIgnoreAllWarnings(NoWarnings); // 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) + if (PedanticErrors) Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Error); - else if (OptPedantic) + else if (Pedantic) Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Warn); else Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Ignore); // FIXME: -Wfatal-errors / -Wfatal-errors=foo - for (unsigned i = 0, e = OptWarnings.size(); i != e; ++i) { - const std::string &Opt = OptWarnings[i]; + for (unsigned i = 0, e = Warnings.size(); i != e; ++i) { + const std::string &Opt = Warnings[i]; const char *OptStart = &Opt[0]; const char *OptEnd = OptStart+Opt.size(); assert(*OptEnd == 0 && "Expect null termination for lower-bound search"); diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 4bf92577fd..81a819e38d 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -1496,6 +1496,20 @@ static llvm::cl::opt SilenceRewriteMacroWarning("Wno-rewrite-macros", llvm::cl::init(false), llvm::cl::desc("Silence ObjC rewriting warnings")); +//===----------------------------------------------------------------------===// +// Warning Options +//===----------------------------------------------------------------------===// + +// This gets all -W options, including -Werror, -W[no-]system-headers, etc. The +// driver has stripped off -Wa,foo etc. The driver has also translated -W to +// -Wextra, so we don't need to worry about it. +static llvm::cl::list +OptWarnings("W", llvm::cl::Prefix, llvm::cl::ValueOptional); + +static llvm::cl::opt OptPedantic("pedantic"); +static llvm::cl::opt OptPedanticErrors("pedantic-errors"); +static llvm::cl::opt OptNoWarnings("w"); + //===----------------------------------------------------------------------===// // -dump-build-information Stuff //===----------------------------------------------------------------------===// @@ -2028,7 +2042,8 @@ int main(int argc, char **argv) { // Configure our handling of diagnostics. Diagnostic Diags(DiagClient.get()); - if (ProcessWarningOptions(Diags)) + if (ProcessWarningOptions(Diags, OptWarnings, OptPedantic, OptPedanticErrors, + OptNoWarnings)) return 1; // -I- is a deprecated GCC feature, scan for it and reject it. diff --git a/tools/clang-cc/clang-cc.h b/tools/clang-cc/clang-cc.h index bdd79cdc98..b08345c188 100644 --- a/tools/clang-cc/clang-cc.h +++ b/tools/clang-cc/clang-cc.h @@ -35,7 +35,10 @@ class LangOptions; /// ProcessWarningOptions - Initialize the diagnostic client and process the /// warning options specified on the command line. -bool ProcessWarningOptions(Diagnostic &Diags); +bool ProcessWarningOptions(Diagnostic &Diags, + std::vector &Warnings, + bool Pedantic, bool PedanticErrors, + bool NoWarnings); /// DoPrintPreprocessedInput - Implement -E mode. void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS);