[cfe-dev] Inconsistency between clang-query and ASTmatcher with named values

David Come via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 21 04:34:16 PDT 2017


Hello,


There is an Inconsistency between clang-query and matcher with named values.

An user can declare a named value whose name contains an underscore. If 
used, clang-query reports (from libASTMatcher) a parsing error.

Example :

clang-query> let f fieldDecl(hasName("s"))
clang-query> match f

Match #1:

/home/david/code/pangolin/ws/resources/cpp_projects/test1/src/t.cpp:13:3: 
note: "root" binds here
   std::string s;
   ^~~~~~~~~~~~~
1 match.
clang-query> m recordDecl(has(f))

Match #1:

/home/david/code/pangolin/ws/resources/cpp_projects/test1/src/t.cpp:12:1: 
note: "root" binds here
struct B {
^~~~~~~~~~
1 match.
clang-query> let f_ fieldDecl(hasName("s"))
clang-query> match f_
1:3: Expected end of code.
clang-query> m recordDecl(has(f_))
1:2: Error parsing argument 1 for matcher recordDecl.
1:18: Error parsing matcher. Found token <_> while looking for ','.



Regards,

Côme David




More information about the cfe-dev mailing list