///
/// \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());
++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) {
// 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());
// 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());