aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-06-14 21:37:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-06-14 21:37:09 +0000
commiteda3f707fd53f90f4232b0e694d3f5514237aba5 (patch)
treef060c1e50c532940e061ad021e89237a7f56e4bc /lib/Driver/Driver.cpp
parentf78925f633e949f06521d9ffd937019e59f35efc (diff)
Driver: Fix PR4062 by dissecting one particular -Wp, form.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 4351433945..0da26b70e0 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -120,12 +120,12 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
// Unfortunately, we have to parse some forwarding options (-Xassembler,
// -Xlinker, -Xpreprocessor) because we either integrate their functionality
// (assembler and preprocessor), or bypass a previous driver ('collect2').
- if (A->getOption().matches(options::OPT_Xlinker) &&
- A->getValue(Args) == llvm::StringRef("--no-demangle")) {
- DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_Xlinker__no_demangle));
- continue;
- } else if (A->getOption().matches(options::OPT_Wl_COMMA) &&
- A->containsValue("--no-demangle")) {
+
+ // Rewrite linker options, to replace --no-demangle with a custom internal
+ // option.
+ if ((A->getOption().matches(options::OPT_Wl_COMMA) ||
+ A->getOption().matches(options::OPT_Xlinker)) &&
+ A->containsValue("--no-demangle")) {
// Add the rewritten no-demangle argument.
DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_Xlinker__no_demangle));
@@ -138,6 +138,19 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
continue;
}
+ // Rewrite preprocessor options, to replace -Wp,-MD,FOO which is used by
+ // some build systems. We don't try to be complete here because we don't
+ // care to encourage this usage model.
+ if (A->getOption().matches(options::OPT_Wp_COMMA) &&
+ A->getNumValues() == 2 &&
+ A->getValue(Args, 0) == llvm::StringRef("-MD")) {
+ // Rewrite to -MD along with -MF.
+ DAL->AddFlagArg(A, Opts->getOption(options::OPT_MD));
+ DAL->AddSeparateArg(A, Opts->getOption(options::OPT_MF),
+ A->getValue(Args, 1));
+ continue;
+ }
+
DAL->append(*it);
}