[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 16:59:26 PDT 2020


njames93 marked an inline comment as done.
njames93 added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/utils/Matchers.cpp:17
+
+Matcher<NamedDecl> hasAnyListedName(std::vector<std::string> Names) {
+  return Matcher<NamedDecl>(new HasNameMatcher(std::move(Names)));
----------------
gribozavr2 wrote:
> njames93 wrote:
> > gribozavr2 wrote:
> > > This matcher sounds generally useful. I think it would be better placed in ASTMatchers.h, WDYT? Can we make it an overload of `hasAnyName`?
> > `hasAnyName` is a const variable who's type is `VariadicFunction` so it can't be overloaded unfortunately. I personally didn't want it in ASTMatchers.h as its mainly useful for `clang-tidy` checks that load in configurations. It doesn't have a place in say `clang-query`.
> > hasAnyName is a const variable who's type is VariadicFunction so it can't be overloaded unfortunately.
> 
> I thought we had facilities to declare polymorphic matchers that could help here.
> 
> > I personally didn't want it in ASTMatchers.h as its mainly useful for clang-tidy checks that load in configurations.
> 
> A lot of user-defined tools are quite similar.
Polymorphic matchers are matchers that can match against different types of nodes, what we want here is match against one type of node, but different overloads. I am thinking though that With some nifty retooling of `VariadicFunction` you could possible change it so that you can call its `operator()` with types that are convertible to its `ArgT`. However that is a deep rabbit hole to go down for the purpose of what this patch is trying to do


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75911/new/

https://reviews.llvm.org/D75911





More information about the cfe-commits mailing list