diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-26 19:54:40 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-26 19:54:40 +0000 |
commit | 6406f7b8e0fc43c5f9d14bb3cd1d7d9192e3d277 (patch) | |
tree | e1d44a3a5a3732181039d9607893c24807a2fc65 /clang/lib/Basic | |
parent | cb5674b9c2e4d7944bd8fe0ed92f316e8e5d5f30 (diff) | |
download | bcm5719-llvm-6406f7b8e0fc43c5f9d14bb3cd1d7d9192e3d277.tar.gz bcm5719-llvm-6406f7b8e0fc43c5f9d14bb3cd1d7d9192e3d277.zip |
Return a std::unique_ptr from getBufferForFile. NFC.
llvm-svn: 216476
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/FileManager.cpp | 20 | ||||
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 6 |
2 files changed, 13 insertions, 13 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index 07297baf6d5..c0522966e38 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -386,9 +386,9 @@ void FileManager::FixupRelativePath(SmallVectorImpl<char> &path) const { path = NewPath; } -llvm::MemoryBuffer *FileManager:: -getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, - bool isVolatile, bool ShouldCloseOpenFile) { +std::unique_ptr<llvm::MemoryBuffer> +FileManager::getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, + bool isVolatile, bool ShouldCloseOpenFile) { std::unique_ptr<llvm::MemoryBuffer> Result; std::error_code ec; @@ -409,7 +409,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, // FileEntry is open or not. if (ShouldCloseOpenFile) Entry->closeFile(); - return Result.release(); + return Result; } // Otherwise, open the file. @@ -419,7 +419,7 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, /*RequiresNullTerminator=*/true, isVolatile); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.release(); + return Result; } SmallString<128> FilePath(Entry->getName()); @@ -428,18 +428,18 @@ getBufferForFile(const FileEntry *Entry, std::string *ErrorStr, /*RequiresNullTerminator=*/true, isVolatile); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.release(); + return Result; } -llvm::MemoryBuffer *FileManager:: -getBufferForFile(StringRef Filename, std::string *ErrorStr) { +std::unique_ptr<llvm::MemoryBuffer> +FileManager::getBufferForFile(StringRef Filename, std::string *ErrorStr) { std::unique_ptr<llvm::MemoryBuffer> Result; std::error_code ec; if (FileSystemOpts.WorkingDir.empty()) { ec = FS->getBufferForFile(Filename, Result); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.release(); + return Result; } SmallString<128> FilePath(Filename); @@ -447,7 +447,7 @@ getBufferForFile(StringRef Filename, std::string *ErrorStr) { ec = FS->getBufferForFile(FilePath.c_str(), Result); if (ec && ErrorStr) *ErrorStr = ec.message(); - return Result.release(); + return Result; } /// getStatValue - Get the 'stat' information for the specified path, diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 14de7607c3b..ef52e824b14 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -96,9 +96,9 @@ llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag, std::string ErrorStr; bool isVolatile = SM.userFilesAreVolatile() && !IsSystemFile; - Buffer.setPointer(SM.getFileManager().getBufferForFile(ContentsEntry, - &ErrorStr, - isVolatile)); + Buffer.setPointer(SM.getFileManager() + .getBufferForFile(ContentsEntry, &ErrorStr, isVolatile) + .release()); // If we were unable to open the file, then we are in an inconsistent // situation where the content cache referenced a file which no longer |