[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 27 07:07:54 PDT 2018


martong added a comment.

> If you know the node is a decl, wrapping it in decl() should be enough.
>  Does this work?
>  auto WrappedMatcher = decl(anyOf(...));

Unfortunately this gives again the private ctor error (the same error when I called explicitly the overload with the `DeclarationMatcher`):

  ../../git/llvm/tools/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1339:13: error: calling a private constructor of class 'clang::ast_matchers::internal::Matcher<clang::Decl>'
      return {Matcher<T>(std::get<Is>(Params))...};
              ^
  ../../git/llvm/tools/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:1331:16: note: in instantiation of function template specialization 'clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcher<clang::Stmt>, clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<internal::HasDescendantMatcher, clang::ast_matchers::internal::TypeList<clang::Decl, clang::Stmt, clang::NestedNameSpecifier, clang::NestedNameSpecifierLoc, clang::QualType, clang::Type, clang::TypeLoc, clang::CXXCtorInitializer>, clang::ast_matchers::internal::TypeList<clang::Decl, clang::Stmt, clang::NestedNameSpecifier, clang::NestedNameSpecifierLoc, clang::TypeLoc, clang::QualType> >::Adaptor<clang::Stmt> >::getMatchers<clang::Decl, 0, 1>' requested here
                 getMatchers<T>(llvm::index_sequence_for<Ps...>()))
                 ^
  ../../git/llvm/tools/clang/unittests/AST/DeclMatcher.h:35:32: note: in instantiation of function template specialization 'clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcher<clang::Stmt>, clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<internal::HasDescendantMatcher, clang::ast_matchers::internal::TypeList<clang::Decl, clang::Stmt, clang::NestedNameSpecifier, clang::NestedNameSpecifierLoc, clang::QualType, clang::Type, clang::TypeLoc, clang::CXXCtorInitializer>, clang::ast_matchers::internal::TypeList<clang::Decl, clang::Stmt, clang::NestedNameSpecifier, clang::NestedNameSpecifierLoc, clang::TypeLoc, clang::QualType> >::Adaptor<clang::Stmt> >::operator Matcher<clang::Decl>' requested here
      auto WrappedMatcher = decl(anyOf(AMatcher.bind(""), hasDescendant(AMatcher.bind(""))));
                                 ^

Even if it would work then how could I support nodes other than decls (e.g. stmt())?


Repository:
  rC Clang

https://reviews.llvm.org/D49840





More information about the cfe-commits mailing list