Additionally, from looking at the PathV1.h comments, it looks like the Windows version actually violates the contract "@brief Construct a path to an new, unique, existing temporary directory."<div><br></div><div>
Cheers,</div><div>/Manuel<br><br><div class="gmail_quote">On Tue, May 29, 2012 at 8:50 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div><div class="h5">On Sun, May 27, 2012 at 4:01 PM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

2012/5/23 Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>>:<br>
<div>> Author: klimek<br>
> Date: Tue May 22 12:01:35 2012<br>
> New Revision: 157260<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=157260&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=157260&view=rev</a><br>
> Log:<br>
> Adds a method overwriteChangedFiles to the Rewriter. This is implemented by<br>
> first writing the changed files to a temporary location and then overwriting<br>
> the original files atomically.<br>
><br>
> Also adds a RewriterTestContext to aid unit testing rewrting logic in general.<br>
><br>
><br>
> Added:<br>
>    cfe/trunk/unittests/Tooling/RewriterTest.cpp   (with props)<br>
>    cfe/trunk/unittests/Tooling/RewriterTestContext.h   (with props)<br>
> Modified:<br>
>    cfe/trunk/include/clang/Rewrite/Rewriter.h<br>
>    cfe/trunk/lib/Rewrite/Rewriter.cpp<br>
>    cfe/trunk/unittests/CMakeLists.txt<br>
<br>
<br>
</div><div><div>> Added: cfe/trunk/unittests/Tooling/RewriterTestContext.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RewriterTestContext.h?rev=157260&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RewriterTestContext.h?rev=157260&view=auto</a><br>


> ==============================================================================<br>
> --- cfe/trunk/unittests/Tooling/RewriterTestContext.h (added)<br>
> +++ cfe/trunk/unittests/Tooling/RewriterTestContext.h Tue May 22 12:01:35 2012<br>
> @@ -0,0 +1,120 @@<br>
> +//===--- RewriterTestContext.h ----------------------------------*- C++ -*-===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +//<br>
> +//  This file defines a utility class for Rewriter related tests.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#ifndef LLVM_CLANG_REWRITER_TEST_CONTEXT_H<br>
> +#define LLVM_CLANG_REWRITER_TEST_CONTEXT_H<br>
> +<br>
> +#include "clang/Basic/Diagnostic.h"<br>
> +#include "clang/Basic/FileManager.h"<br>
> +#include "clang/Basic/LangOptions.h"<br>
> +#include "clang/Basic/SourceManager.h"<br>
> +#include "clang/Frontend/DiagnosticOptions.h"<br>
> +#include "clang/Frontend/TextDiagnosticPrinter.h"<br>
> +#include "clang/Rewrite/Rewriter.h"<br>
> +#include "llvm/Support/Path.h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +<br>
> +namespace clang {<br>
> +<br>
> +/// \brief A class that sets up a ready to use Rewriter.<br>
> +///<br>
> +/// Useful in unit tests that need a Rewriter. Creates all dependencies<br>
> +/// of a Rewriter with default values for testing and provides convenience<br>
> +/// methods, which help with writing tests that change files.<br>
> +class RewriterTestContext {<br>
> + public:<br>
> +  RewriterTestContext()<br>
> +      : Diagnostics(llvm::IntrusiveRefCntPtr<DiagnosticIDs>()),<br>
> +        DiagnosticPrinter(llvm::outs(), DiagnosticOptions()),<br>
> +        Files((FileSystemOptions())),<br>
> +        Sources(Diagnostics, Files),<br>
> +        Rewrite(Sources, Options) {<br>
> +    Diagnostics.setClient(&DiagnosticPrinter, false);<br>
> +  }<br>
> +<br>
> +  ~RewriterTestContext() {<br>
> +    if (TemporaryDirectory.isValid()) {<br>
> +      std::string ErrorInfo;<br>
> +      TemporaryDirectory.eraseFromDisk(true, &ErrorInfo);<br>
> +      assert(ErrorInfo.empty());<br>
> +    }<br>
> +  }<br>
<br>
</div></div>Don't try to remove the TemporaryDirectory given by PathV1. Fixed in r157530.<br>
See also r157529.<br></blockquote><div><br></div></div></div><div>The Windows and Unix implementation of GetTemporaryDirectory seem to disagree on the contract here.</div><div>From what I can see the Unix implementation neither reuses the path, nor deletes it on exit (both need to be done).</div>

<div><br></div><div>Why does the Windows implementation re-use the temporary directory?</div><div><br></div><div>Cheers,</div><div>/Manuel</div><div><br></div></div>
</blockquote></div><br></div>