[cfe-dev] AST Matching: Maching FieldDecl while excluding matches in ClassTemplateDecl

Miklos Vajna via cfe-dev cfe-dev at lists.llvm.org
Fri May 29 15:34:04 PDT 2020


Hi Hiren,

On Wed, Apr 22, 2020 at 09:50:07PM -0400, Hiren Patel via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> Note that Match #1 and #3 are what I want.  Match #2 is coming from
> the ClassTemplateDecl, which I do not want to match on.  Could someone
> provide me with some guidance to exclude matches for a FieldDecl's
> parent class declaration being a template declaration but not a class
> template specialization?

I guess what you want is that either it's not a template class or it's a
template instantiation, i.e.

fieldDecl(
    anyOf(unless(hasParent(cxxRecordDecl(hasParent(classTemplateDecl())))),
          hasParent(cxxRecordDecl(isTemplateInstantiation()))))

Does that help?

Regards,

Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200530/d61fae9f/attachment.sig>


More information about the cfe-dev mailing list