I am writing a libtooling refactoring tool. I have a class, say Foo , defined in the foo.h header. I want to see if foo.h included in the file. Currently, to check if bar.cc includes foo.h , I just use recordDecl(hasName("Foo")) . This works because class Foo { ... }; will exist inside bar.cc AST after pre-processing if bar.cc includes bar.cc
But this does not work if, for example, bar.cc includes cat.h , which includes foo.h I want bar.cc EXPLICITLY to include bar.cc
In addition, I would like to be able to match #define macros.
The way I wrote my tool made these two goals impossible, because the AST, with which I agree, has already been pre-processed. Is what I'm trying to do even possible? I dug up a link to the Preprocessor class on the Clang Doxygen pages, but I didn’t quite find what I was looking for.
source share