[PATCH] D120512: [clang-format] Fix requires related crash
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 26 22:49:13 PST 2022
HazardyKnusperkeks updated this revision to Diff 411658.
HazardyKnusperkeks added a comment.
Changed test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120512/new/
https://reviews.llvm.org/D120512
Files:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24051,6 +24051,13 @@
" return number_zero_v<T>;\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) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120512.411658.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220227/5fb2355e/attachment.bin>
More information about the cfe-commits
mailing list