https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/93439

…ogic

>From ac03e1506b5ea0d00038501c4f41d5b30c8fa2b3 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpi...@gmail.com>
Date: Sun, 26 May 2024 22:01:48 -0700
Subject: [PATCH] Code implementing the
 SpacesInParensOptions.ExceptDoubleParentheses logic

---
 clang/lib/Format/TokenAnnotator.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 7c4c76a91f2c5..c204d107b12b7 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4346,6 +4346,14 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
        Right.is(tok::r_brace) && Right.isNot(BK_Block))) {
     return Style.SpacesInParensOptions.InEmptyParentheses;
   }
+  if (Style.SpacesInParens == FormatStyle::SIPO_Custom &&
+      Style.SpacesInParensOptions.ExceptDoubleParentheses &&
+      ((Left.is(tok::l_paren) && Right.is(tok::l_paren)) ||
+       (Left.is(tok::r_paren) && Right.is(tok::r_paren)))) {
+    const auto *Tok = Left.MatchingParen;
+    if (Tok && Tok->Previous == Right.MatchingParen)
+      return false;
+  }
   if (Style.SpacesInParensOptions.InConditionalStatements) {
     const FormatToken *LeftParen = nullptr;
     if (Left.is(tok::l_paren))

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to