Author: Scott Linder Date: 2021-04-30T17:11:50Z New Revision: cab19d84ce85cbceec7fde515cc686d6a83a5f9d
URL: https://github.com/llvm/llvm-project/commit/cab19d84ce85cbceec7fde515cc686d6a83a5f9d DIFF: https://github.com/llvm/llvm-project/commit/cab19d84ce85cbceec7fde515cc686d6a83a5f9d.diff LOG: [NFC] Refactor ExecuteAssembler in cc1as_main.cpp Introduce an extra scope (another static function) to replace calls to `unique_ptr::reset` with implicit destructors via RAII. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101542 Added: Modified: clang/tools/driver/cc1as_main.cpp Removed: ################################################################################ diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 083fc0846ac18..d4fa60c963d78 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -333,8 +333,8 @@ getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) { return Out; } -static bool ExecuteAssembler(AssemblerInvocation &Opts, - DiagnosticsEngine &Diags) { +static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, + DiagnosticsEngine &Diags) { // Get the target specific parser. std::string Error; const Target *TheTarget = TargetRegistry::lookupTarget(Opts.Triple, Error); @@ -531,12 +531,12 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, Failed = Parser->Run(Opts.NoInitialTextSection); } - // Parser has a reference to the output stream (Str), so close Parser first. - Parser.reset(); - Str.reset(); - // Close the output stream early. - BOS.reset(); - FDOS.reset(); + return Failed; +} + +static bool ExecuteAssembler(AssemblerInvocation &Opts, + DiagnosticsEngine &Diags) { + bool Failed = ExecuteAssemblerImpl(Opts, Diags); // Delete output file if there were errors. if (Failed) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits