[BatchMode] Fix a single-primary assumption in FrontendTool, add test.

This commit is contained in:
Graydon Hoare
2018-02-28 15:57:27 -08:00
parent 9cc534a05a
commit ac11a2688c
2 changed files with 20 additions and 4 deletions

View File

@@ -810,17 +810,17 @@ generateSILModules(CompilerInvocation &Invocation, CompilerInstance &Instance) {
// If there are primary source files, build a separate SILModule for
// each source file, and run the remaining SILOpt-Serialize-IRGen-LLVM
// once for each such input.
if (auto *PrimaryFile = Instance.getPrimarySourceFile()) {
std::deque<PostSILGenInputs> PSGIs;
for (auto *PrimaryFile : Instance.getPrimarySourceFiles()) {
auto SM = performSILGeneration(*PrimaryFile, SILOpts, None);
std::deque<PostSILGenInputs> PSGIs;
const PrimarySpecificPaths PSPs =
Instance.getPrimarySpecificPathsForSourceFile(*PrimaryFile);
PSGIs.push_back(PostSILGenInputs{std::move(SM), true, PrimaryFile, PSPs});
return PSGIs;
}
if (!PSGIs.empty())
return PSGIs;
// If there are primary inputs but no primary _source files_, there might be
// a primary serialized input.
std::deque<PostSILGenInputs> PSGIs;
for (FileUnit *fileUnit : mod->getFiles()) {
if (auto SASTF = dyn_cast<SerializedASTFile>(fileUnit))
if (Invocation.getFrontendOptions().InputsAndOutputs.isInputPrimary(