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: 9 additions & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,15 @@ class AnnotatingParser {
Keywords.kw___has_include_next)) {
parseHasInclude();
}
if (Style.isCSharp()) {
if (IsCpp) {
if (Next && Next->is(tok::l_paren) && Prev &&
Prev->isOneOf(tok::kw___cdecl, tok::kw___stdcall,
tok::kw___fastcall, tok::kw___thiscall,
tok::kw___regcall, tok::kw___vectorcall)) {
Tok->setFinalizedType(TT_FunctionDeclarationName);
Next->setFinalizedType(TT_FunctionDeclarationLParen);
}
} else if (Style.isCSharp()) {
if (Tok->is(Keywords.kw_where) && Next && Next->isNot(tok::l_paren)) {
Tok->setType(TT_CSharpGenericTypeConstraint);
parseCSharpGenericTypeConstraint();
Expand Down
5 changes: 5 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,11 @@ TEST_F(TokenAnnotatorTest, UnderstandsFunctionDeclarationNames) {
EXPECT_TOKEN(Tokens[16], tok::l_paren, TT_FunctionDeclarationLParen);
EXPECT_TOKEN(Tokens[18], tok::arrow, TT_TrailingReturnArrow);

Tokens = annotate("void __stdcall f();");
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
EXPECT_TOKEN(Tokens[2], tok::identifier, TT_FunctionDeclarationName);
EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_FunctionDeclarationLParen);

Tokens = annotate("int iso_time(time_t);");
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
Expand Down
Loading