diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3963,7 +3963,7 @@ return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always; return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes; } - if (Left.ClosesRequiresClause) { + if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) { switch (Style.RequiresClausePosition) { case FormatStyle::RCPS_OwnLine: case FormatStyle::RCPS_WithPreceding: 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 @@ -23861,6 +23861,11 @@ "}", Style); + verifyFormat("template \n" + "int bar(T t)\n" + " requires F;", + Style); + Style.IndentRequiresClause = false; verifyFormat("template \n" "requires F\n" @@ -23881,6 +23886,7 @@ verifyFormat("template requires Foo struct Bar {};\n" "template requires Foo void bar() {}\n" "template void bar() requires Foo {}\n" + "template void bar() requires Foo;\n" "template requires Foo Bar(T) -> Bar;", Style); @@ -23933,6 +23939,9 @@ "void bar()\n" "requires Foo {}\n" "template \n" + "void bar()\n" + "requires Foo;\n" + "template \n" "requires Foo Bar(T) -> Bar;", Style); @@ -23992,6 +24001,7 @@ "template \n" "void bar() requires Foo\n" "{}\n" + "template void bar() requires Foo;\n" "template requires Foo\n" "Bar(T) -> Bar;", Style);