r296408 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded
Galina Kistanova via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 27 17:28:17 PST 2017
Hello Nico,
This commit broke test on one of our builders:
Clang :: Format/inplace.cpp
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6151/steps/test/logs/stdio
Please have a look.
Thanks
Galina
On Mon, Feb 27, 2017 at 2:59 PM, Nico Weber via cfe-commits <
cfe-commits at lists.llvm.org> wrote:
> Author: nico
> Date: Mon Feb 27 16:59:58 2017
> New Revision: 296408
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296408&view=rev
> Log:
> clang-format: Don't leave behind temp files in -i mode on Windows,
> PR26125, reloaded
>
> Second attempt after http://llvm.org/viewvc/llvm-
> project?rev=296166&view=rev
>
> In the first attempt, Code (the memory buffer backing the input file) was
> reset
> before overwriteChangedFiles() was called, but overwriteChangedFiles()
> still
> reads from it. This time, load the whole input file into memory instead of
> using mmap when formatting in-place.
>
> (Since the test is identical to what was in the repo before chapuni's
> revert,
> svn diff doesn't show it – see the above link for the test.)
>
> https://reviews.llvm.org/D30385
>
> Added:
> cfe/trunk/test/Format/inplace.cpp
> - copied unchanged from r296236, cfe/trunk/test/Format/inplace.cpp
> Modified:
> cfe/trunk/tools/clang-format/ClangFormat.cpp
>
> Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-
> format/ClangFormat.cpp?rev=296408&r1=296407&r2=296408&view=diff
> ============================================================
> ==================
> --- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
> +++ cfe/trunk/tools/clang-format/ClangFormat.cpp Mon Feb 27 16:59:58 2017
> @@ -236,8 +236,15 @@ static void outputReplacementsXML(const
>
> // Returns true on error.
> static bool format(StringRef FileName) {
> + if (!OutputXML && Inplace && FileName == "-") {
> + errs() << "error: cannot use -i when reading from stdin.\n";
> + return false;
> + }
> + // On Windows, overwriting a file with an open file mapping doesn't
> work,
> + // so read the whole file into memory when formatting in-place.
> ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr =
> - MemoryBuffer::getFileOrSTDIN(FileName);
> + !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
> + MemoryBuffer::getFileOrSTDIN(FileName);
> if (std::error_code EC = CodeOrErr.getError()) {
> errs() << EC.message() << "\n";
> return true;
> @@ -297,9 +304,7 @@ static bool format(StringRef FileName) {
> Rewriter Rewrite(Sources, LangOptions());
> tooling::applyAllReplacements(Replaces, Rewrite);
> if (Inplace) {
> - if (FileName == "-")
> - errs() << "error: cannot use -i when reading from stdin.\n";
> - else if (Rewrite.overwriteChangedFiles())
> + if (Rewrite.overwriteChangedFiles())
> return true;
> } else {
> if (Cursor.getNumOccurrences() != 0)
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170227/ab792f3a/attachment.html>
More information about the cfe-commits
mailing list