@@ -1639,23 +1639,29 @@ class AnnotatingParser {
16391639 case tok::kw_operator:
16401640 if (Style.isProto ())
16411641 break ;
1642- // C++ user-defined conversion function.
1643- if (IsCpp && CurrentToken &&
1644- (CurrentToken->is (tok::kw_auto) ||
1645- CurrentToken->isTypeName (LangOpts))) {
1646- FormatToken *LParen;
1647- if (CurrentToken->startsSequence (tok::kw_decltype, tok::l_paren,
1648- tok::kw_auto, tok::r_paren)) {
1649- LParen = CurrentToken->Next ->Next ->Next ->Next ;
1650- } else {
1651- for (LParen = CurrentToken->Next ;
1652- LParen && LParen->isNot (tok::l_paren); LParen = LParen->Next ) {
1642+ // Handle C++ user-defined conversion function.
1643+ if (IsCpp && CurrentToken) {
1644+ const auto *Info = CurrentToken->Tok .getIdentifierInfo ();
1645+ // What follows Tok is an identifier or a non-operator keyword.
1646+ if (Info && !(Info->isCPlusPlusOperatorKeyword () ||
1647+ CurrentToken->isPlacementOperator () ||
1648+ CurrentToken->is (tok::kw_co_await))) {
1649+ FormatToken *LParen;
1650+ if (CurrentToken->startsSequence (tok::kw_decltype, tok::l_paren,
1651+ tok::kw_auto, tok::r_paren)) {
1652+ // Skip `decltype(auto)`.
1653+ LParen = CurrentToken->Next ->Next ->Next ->Next ;
1654+ } else {
1655+ // Skip to l_paren.
1656+ for (LParen = CurrentToken->Next ;
1657+ LParen && LParen->isNot (tok::l_paren); LParen = LParen->Next ) {
1658+ }
1659+ }
1660+ if (LParen && LParen->is (tok::l_paren)) {
1661+ Tok->setFinalizedType (TT_FunctionDeclarationName);
1662+ LParen->setFinalizedType (TT_FunctionDeclarationLParen);
1663+ break ;
16531664 }
1654- }
1655- if (LParen && LParen->startsSequence (tok::l_paren, tok::r_paren)) {
1656- Tok->setFinalizedType (TT_FunctionDeclarationName);
1657- LParen->setFinalizedType (TT_FunctionDeclarationLParen);
1658- break ;
16591665 }
16601666 }
16611667 while (CurrentToken &&
@@ -3018,7 +3024,7 @@ class AnnotatingParser {
30183024 return TT_UnaryOperator;
30193025 if (PrevToken->is (TT_TypeName))
30203026 return TT_PointerOrReference;
3021- if (PrevToken->isOneOf (tok::kw_new, tok::kw_delete ) && Tok.is (tok::ampamp))
3027+ if (PrevToken->isPlacementOperator ( ) && Tok.is (tok::ampamp))
30223028 return TT_BinaryOperator;
30233029
30243030 const FormatToken *NextToken = Tok.getNextNonComment ();
@@ -3808,7 +3814,7 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
38083814 return Next;
38093815 if (Next->is (TT_OverloadedOperator))
38103816 continue ;
3811- if (Next->isOneOf (tok::kw_new, tok::kw_delete, tok::kw_co_await)) {
3817+ if (Next->isPlacementOperator () || Next-> is ( tok::kw_co_await)) {
38123818 // For 'new[]' and 'delete[]'.
38133819 if (Next->Next &&
38143820 Next->Next ->startsSequence (tok::l_square, tok::r_square)) {
@@ -4819,7 +4825,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48194825 spaceRequiredBeforeParens (Right);
48204826 }
48214827 if (Style.SpaceBeforeParens == FormatStyle::SBPO_Custom &&
4822- Left.isOneOf (tok::kw_new, tok::kw_delete ) &&
4828+ Left.isPlacementOperator ( ) &&
48234829 Right.isNot (TT_OverloadedOperatorLParen) &&
48244830 !(Line.MightBeFunctionDecl && Left.is (TT_FunctionDeclarationName))) {
48254831 const auto *RParen = Right.MatchingParen ;
@@ -4862,7 +4868,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48624868 return Style.SpaceBeforeParensOptions .AfterControlStatements ||
48634869 spaceRequiredBeforeParens (Right);
48644870 }
4865- if (Left.isOneOf (tok::kw_new, tok::kw_delete ) ||
4871+ if (Left.isPlacementOperator ( ) ||
48664872 (Left.is (tok::r_square) && Left.MatchingParen &&
48674873 Left.MatchingParen ->Previous &&
48684874 Left.MatchingParen ->Previous ->is (tok::kw_delete))) {
0 commit comments