Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2569,6 +2569,12 @@ bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) {
if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
addUnwrappedLine();
break;
case tok::kw_requires: {
auto *RequiresToken = FormatTok;
nextToken();
parseRequiresExpression(RequiresToken);
break;
}
default:
nextToken();
break;
Expand Down
6 changes: 6 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26973,6 +26973,12 @@ TEST_F(FormatTest, RequiresExpressionIndentation) {
Style);
}

TEST_F(FormatTest, RequiresExpressionInBracedInitializer) {
verifyFormat("bool foo{requires { 0; }};");
verifyFormat("int bar{requires(T t) { t.f(); }};");
verifyFormat("auto baz{requires { typename T::type; } && true};");
}

TEST_F(FormatTest, StatementAttributeLikeMacros) {
FormatStyle Style = getLLVMStyle();
StringRef Source = "void Foo::slot() {\n"
Expand Down