Author: nico Date: Fri Feb 24 14:49:00 2017 New Revision: 296166 URL: http://llvm.org/viewvc/llvm-project?rev=296166&view=rev Log: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125
Fix and analysis by Wei Mao <weim...@gmail.com> (see bug), test by me. Added: cfe/trunk/test/Format/inplace.cpp Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp Added: cfe/trunk/test/Format/inplace.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Format/inplace.cpp?rev=296166&view=auto ============================================================================== --- cfe/trunk/test/Format/inplace.cpp (added) +++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 14:49:00 2017 @@ -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; Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=296166&r1=296165&r2=296166&view=diff ============================================================================== --- cfe/trunk/tools/clang-format/ClangFormat.cpp (original) +++ cfe/trunk/tools/clang-format/ClangFormat.cpp Fri Feb 24 14:49:00 2017 @@ -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"; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits