ParmVarDecl of CXXConstructorDecl Matcher

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ParmVarDecl of CXXConstructorDecl Matcher

shirley breuer via cfe-dev
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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: ParmVarDecl of CXXConstructorDecl Matcher

shirley breuer via cfe-dev
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

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

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev