summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ExecutionEngine/ObjectBuffer.h5
-rw-r--r--include/llvm/Support/MemoryBuffer.h17
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp8
-rw-r--r--lib/IR/Core.cpp13
-rw-r--r--lib/LTO/LTOModule.cpp3
-rw-r--r--lib/MC/MCParser/AsmParser.cpp8
-rw-r--r--lib/Support/MemoryBuffer.cpp61
-rw-r--r--tools/gold/gold-plugin.cpp4
-rw-r--r--tools/lli/lli.cpp3
-rw-r--r--unittests/Bitcode/BitReaderTest.cpp4
-rw-r--r--unittests/ExecutionEngine/JIT/JITTest.cpp6
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp7
-rw-r--r--unittests/Support/LineIteratorTest.cpp14
-rw-r--r--unittests/Support/SourceMgrTest.cpp4
-rw-r--r--unittests/Support/YAMLParserTest.cpp4
-rw-r--r--utils/FileCheck/FileCheck.cpp9
16 files changed, 81 insertions, 89 deletions
diff --git a/include/llvm/ExecutionEngine/ObjectBuffer.h b/include/llvm/ExecutionEngine/ObjectBuffer.h
index 9b234684fac..1950ad6deb9 100644
--- a/include/llvm/ExecutionEngine/ObjectBuffer.h
+++ b/include/llvm/ExecutionEngine/ObjectBuffer.h
@@ -62,9 +62,8 @@ public:
OS.flush();
// Make the data accessible via the ObjectBuffer::Buffer
- Buffer.reset(MemoryBuffer::getMemBuffer(StringRef(SV.data(), SV.size()),
- "",
- false));
+ Buffer =
+ MemoryBuffer::getMemBuffer(StringRef(SV.data(), SV.size()), "", false);
}
protected:
diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h
index 827d896686d..bba32a102e4 100644
--- a/include/llvm/Support/MemoryBuffer.h
+++ b/include/llvm/Support/MemoryBuffer.h
@@ -98,28 +98,29 @@ public:
/// Open the specified memory range as a MemoryBuffer. Note that InputData
/// must be null terminated if RequiresNullTerminator is true.
- static MemoryBuffer *getMemBuffer(StringRef InputData,
- StringRef BufferName = "",
- bool RequiresNullTerminator = true);
+ static std::unique_ptr<MemoryBuffer>
+ getMemBuffer(StringRef InputData, StringRef BufferName = "",
+ bool RequiresNullTerminator = true);
static std::unique_ptr<MemoryBuffer>
getMemBuffer(MemoryBufferRef Ref, bool RequiresNullTerminator = true);
/// Open the specified memory range as a MemoryBuffer, copying the contents
/// and taking ownership of it. InputData does not have to be null terminated.
- static MemoryBuffer *getMemBufferCopy(StringRef InputData,
- StringRef BufferName = "");
+ static std::unique_ptr<MemoryBuffer>
+ getMemBufferCopy(StringRef InputData, StringRef BufferName = "");
/// Allocate a new zero-initialized MemoryBuffer of the specified size. Note
/// that the caller need not initialize the memory allocated by this method.
/// The memory is owned by the MemoryBuffer object.
- static MemoryBuffer *getNewMemBuffer(size_t Size, StringRef BufferName = "");
+ static std::unique_ptr<MemoryBuffer>
+ getNewMemBuffer(size_t Size, StringRef BufferName = "");
/// Allocate a new MemoryBuffer of the specified size that is not initialized.
/// Note that the caller should initialize the memory allocated by this
/// method. The memory is owned by the MemoryBuffer object.
- static MemoryBuffer *getNewUninitMemBuffer(size_t Size,
- StringRef BufferName = "");
+ static std::unique_ptr<MemoryBuffer>
+ getNewUninitMemBuffer(size_t Size, StringRef BufferName = "");
/// Read all of stdin into a file buffer, and return it.
static ErrorOr<std::unique_ptr<MemoryBuffer>> getSTDIN();
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 35a2842c70f..71dca74e64d 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -110,9 +110,11 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
HasDiagHandler = true;
}
- std::unique_ptr<MemoryBuffer> Buffer(
- isNullTerminated ? MemoryBuffer::getMemBuffer(Str, "<inline asm>")
- : MemoryBuffer::getMemBufferCopy(Str, "<inline asm>"));
+ std::unique_ptr<MemoryBuffer> Buffer;
+ if (isNullTerminated)
+ Buffer = MemoryBuffer::getMemBuffer(Str, "<inline asm>");
+ else
+ Buffer = MemoryBuffer::getMemBufferCopy(Str, "<inline asm>");
// Tell SrcMgr about this buffer, it takes ownership of the buffer.
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index d81533b20c2..acf63a36d26 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -2655,10 +2655,9 @@ LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(
const char *BufferName,
LLVMBool RequiresNullTerminator) {
- return wrap(MemoryBuffer::getMemBuffer(
- StringRef(InputData, InputDataLength),
- StringRef(BufferName),
- RequiresNullTerminator));
+ return wrap(MemoryBuffer::getMemBuffer(StringRef(InputData, InputDataLength),
+ StringRef(BufferName),
+ RequiresNullTerminator).release());
}
LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
@@ -2666,9 +2665,9 @@ LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(
size_t InputDataLength,
const char *BufferName) {
- return wrap(MemoryBuffer::getMemBufferCopy(
- StringRef(InputData, InputDataLength),
- StringRef(BufferName)));
+ return wrap(
+ MemoryBuffer::getMemBufferCopy(StringRef(InputData, InputDataLength),
+ StringRef(BufferName)).release());
}
const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf) {
diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp
index 76b5e197a62..88f82f0722a 100644
--- a/lib/LTO/LTOModule.cpp
+++ b/lib/LTO/LTOModule.cpp
@@ -168,8 +168,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBufferRef Buffer,
std::unique_ptr<MemoryBuffer>
LTOModule::makeBuffer(const void *mem, size_t length, StringRef name) {
const char *startPtr = (const char*)mem;
- return std::unique_ptr<MemoryBuffer>(
- MemoryBuffer::getMemBuffer(StringRef(startPtr, length), name, false));
+ return MemoryBuffer::getMemBuffer(StringRef(startPtr, length), name, false);
}
/// objcClassNameFromExpression - Get string that the data pointer points to.
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index c82e1183aaf..a1b469d6797 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -2118,8 +2118,8 @@ bool AsmParser::handleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc) {
// instantiation.
OS << ".endmacro\n";
- std::unique_ptr<MemoryBuffer> Instantiation(
- MemoryBuffer::getMemBufferCopy(OS.str(), "<instantiation>"));
+ std::unique_ptr<MemoryBuffer> Instantiation =
+ MemoryBuffer::getMemBufferCopy(OS.str(), "<instantiation>");
// Create the macro instantiation object and add to the current macro
// instantiation stack.
@@ -4304,8 +4304,8 @@ void AsmParser::instantiateMacroLikeBody(MCAsmMacro *M, SMLoc DirectiveLoc,
raw_svector_ostream &OS) {
OS << ".endr\n";
- std::unique_ptr<MemoryBuffer> Instantiation(
- MemoryBuffer::getMemBufferCopy(OS.str(), "<instantiation>"));
+ std::unique_ptr<MemoryBuffer> Instantiation =
+ MemoryBuffer::getMemBufferCopy(OS.str(), "<instantiation>");
// Create the macro instantiation object and add to the current macro
// instantiation stack.
diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp
index 9bb6b42466b..fe4759219c9 100644
--- a/lib/Support/MemoryBuffer.cpp
+++ b/lib/Support/MemoryBuffer.cpp
@@ -94,13 +94,12 @@ public:
};
}
-/// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note
-/// that InputData must be a null terminated if RequiresNullTerminator is true!
-MemoryBuffer *MemoryBuffer::getMemBuffer(StringRef InputData,
- StringRef BufferName,
- bool RequiresNullTerminator) {
- return new (NamedBufferAlloc(BufferName))
+std::unique_ptr<MemoryBuffer>
+MemoryBuffer::getMemBuffer(StringRef InputData, StringRef BufferName,
+ bool RequiresNullTerminator) {
+ auto *Ret = new (NamedBufferAlloc(BufferName))
MemoryBufferMem(InputData, RequiresNullTerminator);
+ return std::unique_ptr<MemoryBuffer>(Ret);
}
std::unique_ptr<MemoryBuffer>
@@ -109,24 +108,19 @@ MemoryBuffer::getMemBuffer(MemoryBufferRef Ref, bool RequiresNullTerminator) {
Ref.getBuffer(), Ref.getBufferIdentifier(), RequiresNullTerminator));
}
-/// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
-/// copying the contents and taking ownership of it. This has no requirements
-/// on EndPtr[0].
-MemoryBuffer *MemoryBuffer::getMemBufferCopy(StringRef InputData,
- StringRef BufferName) {
- MemoryBuffer *Buf = getNewUninitMemBuffer(InputData.size(), BufferName);
- if (!Buf) return nullptr;
+std::unique_ptr<MemoryBuffer>
+MemoryBuffer::getMemBufferCopy(StringRef InputData, StringRef BufferName) {
+ std::unique_ptr<MemoryBuffer> Buf =
+ getNewUninitMemBuffer(InputData.size(), BufferName);
+ if (!Buf)
+ return nullptr;
memcpy(const_cast<char*>(Buf->getBufferStart()), InputData.data(),
InputData.size());
return Buf;
}
-/// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size
-/// that is not initialized. Note that the caller should initialize the
-/// memory allocated by this method. The memory is owned by the MemoryBuffer
-/// object.
-MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
- StringRef BufferName) {
+std::unique_ptr<MemoryBuffer>
+MemoryBuffer::getNewUninitMemBuffer(size_t Size, StringRef BufferName) {
// Allocate space for the MemoryBuffer, the data and the name. It is important
// that MemoryBuffer and data are aligned so PointerIntPair works with them.
// TODO: Is 16-byte alignment enough? We copy small object files with large
@@ -135,7 +129,8 @@ MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
RoundUpToAlignment(sizeof(MemoryBufferMem) + BufferName.size() + 1, 16);
size_t RealLen = AlignedStringLen + Size + 1;
char *Mem = static_cast<char*>(operator new(RealLen, std::nothrow));
- if (!Mem) return nullptr;
+ if (!Mem)
+ return nullptr;
// The name is stored after the class itself.
CopyStringRef(Mem + sizeof(MemoryBufferMem), BufferName);
@@ -144,15 +139,15 @@ MemoryBuffer *MemoryBuffer::getNewUninitMemBuffer(size_t Size,
char *Buf = Mem + AlignedStringLen;
Buf[Size] = 0; // Null terminate buffer.
- return new (Mem) MemoryBufferMem(StringRef(Buf, Size), true);
+ auto *Ret = new (Mem) MemoryBufferMem(StringRef(Buf, Size), true);
+ return std::unique_ptr<MemoryBuffer>(Ret);
}
-/// getNewMemBuffer - Allocate a new zero-initialized MemoryBuffer of the
-/// specified size. Note that the caller need not initialize the memory
-/// allocated by this method. The memory is owned by the MemoryBuffer object.
-MemoryBuffer *MemoryBuffer::getNewMemBuffer(size_t Size, StringRef BufferName) {
- MemoryBuffer *SB = getNewUninitMemBuffer(Size, BufferName);
- if (!SB) return nullptr;
+std::unique_ptr<MemoryBuffer>
+MemoryBuffer::getNewMemBuffer(size_t Size, StringRef BufferName) {
+ std::unique_ptr<MemoryBuffer> SB = getNewUninitMemBuffer(Size, BufferName);
+ if (!SB)
+ return nullptr;
memset(const_cast<char*>(SB->getBufferStart()), 0, Size);
return SB;
}
@@ -226,9 +221,7 @@ getMemoryBufferForStream(int FD, StringRef BufferName) {
Buffer.set_size(Buffer.size() + ReadBytes);
} while (ReadBytes != 0);
- std::unique_ptr<MemoryBuffer> Ret(
- MemoryBuffer::getMemBufferCopy(Buffer, BufferName));
- return std::move(Ret);
+ return MemoryBuffer::getMemBufferCopy(Buffer, BufferName);
}
static ErrorOr<std::unique_ptr<MemoryBuffer>>
@@ -360,15 +353,15 @@ getOpenFileImpl(int FD, const char *Filename, uint64_t FileSize,
return std::move(Result);
}
- MemoryBuffer *Buf = MemoryBuffer::getNewUninitMemBuffer(MapSize, Filename);
+ std::unique_ptr<MemoryBuffer> Buf =
+ MemoryBuffer::getNewUninitMemBuffer(MapSize, Filename);
if (!Buf) {
// Failed to create a buffer. The only way it can fail is if
// new(std::nothrow) returns 0.
return make_error_code(errc::not_enough_memory);
}
- std::unique_ptr<MemoryBuffer> SB(Buf);
- char *BufPtr = const_cast<char*>(SB->getBufferStart());
+ char *BufPtr = const_cast<char *>(Buf->getBufferStart());
size_t BytesLeft = MapSize;
#ifndef HAVE_PREAD
@@ -396,7 +389,7 @@ getOpenFileImpl(int FD, const char *Filename, uint64_t FileSize,
BufPtr += NumRead;
}
- return std::move(SB);
+ return std::move(Buf);
}
ErrorOr<std::unique_ptr<MemoryBuffer>>
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 33602563731..fd505b0bf15 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -276,8 +276,8 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
message(LDPL_ERROR, "Failed to get a view of %s", file->name);
return LDPS_ERR;
}
- buffer.reset(MemoryBuffer::getMemBuffer(
- StringRef((char *)view, file->filesize), "", false));
+ buffer = MemoryBuffer::getMemBuffer(StringRef((char *)view, file->filesize),
+ "", false);
} else {
int64_t offset = 0;
// Gold has found what might be IR part-way inside of a file, such as
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 7abbbbbb389..b69e91c5d4d 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -294,8 +294,7 @@ public:
// because the file has probably just been mmapped. Instead we make
// a copy. The filed-based buffer will be released when it goes
// out of scope.
- return std::unique_ptr<MemoryBuffer>(
- MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer()));
+ return MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer());
}
private:
diff --git a/unittests/Bitcode/BitReaderTest.cpp b/unittests/Bitcode/BitReaderTest.cpp
index 663024679c9..eb6c125b79b 100644
--- a/unittests/Bitcode/BitReaderTest.cpp
+++ b/unittests/Bitcode/BitReaderTest.cpp
@@ -51,8 +51,8 @@ static std::unique_ptr<Module> getLazyModuleFromAssembly(LLVMContext &Context,
SmallString<1024> &Mem,
const char *Assembly) {
writeModuleToBuffer(parseAssembly(Assembly), Mem);
- std::unique_ptr<MemoryBuffer> Buffer(
- MemoryBuffer::getMemBuffer(Mem.str(), "test", false));
+ std::unique_ptr<MemoryBuffer> Buffer =
+ MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
ErrorOr<Module *> ModuleOrErr = getLazyBitcodeModule(Buffer, Context);
return std::unique_ptr<Module>(ModuleOrErr.get());
}
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp
index 55b86125776..ffedbfc1239 100644
--- a/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/JITTest.cpp
@@ -632,9 +632,9 @@ std::string AssembleToBitcode(LLVMContext &Context, const char *Assembly) {
ExecutionEngine *getJITFromBitcode(
LLVMContext &Context, const std::string &Bitcode, Module *&M) {
// c_str() is null-terminated like MemoryBuffer::getMemBuffer requires.
- std::unique_ptr<MemoryBuffer> BitcodeBuffer(
- MemoryBuffer::getMemBuffer(Bitcode, "Bitcode for test"));
- ErrorOr<Module*> ModuleOrErr = getLazyBitcodeModule(BitcodeBuffer, Context);
+ std::unique_ptr<MemoryBuffer> BitcodeBuffer =
+ MemoryBuffer::getMemBuffer(Bitcode, "Bitcode for test");
+ ErrorOr<Module *> ModuleOrErr = getLazyBitcodeModule(BitcodeBuffer, Context);
if (std::error_code EC = ModuleOrErr.getError()) {
ADD_FAILURE() << EC.message();
return nullptr;
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
index f230fb82434..8756a2b1782 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
@@ -41,8 +41,7 @@ public:
return nullptr;
// Our test cache wants to maintain ownership of its object buffers
// so we make a copy here for the execution engine.
- return std::unique_ptr<MemoryBuffer>(
- MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer()));
+ return MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer());
}
// Test-harness-specific functions
@@ -65,8 +64,8 @@ public:
private:
MemoryBuffer *copyBuffer(MemoryBufferRef Buf) {
// Create a local copy of the buffer.
- std::unique_ptr<MemoryBuffer> NewBuffer(
- MemoryBuffer::getMemBufferCopy(Buf.getBuffer()));
+ std::unique_ptr<MemoryBuffer> NewBuffer =
+ MemoryBuffer::getMemBufferCopy(Buf.getBuffer());
MemoryBuffer *Ret = NewBuffer.get();
AllocatedBuffers.push_back(std::move(NewBuffer));
return Ret;
diff --git a/unittests/Support/LineIteratorTest.cpp b/unittests/Support/LineIteratorTest.cpp
index 18f3fa99bcd..2c8e1432bb3 100644
--- a/unittests/Support/LineIteratorTest.cpp
+++ b/unittests/Support/LineIteratorTest.cpp
@@ -95,19 +95,19 @@ TEST(LineIteratorTest, EmptyBuffers) {
EXPECT_TRUE(line_iterator(*Buffer).is_at_eof());
EXPECT_EQ(line_iterator(), line_iterator(*Buffer));
- Buffer.reset(MemoryBuffer::getMemBuffer("\n\n\n"));
+ Buffer = MemoryBuffer::getMemBuffer("\n\n\n");
EXPECT_TRUE(line_iterator(*Buffer).is_at_eof());
EXPECT_EQ(line_iterator(), line_iterator(*Buffer));
- Buffer.reset(MemoryBuffer::getMemBuffer("# foo\n"
- "\n"
- "# bar"));
+ Buffer = MemoryBuffer::getMemBuffer("# foo\n"
+ "\n"
+ "# bar");
EXPECT_TRUE(line_iterator(*Buffer, '#').is_at_eof());
EXPECT_EQ(line_iterator(), line_iterator(*Buffer, '#'));
- Buffer.reset(MemoryBuffer::getMemBuffer("\n"
- "# baz\n"
- "\n"));
+ Buffer = MemoryBuffer::getMemBuffer("\n"
+ "# baz\n"
+ "\n");
EXPECT_TRUE(line_iterator(*Buffer, '#').is_at_eof());
EXPECT_EQ(line_iterator(), line_iterator(*Buffer, '#'));
}
diff --git a/unittests/Support/SourceMgrTest.cpp b/unittests/Support/SourceMgrTest.cpp
index 26310c11ddb..79c2d7278f1 100644
--- a/unittests/Support/SourceMgrTest.cpp
+++ b/unittests/Support/SourceMgrTest.cpp
@@ -23,8 +23,8 @@ public:
std::string Output;
void setMainBuffer(StringRef Text, StringRef BufferName) {
- std::unique_ptr<MemoryBuffer> MainBuffer(
- MemoryBuffer::getMemBuffer(Text, BufferName));
+ std::unique_ptr<MemoryBuffer> MainBuffer =
+ MemoryBuffer::getMemBuffer(Text, BufferName);
MainBufferID = SM.AddNewSourceBuffer(std::move(MainBuffer), llvm::SMLoc());
}
diff --git a/unittests/Support/YAMLParserTest.cpp b/unittests/Support/YAMLParserTest.cpp
index 63746388946..823a0d6e3e0 100644
--- a/unittests/Support/YAMLParserTest.cpp
+++ b/unittests/Support/YAMLParserTest.cpp
@@ -210,8 +210,8 @@ TEST(YAMLParser, DiagnosticFilenameFromBufferID) {
// When we construct a YAML stream over a named buffer,
// we get its ID as filename in diagnostics.
- std::unique_ptr<MemoryBuffer> Buffer(
- MemoryBuffer::getMemBuffer("[]", "buffername.yaml"));
+ std::unique_ptr<MemoryBuffer> Buffer =
+ MemoryBuffer::getMemBuffer("[]", "buffername.yaml");
yaml::Stream Stream(Buffer->getMemBufferRef(), SM);
Stream.printError(Stream.begin()->getRoot(), "Hello, World!");
EXPECT_EQ("buffername.yaml", GeneratedDiag.getFilename());
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index 9203c4cf33c..9606e64d6f8 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -839,8 +839,8 @@ 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.
- std::unique_ptr<MemoryBuffer> F =
- CanonicalizeInputFile(std::move(*FileOrErr), NoCanonicalizeWhiteSpace);
+ std::unique_ptr<MemoryBuffer> F = CanonicalizeInputFile(
+ std::move(FileOrErr.get()), NoCanonicalizeWhiteSpace);
// Find all instances of CheckPrefix followed by : in the file.
StringRef Buffer = F->getBuffer();
@@ -853,8 +853,9 @@ static bool ReadCheckFile(SourceMgr &SM,
// command line option responsible for the specific implicit CHECK-NOT.
std::string Prefix = std::string("-") + ImplicitCheckNot.ArgStr + "='";
std::string Suffix = "'";
- std::unique_ptr<MemoryBuffer> CmdLine(MemoryBuffer::getMemBufferCopy(
- Prefix + PatternString + Suffix, "command line"));
+ std::unique_ptr<MemoryBuffer> CmdLine = MemoryBuffer::getMemBufferCopy(
+ Prefix + PatternString + Suffix, "command line");
+
StringRef PatternInBuffer =
CmdLine->getBuffer().substr(Prefix.size(), PatternString.size());
SM.AddNewSourceBuffer(std::move(CmdLine), SMLoc());