[llvm] r224003 - Use unique_ptr to remove an explicit delete. Change return type to pass the unique_ptr to caller.
Craig Topper
craig.topper at gmail.com
Wed Dec 10 23:04:46 PST 2014
Author: ctopper
Date: Thu Dec 11 01:04:46 2014
New Revision: 224003
URL: http://llvm.org/viewvc/llvm-project?rev=224003&view=rev
Log:
Use unique_ptr to remove an explicit delete. Change return type to pass the unique_ptr to caller.
Modified:
llvm/trunk/tools/llc/llc.cpp
Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=224003&r1=224002&r2=224003&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Thu Dec 11 01:04:46 2014
@@ -95,9 +95,9 @@ static cl::opt<bool> AsmVerbose("asm-ver
static int compileModule(char **, LLVMContext &);
-static tool_output_file *GetOutputStream(const char *TargetName,
- Triple::OSType OS,
- const char *ProgName) {
+static std::unique_ptr<tool_output_file>
+GetOutputStream(const char *TargetName, Triple::OSType OS,
+ const char *ProgName) {
// If we don't yet have an output filename, make one.
if (OutputFilename.empty()) {
if (InputFilename == "-")
@@ -151,10 +151,10 @@ static tool_output_file *GetOutputStream
sys::fs::OpenFlags OpenFlags = sys::fs::F_None;
if (!Binary)
OpenFlags |= sys::fs::F_Text;
- tool_output_file *FDOut = new tool_output_file(OutputFilename, EC, OpenFlags);
+ auto FDOut = llvm::make_unique<tool_output_file>(OutputFilename, EC,
+ OpenFlags);
if (EC) {
errs() << EC.message() << '\n';
- delete FDOut;
return nullptr;
}
More information about the llvm-commits
mailing list