Make clang::format::reformat work with non 0-terminated strings.

llvm-svn: 257259
This commit is contained in:
Daniel Jasper 2016-01-09 15:56:57 +00:00
parent 417fc81540
commit 88c163460c
1 changed files with 3 additions and 2 deletions

View File

@ -1902,8 +1902,9 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
new DiagnosticOptions);
SourceManager SourceMgr(Diagnostics, Files);
InMemoryFileSystem->addFile(FileName, 0,
llvm::MemoryBuffer::getMemBuffer(Code, FileName));
InMemoryFileSystem->addFile(
FileName, 0, llvm::MemoryBuffer::getMemBuffer(
Code, FileName, /*RequiresNullTerminator=*/false));
FileID ID = SourceMgr.createFileID(Files.getFile(FileName), SourceLocation(),
clang::SrcMgr::C_User);
SourceLocation StartOfFile = SourceMgr.getLocForStartOfFile(ID);