================
@@ -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 = [&]() {
+      const auto *RPrev = RightParen ? RightParen->Previous : nullptr;
+      const auto *LNext = LeftParen->Next;
+      const auto *LPrev = LeftParen->Previous;
+      const bool DoubleParens =
+          RPrev && RPrev->is(tok::r_paren) && LNext && LNext->is(tok::l_paren);
+      auto HasEqualBeforeNextParen = [&]() {
----------------
HazardyKnusperkeks wrote:

```suggestion
      if (RPrev && RPrev->is(tok::r_paren) && LNext && LNext->is(tok::l_paren))
        return false;
      auto HasEqualBeforeNextParen = [&]() {
```
Don't calculate all the stuff, if not needed.

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

Reply via email to