[cfe-commits] r172497 - in /cfe/trunk: include/clang/Frontend/Utils.h lib/Frontend/Warnings.cpp test/Driver/warning-options.cpp test/Frontend/warning-options.cpp tools/driver/driver.cpp

Chad Rosier mcrosier at apple.com
Mon Jan 14 17:21:54 PST 2013


Author: mcrosier
Date: Mon Jan 14 19:21:53 2013
New Revision: 172497

URL: http://llvm.org/viewvc/llvm-project?rev=172497&view=rev
Log:
[driver] Warnings for warning options are handled by the frontend.  The driver needs to process the
warning options to setup diagnostic state, but should not be emitting warnings as these would be
rudndant with what the frontend emits.
rdar://13001556

Added:
    cfe/trunk/test/Frontend/warning-options.cpp
Modified:
    cfe/trunk/include/clang/Frontend/Utils.h
    cfe/trunk/lib/Frontend/Warnings.cpp
    cfe/trunk/test/Driver/warning-options.cpp
    cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=172497&r1=172496&r2=172497&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Mon Jan 14 19:21:53 2013
@@ -60,7 +60,8 @@
 /// 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,

Modified: cfe/trunk/lib/Frontend/Warnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Warnings.cpp?rev=172497&r1=172496&r2=172497&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/Warnings.cpp (original)
+++ cfe/trunk/lib/Frontend/Warnings.cpp Mon Jan 14 19:21:53 2013
@@ -48,7 +48,8 @@
 }
 
 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 @@
   // 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];

Modified: cfe/trunk/test/Driver/warning-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/warning-options.cpp?rev=172497&r1=172496&r2=172497&view=diff
==============================================================================
--- cfe/trunk/test/Driver/warning-options.cpp (original)
+++ cfe/trunk/test/Driver/warning-options.cpp Mon Jan 14 19:21:53 2013
@@ -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'

Added: cfe/trunk/test/Frontend/warning-options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-options.cpp?rev=172497&view=auto
==============================================================================
--- cfe/trunk/test/Frontend/warning-options.cpp (added)
+++ cfe/trunk/test/Frontend/warning-options.cpp Mon Jan 14 19:21:53 2013
@@ -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'?

Modified: cfe/trunk/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=172497&r1=172496&r2=172497&view=diff
==============================================================================
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Mon Jan 14 19:21:53 2013
@@ -395,7 +395,7 @@
   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);





More information about the cfe-commits mailing list