]> granicus.if.org Git - clang/commitdiff
[driver] Warnings for warning options are handled by the frontend. The driver needs...
authorChad Rosier <mcrosier@apple.com>
Tue, 15 Jan 2013 01:21:53 +0000 (01:21 +0000)
committerChad Rosier <mcrosier@apple.com>
Tue, 15 Jan 2013 01:21:53 +0000 (01:21 +0000)
warning options to setup diagnostic state, but should not be emitting warnings as these would be
rudndant with what the frontend emits.
rdar://13001556

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172497 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/Utils.h
lib/Frontend/Warnings.cpp
test/Driver/warning-options.cpp
test/Frontend/warning-options.cpp [new file with mode: 0644]
tools/driver/driver.cpp

index 6b1fc630e234bc0f8348d740599cb6f1a79a323e..8830dced3cc2db7dca0457a78024675c2fcaa108 100644 (file)
@@ -60,7 +60,8 @@ void InitializePreprocessor(Preprocessor &PP,
 /// ProcessWarningOptions - Initialize the diagnostic client and process the
 /// warning options specified on the command line.
 void ProcessWarningOptions(DiagnosticsEngine &Diags,
-                           const DiagnosticOptions &Opts);
+                           const DiagnosticOptions &Opts,
+                           bool ReportDiags = true);
 
 /// DoPrintPreprocessedInput - Implement -E mode.
 void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS,
index b4c6b0bd735324e77cff95e67acf2b067fa2ef5f..767096a1c990afe2589fa99090cf8499cc64a8e6 100644 (file)
@@ -48,7 +48,8 @@ static void EmitUnknownDiagWarning(DiagnosticsEngine &Diags,
 }
 
 void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
-                                  const DiagnosticOptions &Opts) {
+                                  const DiagnosticOptions &Opts,
+                                  bool ReportDiags) {
   Diags.setSuppressSystemWarnings(true);  // Default to -Wno-system-headers
   Diags.setIgnoreAllWarnings(Opts.IgnoreWarnings);
   Diags.setShowOverloads(Opts.getShowOverloads());
@@ -84,6 +85,12 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
   // conflicting options.
   for (unsigned Report = 0, ReportEnd = 2; Report != ReportEnd; ++Report) {
     bool SetDiagnostic = (Report == 0);
+
+    // If we've set the diagnostic state and are not reporting diagnostics then
+    // we're done.
+    if (!SetDiagnostic && !ReportDiags)
+      break;
+
     for (unsigned i = 0, e = Opts.Warnings.size(); i != e; ++i) {
       StringRef Opt = Opts.Warnings[i];
       StringRef OrigOpt = Opts.Warnings[i];
index 6dafa1c36a237f7833a2c52494988cd8a633d8e0..f1a335d2139d15ae9c653c841ab2350ae54a9ab1 100644 (file)
@@ -3,12 +3,6 @@
 // RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s
 // LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128
 
-// RUN: %clang -### -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
-// RUN:        -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
-// CHECK: unknown warning option '-Wmonkey'
-// CHECK: unknown warning option '-Wno-monkey'
-// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?
-
 // FIXME: Remove this together with -Warc-abi once an Xcode is released that doesn't pass this flag.
 // RUN: %clang -### -Warc-abi -Wno-arc-abi %s 2>&1 | FileCheck -check-prefix=ARCABI %s
 // ARCABI-NOT: unknown warning option '-Warc-abi'
diff --git a/test/Frontend/warning-options.cpp b/test/Frontend/warning-options.cpp
new file mode 100644 (file)
index 0000000..85bea62
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
+// RUN:        -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
+// CHECK: unknown warning option '-Wmonkey'
+// CHECK: unknown warning option '-Wno-monkey'
+// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?
index de2b899bfaa8ff5697b22715eae2aef3b0d49874..81bc985cc6cd71fbfba2a36e63d9d6c2ebc822cb 100644 (file)
@@ -395,7 +395,7 @@ int main(int argc_, const char **argv_) {
   IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
 
   DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);
-  ProcessWarningOptions(Diags, *DiagOpts);
+  ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path.str(), llvm::sys::getDefaultTargetTriple(),
                    "a.out", Diags);