From 403f76ee02a3151a9eb2bf7b379a308da2a919ea Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 6 Aug 2012 04:09:06 +0000 Subject: PR13529: Don't crash if the driver sees an unused input file when running as 'clang-cpp'. For now, the test uses "REQUIRES: shell" to determine if the host system supports "ln -s", which it uses to create a 'clang-cpp' symlink. This is a bit hacky and should likely be directly supported by lit.cfg. llvm-svn: 161317 --- clang/lib/Driver/Driver.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 671c0acaab2..1c47d5c9da0 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1131,18 +1131,27 @@ void Driver::BuildActions(const ToolChain &TC, const DerivedArgList &Args, if (Args.hasArg(options::OPT_Qunused_arguments)) continue; + // Special case when final phase determined by binary name, rather than + // by a command-line argument with a corresponding Arg. + if (CCCIsCPP) + Diag(clang::diag::warn_drv_input_file_unused_by_cpp) + << InputArg->getAsString(Args) + << getPhaseName(InitialPhase); // Special case '-E' warning on a previously preprocessed file to make // more sense. - if (InitialPhase == phases::Compile && FinalPhase == phases::Preprocess && - getPreprocessedType(InputType) == types::TY_INVALID) + else if (InitialPhase == phases::Compile && + FinalPhase == phases::Preprocess && + getPreprocessedType(InputType) == types::TY_INVALID) Diag(clang::diag::warn_drv_preprocessed_input_file_unused) << InputArg->getAsString(Args) - << FinalPhaseArg->getOption().getName(); + << !!FinalPhaseArg + << FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""; else Diag(clang::diag::warn_drv_input_file_unused) << InputArg->getAsString(Args) << getPhaseName(InitialPhase) - << FinalPhaseArg->getOption().getName(); + << !!FinalPhaseArg + << FinalPhaseArg ? FinalPhaseArg->getOption().getName() : ""; continue; } -- cgit v1.2.3