[clang] [clang-format] Add SpacesInParensOption for attributes and filtering for repeated parens (PR #77522)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 23 12:51:51 PST 2024
================
@@ -4006,11 +3993,58 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
}
if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) {
- return (Right.is(TT_CastRParen) ||
- (Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
- ? Style.SpacesInParensOptions.InCStyleCasts
- : Style.SpacesInParensOptions.Other;
+ const FormatToken *LeftParen =
+ Left.is(tok::l_paren) ? &Left : Right.MatchingParen;
+ const FormatToken *RightParen =
+ LeftParen ? LeftParen->MatchingParen : nullptr;
+ const auto IsAttributeParen = [](const FormatToken *Paren) {
+ return Paren && Paren->isOneOf(TT_AttributeLParen, TT_AttributeRParen);
+ };
+ auto AddSpaceInDoubleParens = [&]() {
----------------
HazardyKnusperkeks wrote:
Isn't it more like AddSpace**Except**InDoubleParens?
https://github.com/llvm/llvm-project/pull/77522
More information about the cfe-commits
mailing list