[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

Gedare Bloom via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 11 11:18:56 PST 2022


gedare updated this revision to Diff 474812.
gedare added a comment.

Run tests and fix bad breaks. Fix comment style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137762

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5001,10 +5001,13 @@
       return false;
     }
     const FormatToken *Previous = Right.MatchingParen->Previous;
-    // Avoid breaking when there is an opening parens immediately following
+    // Avoid breaking when there is another parens immediately following
     // a closing parens, such as in cast operators and indirect function calls.
     return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||
-             (Right.Next && Right.Next->isOneOf(tok::l_paren, tok::r_paren)));
+             (Right.Next &&
+              (Right.Next->is(tok::l_paren) ||
+               (Right.Next->is(tok::r_paren) &&
+                (Right.NestingLevel == 0 || Previous->is(tok::star))))));
   }
 
   // Allow breaking after a trailing annotation, e.g. after a method


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137762.474812.patch
Type: text/x-patch
Size: 978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221111/66bde407/attachment.bin>


More information about the cfe-commits mailing list