================ @@ -4007,26 +3992,45 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return true; } - // TODO: check consecutive parens if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) { - if (Right.is(TT_CastRParen) || - (Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) { - return Style.SpacesInParensOptions.InCStyleCasts != - FormatStyle::SIPCS_Never; + const FormatToken *LeftParen = + Left.is(tok::l_paren) ? &Left : Right.MatchingParen; + const FormatToken *RightParen = + LeftParen ? LeftParen->MatchingParen : nullptr; + + auto NotConsecutiveParens = [&](auto *Left, auto *Right) { + return Left && Left->Next && Left->Next->isNot(tok::l_paren) && Right && + Right->Previous && Right->Previous->isNot(tok::r_paren); + }; + const auto AddSpace = [&](FormatStyle::SpacesInParensCustomStyle Option) { + if (Option == FormatStyle::SIPCS_Always) + return true; + if (Option == FormatStyle::SIPCS_NonConsecutive) { + if (NotConsecutiveParens(LeftParen, RightParen)) + return true; + } ---------------- HazardyKnusperkeks wrote:
```suggestion if (Option == FormatStyle::SIPCS_NonConsecutive && NotConsecutiveParens(LeftParen, RightParen)) { return true; } ``` https://github.com/llvm/llvm-project/pull/77522 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits