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

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 08:01:34 PDT 2019


ymandel marked 2 inline comments as done.
ymandel added inline comments.


================
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);
----------------
krasimir wrote:
> 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.
Agreed!


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