r296237 - Revert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows, PR26125", and r296171.

NAKAMURA Takumi via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 19:45:49 PST 2017


Author: chapuni
Date: Fri Feb 24 21:45:49 2017
New Revision: 296237

URL: http://llvm.org/viewvc/llvm-project?rev=296237&view=rev
Log:
Revert r296166, "clang-format: Don't leave behind temp files in -i mode on Windows, PR26125", and r296171.

(MemoryBuffer)Code.reset() was too early.

  ==26912== Invalid read of size 1
  ==26912==    at 0x437E1D: llvm::MemoryBuffer::init(char const*, char const*, bool) (MemoryBuffer.cpp:47)
  ==26912==    by 0x438013: (anonymous namespace)::MemoryBufferMem::MemoryBufferMem(llvm::StringRef, bool) (MemoryBuffer.cpp:86)
  ==26912==    by 0x438128: llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, llvm::StringRef, bool) (MemoryBuffer.cpp:112)
  ==26912==    by 0x4E189D: clang::vfs::detail::(anonymous namespace)::InMemoryFileAdaptor::getBuffer(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:443)
  ==26912==    by 0x4DF5BA: clang::vfs::FileSystem::getBufferForFile(llvm::Twine const&, long, bool, bool) (VirtualFileSystem.cpp:94)
  ==26912==    by 0x4B72EC: clang::FileManager::getBufferForFile(clang::FileEntry const*, bool, bool) (FileManager.cpp:443)
  ==26912==    by 0x4C1F81: clang::SrcMgr::ContentCache::getBuffer(clang::DiagnosticsEngine&, clang::SourceManager const&, clang::SourceLocation, bool*) const (SourceManager.cpp:98)
  ==26912==    by 0x4C50E5: clang::SourceManager::getBufferData(clang::FileID, bool*) const (SourceManager.cpp:689)
  ==26912==    by 0x58E794: clang::Rewriter::getEditBuffer(clang::FileID) (Rewriter.cpp:230)
  ==26912==    by 0x407297: clang::format::format(llvm::StringRef) (ClangFormat.cpp:311)
  ==26912==    by 0x4078D7: main (ClangFormat.cpp:363)

Removed:
    cfe/trunk/test/Format/inplace.cpp
Modified:
    cfe/trunk/tools/clang-format/ClangFormat.cpp

Removed: cfe/trunk/test/Format/inplace.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296236&view=auto
==============================================================================
--- cfe/trunk/test/Format/inplace.cpp (original)
+++ cfe/trunk/test/Format/inplace.cpp (removed)
@@ -1,263 +0,0 @@
-// Regression test to check that clang-format does not leave behind temporary
-// files on Windows when doing in-place formatting.
-// RUN: rm %T/inplace*
-// RUN: cp %s %T/inplace.cpp
-// RUN: clang-format -style=LLVM -i %T/inplace.cpp
-// RUN: ls %T > %T/files.txt
-// RUN: FileCheck -strict-whitespace -input-file=%T/files.txt %s
-
-// CHECK-NOT: RF{{.*}}.TMP
-
-// The file needs to be larger than 16kiB so that Windows creates a real file
-// mapping object for it.
- int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;
-int this_is_my_int_there_are_many_like_it_but_this_one_is_mine;

Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=296237&r1=296236&r2=296237&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Fri Feb 24 21:45:49 2017
@@ -296,7 +296,6 @@ static bool format(StringRef FileName) {
                                    InMemoryFileSystem.get());
     Rewriter Rewrite(Sources, LangOptions());
     tooling::applyAllReplacements(Replaces, Rewrite);
-    Code.reset();
     if (Inplace) {
       if (FileName == "-")
         errs() << "error: cannot use -i when reading from stdin.\n";




More information about the cfe-commits mailing list