]> granicus.if.org Git - clang/commitdiff
Make clang::format::reformat work with non 0-terminated strings.
authorDaniel Jasper <djasper@google.com>
Sat, 9 Jan 2016 15:56:57 +0000 (15:56 +0000)
committerDaniel Jasper <djasper@google.com>
Sat, 9 Jan 2016 15:56:57 +0000 (15:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257259 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp

index ca3d08fa2cd971a5994d1dc2907b5dcbca020026..2ea3b07a291c6c1ee9dcbb5f365984175eeb3eb2 100644 (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);