[clang] [clang-format] Handle generic selections inside parentheses (PR #79785)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 30 01:26:33 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;
----------------
owenca wrote:
To be consistent with the other dozen similar sinppets:
```suggestion
State.Stack.size() > 1) {
NewParenState.Indent =
State.Stack[State.Stack.size() - 2].Indent + Style.ContinuationIndentWidth;
```
https://github.com/llvm/llvm-project/pull/79785
More information about the cfe-commits
mailing list