Cleaner handling of cases where action produces no output or where there are no inputs.

This commit is contained in:
David Ungar
2018-02-07 13:50:29 -08:00
parent ba4f2a84b4
commit ef02d0bfc0
5 changed files with 62 additions and 24 deletions

View File

@@ -289,9 +289,7 @@ void FrontendInputsAndOutputs::forEachInputProducingAMainOutputFile(
void FrontendInputsAndOutputs::setMainAndSupplementaryOutputs(
ArrayRef<std::string> outputFiles,
SupplementaryOutputPaths supplementaryOutputs) {
if (outputFiles.empty())
;
else if (hasPrimaryInputs()) {
if (hasPrimaryInputs()) {
unsigned i = 0;
for (auto index : indices(AllInputs)) {
InputFile &f = AllInputs[index];
@@ -344,15 +342,14 @@ bool FrontendInputsAndOutputs::hasNamedOutputFile() const {
unsigned
FrontendInputsAndOutputs::countOfFilesProducingSupplementaryOutput() const {
assertMustNotBeMoreThanOnePrimaryInput();
return 1; // will be extended when batch mode is implemented
return hasPrimaryInputs() ? primaryInputCount() : hasInputs() ? 1 : 0;
}
void FrontendInputsAndOutputs::forEachInputProducingSupplementaryOutput(
llvm::function_ref<void(const InputFile &)> fn) const {
if (hasPrimaryInputs())
forEachPrimaryInput(fn);
else
else if (hasInputs())
fn(firstInput());
}