From e14625faa66e23da866e065b527d4e766a2f449d Mon Sep 17 00:00:00 2001 From: Serge Guelton Date: Wed, 12 Jul 2017 08:03:44 +0000 Subject: Have Module::createRNG return a unique_ptr Instead of a raw pointer, this makes memory management safer. llvm-svn: 307762 --- llvm/lib/IR/Module.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/IR/Module.cpp') diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index f8853ed16..fdc7de6 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -88,7 +88,7 @@ Module::~Module() { delete static_cast *>(NamedMDSymTab); } -RandomNumberGenerator *Module::createRNG(const Pass* P) const { +std::unique_ptr Module::createRNG(const Pass* P) const { SmallString<32> Salt(P->getPassName()); // This RNG is guaranteed to produce the same random stream only @@ -103,7 +103,7 @@ RandomNumberGenerator *Module::createRNG(const Pass* P) const { // store salt metadata from the Module constructor. Salt += sys::path::filename(getModuleIdentifier()); - return new RandomNumberGenerator(Salt); + return std::unique_ptr{new RandomNumberGenerator(Salt)}; } /// getNamedValue - Return the first global value in the module with -- cgit v1.1