Skip to content

Commit a27ff17

Browse files
authored
[clang-format] Fix a regression in annotating ObjCBlockLParen (#107021)
Fixes #106994.
1 parent 12c0823 commit a27ff17

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,8 +3588,7 @@ static FormatToken *getFunctionName(const AnnotatedLine &Line,
35883588

35893589
// Make sure the name is followed by a pair of parentheses.
35903590
if (Name) {
3591-
if (Tok->is(tok::l_paren) && Tok->isNot(TT_FunctionTypeLParen) &&
3592-
Tok->MatchingParen) {
3591+
if (Tok->is(tok::l_paren) && Tok->is(TT_Unknown) && Tok->MatchingParen) {
35933592
OpeningParen = Tok;
35943593
return Name;
35953594
}

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsObjCBlock) {
16781678
"}();");
16791679
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
16801680
EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_ObjCBlockLBrace);
1681+
1682+
Tokens = annotate("id (^block)(Foo *a) = ^id _Nullable(Foo *_Nullable a) {\n"
1683+
" return a;\n"
1684+
"};");
1685+
ASSERT_EQ(Tokens.size(), 27u) << Tokens;
1686+
EXPECT_TOKEN(Tokens[0], tok::identifier, TT_Unknown); // Not CtorDtorDeclName.
1687+
EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ObjCBlockLParen);
16811688
}
16821689

16831690
TEST_F(TokenAnnotatorTest, UnderstandsObjCMethodExpr) {

0 commit comments

Comments
 (0)