Skip to content

Commit 4fb8078

Browse files
authored
[clang-format] Fix annotation of class name after requires clause (#125019)
Uncovered in #124891.
1 parent 381416a commit 4fb8078

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,8 @@ class AnnotatingParser {
15651565
if (const auto *Previous = Tok->Previous;
15661566
!Previous ||
15671567
(!Previous->isAttribute() &&
1568-
!Previous->isOneOf(TT_RequiresClause, TT_LeadingJavaAnnotation))) {
1568+
!Previous->isOneOf(TT_RequiresClause, TT_LeadingJavaAnnotation,
1569+
TT_BinaryOperator))) {
15691570
Line.MightBeFunctionDecl = true;
15701571
Tok->MightBeFunctionDeclParen = true;
15711572
}

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
11431143
EXPECT_TOKEN(Tokens[16], tok::pipepipe, TT_BinaryOperator);
11441144
EXPECT_TOKEN(Tokens[21], tok::ampamp, TT_BinaryOperator);
11451145
EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
1146+
// Not TT_TrailingAnnotation.
1147+
EXPECT_TOKEN(Tokens[28], tok::identifier, TT_Unknown);
11461148
EXPECT_TOKEN(Tokens[31], tok::greater, TT_TemplateCloser);
11471149
EXPECT_EQ(Tokens[31]->FakeRParens, 1u);
11481150
EXPECT_TRUE(Tokens[31]->ClosesRequiresClause);
1151+
// Not TT_TrailingAnnotation.
1152+
EXPECT_TOKEN(Tokens[33], tok::identifier, TT_Unknown);
11491153

11501154
Tokens =
11511155
annotate("template<typename T>\n"

0 commit comments

Comments
 (0)