[PATCH] D67659: [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 07:42:49 PDT 2019


krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!



================
Comment at: clang/lib/Format/Format.cpp:1420
 
-    for (auto &Line : AnnotatedLines) {
-      if (Line->Affected) {
-        cleanupRight(Line->First, tok::comma, tok::comma);
-        cleanupRight(Line->First, TT_CtorInitializerColon, tok::comma);
-        cleanupRight(Line->First, tok::l_paren, tok::comma);
-        cleanupLeft(Line->First, tok::comma, tok::r_paren);
-        cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace);
-        cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace);
-        cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal);
-      }
-    }
+    for (auto &Line : AnnotatedLines)
+      cleanupLine(Line);
----------------
nit: (I realize this code was like this before, but,)
I find it more useful to have `auto *Line` instead of `auto &Line` (and similarly `auto *Child` instead of `auto &Child` at line 1028 below) as that makes it immediately clear that inside the body of the for loop we need to use `->` to access members of the object.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67659/new/

https://reviews.llvm.org/D67659





More information about the cfe-commits mailing list