diff options
author | Chad Rosier <mcrosier@apple.com> | 2013-02-21 18:56:55 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2013-02-21 18:56:55 +0000 |
commit | 79165b82ddc881c705275fe9eb5a745f717a1eda (patch) | |
tree | 03128d4e5a70915615643be131a271df2c465952 | |
parent | 6aad4a31b35df07fe818f193fcfd3c0197aea467 (diff) |
[driver] Handle the processing of the QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS
before the DiagnosticsEngine is instantiated. Otherwise, warning options are
not handled correctly.
rdar://13254743
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175779 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Driver/qa_override.c | 7 | ||||
-rw-r--r-- | tools/driver/driver.cpp | 52 |
2 files changed, 33 insertions, 26 deletions
diff --git a/test/Driver/qa_override.c b/test/Driver/qa_override.c index 5f96976ee9..341736fe4f 100644 --- a/test/Driver/qa_override.c +++ b/test/Driver/qa_override.c @@ -1,6 +1,13 @@ // RUN: env QA_OVERRIDE_GCC3_OPTIONS="#+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa Omagic ^-ccc-print-options " %clang x -O2 b -O3 2>&1 | FileCheck %s +// RUN: env QA_OVERRIDE_GCC3_OPTIONS="x-Werror +-mfoo" %clang -Werror %s -c 2>&1 | FileCheck %s -check-prefix=RM-WERROR + // CHECK-NOT: ### // CHECK: Option 0 - Name: "-ccc-print-options", Values: {} // CHECK-NEXT: Option 1 - Name: "<input>", Values: {"x"} // CHECK-NEXT: Option 2 - Name: "-O", Values: {"ignore"} // CHECK-NEXT: Option 3 - Name: "-O", Values: {"magic"} + +// RM-WERROR: ### QA_OVERRIDE_GCC3_OPTIONS: x-Werror +-mfoo +// RM-WERROR-NEXT: ### Deleting argument -Werror +// RM-WERROR-NEXT: ### Adding argument -mfoo at end +// RM-WERROR-NEXT: clang: warning: argument unused during compilation: '-mfoo' diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index ee2d5f5963..de627fb58b 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -373,6 +373,32 @@ int main(int argc_, const char **argv_) { } } + // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a + // command line behind the scenes. + if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) { + // FIXME: Driver shouldn't take extra initial argument. + ApplyQAOverride(argv, OverrideStr, SavedStrings); + } else if (const char *Cur = ::getenv("CCC_ADD_ARGS")) { + // FIXME: Driver shouldn't take extra initial argument. + std::vector<const char*> ExtraArgs; + + for (;;) { + const char *Next = strchr(Cur, ','); + + if (Next) { + ExtraArgs.push_back(SaveStringInSet(SavedStrings, + std::string(Cur, Next))); + Cur = Next + 1; + } else { + if (*Cur != '\0') + ExtraArgs.push_back(SaveStringInSet(SavedStrings, Cur)); + break; + } + } + + argv.insert(&argv[1], ExtraArgs.begin(), ExtraArgs.end()); + } + llvm::sys::Path Path = GetExecutablePath(argv[0], CanonicalPrefixes); IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions; @@ -438,32 +464,6 @@ int main(int argc_, const char **argv_) { if (TheDriver.CCLogDiagnostics) TheDriver.CCLogDiagnosticsFilename = ::getenv("CC_LOG_DIAGNOSTICS_FILE"); - // Handle QA_OVERRIDE_GCC3_OPTIONS and CCC_ADD_ARGS, used for editing a - // command line behind the scenes. - if (const char *OverrideStr = ::getenv("QA_OVERRIDE_GCC3_OPTIONS")) { - // FIXME: Driver shouldn't take extra initial argument. - ApplyQAOverride(argv, OverrideStr, SavedStrings); - } else if (const char *Cur = ::getenv("CCC_ADD_ARGS")) { - // FIXME: Driver shouldn't take extra initial argument. - std::vector<const char*> ExtraArgs; - - for (;;) { - const char *Next = strchr(Cur, ','); - - if (Next) { - ExtraArgs.push_back(SaveStringInSet(SavedStrings, - std::string(Cur, Next))); - Cur = Next + 1; - } else { - if (*Cur != '\0') - ExtraArgs.push_back(SaveStringInSet(SavedStrings, Cur)); - break; - } - } - - argv.insert(&argv[1], ExtraArgs.begin(), ExtraArgs.end()); - } - OwningPtr<Compilation> C(TheDriver.BuildCompilation(argv)); int Res = 0; SmallVector<std::pair<int, const Command *>, 4> FailingCommands; |