diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2174,7 +2174,8 @@ parseBracedList(); break; case tok::less: - if (Style.Language == FormatStyle::LK_Proto) { + if (Style.Language == FormatStyle::LK_Proto || + ClosingBraceKind == tok::greater) { nextToken(); parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false, /*ClosingBraceKind=*/tok::greater); @@ -3218,6 +3219,7 @@ if (!FormatTok->is(tok::less)) return; + nextToken(); parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false, /*ClosingBraceKind=*/tok::greater); break; @@ -3258,9 +3260,11 @@ // Read identifier with optional template declaration. nextToken(); - if (FormatTok->is(tok::less)) + if (FormatTok->is(tok::less)) { + nextToken(); parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false, /*ClosingBraceKind=*/tok::greater); + } break; } } while (!eof()); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24040,6 +24040,12 @@ verifyFormat("template \n" "concept Same = __is_same_as;"); + verifyFormat( + "template \n" + "concept _Can_reread_dest =\n" + " std::forward_iterator<_OutIt> &&\n" + " std::same_as, std::iter_value_t<_OutIt>>;"); + auto Style = getLLVMStyle(); Style.BreakBeforeConceptDeclarations = FormatStyle::BBCDS_Allowed;