[cfe-dev] hasType(qualType(...)) is this a legal part of an ASTMatcher?

Christian Schafmeister chris.schaf at verizon.net
Sun Feb 23 07:46:14 PST 2014


If I read the documentation at http://clang.llvm.org/docs/LibASTMatchersReference.html correctly, the partial matcher  "hasType(qualType(…))" is not legal.

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/71242ce6/attachment.html>


More information about the cfe-dev mailing list