[cfe-dev] How to match the locations of types?

Richard via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 11 07:47:32 PST 2016


I can use AST matchers to match things like functionProtoType(), but
they don't have any location information that I can find.

How do I use the AST matchers to match the specific locations in
source code that contain text describing types?

To be more specific with an example:

 1  extern void f();
 2  
 3  void f() {
 4  }
 5  
 6  int g() {
 7    f();
 8    return 1;
 9  }
10  
11  int main()
12  {
13    return g();
14  }

If I want to match the type "int", then I want to match lines 6 and 11.

If I want to match the type "void()", then I want to match lines 1 and 3.

When I experiment with clang-query, it reports a bunch of matches, but
they have no matched output and they report no locations, so I have no
idea how this is useful.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list