llvm-project/clang/unittests/Format
Krasimir Georgiev a1c30937ce [clang-format] Handle trailing comment sections in import statement lines
Summary:
This patch updates the handling of multiline trailing comment sections in
import statement lines to make it more consistent with the case in general.
This includes updating the parsing logic to collect the trailing comment
sections and the formatting logic to not insert escaped newlines at the end of
comment lines in import statement lines.

Specifically, before this patch this code:
```
#include <a> // line 1
             // line 2
```
will be turned into two unwrapped lines, whereas this code:
```
int i; // line 1
       // line 2
```
is turned into a single unwrapped line, enabling reflowing across comments.

An example where the old behaviour is bad is when partially formatting the lines
3 to 4 of this code:
```
#include <a> // line 1
             // line 2

int i;
```
which gets turned into:
```
#include <a> // line 1
             // line 2

             int i;
```
because the two comment lines were independent and the indent was copied.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 303415
2017-05-19 10:34:57 +00:00
..
CMakeLists.txt [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
CleanupTest.cpp [clang-format] Clang-tidy cleanup of CleanupTest.cpp, NFC 2017-04-21 14:21:21 +00:00
FormatTest.cpp JavaScript allows parameter lists to include trailing commas: 2017-05-15 11:15:29 +00:00
FormatTestComments.cpp clang-format: fix prefix for doxygen comments after member 2017-05-18 07:36:21 +00:00
FormatTestJS.cpp clang-format: [JS] for await, and fix a crash with for loops. 2017-05-18 21:19:29 +00:00
FormatTestJava.cpp [clang-format] Recognize Java logical shift assignment operator 2017-04-11 15:50:04 +00:00
FormatTestObjC.cpp [clang-format] Replace IncompleteFormat by a struct with Line 2017-04-21 14:35:20 +00:00
FormatTestProto.cpp clang-format: Make it very slighly more expensive to wrap between "= {". 2017-03-14 00:40:32 +00:00
FormatTestSelective.cpp [clang-format] Handle trailing comment sections in import statement lines 2017-05-19 10:34:57 +00:00
FormatTestUtils.h Header guard canonicalization, clang part. 2014-08-13 16:25:19 +00:00
NamespaceEndCommentsFixerTest.cpp [clang-format] Clang-tidy cleanup of NamespaceEndCommentFixerTest.cpp, NFC 2017-04-21 14:30:01 +00:00
SortImportsTestJS.cpp clang-format: [JS] Fix line breaks before comments when sorting imports. 2016-09-19 07:02:34 +00:00
SortIncludesTest.cpp clang-format: Correctly calculate affected ranges when sorting #includes. 2016-08-30 21:33:41 +00:00