diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1804,21 +1804,8 @@ FormatToken *LeadingIdentifier = Current.Previous->MatchingParen->Previous; - // Differentiate a deduction guide by seeing the - // > of the template prior to the leading identifier. - if (LeadingIdentifier) { - FormatToken *PriorLeadingIdentifier = LeadingIdentifier->Previous; - // Skip back past explicit decoration - if (PriorLeadingIdentifier && - PriorLeadingIdentifier->is(tok::kw_explicit)) { - PriorLeadingIdentifier = PriorLeadingIdentifier->Previous; - } - - return PriorLeadingIdentifier && - (PriorLeadingIdentifier->is(TT_TemplateCloser) || - PriorLeadingIdentifier->ClosesRequiresClause) && - LeadingIdentifier->TokenText == Current.Next->TokenText; - } + return LeadingIdentifier && + LeadingIdentifier->TokenText == Current.Next->TokenText; } } return false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -8001,12 +8001,14 @@ verifyFormat("template x() -> x<1>;"); verifyFormat("template explicit x(T &) -> x<1>;"); + verifyFormat("A(const char *) -> A;"); + verifyFormat("A() -> A;"); + // Ensure not deduction guides. verifyFormat("c()->f();"); verifyFormat("x()->foo<1>;"); verifyFormat("x = p->foo<3>();"); verifyFormat("x()->x<1>();"); - verifyFormat("x()->x<1>;"); } TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {