summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-03-13 20:09:56 +0000
committerChad Rosier <mcrosier@apple.com>2012-03-13 20:09:56 +0000
commit2dec85b21822f950bf6035640c496ad835e11728 (patch)
tree6feb366bf192bf25d6a4ca2244e7e5d318722bc6 /tools
parentb990d039c7e01ad0055dcbd1e13a691813397b96 (diff)
[driver] Parse diagnostic args in the driver.
Previously, only diagnostics thrown by the cc1 process were actually honoring the diagnostic options given on the command line, like -Werror. Reuse the existing code in Frontend currently used for cc1, adjusting it to not interpret -Wl, linker flags as warnings. Also fix a faulty test exposed by this change. It wasn't actually testing anything, and was giving this warning: clang-3: warning: argument unused during compilation: '-verify' Which -Werror didn't turn into an error because it was output by the driver, not the cc1 process, and diagnostic options weren't parsed by the driver. And you couldn't see the warning when running the test suite. Fixes PR12181. Patch by Dylan Noblesmith <nobled@dreamwidth.org>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/driver/driver.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index 9e666eb43f..8c05fff4de 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -12,11 +12,16 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Driver/ArgList.h"
+#include "clang/Driver/CC1Options.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Option.h"
+#include "clang/Driver/OptTable.h"
+#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Frontend/Utils.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
@@ -370,11 +375,27 @@ int main(int argc_, const char **argv_) {
llvm::sys::Path Path = GetExecutablePath(argv[0], CanonicalPrefixes);
+ DiagnosticOptions DiagOpts;
+ {
+ // Note that ParseDiagnosticArgs() uses the cc1 option table.
+ OwningPtr<OptTable> CC1Opts(createCC1OptTable());
+ unsigned MissingArgIndex, MissingArgCount;
+ OwningPtr<InputArgList> Args(CC1Opts->ParseArgs(argv.begin()+1, argv.end(),
+ MissingArgIndex, MissingArgCount));
+ // We ignore MissingArgCount and the return value of ParseDiagnosticArgs.
+ // Any errors that would be diagnosed here will also be diagnosed later,
+ // when the DiagnosticsEngine actually exists.
+ (void) ParseDiagnosticArgs(DiagOpts, *Args);
+ }
+ // Now we can create the DiagnosticsEngine with a properly-filled-out
+ // DiagnosticOptions instance.
TextDiagnosticPrinter *DiagClient
- = new TextDiagnosticPrinter(llvm::errs(), DiagnosticOptions());
+ = new TextDiagnosticPrinter(llvm::errs(), DiagOpts);
DiagClient->setPrefix(llvm::sys::path::stem(Path.str()));
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
+
DiagnosticsEngine Diags(DiagID, DiagClient);
+ ProcessWarningOptions(Diags, DiagOpts);
#ifdef CLANG_IS_PRODUCTION
const bool IsProduction = true;