[clang] [clang-format] Fix formatting with consecutive requires clauses (PR #220792)
Abdul Mohammad via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 6 21:09:02 PDT 2026
================
@@ -3351,9 +3356,18 @@ class ExpressionParser {
// Consume scopes: (), [], <> and {}
// In addition to that we handle require clauses as scope, so that the
// constraints in that are correctly indented.
- if (Current->opensScope() ||
- Current->isOneOf(TT_RequiresClause,
+ if (Current->isOneOf(TT_RequiresClause,
TT_RequiresClauseInARequiresExpression)) {
+ const auto *End = Current;
+ while (End && !End->ClosesRequiresClause)
+ End = End->Next;
+
+ const auto *PreviousLimit = RequiresClauseLimit;
+ RequiresClauseLimit = End ? End->getNextNonComment() : PreviousLimit;
+ next();
+ parse();
+ RequiresClauseLimit = PreviousLimit;
----------------
abdulm5 wrote:
I think its needed, its for the nested require clauses. So while parsing an outer requires clause, parse() could encounter an inner requires clause and end the boundary. I think restoring it ensures that the parsing still stops at the end of the outer clause, so thats why I added the nested regression test.
https://github.com/llvm/llvm-project/pull/220792
More information about the cfe-commits
mailing list