[Driver] Use return value instead of out parameter for buildOutputFileMap.

No functionality change, just a cleanup.

Swift SVN r23966
This commit is contained in:
Jordan Rose
2014-12-17 00:26:25 +00:00
parent c385a9d43a
commit c5547f7068
3 changed files with 17 additions and 23 deletions

View File

@@ -201,8 +201,7 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
}
}
std::unique_ptr<OutputFileMap> OFM;
buildOutputFileMap(*TranslatedArgList, OFM);
std::unique_ptr<OutputFileMap> OFM = buildOutputFileMap(*TranslatedArgList);
if (Diags.hadAnyError())
return nullptr;
@@ -934,19 +933,19 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) {
return true;
}
void
Driver::buildOutputFileMap(const llvm::opt::DerivedArgList &Args,
std::unique_ptr<OutputFileMap> &OFM) const {
if (const Arg *A = Args.getLastArg(options::OPT_output_file_map)) {
// TODO: perform some preflight checks to ensure the file exists.
OFM = OutputFileMap::loadFromPath(A->getValue());
if (!OFM)
// TODO: emit diagnostic with error string
Diags.diagnose(SourceLoc(), diag::error_unable_to_load_output_file_map);
} else {
// We don't have an OutputFileMap, so reset the unique_ptr.
OFM.reset();
std::unique_ptr<OutputFileMap>
Driver::buildOutputFileMap(const llvm::opt::DerivedArgList &Args) const {
const Arg *A = Args.getLastArg(options::OPT_output_file_map);
if (!A)
return nullptr;
// TODO: perform some preflight checks to ensure the file exists.
auto OFM = OutputFileMap::loadFromPath(A->getValue());
if (!OFM) {
// TODO: emit diagnostic with error string
Diags.diagnose(SourceLoc(), diag::error_unable_to_load_output_file_map);
}
return std::move(OFM);
}
void Driver::buildJobs(const ActionList &Actions, const OutputInfo &OI,