Skip to content

Commit 8e31050

Browse files
authored
[clang-format] Fix a bug in annotating overloaded co_await decl (llvm#124240)
Fixes llvm#124223.
1 parent 4ea44eb commit 8e31050

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
@@ -3784,7 +3784,7 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
37843784
return Next;
37853785
if (Next->is(TT_OverloadedOperator))
37863786
continue;
3787-
if (Next->isOneOf(tok::kw_new, tok::kw_delete)) {
3787+
if (Next->isOneOf(tok::kw_new, tok::kw_delete, tok::kw_co_await)) {
37883788
// For 'new[]' and 'delete[]'.
37893789
if (Next->Next &&
37903790
Next->Next->startsSequence(tok::l_square, tok::r_square)) {

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
10251025
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_OverloadedOperatorLParen);
10261026
EXPECT_TOKEN(Tokens[8], tok::amp, TT_PointerOrReference);
10271027
EXPECT_TOKEN(Tokens[12], tok::amp, TT_PointerOrReference);
1028+
1029+
Tokens = annotate("SomeLoooooooooooooooooType::Awaitable\n"
1030+
"SomeLoooooooooooooooooType::operator co_await();");
1031+
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
1032+
EXPECT_TOKEN(Tokens[3], tok::identifier, TT_FunctionDeclarationName);
1033+
EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_OverloadedOperatorLParen);
10281034
}
10291035

10301036
TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

0 commit comments

Comments
 (0)