https://eli.thegreenplace.net/2014/07/29/ast-matchers-and-clang-refactoring-tools/
clang-query + скрипты для него могут много интересного
классная штука, но почему она дублирует вывод? на тестовом файле в 5 строк, в котором есть только struct X { int x; };:
$ echo 'match recordDecl(hasName("X"))' | clang-query shush.cpp --
Match #1: /work/sources_a/tech1/shush.cpp:3:3: note: "root" binds here
struct X {
^~~~~~~~~~
Match #2: /work/sources_a/tech1/shush.cpp:3:3: note: "root" binds here
struct X {
^~~~~~~~
2 matches.
на файле из проекта:
$ echo 'match recordDecl(hasName("RingInfo"))' | clang-query src/ablock.cpp
Match #1: src/ablock.cpp:5169:2: note: "root" binds here
struct RingInfo {
^~~~~~~~~~~~~~~~~
Match #2: src/ablock.cpp:5169:2: note: "root" binds here
struct RingInfo {
^~~~~~~~~~~~~~~
Match #3: src/ablock.cpp:5169:2: note: "root" binds here
struct RingInfo {
^~~~~~~~~~~~~~~~~
Match #4: src/ablock.cpp:5169:2: note: "root" binds here
struct RingInfo {
^~~~~~~~~~~~~~~
4 matches.