r215864 - Use std::unique_ptr in a few methods that take ownership.
Rafael Espindola
rafael.espindola at gmail.com
Sun Aug 17 16:12:28 PDT 2014
Author: rafael
Date: Sun Aug 17 18:12:27 2014
New Revision: 215864
URL: http://llvm.org/viewvc/llvm-project?rev=215864&view=rev
Log:
Use std::unique_ptr in a few methods that take ownership.
Modified:
cfe/trunk/include/clang/ARCMigrate/FileRemapper.h
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
Modified: cfe/trunk/include/clang/ARCMigrate/FileRemapper.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ARCMigrate/FileRemapper.h?rev=215864&r1=215863&r2=215864&view=diff
==============================================================================
--- cfe/trunk/include/clang/ARCMigrate/FileRemapper.h (original)
+++ cfe/trunk/include/clang/ARCMigrate/FileRemapper.h Sun Aug 17 18:12:27 2014
@@ -52,14 +52,14 @@ public:
bool overwriteOriginal(DiagnosticsEngine &Diag,
StringRef outputDir = StringRef());
- void remap(StringRef filePath, llvm::MemoryBuffer *memBuf);
+ void remap(StringRef filePath, std::unique_ptr<llvm::MemoryBuffer> memBuf);
void applyMappings(PreprocessorOptions &PPOpts) const;
void clear(StringRef outputDir = StringRef());
private:
- void remap(const FileEntry *file, llvm::MemoryBuffer *memBuf);
+ void remap(const FileEntry *file, std::unique_ptr<llvm::MemoryBuffer> memBuf);
void remap(const FileEntry *file, const FileEntry *newfile);
const FileEntry *getOriginalFile(StringRef filePath);
Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=215864&r1=215863&r2=215864&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Sun Aug 17 18:12:27 2014
@@ -597,11 +597,12 @@ bool MigrationProcess::applyTransform(Tr
llvm::raw_svector_ostream vecOS(newText);
buf.write(vecOS);
vecOS.flush();
- llvm::MemoryBuffer *memBuf = llvm::MemoryBuffer::getMemBufferCopy(
- StringRef(newText.data(), newText.size()), newFname);
+ std::unique_ptr<llvm::MemoryBuffer> memBuf(
+ llvm::MemoryBuffer::getMemBufferCopy(
+ StringRef(newText.data(), newText.size()), newFname));
SmallString<64> filePath(file->getName());
Unit->getFileManager().FixupRelativePath(filePath);
- Remapper.remap(filePath.str(), memBuf);
+ Remapper.remap(filePath.str(), std::move(memBuf));
}
return false;
Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=215864&r1=215863&r2=215864&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Sun Aug 17 18:12:27 2014
@@ -207,15 +207,17 @@ void FileRemapper::applyMappings(Preproc
PPOpts.RetainRemappedFileBuffers = true;
}
-void FileRemapper::remap(StringRef filePath, llvm::MemoryBuffer *memBuf) {
- remap(getOriginalFile(filePath), memBuf);
+void FileRemapper::remap(StringRef filePath,
+ std::unique_ptr<llvm::MemoryBuffer> memBuf) {
+ remap(getOriginalFile(filePath), std::move(memBuf));
}
-void FileRemapper::remap(const FileEntry *file, llvm::MemoryBuffer *memBuf) {
+void FileRemapper::remap(const FileEntry *file,
+ std::unique_ptr<llvm::MemoryBuffer> memBuf) {
assert(file);
Target &targ = FromToMappings[file];
resetTarget(targ);
- targ = memBuf;
+ targ = memBuf.release();
}
void FileRemapper::remap(const FileEntry *file, const FileEntry *newfile) {
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=215864&r1=215863&r2=215864&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Sun Aug 17 18:12:27 2014
@@ -1821,11 +1821,12 @@ void ObjCMigrateASTConsumer::HandleTrans
llvm::raw_svector_ostream vecOS(newText);
buf.write(vecOS);
vecOS.flush();
- llvm::MemoryBuffer *memBuf = llvm::MemoryBuffer::getMemBufferCopy(
- StringRef(newText.data(), newText.size()), file->getName());
+ std::unique_ptr<llvm::MemoryBuffer> memBuf(
+ llvm::MemoryBuffer::getMemBufferCopy(
+ StringRef(newText.data(), newText.size()), file->getName()));
SmallString<64> filePath(file->getName());
FileMgr.FixupRelativePath(filePath);
- Remapper.remap(filePath.str(), memBuf);
+ Remapper.remap(filePath.str(), std::move(memBuf));
}
if (IsOutputFile) {
More information about the cfe-commits
mailing list