[clang-format] Do not emit replacements while regrouping if Cpp includes are OK
authorKrasimir Georgiev <krasimir@google.com>
Wed, 3 Apr 2019 15:16:04 +0000 (15:16 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Wed, 3 Apr 2019 15:16:04 +0000 (15:16 +0000)
commit925bb20c794ffe0397e5c764b3d01c859c3f5cdf
treeac9a07f1f1d7a24f8fdd5fbcb1081e235598bf4b
parentd4e5500cfafcb6fcc291cd284193ac65c8c92312
[clang-format] Do not emit replacements while regrouping if Cpp includes are OK

Summary:
Currently clang-format would always emit a replacement for multi-block #include
sections if `IBS_Regroup`, even if the sections are correct:
```
% cat ~/test.h
#include <a.h>

#include "b.h"
% bin/clang-format --output-replacements-xml -style=google ~/test.h
<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='0' length='30'>#include &lt;a.h>&#10;&#10;#include "b.h"</replacement>
</replacements>
%
```

This change makes clang-format not emit replacements in this case.
The logic is similar to the one implemented for Java in r354452.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 357599
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp