]> granicus.if.org Git - clang/commit
[clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Tue, 17 Sep 2019 15:10:39 +0000 (15:10 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Tue, 17 Sep 2019 15:10:39 +0000 (15:10 +0000)
commite71234de99baf91e6e490fa338259cade0085135
tree56cfa9587f4d1fd975cfc9d70ea5df58a8ef82fb
parent8fedffb258f989cee4b15dd11aa5c9f18b05820e
[clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

Summary:
AnnotatedLine has a tree structure, and things like the body of a lambda will be
a child of the lambda expression. For example,

    [&]() { foo(a); };

will have an AnnotatedLine with a child:

    [&]() {};
     '- foo(a);

Currently, when the `Cleaner` class analyzes the affected lines, it does not
cleanup the lines' children nodes, which results in missed cleanup
opportunities, like the lambda body in the example above.

This revision extends the algorithm to visit children, thereby fixing the above problem.

Patch by Eric Li.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

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