From 2715fce5244c2058aa02d45bda262904e7efa1ad Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 26 Sep 2012 19:01:49 +0000 Subject: [PATCH] Allow -MF to be used in combination with -E -M or -E -MM. Fixes PR13851. Patch by Dimitry Andric! llvm-svn: 164717 --- clang/lib/Driver/Tools.cpp | 6 +++--- clang/test/Preprocessor/pr13851.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 clang/test/Preprocessor/pr13851.c diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index f77d8ee..12564b4 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -219,11 +219,11 @@ void Clang::AddPreprocessingOptions(Compilation &C, (A = Args.getLastArg(options::OPT_MMD))) { // Determine the output location. const char *DepFile; - if (Output.getType() == types::TY_Dependencies) { - DepFile = Output.getFilename(); - } else if (Arg *MF = Args.getLastArg(options::OPT_MF)) { + if (Arg *MF = Args.getLastArg(options::OPT_MF)) { DepFile = MF->getValue(Args); C.addFailureResultFile(DepFile); + } else if (Output.getType() == types::TY_Dependencies) { + DepFile = Output.getFilename(); } else if (A->getOption().matches(options::OPT_M) || A->getOption().matches(options::OPT_MM)) { DepFile = "-"; diff --git a/clang/test/Preprocessor/pr13851.c b/clang/test/Preprocessor/pr13851.c new file mode 100644 index 0000000..537594d --- /dev/null +++ b/clang/test/Preprocessor/pr13851.c @@ -0,0 +1,11 @@ +// Check that -E -M -MF does not cause an "argument unused" error, by adding +// -Werror to the clang invocation. Also check the dependency output, if any. +// RUN: %clang -Werror -E -M -MF %t-M.d %s +// RUN: FileCheck --input-file=%t-M.d %s +// CHECK: pr13851.o: +// CHECK: pr13851.c + +// Check that -E -MM -MF does not cause an "argument unused" error, by adding +// -Werror to the clang invocation. Also check the dependency output, if any. +// RUN: %clang -Werror -E -MM -MF %t-MM.d %s +// RUN: FileCheck --input-file=%t-MM.d %s -- 2.7.4