[PATCH] D69218: [ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level)

Nikita Kniazev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 21 18:18:50 PDT 2021


nick added inline comments.


================
Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3812-3821
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
     hasType,
     AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl,
-                                    ValueDecl),
+                                    ValueDecl, CXXBaseSpecifier),
     internal::Matcher<QualType>, InnerMatcher, 0) {
   QualType QT = internal::getUnderlyingType(Node);
   if (!QT.isNull())
----------------
njames93 wrote:
> I don't think the change to this matcher is warranted.
> The `hasType` matcher that accepts a DeclarationMatcher already has support for cxxBaseSpecifier.
> However overloading the matcher that takes a QualType matcher doesn't make sense as base specifiers have no qualifications.
What should I use in D69000 then? It is been a very long time since I developed and published these patches, but D69000 definitely requires this matcher, without it I get:

```
llvm-project\clang\include\clang\ASTMatchers\ASTMatchersInternal.h(1569): error C2338: right polymorphic conversion
llvm-project\clang-tools-extra\clang-tidy\modernize\DeprecatedIteratorBaseCheck.cpp(200): note: see reference to function template instantiation 'clang::ast_matchers::internal::PolymorphicMatcher<clang::ast_matchers::internal::matcher_hasType0Matcher,void (clang::ast_matchers::internal::TypeList<clang::Expr,clang::FriendDecl,clang::TypedefNameDecl,clang::ValueDecl>),clang::ast_matchers::internal::Matcher<clang::QualType>>::operator clang::ast_matchers::internal::Matcher<clang::CXXBaseSpecifier>(void) const<clang::CXXBaseSpecifier>' being compiled
llvm-project\clang-tools-extra\clang-tidy\modernize\DeprecatedIteratorBaseCheck.cpp(192): note: see reference to function template instantiation 'clang::ast_matchers::internal::PolymorphicMatcher<clang::ast_matchers::internal::matcher_hasType0Matcher,void (clang::ast_matchers::internal::TypeList<clang::Expr,clang::FriendDecl,clang::TypedefNameDecl,clang::ValueDecl>),clang::ast_matchers::internal::Matcher<clang::QualType>>::operator clang::ast_matchers::internal::Matcher<clang::CXXBaseSpecifier>(void) const<clang::CXXBaseSpecifier>' being compiled
```



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

https://reviews.llvm.org/D69218



More information about the cfe-commits mailing list