llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/143083.diff 2 Files Affected: - (modified) clang/lib/Format/TokenAnnotator.cpp (+9-1) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+5) ``````````diff diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 37ab40ca97bff..aed1672afac66 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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(); diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 9d62ff8d39a77..d64e34de1fcf4 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -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); `````````` </details> https://github.com/llvm/llvm-project/pull/143083 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits