[PATCH] D156259: [clang-format] Fix a bug that erroneously placed function arguments on a new line despite all arguments being able to fit on the same line.

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 3 17:26:04 PDT 2023


owenpan added inline comments.


================
Comment at: clang/docs/ReleaseNotes.rst:167-168
 ------------
+- Fix a bug that erroneously placed function arguments on a new line despite
+all arguments being able to fit on the same line.
 
----------------
Please delete it. We only update the release note for new options.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:658-659
+  bool DisallowLineBreaksOnThisLine =
+      (Style.Language == FormatStyle::LK_Cpp ||
+       Style.Language == FormatStyle::LK_ObjC) &&
+      [&Current] {
----------------



================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:667-669
+        if (!PrevNonComment)
+          return false;
+        if (!PrevNonComment->is(tok::l_paren))
----------------



================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:676
+          return false;
+
+        if (BlockParameterCount > 1)
----------------
        // Multiple lambdas in the same function call.



================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:679
+          return true;
+
+        if (!PrevNonComment->Role)
----------------
        // A lambda followed by another arg.



================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:686-692
+        if (!Next)
+          return false;
+
+        if (!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret))
+          return true;
+
+        return false;
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156259



More information about the cfe-commits mailing list