<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:nicolasweber@gmx.de" title="Nico Weber <nicolasweber@gmx.de>"> <span class="fn">Nico Weber</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Clang format creates unwanted temporary files when batching processing on windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=26125">bug 26125</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>FIXED
           </td>
           <td>---
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Clang format creates unwanted temporary files when batching processing on windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=26125#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED - Clang format creates unwanted temporary files when batching processing on windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=26125">bug 26125</a>
              from <span class="vcard"><a class="email" href="mailto:nicolasweber@gmx.de" title="Nico Weber <nicolasweber@gmx.de>"> <span class="fn">Nico Weber</span></a>
</span></b>
        <pre>Fix got reverted here:
<a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=296237">http://llvm.org/viewvc/llvm-project?view=revision&revision=296237</a> with reason

"""

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)
"""


<a href="http://llvm-cs.pcc.me.uk/tools/clang/lib/Rewrite/Rewriter.cpp#446">http://llvm-cs.pcc.me.uk/tools/clang/lib/Rewrite/Rewriter.cpp#446</a> is what
writes the reformatted file, and AtomicallyMovedFile right above does the
actual work. Resetting the mapping at the start in that dtor would probably be
the right place.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>