diff --git a/include/swift/Driver/Driver.h b/include/swift/Driver/Driver.h index 92def5f98aa..fc3ab958629 100644 --- a/include/swift/Driver/Driver.h +++ b/include/swift/Driver/Driver.h @@ -208,13 +208,8 @@ public: ActionList &Actions) const; /// Construct the OutputFileMap for the driver from the given arguments. - /// - /// \param Args The input arguments. - /// \param[out] OFM a unique_ptr which, upon return, will point to the - /// OutputFileMap for this driver, or nullptr if one does not exist - /// (or could not be constructed). - void buildOutputFileMap(const llvm::opt::DerivedArgList &Args, - std::unique_ptr &OFM) const; + std::unique_ptr + buildOutputFileMap(const llvm::opt::DerivedArgList &Args) const; /// Add top-level Jobs to Compilation \p C for the given \p Actions and /// OutputInfo. diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 2dcbd4d9a60..a2e4205d072 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -47,8 +47,8 @@ Compilation::Compilation(const Driver &D, const ToolChain &DefaultToolChain, Level(Level), Jobs(new JobList), InputArgs(std::move(InputArgs)), TranslatedArgs(std::move(TranslatedArgs)), NumberOfParallelCommands(NumberOfParallelCommands), - EnableIncrementalBuild(EnableIncrementalBuild), - SkipTaskExecution(SkipTaskExecution) { + SkipTaskExecution(SkipTaskExecution), + EnableIncrementalBuild(EnableIncrementalBuild) { }; using CommandSet = llvm::DenseSet; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 38a4c05be75..4e4aea11807 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -201,8 +201,7 @@ std::unique_ptr Driver::buildCompilation( } } - std::unique_ptr OFM; - buildOutputFileMap(*TranslatedArgList, OFM); + std::unique_ptr 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 &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 +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,