This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG8384347997f8: [clang-format] Don't require deduction guides to be templates (authored by rymiel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139416/new/ https://reviews.llvm.org/D139416 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8008,12 +8008,14 @@ verifyFormat("template <class T> x() -> x<1>;"); verifyFormat("template <class T> explicit x(T &) -> x<1>;"); + verifyFormat("A(const char *) -> A<string &>;"); + verifyFormat("A() -> A<int>;"); + // Ensure not deduction guides. verifyFormat("c()->f<int>();"); verifyFormat("x()->foo<1>;"); verifyFormat("x = p->foo<3>();"); verifyFormat("x()->x<1>();"); - verifyFormat("x()->x<1>;"); } TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ 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;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8008,12 +8008,14 @@ verifyFormat("template <class T> x() -> x<1>;"); verifyFormat("template <class T> explicit x(T &) -> x<1>;"); + verifyFormat("A(const char *) -> A<string &>;"); + verifyFormat("A() -> A<int>;"); + // Ensure not deduction guides. verifyFormat("c()->f<int>();"); verifyFormat("x()->foo<1>;"); verifyFormat("x = p->foo<3>();"); verifyFormat("x()->x<1>();"); - verifyFormat("x()->x<1>;"); } TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ 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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits