diff options
author | Nico Weber <nicolasweber@gmx.de> | 2017-02-24 20:49:00 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2017-02-24 20:49:00 +0000 |
commit | 41b37d854acedb330b5a5ad20f7e4b23af169955 (patch) | |
tree | 592de0a7375c41671f26b401120b6f7a7f50d6e8 | |
parent | 13406afd093894bf7502a0357da3ec4f3e84c31e (diff) |
clang-format: Don't leave behind temp files in -i mode on Windows, PR26125
Fix and analysis by Wei Mao <weimao1@gmail.com> (see bug), test by me.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296166 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Format/inplace.cpp | 263 | ||||
-rw-r--r-- | tools/clang-format/ClangFormat.cpp | 1 |
2 files changed, 264 insertions, 0 deletions
diff --git a/test/Format/inplace.cpp b/test/Format/inplace.cpp new file mode 100644 index 0000000000..1a00eb44b8 --- /dev/null +++ b/test/Format/inplace.cpp @@ -0,0 +1,263 @@ +// Regression test to check that clang-format does not leave behind temporary +// files on Windows when doing in-place formatting. +// RUN: rm %T/* +// 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; diff --git a/tools/clang-format/ClangFormat.cpp b/tools/clang-format/ClangFormat.cpp index 941f90396d..47946d8734 100644 --- a/tools/clang-format/ClangFormat.cpp +++ b/tools/clang-format/ClangFormat.cpp @@ -296,6 +296,7 @@ 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"; |