[cfe-dev] clang Find the last #include
于 秋沣 via cfe-dev
cfe-dev at lists.llvm.org
Fri Dec 8 01:24:51 PST 2017
I'm working on a project which given a C/C++ source code, I need to find the last #include and insert one additional #include right after that. For example, suppose I have a file called Test.c which looks like this:
// some code here...
I want to get the location of the #include <stdlib.h> and insert one extra #include, then the code should be like this:
// some code here....
I feel like the right class I need to use is clang::Preprocessor and clang::PPCallbacks, but I haven't figured out a way to implement this.
Any help would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev