summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-06 04:09:06 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-06 04:09:06 +0000
commit403f76ee02a3151a9eb2bf7b379a308da2a919ea (patch)
tree83db46374aab44de38d8496dda39d097d160fc23 /clang/lib/Driver/Driver.cpp
parent18f07db183f563bd645f69adf9315f9b57accc62 (diff)
downloadbcm5719-llvm-403f76ee02a3151a9eb2bf7b379a308da2a919ea.tar.gz
bcm5719-llvm-403f76ee02a3151a9eb2bf7b379a308da2a919ea.zip
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
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp17
1 files changed, 13 insertions, 4 deletions
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;
}
OpenPOWER on IntegriCloud