[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent
Gedare Bloom via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 9 21:28:04 PST 2022
gedare updated this revision to Diff 474430.
gedare added a comment.
Add a fix to enable breaking for continuation after a )(
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137762/new/
https://reviews.llvm.org/D137762
Files:
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/TokenAnnotator.cpp
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -5001,7 +5001,10 @@
return false;
}
const FormatToken *Previous = Right.MatchingParen->Previous;
- return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+ // avoid breaking when there is an opening 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->is(tok::l_paren)));
}
// Allow breaking after a trailing annotation, e.g. after a method
Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -717,7 +717,7 @@
Style.Cpp11BracedListStyle)) &&
State.Column > getNewLineColumn(State) &&
(!Previous.Previous || !Previous.Previous->isOneOf(
- tok::kw_for, tok::kw_while, tok::kw_switch)) &&
+ tok::r_paren, tok::kw_for, tok::kw_while, tok::kw_switch)) &&
// Don't do this for simple (no expressions) one-argument function calls
// as that feels like needlessly wasting whitespace, e.g.:
//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137762.474430.patch
Type: text/x-patch
Size: 1456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221110/13219951/attachment-0001.bin>
More information about the cfe-commits
mailing list