[cfe-dev] ast matchers, structDecl, unionDecl missing? recordDecl is only for CXXRecordDecl

mobi phil mobi at mobiphil.com
Sun Jan 4 19:33:21 PST 2015


thanks for the answer and for the promised fix. Please also consider
renaming recordDecl matcher to cxxRecordDecl to reflect the correct type


> There is no "return" kind on a matcher because the matcher always returns
>> 'bool'.
>>
>
>

was bit dizzy from the matchers, so maybe did not express myself correctly.
Was more using the wording from
http://clang.llvm.org/docs/LibASTMatchersReference.html
Was referring to the "returned" objects by the matchers and not the return
type of o matcher method on a node. Now going back to this page, I think
there is a mistake in the header of the matchers table. I think the
"Parameters" should be swapped with the "Return types". Or I am still
confused with the wording. Does "parameter" here mean the ast node argument
passed to the matcher method? That is recordDecl is applied aggainst Decl
and returns CXXRecord?
Also after reading through the table few times I discovered that the
matcher names are "clickable" and a little doc expands. Probably not so
obvious for most people.




> It is impossible to know the real type of the node before matching, as it
>> could be a subclass of what you are matching.
>>
> A DynTypedMatcher has 2 "Kinds": SupportedKind and RestrictKind.
>


> SupportedKind is the minimum static type that the matcher accepts. This is
> the argument type used in the static matcher declaration.
> It is used to simulate the compile time errors you would get on the static
> matchers during parsing of the dynamic matchers.
> For example, recordDecl() has a SupportedKind of Decl because it takes any
> Decl node to check if it is a CXXRecordDecl, hasName() has a SupportedKind
> of NamedDecl.
>
> RestrictKind is the minimum dynamic type that the matcher accepts. This is
> used to do the type matching.
> For example, recordDecl() has a RestrictKind of CXXRecordDecl because it
> needs a node that is a CXXRecordDecl, hasName() has a RestrictKind of
> NamedDecl.
> There are some optimizations on the dynamic matcher creation that
> propagates and combines the RestrictKind to reject values earlier.
> RestrictKind has to be the same or a subclass of SupportedKind.
>
> You should be able to use RestrictKind to determine the API supported by
> the matched node.
>

Well, was not trying to find out the the "real" type as obviously the real
type is hidden in the ast itself and that is not known when the matcher is
being constructed. I am interested indeed in the RestrictedType, Will give
a try in few days and report.



rgrds,
mobi phil

being mobile, but including technology
http://mobiphil.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150105/e4382836/attachment.html>


More information about the cfe-dev mailing list