Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3791,12 +3791,18 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
if (Current.is(TT_FunctionDeclarationName))
return true;

if (Current.isNoneOf(tok::identifier, tok::kw_operator))
if (!Current.Tok.getIdentifierInfo())
return false;

const auto *Prev = Current.getPreviousNonComment();
assert(Prev);

if (Prev->is(tok::coloncolon))
Prev = Prev->Previous;

if (!Prev)
return false;

const auto &Previous = *Prev;

if (const auto *PrevPrev = Previous.getPreviousNonComment();
Expand Down Expand Up @@ -3845,8 +3851,6 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,

// Find parentheses of parameter list.
if (Current.is(tok::kw_operator)) {
if (Line.startsWith(tok::kw_friend))
return true;
if (Previous.Tok.getIdentifierInfo() &&
Previous.isNoneOf(tok::kw_return, tok::kw_co_return)) {
return true;
Expand Down
5 changes: 0 additions & 5 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,11 +1129,6 @@ TEST_F(TokenAnnotatorTest, UnderstandsOverloadedOperators) {
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
// Not TT_FunctionDeclarationName.
EXPECT_TOKEN(Tokens[3], tok::kw_operator, TT_Unknown);

Tokens = annotate("SomeAPI::operator()();");
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
// Not TT_FunctionDeclarationName.
EXPECT_TOKEN(Tokens[2], tok::kw_operator, TT_Unknown);
}

TEST_F(TokenAnnotatorTest, OverloadedOperatorInTemplate) {
Expand Down
Loading