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 @@ -2994,7 +2994,6 @@ void UnwrappedLineParser::parseRequiresClause(FormatToken *RequiresToken) { assert(FormatTok->getPreviousNonComment() == RequiresToken); assert(RequiresToken->is(tok::kw_requires) && "'requires' expected"); - assert(RequiresToken->getType() == TT_Unknown); // If there is no previous token, we are within a requires expression, // otherwise we will always have the template or function declaration in front @@ -3023,7 +3022,6 @@ void UnwrappedLineParser::parseRequiresExpression(FormatToken *RequiresToken) { assert(FormatTok->getPreviousNonComment() == RequiresToken); assert(RequiresToken->is(tok::kw_requires) && "'requires' expected"); - assert(RequiresToken->getType() == TT_Unknown); RequiresToken->setFinalizedType(TT_RequiresExpression); 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 @@ -24053,6 +24053,13 @@ " return number_zero_v;\n" " }\n" "};"); + + // Not a clause, but we once hit an assert. + verifyFormat("#if 0\n" + "#else\n" + "foo();\n" + "#endif\n" + "bar(requires);"); } TEST_F(FormatTest, StatementAttributeLikeMacros) {