[cfe-dev] ParmVarDecl of CXXConstructorDecl Matcher

Nathan James via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 4 14:43:06 PST 2021


On Thu, 2021-02-04 at 21:34 +0000, Hartogs Siegfried via cfe-dev wrote:
> Hello everyone, 
> 
> How would one write a matcher that looks for ParmVarDecls that don't
> occur in constructor decls?
> I'd figure
>  parmVarDecl(unless(hasParent(cxxConstructorDecl()))),
> but that doesn't work.
> Replacing hasParent with hasAncestor seems to work, but looks weird
> considering ParmVarDecls look like direct children of FunctionDecls
> in the AST. Is there something special about ParmVarDecls, also since
> there is the hasAnyParameter matcher?
> 
> Thanks!
> Sigi
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

Hi Sigi,

I'm not sure if this is intended behaviour, but it seems the parent of
a `ParmVarDecl` is a `TypeLoc`.
For now this should serve your purpose, but I think this may need
looking into.
`parmVarDecl(hasParent(typeLoc(unless(hasParent(cxxConstructorDecl())))
))`

~Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210204/177d8cee/attachment.html>


More information about the cfe-dev mailing list