Skip to content

Commit ab4c939

Browse files
authored
[clang-format] Fix a bug in annotating TT_PointerOrReference (llvm#136073)
Fix llvm#135972
1 parent c64f670 commit ab4c939

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,7 @@ class AnnotatingParser {
30263026

30273027
if (!NextToken ||
30283028
NextToken->isOneOf(tok::arrow, tok::equal, tok::comma, tok::r_paren,
3029-
TT_RequiresClause) ||
3029+
TT_RequiresClause, TT_FunctionDeclarationLParen) ||
30303030
(NextToken->is(tok::kw_noexcept) && !IsExpression) ||
30313031
NextToken->canBePointerOrReferenceQualifier() ||
30323032
(NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) {

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmp) {
389389
EXPECT_TOKEN(Tokens[19], tok::l_brace, TT_RequiresExpressionLBrace);
390390
EXPECT_TOKEN(Tokens[20], tok::l_brace, TT_CompoundRequirementLBrace);
391391
EXPECT_TOKEN(Tokens[22], tok::star, TT_BinaryOperator);
392+
393+
Tokens = annotate("return s.operator int *();");
394+
ASSERT_EQ(Tokens.size(), 10u) << Tokens;
395+
EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_FunctionDeclarationName);
396+
EXPECT_TOKEN(Tokens[5], tok::star, TT_PointerOrReference);
397+
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionDeclarationLParen);
392398
}
393399

394400
TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {

0 commit comments

Comments
 (0)