[clang] [clang-format] Handle generic selections inside parentheses (PR #79785)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 29 12:05:21 PST 2024


================
@@ -1694,8 +1694,11 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
     // Special case for generic selection expressions, its comma-separated
     // expressions are not aligned to the opening paren like regular calls, but
     // rather continuation-indented relative to the _Generic keyword.
-    if (Previous && Previous->endsSequence(tok::l_paren, tok::kw__Generic))
-      NewParenState.Indent = CurrentState.LastSpace;
+    if (Previous && Previous->endsSequence(tok::l_paren, tok::kw__Generic) &&
+        State.Stack.size() >= 2) {
+      NewParenState.Indent =
+          State.Stack.end()[-2].Indent + Style.ContinuationIndentWidth;
----------------
HazardyKnusperkeks wrote:

This is freaky, never thought I'd ever see operator[] on iterators used, and in such a way.

https://github.com/llvm/llvm-project/pull/79785


More information about the cfe-commits mailing list