From 240c528f0cfa77bff16a2bd5e95935099a126b85 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 16 Apr 2016 22:25:36 +0000 Subject: [PATCH] LTO: Use a common LibLTOCodeGenerator::init, NFC llvm-svn: 266538 --- tools/lto/lto.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 5a179728e7c..7829dd06d0e 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -119,16 +119,18 @@ static void handleLibLTODiagnostic(lto_codegen_diagnostic_severity_t Severity, // libLTO API semantics, which require that the code generator owns the object // file. struct LibLTOCodeGenerator : LTOCodeGenerator { - LibLTOCodeGenerator() : LTOCodeGenerator(*LTOContext) { - setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } + LibLTOCodeGenerator() : LTOCodeGenerator(*LTOContext) { init(); } LibLTOCodeGenerator(std::unique_ptr Context) : LTOCodeGenerator(*Context), OwnedContext(std::move(Context)) { - setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } + init(); + } // Reset the module first in case MergedModule is created in OwnedContext. // Module must be destructed before its context gets destructed. ~LibLTOCodeGenerator() { resetMergedModule(); } + void init() { setDiagnosticHandler(handleLibLTODiagnostic, nullptr); } + std::unique_ptr NativeObjectFile; std::unique_ptr OwnedContext; };