scott.linder created this revision. scott.linder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Introduce an extra scope (another static function) to replace calls to `unique_ptr::reset` with implicit destructors via RAII. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D101542 Files: clang/tools/driver/cc1as_main.cpp Index: clang/tools/driver/cc1as_main.cpp =================================================================== --- clang/tools/driver/cc1as_main.cpp +++ clang/tools/driver/cc1as_main.cpp @@ -333,8 +333,8 @@ 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 @@ 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) {
Index: clang/tools/driver/cc1as_main.cpp =================================================================== --- clang/tools/driver/cc1as_main.cpp +++ clang/tools/driver/cc1as_main.cpp @@ -333,8 +333,8 @@ 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 @@ 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