]> granicus.if.org Git - clang/commit
[clang-format] [PR43372] - clang-format shows replacements in DOS files when no repla...
authorPaul Hoad <mydeveloperday@gmail.com>
Tue, 1 Oct 2019 20:20:22 +0000 (20:20 +0000)
committerPaul Hoad <mydeveloperday@gmail.com>
Tue, 1 Oct 2019 20:20:22 +0000 (20:20 +0000)
commit3b45bb56b5c3420ec332133c15a3ff7eaaf72572
tree1a8940f034ad13c0f1c81e20365aec2941a5083b
parent8f539ae97c317c0cebee1065bc8c4e24c4ecd544
[clang-format] [PR43372] - clang-format shows replacements in DOS files when no replacement is needed

Summary:
This is a patch to fix PR43372 (https://bugs.llvm.org/show_bug.cgi?id=43372) - clang-format can't format file with includes, ( which really keep providing replacements for already sorted headers.)

A similar issue was addressed by @krasimir in {D60199}, however, this seemingly only prevented the issue when the files being formatted did not contain windows line endings (\r\n)

It's possible this is related to https://twitter.com/StephanTLavavej/status/1176722938243895296 given who @STL_MSFT  works for!

As people often used the existence of replacements to determine if a file needs clang-formatting, this is probably pretty important for windows users

There may be a better way of comparing 2 strings and ignoring \r (which appear in both Results and Code), I couldn't choose between this idiom or the copy_if approach, but I'm happy to change it to whatever people consider more performant.

Reviewers: krasimir, klimek, owenpan, ioeric

Reviewed By: krasimir

Subscribers: cfe-commits, STL_MSFT, krasimir

Tags: #clang-format, #clang, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D68227

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373388 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/Format.cpp
unittests/Format/SortImportsTestJava.cpp
unittests/Format/SortIncludesTest.cpp