[PATCH] D125137: [clang-format] Don't remove braces if a 1-statement body would wrap

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 11 12:35:10 PDT 2022


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

LGTM with nits.



================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:766
+  assert(!Tokens.empty());
+  const auto *LastToken = Tokens.back().Tok;
+  assert(LastToken);
----------------
It might be a matter of taste but adding this variable makes the code harder to read to me.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:777
+    SavedToken.Tok->copyFrom(*Token.Tok);
+    SavedToken.Children = std::move(Token.Children);
+  }
----------------
So the token's children are modified (moved)? Is it done so that children be not considered by the annotator?


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:787
+
+  const int Length = LastToken->TotalLength;
+
----------------
Why not like this?


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

https://reviews.llvm.org/D125137



More information about the cfe-commits mailing list