[clang] [clang-format] Correctly annotate user-defined conversion functions (PR #131434)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 15 03:37:45 PDT 2025
================
@@ -1639,6 +1639,25 @@ class AnnotatingParser {
case tok::kw_operator:
if (Style.isProto())
break;
+ // C++ user-defined conversion function.
+ if (IsCpp && CurrentToken &&
+ (CurrentToken->is(tok::kw_auto) ||
+ CurrentToken->isTypeName(LangOpts))) {
+ FormatToken *LParen;
+ if (CurrentToken->startsSequence(tok::kw_decltype, tok::l_paren,
+ tok::kw_auto, tok::r_paren)) {
+ LParen = CurrentToken->Next->Next->Next->Next;
+ } else {
+ for (LParen = CurrentToken->Next;
+ LParen && LParen->isNot(tok::l_paren); LParen = LParen->Next) {
+ }
+ }
+ if (LParen && LParen->startsSequence(tok::l_paren, tok::r_paren)) {
----------------
HazardyKnusperkeks wrote:
This does not match on `operator Foo(void)`.
https://github.com/llvm/llvm-project/pull/131434
More information about the cfe-commits
mailing list