[PATCH] D69218: [ASTMatchers] Add `cxxBaseSpecifier` matcher (non-top-level)
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 22 04:57:09 PDT 2021
aaron.ballman 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())
----------------
nick wrote:
> 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
> ```
>
> However overloading the matcher that takes a QualType matcher doesn't make sense as base specifiers have no qualifications.
`QualType` is a convenience wrapper around a `Type` and so I think it's reasonable based on that convenience alone. We have some matchers that return a `QualType`, like `asString()`, which I could imagine a user wanting to use with `cxxBaseSpecifier()`. e.g., `cxxBaseSpecifier(asString("SomeClass"))`
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69218/new/
https://reviews.llvm.org/D69218
More information about the cfe-commits
mailing list