Skip to content

[ASTMatchers][NFC] Replace makeMatcher function with CTAD #147197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/utils/Matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -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>
Expand Down
8 changes: 6 additions & 2 deletions clang/include/clang/ASTMatchers/ASTMatchersInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/ASTMatchers/ASTMatchersMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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( \
Expand Down Expand Up @@ -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> ( \
Expand Down Expand Up @@ -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)); \
} \
Expand Down Expand Up @@ -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))); \
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Tooling/Transformer/RewriteRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)))));
}

Expand Down