forked from OSchip/llvm-project
Use a unique_ptr instead of manual deletion for PIMPL idiom (NFC)
PiperOrigin-RevId: 230930254
This commit is contained in:
parent
ba1715f407
commit
d9ce382fc9
|
@ -68,9 +68,8 @@ public:
|
|||
llvm::Error invoke(StringRef name, Args &... args);
|
||||
|
||||
private:
|
||||
// FIXME: we may want a `unique_ptr` here if impl::OrcJIT decides to provide
|
||||
// a default constructor.
|
||||
impl::OrcJIT *jit;
|
||||
// Private implementation of the JIT (PIMPL)
|
||||
std::unique_ptr<impl::OrcJIT> jit;
|
||||
llvm::LLVMContext llvmContext;
|
||||
};
|
||||
|
||||
|
|
|
@ -257,10 +257,8 @@ void packFunctionArguments(llvm::Module *module) {
|
|||
}
|
||||
}
|
||||
|
||||
ExecutionEngine::~ExecutionEngine() {
|
||||
if (jit)
|
||||
delete jit;
|
||||
}
|
||||
// Out of line for PIMPL unique_ptr.
|
||||
ExecutionEngine::~ExecutionEngine() = default;
|
||||
|
||||
Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(Module *m) {
|
||||
auto engine = llvm::make_unique<ExecutionEngine>();
|
||||
|
@ -280,7 +278,7 @@ Expected<std::unique_ptr<ExecutionEngine>> ExecutionEngine::create(Module *m) {
|
|||
setupTargetTriple(llvmModule.get());
|
||||
packFunctionArguments(llvmModule.get());
|
||||
|
||||
engine->jit = std::move(*expectedJIT).release();
|
||||
engine->jit = std::move(*expectedJIT);
|
||||
if (auto err = engine->jit->addModule(std::move(llvmModule)))
|
||||
return std::move(err);
|
||||
|
||||
|
|
Loading…
Reference in New Issue