[lld] r203809 - Replace OwningPtr with std::unique_ptr.
Ahmed Charles
ahmedcharles at gmail.com
Thu Mar 13 09:20:39 PDT 2014
Author: ace2001ac
Date: Thu Mar 13 11:20:38 2014
New Revision: 203809
URL: http://llvm.org/viewvc/llvm-project?rev=203809&view=rev
Log:
Replace OwningPtr with std::unique_ptr.
This results in some simplifications to the code where an OwningPtr had to
be used with the previous api and then ownership moved to a unique_ptr for
the rest of lld.
Modified:
lld/trunk/include/lld/Core/LLVM.h
lld/trunk/include/lld/Driver/CoreInputGraph.h
lld/trunk/include/lld/ReaderWriter/LinkerScript.h
lld/trunk/lib/Core/InputGraph.cpp
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/lib/Passes/RoundTripNativePass.cpp
lld/trunk/lib/Passes/RoundTripYAMLPass.cpp
lld/trunk/lib/ReaderWriter/ELF/Chunk.h
lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h
lld/trunk/lib/ReaderWriter/FileArchive.cpp
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp
lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/lib/ReaderWriter/Reader.cpp
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
lld/trunk/utils/linker-script-test/linker-script-test.cpp
Modified: lld/trunk/include/lld/Core/LLVM.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LLVM.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LLVM.h (original)
+++ lld/trunk/include/lld/Core/LLVM.h Thu Mar 13 11:20:38 2014
@@ -28,7 +28,6 @@ namespace llvm {
class Twine;
class MemoryBuffer;
template<typename T> class ArrayRef;
- template<class T> class OwningPtr;
template<unsigned InternalLen> class SmallString;
template<typename T, unsigned N> class SmallVector;
template<typename T> class SmallVectorImpl;
@@ -63,7 +62,6 @@ namespace lld {
using llvm::Twine;
using llvm::MemoryBuffer;
using llvm::ArrayRef;
- using llvm::OwningPtr;
using llvm::SmallString;
using llvm::SmallVector;
using llvm::SmallVectorImpl;
Modified: lld/trunk/include/lld/Driver/CoreInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/CoreInputGraph.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/CoreInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/CoreInputGraph.h Thu Mar 13 11:20:38 2014
@@ -20,9 +20,9 @@
#include "lld/Core/InputGraph.h"
#include "lld/ReaderWriter/CoreLinkingContext.h"
#include "lld/ReaderWriter/Reader.h"
-#include "llvm/ADT/OwningPtr.h"
#include <map>
+#include <memory>
namespace lld {
@@ -45,11 +45,10 @@ public:
return make_error_code(llvm::errc::no_such_file_or_directory);
// Create a memory buffer
- OwningPtr<MemoryBuffer> opmb;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(*filePath, opmb))
+ std::unique_ptr<MemoryBuffer> mb;
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(*filePath, mb))
return ec;
- std::unique_ptr<MemoryBuffer> mb(opmb.take());
_buffer = std::move(mb);
return ctx.registry().parseFile(_buffer, _files);
}
Modified: lld/trunk/include/lld/ReaderWriter/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/LinkerScript.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/LinkerScript.h (original)
+++ lld/trunk/include/lld/ReaderWriter/LinkerScript.h Thu Mar 13 11:20:38 2014
@@ -18,7 +18,6 @@
#include "lld/Core/LLVM.h"
#include "lld/Core/range.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -26,6 +25,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
+#include <memory>
#include <vector>
namespace lld {
Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Thu Mar 13 11:20:38 2014
@@ -10,7 +10,8 @@
#include "lld/Core/InputGraph.h"
#include "lld/Core/Resolver.h"
-#include "llvm/ADT/OwningPtr.h"
+
+#include <memory>
using namespace lld;
@@ -137,12 +138,11 @@ FileNode::FileNode(StringRef path, int64
/// \brief Read the file into _buffer.
error_code FileNode::getBuffer(StringRef filePath) {
// Create a memory buffer
- OwningPtr<MemoryBuffer> opmb;
+ std::unique_ptr<MemoryBuffer> mb;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(filePath, opmb))
+ if (error_code ec = MemoryBuffer::getFileOrSTDIN(filePath, mb))
return ec;
- std::unique_ptr<MemoryBuffer> mb(opmb.take());
_buffer = std::move(mb);
return error_code::success();
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Mar 13 11:20:38 2014
@@ -20,7 +20,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/Arg.h"
@@ -34,6 +33,7 @@
#include <algorithm>
#include <cctype>
#include <map>
+#include <memory>
#include <sstream>
namespace lld {
@@ -249,7 +249,7 @@ static bool parseSection(StringRef optio
static bool readFile(PECOFFLinkingContext &ctx, StringRef path,
ArrayRef<uint8_t> &result) {
- OwningPtr<MemoryBuffer> buf;
+ std::unique_ptr<MemoryBuffer> buf;
if (MemoryBuffer::getFile(path, buf))
return false;
result = ctx.allocate(ArrayRef<uint8_t>(
@@ -351,10 +351,10 @@ static bool parseExport(StringRef option
// Read module-definition file.
static llvm::Optional<moduledef::Directive *>
parseDef(StringRef option, llvm::BumpPtrAllocator &alloc) {
- OwningPtr<MemoryBuffer> buf;
+ std::unique_ptr<MemoryBuffer> buf;
if (MemoryBuffer::getFile(option, buf))
return llvm::None;
- moduledef::Lexer lexer(std::unique_ptr<MemoryBuffer>(buf.take()));
+ moduledef::Lexer lexer(std::move(buf));
moduledef::Parser parser(lexer, alloc);
return parser.parse();
}
Modified: lld/trunk/lib/Passes/RoundTripNativePass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/RoundTripNativePass.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/Passes/RoundTripNativePass.cpp (original)
+++ lld/trunk/lib/Passes/RoundTripNativePass.cpp Thu Mar 13 11:20:38 2014
@@ -14,10 +14,11 @@
#include "lld/ReaderWriter/Simple.h"
#include "lld/ReaderWriter/Writer.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
+#include <memory>
+
using namespace lld;
/// Perform the actual pass
@@ -36,11 +37,10 @@ void RoundTripNativePass::perform(std::u
// The file that is written would be kept around if there is a problem
// writing to the file or when reading atoms back from the file.
nativeWriter->writeFile(*mergedFile, tmpNativeFile.str());
- OwningPtr<MemoryBuffer> buff;
- if (MemoryBuffer::getFile(tmpNativeFile.str(), buff))
+ std::unique_ptr<MemoryBuffer> mb;
+ if (MemoryBuffer::getFile(tmpNativeFile.str(), mb))
return;
- std::unique_ptr<MemoryBuffer> mb(buff.take());
error_code ec = _context.registry().parseFile(mb, _nativeFile);
if (ec) {
// Note: we need a way for Passes to report errors.
Modified: lld/trunk/lib/Passes/RoundTripYAMLPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/RoundTripYAMLPass.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/Passes/RoundTripYAMLPass.cpp (original)
+++ lld/trunk/lib/Passes/RoundTripYAMLPass.cpp Thu Mar 13 11:20:38 2014
@@ -13,10 +13,11 @@
#include "lld/ReaderWriter/Simple.h"
#include "lld/ReaderWriter/Writer.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
+#include <memory>
+
// Skip YAML files larger than this to avoid OOM error. The YAML reader consumes
// excessively large amount of memory when parsing a large file.
// TODO: Fix the YAML reader to reduce memory footprint.
@@ -40,12 +41,11 @@ void RoundTripYAMLPass::perform(std::uni
// The file that is written would be kept around if there is a problem
// writing to the file or when reading atoms back from the file.
yamlWriter->writeFile(*mergedFile, tmpYAMLFile.str());
- OwningPtr<MemoryBuffer> buff;
- if (MemoryBuffer::getFile(tmpYAMLFile.str(), buff))
+ std::unique_ptr<MemoryBuffer> mb;
+ if (MemoryBuffer::getFile(tmpYAMLFile.str(), mb))
return;
- if (buff->getBufferSize() < MAX_YAML_FILE_SIZE) {
- std::unique_ptr<MemoryBuffer> mb(buff.take());
+ if (mb->getBufferSize() < MAX_YAML_FILE_SIZE) {
error_code ec = _context.registry().parseFile(mb, _yamlFile);
if (ec) {
// Note: we need a way for Passes to report errors.
Modified: lld/trunk/lib/ReaderWriter/ELF/Chunk.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Chunk.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Chunk.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Chunk.h Thu Mar 13 11:20:38 2014
@@ -12,7 +12,6 @@
#include "lld/Core/LLVM.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/Allocator.h"
@@ -21,6 +20,8 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
+#include <memory>
+
namespace lld {
class ELFLinkingContext;
Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Thu Mar 13 11:20:38 2014
@@ -22,7 +22,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
@@ -31,6 +30,7 @@
#include "llvm/Support/Format.h"
#include <map>
+#include <memory>
#include <tuple>
#include <unordered_map>
Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Thu Mar 13 11:20:38 2014
@@ -429,7 +429,7 @@ template <class ELFT> uint64_t OutputELF
template <class ELFT>
error_code OutputELFWriter<ELFT>::writeOutput(const File &file,
StringRef path) {
- OwningPtr<FileOutputBuffer> buffer;
+ std::unique_ptr<FileOutputBuffer> buffer;
ScopedTask createOutputTask(getDefaultDomain(), "ELF Writer Create Output");
error_code ec = FileOutputBuffer::create(path, outputFileSize(), buffer,
FileOutputBuffer::F_executable);
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Thu Mar 13 11:20:38 2014
@@ -21,7 +21,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/Allocator.h"
@@ -31,6 +30,8 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
+#include <memory>
+
namespace lld {
namespace elf {
template <class> class MergedSections;
Modified: lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h Thu Mar 13 11:20:38 2014
@@ -19,7 +19,6 @@
#include "lld/ReaderWriter/Writer.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/Allocator.h"
@@ -27,6 +26,7 @@
#include "llvm/Support/ELF.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.h"
+#include <memory>
namespace lld {
namespace elf {
Modified: lld/trunk/lib/ReaderWriter/FileArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/FileArchive.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/FileArchive.cpp (original)
+++ lld/trunk/lib/ReaderWriter/FileArchive.cpp Thu Mar 13 11:20:38 2014
@@ -11,7 +11,6 @@
#include "lld/Core/LLVM.h"
#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ObjectFile.h"
@@ -19,6 +18,7 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/MemoryBuffer.h"
+#include <memory>
#include <set>
#include <unordered_map>
@@ -51,10 +51,10 @@ public:
return nullptr;
if (dataSymbolOnly) {
- OwningPtr<MemoryBuffer> buff;
+ std::unique_ptr<MemoryBuffer> buff;
if (ci->getMemoryBuffer(buff, true))
return nullptr;
- if (isDataSymbol(buff.take(), name))
+ if (isDataSymbol(std::move(buff), name))
return nullptr;
}
@@ -101,20 +101,19 @@ protected:
error_code
instantiateMember(Archive::child_iterator member,
std::vector<std::unique_ptr<File>> &result) const {
- OwningPtr<MemoryBuffer> buff;
- if (error_code ec = member->getMemoryBuffer(buff, true))
+ std::unique_ptr<MemoryBuffer> mb;
+ if (error_code ec = member->getMemoryBuffer(mb, true))
return ec;
if (_logLoading)
- llvm::outs() << buff->getBufferIdentifier() << "\n";
- std::unique_ptr<MemoryBuffer> mb(buff.take());
+ llvm::outs() << mb->getBufferIdentifier() << "\n";
_registry.parseFile(mb, result);
const char *memberStart = member->getBuffer().data();
_membersInstantiated.insert(memberStart);
return error_code::success();
}
- error_code isDataSymbol(MemoryBuffer *mb, StringRef symbol) const {
- auto objOrErr(ObjectFile::createObjectFile(mb));
+ error_code isDataSymbol(std::unique_ptr<MemoryBuffer> mb, StringRef symbol) const {
+ auto objOrErr(ObjectFile::createObjectFile(mb.release()));
if (auto ec = objOrErr.getError())
return ec;
std::unique_ptr<ObjectFile> obj(objOrErr.get());
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp Thu Mar 13 11:20:38 2014
@@ -933,7 +933,7 @@ error_code MachOFileLayout::writeBinary(
if (_ec)
return _ec;
// Create FileOutputBuffer with calculated size.
- OwningPtr<llvm::FileOutputBuffer> fob;
+ std::unique_ptr<llvm::FileOutputBuffer> fob;
unsigned flags = 0;
if (_file.fileType != llvm::MachO::MH_OBJECT)
flags = llvm::FileOutputBuffer::F_executable;
Modified: lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp (original)
+++ lld/trunk/lib/ReaderWriter/Native/ReaderNative.cpp Thu Mar 13 11:20:38 2014
@@ -17,7 +17,6 @@
#include "lld/Core/File.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -369,7 +368,7 @@ public:
}
virtual ~File() {
- // _buffer is automatically deleted because of OwningPtr<>
+ // _buffer is automatically deleted because of std::unique_ptr<>
// All other ivar pointers are pointers into the MemoryBuffer, except
// the _definedAtoms array which was allocated to contain an array
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Thu Mar 13 11:20:38 2014
@@ -272,14 +272,14 @@ FileCOFF::FileCOFF(std::unique_ptr<Memor
auto binaryOrErr = llvm::object::createBinary(mb.release());
if ((ec = binaryOrErr.getError()))
return;
- OwningPtr<llvm::object::Binary> bin(binaryOrErr.get());
+ std::unique_ptr<llvm::object::Binary> bin(binaryOrErr.get());
_obj.reset(dyn_cast<const llvm::object::COFFObjectFile>(bin.get()));
if (!_obj) {
ec = make_error_code(llvm::object::object_error::invalid_file_type);
return;
}
- bin.take();
+ bin.release();
// Read .drectve section if exists.
ArrayRef<uint8_t> directives;
@@ -912,10 +912,9 @@ public:
llvm::FileRemover coffFileRemover(*coffPath);
// Read and parse the COFF
- OwningPtr<MemoryBuffer> opmb;
- if (error_code ec = MemoryBuffer::getFile(*coffPath, opmb))
+ std::unique_ptr<MemoryBuffer> newmb;
+ if (error_code ec = MemoryBuffer::getFile(*coffPath, newmb))
return ec;
- std::unique_ptr<MemoryBuffer> newmb(opmb.take());
error_code ec;
std::unique_ptr<FileCOFF> file(new FileCOFF(std::move(newmb), ec));
if (ec)
@@ -938,7 +937,7 @@ private:
// Write the memory buffer contents to .res file, so that we can run
// cvtres.exe on it.
- OwningPtr<llvm::FileOutputBuffer> buffer;
+ std::unique_ptr<llvm::FileOutputBuffer> buffer;
if (error_code ec = llvm::FileOutputBuffer::create(
tempFilePath.str(), mb->getBufferSize(), buffer))
return ec;
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Mar 13 11:20:38 2014
@@ -1016,7 +1016,7 @@ error_code PECOFFWriter::writeFile(const
}
uint64_t totalSize = _chunks.back()->fileOffset() + _chunks.back()->size();
- OwningPtr<llvm::FileOutputBuffer> buffer;
+ std::unique_ptr<llvm::FileOutputBuffer> buffer;
error_code ec = llvm::FileOutputBuffer::create(
path, totalSize, buffer, llvm::FileOutputBuffer::F_executable);
if (ec)
Modified: lld/trunk/lib/ReaderWriter/Reader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/Reader.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/Reader.cpp (original)
+++ lld/trunk/lib/ReaderWriter/Reader.cpp Thu Mar 13 11:20:38 2014
@@ -9,13 +9,14 @@
#include "lld/ReaderWriter/Reader.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/system_error.h"
+#include <memory>
+
namespace lld {
Reader::~Reader() {
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Thu Mar 13 11:20:38 2014
@@ -20,7 +20,6 @@
#include "lld/Core/Reference.h"
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Debug.h"
@@ -31,6 +30,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
+#include <memory>
#include <string>
using llvm::yaml::MappingTraits;
Modified: lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp (original)
+++ lld/trunk/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp Thu Mar 13 11:20:38 2014
@@ -10,18 +10,17 @@
#include "gtest/gtest.h"
#include "../../lib/ReaderWriter/MachO/MachONormalizedFile.h"
-#include <llvm/ADT/OwningPtr.h>
#include <llvm/ADT/Twine.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/MachO.h>
#include <llvm/Support/system_error.h>
#include <cassert>
+#include <memory>
#include <vector>
using llvm::StringRef;
using llvm::MemoryBuffer;
-using llvm::OwningPtr;
using llvm::SmallString;
using llvm::Twine;
using llvm::ErrorOr;
@@ -34,10 +33,8 @@ using namespace lld::mach_o::normalized;
// Normalized file to nf parameter.
static void fromBinary(StringRef path, std::unique_ptr<MemoryBuffer> &mb,
std::unique_ptr<NormalizedFile> &nf, StringRef archStr) {
- OwningPtr<MemoryBuffer> opmb;
- error_code ec = MemoryBuffer::getFile(path, opmb);
+ error_code ec = MemoryBuffer::getFile(path, mb);
EXPECT_FALSE(ec);
- mb.reset(opmb.take());
ErrorOr<std::unique_ptr<NormalizedFile>> r =
lld::mach_o::normalized::readBinary(
Modified: lld/trunk/utils/linker-script-test/linker-script-test.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/utils/linker-script-test/linker-script-test.cpp?rev=203809&r1=203808&r2=203809&view=diff
==============================================================================
--- lld/trunk/utils/linker-script-test/linker-script-test.cpp (original)
+++ lld/trunk/utils/linker-script-test/linker-script-test.cpp Thu Mar 13 11:20:38 2014
@@ -26,12 +26,12 @@ int main(int argc, const char **argv) {
llvm::PrettyStackTraceProgram X(argc, argv);
{
- llvm::OwningPtr<MemoryBuffer> mb;
+ std::unique_ptr<MemoryBuffer> mb;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(argv[1], mb)) {
llvm::errs() << ec.message() << "\n";
return 1;
}
- Lexer l(std::unique_ptr<MemoryBuffer>(mb.take()));
+ Lexer l(std::move(mb));
Token tok;
while (true) {
l.lex(tok);
@@ -41,12 +41,12 @@ int main(int argc, const char **argv) {
}
}
{
- llvm::OwningPtr<MemoryBuffer> mb;
+ std::unique_ptr<MemoryBuffer> mb;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(argv[1], mb)) {
llvm::errs() << ec.message() << "\n";
return 1;
}
- Lexer l(std::unique_ptr<MemoryBuffer>(mb.take()));
+ Lexer l(std::move(mb));
Parser p(l);
LinkerScript *ls = p.parse();
if (ls)
More information about the llvm-commits
mailing list