[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
vbvictor wrote: Build errors seem unrelated to this change https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` running on `suse-gary-m68k-cross` while building `clang-tools-extra,clang` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/12990 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) ... [36/170] Building CXX object tools/clang/tools/extra/clangd/unittests/CMakeFiles/ClangdTests.dir/ParsedASTTests.cpp.o [37/170] Building CXX object tools/clang/tools/extra/unittests/clang-tidy/CMakeFiles/ClangTidyTests.dir/TransformerClangTidyCheckTest.cpp.o [38/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SimplifyConstraintsTest.cpp.o [39/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TestingSupportTest.cpp.o [40/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TestingSupport.cpp.o [41/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp.o [42/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp.o [43/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/SignAnalysisTest.cpp.o [44/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferBranchTest.cpp.o [45/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferTest.cpp.o FAILED: tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferTest.cpp.o /usr/bin/c++ -DEXPERIMENTAL_KEY_INSTRUCTIONS -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/unittests -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/tools/clang/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/llvm/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Tooling -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googletest/include -I/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/third-party/unittest/googlemock/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -O3 -DNDEBUG -std=c++17 -Wno-variadic-macros -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -Wno-suggest-override -MD -MT tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferTest.cpp.o -MF tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferTest.cpp.o.d -o tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/Analysis/FlowSensitive/TransferTest.cpp.o -c /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp c++: fatal error: Killed signal terminated program cc1plus compilation terminated. [46/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/SymbolReaperTest.cpp.o [47/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/IsCLibraryFunctionTest.cpp.o [48/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/StaticAnalyzer/ParamRegionTest.cpp.o [49/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/ASTMatchers/GtestMatchersTest.cpp.o [50/170] Building CXX object tools/clang/unittests/CMakeFiles/AllClangUnitTests.dir/AST/ByteCode/toAPValue.cpp.o /var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/unittests/AST/ByteCode/toAPValue.cpp: In member function ‘virtual void ToAPValue_Pointers_Test::TestBody()’: /var/lib/
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
github-actions[bot] wrote: @localspook Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/vbvictor closed https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/vbvictor approved this pull request. https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/vbvictor edited https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
@@ -672,9 +672,15 @@ class Matcher {
DynTypedMatcher Implementation;
}; // class Matcher
-/// A convenient helper for creating a Matcher without specifying
-/// the template type argument.
+// Deduction guide for Matcher.
+template Matcher(MatcherInterface *) -> Matcher;
+
+// TODO: Remove in LLVM 23.
template
+[[deprecated(
+"makeMatcher() is deprecated and will be removed in LLVM 23. "
+"Uses of it can be replaced with direct calls to Matcher's "
+"constructor; with C++17's CTAD, template arguments will be deduced.")]]
vbvictor wrote:
Could we make message smaller, no need to tell how CTAD works IMO.
We could just with `[[deprecated("Use CTAD constructor instead, 'makeMatcher'
will be removed in LLVM 23")]]`
https://github.com/llvm/llvm-project/pull/147197
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/localspook updated
https://github.com/llvm/llvm-project/pull/147197
>From c9da8d946b867fb6e095cefee44388f240c28c28 Mon Sep 17 00:00:00 2001
From: Victor Chernyakin
Date: Sun, 6 Jul 2025 08:32:49 -0700
Subject: [PATCH 1/2] [ASTMatchers][NFC] Replace `makeMatcher` function with
CTAD
---
clang-tools-extra/clang-tidy/utils/Matchers.h | 4 ++--
clang/include/clang/ASTMatchers/ASTMatchersInternal.h | 7 +--
clang/include/clang/ASTMatchers/ASTMatchersMacros.h | 8
clang/lib/Tooling/Transformer/RewriteRule.cpp | 4 ++--
4 files changed, 9 insertions(+), 14 deletions(-)
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
matchesAnyListedName(llvm::ArrayRef 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
matchesAnyListedTypeName(llvm::ArrayRef 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
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 667a044abcef1..5b092537e5e7c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -672,12 +672,7 @@ class Matcher {
DynTypedMatcher Implementation;
}; // class Matcher
-/// A convenient helper for creating a Matcher without specifying
-/// the template type argument.
-template
-inline Matcher makeMatcher(MatcherInterface *Implementation) {
- return Matcher(Implementation);
-}
+template Matcher(MatcherInterface *) -> Matcher;
/// Interface that allows matchers to traverse the AST.
/// FIXME: Find a better name.
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 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 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 (
\
@@ -200,7 +200,7 @@
}
\
inline ::clang::ast_matchers::internal::Matcher 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 DefineMatcher(
\
llvm::StringRef Param, llvm::Regex::RegexFlags RegexFlag
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
vbvictor wrote: I'd suggest marking it `[[deprecated]]` for now and removing it completely after 2 releases of LLVM (AFAIK that's usual procedure). I've [searched](https://sourcegraph.com/search?q=context:global+::clang::ast_matchers::internal::makeMatcher+-file:.*Matchers%5C.h%24+-file:.*ASTMatchersInternal%5C.h%24+-file:.*ASTMatchersMacros%5C.h%24+-file:.*RewriteRule%5C.cpp%24&patternType=keyword&sm=0) for usages too, and it doesn't seem to be used anywhere, but I think we still need to take into account private forks. If it is used in `clang/lib/Tooling/Transformer/RewriteRule.cpp`, some custom checks/tooling could use it too. https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
@@ -672,12 +672,7 @@ class Matcher {
DynTypedMatcher Implementation;
}; // class Matcher
-/// A convenient helper for creating a Matcher without specifying
-/// the template type argument.
-template
-inline Matcher makeMatcher(MatcherInterface *Implementation) {
- return Matcher(Implementation);
-}
+template Matcher(MatcherInterface *) -> Matcher;
nicovank wrote:
Maybe just a comment here indicating this is a user-defined deduction guide.
https://github.com/llvm/llvm-project/pull/147197
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/nicovank approved this pull request. Looks reasonable to me, thanks! Let's wait for one more set of eyes. I did a quick search for this on GitHub, most hits seem to be in LLVM forks/clones, so it doesn't seem this will impact users (good to check even if internal code). https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/nicovank edited https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
https://github.com/localspook created
https://github.com/llvm/llvm-project/pull/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.
>From c9da8d946b867fb6e095cefee44388f240c28c28 Mon Sep 17 00:00:00 2001
From: Victor Chernyakin
Date: Sun, 6 Jul 2025 08:32:49 -0700
Subject: [PATCH] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD
---
clang-tools-extra/clang-tidy/utils/Matchers.h | 4 ++--
clang/include/clang/ASTMatchers/ASTMatchersInternal.h | 7 +--
clang/include/clang/ASTMatchers/ASTMatchersMacros.h | 8
clang/lib/Tooling/Transformer/RewriteRule.cpp | 4 ++--
4 files changed, 9 insertions(+), 14 deletions(-)
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
matchesAnyListedName(llvm::ArrayRef 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
matchesAnyListedTypeName(llvm::ArrayRef 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
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 667a044abcef1..5b092537e5e7c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -672,12 +672,7 @@ class Matcher {
DynTypedMatcher Implementation;
}; // class Matcher
-/// A convenient helper for creating a Matcher without specifying
-/// the template type argument.
-template
-inline Matcher makeMatcher(MatcherInterface *Implementation) {
- return Matcher(Implementation);
-}
+template Matcher(MatcherInterface *) -> Matcher;
/// Interface that allows matchers to traverse the AST.
/// FIXME: Find a better name.
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 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 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 (
\
@@ -200,7 +200,7 @@
}
\
inline ::clang::ast_matchers::internal::Matcher 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 @@
}
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/147197 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Victor Chernyakin (localspook)
Changes
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/147197.diff
4 Files Affected:
- (modified) clang-tools-extra/clang-tidy/utils/Matchers.h (+2-2)
- (modified) clang/include/clang/ASTMatchers/ASTMatchersInternal.h (+1-6)
- (modified) clang/include/clang/ASTMatchers/ASTMatchersMacros.h (+4-4)
- (modified) clang/lib/Tooling/Transformer/RewriteRule.cpp (+2-2)
``diff
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
matchesAnyListedName(llvm::ArrayRef 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
matchesAnyListedTypeName(llvm::ArrayRef 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
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 667a044abcef1..5b092537e5e7c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -672,12 +672,7 @@ class Matcher {
DynTypedMatcher Implementation;
}; // class Matcher
-/// A convenient helper for creating a Matcher without specifying
-/// the template type argument.
-template
-inline Matcher makeMatcher(MatcherInterface *Implementation) {
- return Matcher(Implementation);
-}
+template Matcher(MatcherInterface *) -> Matcher;
/// Interface that allows matchers to traverse the AST.
/// FIXME: Find a better name.
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 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 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 (
\
@@ -200,7 +200,7 @@
}
\
inline ::clang::ast_matchers::internal::Matcher 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 DefineMatcher(
\
llvm::StringRef Param, ll
[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)
llvmbot wrote:
@llvm/pr-subscribers-clang-tidy
Author: Victor Chernyakin (localspook)
Changes
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/147197.diff
4 Files Affected:
- (modified) clang-tools-extra/clang-tidy/utils/Matchers.h (+2-2)
- (modified) clang/include/clang/ASTMatchers/ASTMatchersInternal.h (+1-6)
- (modified) clang/include/clang/ASTMatchers/ASTMatchersMacros.h (+4-4)
- (modified) clang/lib/Tooling/Transformer/RewriteRule.cpp (+2-2)
``diff
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
matchesAnyListedName(llvm::ArrayRef 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
matchesAnyListedTypeName(llvm::ArrayRef 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
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 667a044abcef1..5b092537e5e7c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -672,12 +672,7 @@ class Matcher {
DynTypedMatcher Implementation;
}; // class Matcher
-/// A convenient helper for creating a Matcher without specifying
-/// the template type argument.
-template
-inline Matcher makeMatcher(MatcherInterface *Implementation) {
- return Matcher(Implementation);
-}
+template Matcher(MatcherInterface *) -> Matcher;
/// Interface that allows matchers to traverse the AST.
/// FIXME: Find a better name.
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 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 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 (
\
@@ -200,7 +200,7 @@
}
\
inline ::clang::ast_matchers::internal::Matcher 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 DefineMatcher(
\
llvm::StringRef Para
