From 8cd452d47137f94c2d00e9dccf11a3deb1c12f05 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 30 Aug 2016 18:55:16 +0000 Subject: PR30195: Fix clang-cl attempting to precompile bogus (non-precompilable) input types. llvm-svn: 280133 --- clang/lib/Driver/Driver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/Driver/Driver.cpp') diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9871f29eb39..a1adb676a39 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1685,12 +1685,14 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, if (YcArg) { // Add a separate precompile phase for the compile phase. if (FinalPhase >= phases::Compile) { + const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType); llvm::SmallVector PCHPL; - types::getCompilationPhases(types::TY_CXXHeader, PCHPL); + types::getCompilationPhases(HeaderType, PCHPL); Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue()); // Build the pipeline for the pch file. - Action *ClangClPch = C.MakeAction(*PchInputArg, InputType); + Action *ClangClPch = + C.MakeAction(*PchInputArg, HeaderType); for (phases::ID Phase : PCHPL) ClangClPch = ConstructPhaseAction(C, Args, Phase, ClangClPch); assert(ClangClPch); @@ -1812,6 +1814,8 @@ Action *Driver::ConstructPhaseAction(Compilation &C, const ArgList &Args, return C.MakeAction(Input, OutputTy); } case phases::Precompile: { + assert(onlyPrecompileType(Input->getType()) && + "asked to precompile non-precompilable type"); types::ID OutputTy = types::TY_PCH; if (Args.hasArg(options::OPT_fsyntax_only)) { // Syntax checks should not emit a PCH file -- cgit v1.2.3