diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-01 14:11:14 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-08-01 14:11:14 +0000 |
commit | ce5dd1acc226fad92ef4ea9efbe814dbc3b0d7c6 (patch) | |
tree | cca931861ca7f8ee1d19422b414751b7181a26a8 /llvm/utils/FileCheck/FileCheck.cpp | |
parent | c960f56ab006a4c323d7d8e1f8722600a2bc28df (diff) | |
download | bcm5719-llvm-ce5dd1acc226fad92ef4ea9efbe814dbc3b0d7c6.tar.gz bcm5719-llvm-ce5dd1acc226fad92ef4ea9efbe814dbc3b0d7c6.zip |
Simplify the code a bit with std::unique_ptr.
llvm-svn: 214514
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r-- | llvm/utils/FileCheck/FileCheck.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp index 9245e1143ad..9cd1fe75760 100644 --- a/llvm/utils/FileCheck/FileCheck.cpp +++ b/llvm/utils/FileCheck/FileCheck.cpp @@ -631,7 +631,7 @@ struct CheckString { /// /// \param PreserveHorizontal Don't squash consecutive horizontal whitespace /// characters to a single space. -static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB, +static MemoryBuffer *CanonicalizeInputFile(std::unique_ptr<MemoryBuffer> MB, bool PreserveHorizontal) { SmallString<128> NewFile; NewFile.reserve(MB->getBufferSize()); @@ -657,12 +657,8 @@ static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB, ++Ptr; } - // Free the old buffer and return a new one. - MemoryBuffer *MB2 = - MemoryBuffer::getMemBufferCopy(NewFile.str(), MB->getBufferIdentifier()); - - delete MB; - return MB2; + return MemoryBuffer::getMemBufferCopy(NewFile.str(), + MB->getBufferIdentifier()); } static bool IsPartOfWord(char c) { @@ -837,7 +833,7 @@ static bool ReadCheckFile(SourceMgr &SM, // If we want to canonicalize whitespace, strip excess whitespace from the // buffer containing the CHECK lines. Remove DOS style line endings. - MemoryBuffer *F = CanonicalizeInputFile(FileOrErr.get().release(), + MemoryBuffer *F = CanonicalizeInputFile(std::move(FileOrErr.get()), NoCanonicalizeWhiteSpace); SM.AddNewSourceBuffer(F, SMLoc()); @@ -1272,7 +1268,7 @@ int main(int argc, char **argv) { // Remove duplicate spaces in the input file if requested. // Remove DOS style line endings. MemoryBuffer *F = - CanonicalizeInputFile(File.release(), NoCanonicalizeWhiteSpace); + CanonicalizeInputFile(std::move(File), NoCanonicalizeWhiteSpace); SM.AddNewSourceBuffer(F, SMLoc()); |