Skip to content

Commit e56033c

Browse files
committed
[clang-format] Correctly annotate static overloaded operator calls
Fixes #160513
1 parent 56d920d commit e56033c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3802,7 +3802,7 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
38023802
const auto *Prev = Current.getPreviousNonComment();
38033803
assert(Prev);
38043804

3805-
if (Prev->is(tok::coloncolon))
3805+
if (Prev->is(tok::coloncolon) && Prev->hasWhitespaceBefore())
38063806
Prev = Prev->Previous;
38073807

38083808
if (!Prev)

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
11291129
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
11301130
// Not TT_FunctionDeclarationName.
11311131
EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);
1132+
1133+
Tokens = annotate("SomeAPI::operator()();");
1134+
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
1135+
// Not TT_FunctionDeclarationName.
1136+
EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
11321137
}
11331138

11341139
TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {

0 commit comments

Comments
 (0)