[cfe-dev] AST matcher "refersToType"
Stephen Kelly via cfe-dev
cfe-dev at lists.llvm.org
Sun Oct 20 02:28:43 PDT 2019
On 18/10/2019 20:56, Brian Schiller via cfe-dev wrote:
> I believe I've found a mistake in the documentation for the
> `refersToType` AST matcher:
> https://clang.llvm.org/docs/LibASTMatchersReference.html#refersToType0
>
> The example code makes use of a matcher called `class`, but I am unable
> to find such a matcher in the docs, and when I try to use it in
> clang-query I get a "matcher not found" error.
>
> I'd be happy to make a patch to the docs, but am actually having trouble
> using the `refersToType` matcher at the moment. I'm trying to match
> calls to `std::make_unique` specialized with a particular class. That
> is, I want `std::make_unique<Demo::Widget>`, but not
> `std::make_unique<Something::Else>`. I'd also be happy with a way to
> filter for the correct matches in the MatchCallback.
You need `refersToType(asString("class Demo::Widget")))`.
Unfortunately this is not very discoverable. I showed some tooling to
make this discoverable here:
https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching-refactoring-tools-eurollvm-and-accu/
but it's not generally available yet.
Thanks,
Stephen.
More information about the cfe-dev
mailing list