[cfe-commits] r86968 - in /cfe/trunk: include/clang/Frontend/DiagnosticOptions.h include/clang/Frontend/Utils.h lib/Frontend/Warnings.cpp tools/clang-cc/Options.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 11 23:28:44 PST 2009
Author: ddunbar
Date: Thu Nov 12 01:28:44 2009
New Revision: 86968
URL: http://llvm.org/viewvc/llvm-project?rev=86968&view=rev
Log:
Move warning options into DiagnosticOptions.
Modified:
cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Frontend/Warnings.cpp
cfe/trunk/tools/clang-cc/Options.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Frontend/DiagnosticOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DiagnosticOptions.h?rev=86968&r1=86967&r2=86968&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/DiagnosticOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/DiagnosticOptions.h Thu Nov 12 01:28:44 2009
@@ -19,6 +19,10 @@
/// engine.
class DiagnosticOptions {
public:
+ unsigned IgnoreWarnings : 1; /// -w
+ unsigned NoRewriteMacros : 1; /// -Wno-rewrite-macros
+ unsigned Pedantic : 1; /// -pedantic
+ unsigned PedanticErrors : 1; /// -pedantic-errors
unsigned ShowColumn : 1; /// Show column number on diagnostics.
unsigned ShowLocation : 1; /// Show source location information.
unsigned ShowCarets : 1; /// Show carets in diagnostics.
@@ -35,16 +39,24 @@
/// testing and analysis.
std::string DumpBuildInformation;
+ /// The list of -W... options used to alter the diagnostic mappings, with the
+ /// prefixes removed.
+ std::vector<std::string> Warnings;
+
public:
DiagnosticOptions() {
- ShowColumn = 1;
- ShowLocation = 1;
+ IgnoreWarnings = 0;
+ MessageLength = 0;
+ NoRewriteMacros = 0;
+ Pedantic = 0;
+ PedanticErrors = 0;
ShowCarets = 1;
+ ShowColors = 0;
+ ShowColumn = 1;
ShowFixits = 1;
- ShowSourceRanges = 0;
+ ShowLocation = 1;
ShowOptionNames = 0;
- ShowColors = 0;
- MessageLength = 0;
+ ShowSourceRanges = 0;
}
};
Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=86968&r1=86967&r2=86968&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Thu Nov 12 01:28:44 2009
@@ -29,6 +29,7 @@
class Decl;
class DependencyOutputOptions;
class Diagnostic;
+class DiagnosticOptions;
class HeaderSearch;
class HeaderSearchOptions;
class IdentifierTable;
@@ -59,10 +60,7 @@
/// ProcessWarningOptions - Initialize the diagnostic client and process the
/// warning options specified on the command line.
-bool ProcessWarningOptions(Diagnostic &Diags,
- std::vector<std::string> &Warnings,
- bool Pedantic, bool PedanticErrors,
- bool NoWarnings);
+bool ProcessWarningOptions(Diagnostic &Diags, const DiagnosticOptions &Opts);
/// DoPrintPreprocessedInput - Implement -E mode.
void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS,
Modified: cfe/trunk/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Warnings.cpp?rev=86968&r1=86967&r2=86968&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/Warnings.cpp (original)
+++ cfe/trunk/lib/Frontend/Warnings.cpp Thu Nov 12 01:28:44 2009
@@ -24,6 +24,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "clang/Lex/LexDiagnostic.h"
+#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include <cstdio>
#include <cstring>
@@ -32,26 +33,24 @@
using namespace clang;
bool clang::ProcessWarningOptions(Diagnostic &Diags,
- std::vector<std::string> &Warnings,
- bool Pedantic, bool PedanticErrors,
- bool NoWarnings) {
+ const DiagnosticOptions &Opts) {
Diags.setSuppressSystemWarnings(true); // Default to -Wno-system-headers
- Diags.setIgnoreAllWarnings(NoWarnings);
+ Diags.setIgnoreAllWarnings(Opts.IgnoreWarnings);
// 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 (PedanticErrors)
+ if (Opts.PedanticErrors)
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Error);
- else if (Pedantic)
+ else if (Opts.Pedantic)
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Warn);
else
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Ignore);
// FIXME: -Wfatal-errors / -Wfatal-errors=foo
- for (unsigned i = 0, e = Warnings.size(); i != e; ++i) {
- const std::string &Opt = Warnings[i];
+ for (unsigned i = 0, e = Opts.Warnings.size(); i != e; ++i) {
+ const std::string &Opt = Opts.Warnings[i];
const char *OptStart = &Opt[0];
const char *OptEnd = OptStart+Opt.size();
assert(*OptEnd == 0 && "Expect null termination for lower-bound search");
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=86968&r1=86967&r2=86968&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Thu Nov 12 01:28:44 2009
@@ -245,6 +245,18 @@
llvm::cl::desc("Do not include fixit information in"
" diagnostics"));
+static llvm::cl::opt<bool> OptNoWarnings("w");
+
+static llvm::cl::opt<bool> OptPedantic("pedantic");
+
+static llvm::cl::opt<bool> OptPedanticErrors("pedantic-errors");
+
+// 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<std::string>
+OptWarnings("W", llvm::cl::Prefix, llvm::cl::ValueOptional);
+
static llvm::cl::opt<bool>
PrintSourceRangeInfo("fdiagnostics-print-source-range-info",
llvm::cl::desc("Print source range spans in numeric form"));
@@ -263,6 +275,10 @@
PrintColorDiagnostic("fcolor-diagnostics",
llvm::cl::desc("Use colors in diagnostics"));
+static llvm::cl::opt<bool>
+SilenceRewriteMacroWarning("Wno-rewrite-macros", llvm::cl::init(false),
+ llvm::cl::desc("Silence ObjC rewriting warnings"));
+
}
//===----------------------------------------------------------------------===//
@@ -664,8 +680,14 @@
void clang::InitializeDiagnosticOptions(DiagnosticOptions &Opts) {
using namespace diagnosticoptions;
+ Opts.Warnings.insert(Opts.Warnings.begin(),
+ OptWarnings.begin(), OptWarnings.end());
Opts.DumpBuildInformation = DumpBuildInformation;
+ Opts.IgnoreWarnings = OptNoWarnings;
Opts.MessageLength = MessageLength;
+ Opts.NoRewriteMacros = SilenceRewriteMacroWarning;
+ Opts.Pedantic = OptPedantic;
+ Opts.PedanticErrors = OptPedanticErrors;
Opts.ShowCarets = !NoCaretDiagnostics;
Opts.ShowColors = PrintColorDiagnostic;
Opts.ShowColumn = !NoShowColumn;
@@ -1106,4 +1128,3 @@
Opts.ShowComments = EnableCommentOutput;
Opts.ShowMacroComments = EnableMacroCommentOutput;
}
-
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86968&r1=86967&r2=86968&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Thu Nov 12 01:28:44 2009
@@ -428,28 +428,6 @@
llvm::cl::desc("Perform Fix-It modifications at the given source location"));
//===----------------------------------------------------------------------===//
-// ObjC Rewriter Options
-//===----------------------------------------------------------------------===//
-
-static llvm::cl::opt<bool>
-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<std::string>
-OptWarnings("W", llvm::cl::Prefix, llvm::cl::ValueOptional);
-
-static llvm::cl::opt<bool> OptPedantic("pedantic");
-static llvm::cl::opt<bool> OptPedanticErrors("pedantic-errors");
-static llvm::cl::opt<bool> OptNoWarnings("w");
-
-//===----------------------------------------------------------------------===//
// Dump Build Information
//===----------------------------------------------------------------------===//
@@ -596,7 +574,8 @@
case RewriteObjC:
OS.reset(ComputeOutFile(CompOpts, InFile, "cpp", true, OutPath));
return CreateObjCRewriter(InFile, OS.get(), PP.getDiagnostics(),
- PP.getLangOptions(), SilenceRewriteMacroWarning);
+ PP.getLangOptions(),
+ CompOpts.getDiagnosticOpts().NoRewriteMacros);
case RewriteBlocks:
return CreateBlockRewriter(InFile, PP.getDiagnostics(),
@@ -1079,8 +1058,7 @@
// Configure our handling of diagnostics.
Diagnostic *Diags = new Diagnostic(DiagClient.take());
- if (ProcessWarningOptions(*Diags, OptWarnings, OptPedantic, OptPedanticErrors,
- OptNoWarnings))
+ if (ProcessWarningOptions(*Diags, Opts))
return 0;
// Set an error handler, so that any LLVM backend diagnostics go through our
More information about the cfe-commits
mailing list