Author: Victor Chernyakin Date: 2025-07-12T14:12:02+03:00 New Revision: 4326f68acbb12d21bc0c139c9b7f0a74a9ec8b69
URL: https://github.com/llvm/llvm-project/commit/4326f68acbb12d21bc0c139c9b7f0a74a9ec8b69 DIFF: https://github.com/llvm/llvm-project/commit/4326f68acbb12d21bc0c139c9b7f0a74a9ec8b69.diff LOG: [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (#147197) C++17's CTAD obsoletes `makeMatcher` (and many `make*` functions like it). The deduction guide is written out explicitly to avoid `-Wctad-maybe-unsupported` warnings. Added: Modified: clang-tools-extra/clang-tidy/utils/Matchers.h clang/include/clang/ASTMatchers/ASTMatchersInternal.h clang/include/clang/ASTMatchers/ASTMatchersMacros.h clang/lib/Tooling/Transformer/RewriteRule.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/utils/Matchers.h b/clang-tools-extra/clang-tidy/utils/Matchers.h index 2b6d377b8fd10..a7683024d69c4 100644 --- a/clang-tools-extra/clang-tidy/utils/Matchers.h +++ b/clang-tools-extra/clang-tidy/utils/Matchers.h @@ -145,7 +145,7 @@ class MatchesAnyListedNameMatcher // qualified name will be used for matching, otherwise its name will be used. inline ::clang::ast_matchers::internal::Matcher<NamedDecl> matchesAnyListedName(llvm::ArrayRef<StringRef> NameList) { - return ::clang::ast_matchers::internal::makeMatcher( + return ::clang::ast_matchers::internal::Matcher( new MatchesAnyListedNameMatcher(NameList)); } @@ -188,7 +188,7 @@ class MatchesAnyListedTypeNameMatcher inline ::clang::ast_matchers::internal::Matcher<QualType> matchesAnyListedTypeName(llvm::ArrayRef<StringRef> NameList, bool CanonicalTypes) { - return ::clang::ast_matchers::internal::makeMatcher( + return ::clang::ast_matchers::internal::Matcher( new MatchesAnyListedTypeNameMatcher(NameList, CanonicalTypes)); } inline ::clang::ast_matchers::internal::Matcher<QualType> diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index 667a044abcef1..5df2294792552 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -672,9 +672,13 @@ class Matcher { DynTypedMatcher Implementation; }; // class Matcher -/// A convenient helper for creating a Matcher<T> without specifying -/// the template type argument. +// Deduction guide for Matcher. +template <typename T> Matcher(MatcherInterface<T> *) -> Matcher<T>; + +// TODO: Remove in LLVM 23. template <typename T> +[[deprecated( + "Use CTAD constructor instead, 'makeMatcher' will be removed in LLVM 23.")]] inline Matcher<T> makeMatcher(MatcherInterface<T> *Implementation) { return Matcher<T>(Implementation); } diff --git a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h index f781e0a565eb3..8ac55e5bb1fc0 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersMacros.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersMacros.h @@ -106,7 +106,7 @@ }; \ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher() { \ - return ::clang::ast_matchers::internal::makeMatcher( \ + return ::clang::ast_matchers::internal::Matcher( \ new internal::matcher_##DefineMatcher##Matcher()); \ } \ inline bool internal::matcher_##DefineMatcher##Matcher::matches( \ @@ -150,7 +150,7 @@ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \ ParamType const &Param) { \ - return ::clang::ast_matchers::internal::makeMatcher( \ + return ::clang::ast_matchers::internal::Matcher( \ new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param)); \ } \ typedef ::clang::ast_matchers::internal::Matcher<Type> ( \ @@ -200,7 +200,7 @@ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \ ParamType1 const &Param1, ParamType2 const &Param2) { \ - return ::clang::ast_matchers::internal::makeMatcher( \ + return ::clang::ast_matchers::internal::Matcher( \ new internal::matcher_##DefineMatcher##OverloadId##Matcher(Param1, \ Param2)); \ } \ @@ -476,7 +476,7 @@ } \ inline ::clang::ast_matchers::internal::Matcher<Type> DefineMatcher( \ llvm::StringRef Param, llvm::Regex::RegexFlags RegexFlags) { \ - return ::clang::ast_matchers::internal::makeMatcher( \ + return ::clang::ast_matchers::internal::Matcher( \ new internal::matcher_##DefineMatcher##OverloadId##Matcher( \ ::clang::ast_matchers::internal::createAndVerifyRegex( \ Param, RegexFlags, #DefineMatcher))); \ diff --git a/clang/lib/Tooling/Transformer/RewriteRule.cpp b/clang/lib/Tooling/Transformer/RewriteRule.cpp index 02a1931dee673..5798a9958fe7a 100644 --- a/clang/lib/Tooling/Transformer/RewriteRule.cpp +++ b/clang/lib/Tooling/Transformer/RewriteRule.cpp @@ -258,9 +258,9 @@ template <typename T> ast_matchers::internal::Matcher<T> forEachDescendantDynamically(ast_matchers::BoundNodes Nodes, DynTypedMatcher M) { - return ast_matchers::internal::makeMatcher(new BindingsMatcher<T>( + return ast_matchers::internal::Matcher(new BindingsMatcher<T>( std::move(Nodes), - ast_matchers::internal::makeMatcher( + ast_matchers::internal::Matcher( new DynamicForEachDescendantMatcher<T>(std::move(M))))); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits