[cfe-dev] hasType(qualType(...)) is this a legal part of an ASTMatcher?
Manuel Klimek
klimek at google.com
Sun Feb 23 11:32:15 PST 2014
On Sun, Feb 23, 2014 at 4:46 PM, Christian Schafmeister <
chris.schaf at verizon.net> wrote:
>
> If I read the documentation at
> http://clang.llvm.org/docs/LibASTMatchersReference.html correctly, the
> partial matcher "hasType(qualType(…))" is not legal.
>
hasType has an overload for Decl and QualType:
http://clang.llvm.org/doxygen/namespaceclang_1_1ast__matchers.html#a605703cba74d951cd64ee10b82bb4139
We have to fix the docs :)
>
> I ask because I’ve seen it used several times, it’s an example in the
> documentation for “isCanonicalType” (see below), and I’m wrapping the
> ASTMatcher library in my Common Lisp environment to write refactoring tools
> in Common Lisp and I’ve used the documentation at
> http://clang.llvm.org/docs/LibASTMatchersReference.html to define what
> matchers are legal and which are not.
>
> I think I need to use hasType(qualType(…)) for a matcher that I’m writing
> and I need to figure out how to work it into my rules.
>
>
> isCanonicalType documentation follows
>
> Matches QualTypes whose canonical type matches InnerMatcher.
>
> Given:
> typedef int &int_ref;
> int a;
> int_ref b = a;
>
> varDecl(*hasType(qualType(*referenceType()))))) will not match the
> declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
>
>
> The predicate hasType(…) requires a Matcher<Decl> as the inner matcher
> and qualType(…) is of type Matcher<QualType>, not Matcher<Decl>.
>
> Any insight that anyone can provide would be very helpful.
>
> Best,
>
>
> Christian Schafmeister
> Associate Professor
> Chemistry Department
> Temple University
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140223/82d372f7/attachment.html>
More information about the cfe-dev
mailing list