Refactoring tool using Python bindings

Hi All,

I want to write tool in python which will go through every source file and add preprocessor macro to the file.

#include <stdio.h>
#include “my_header.h” // This should be inserted by clang python tool

int main() {

}

How can I do this using Python bindings?

Thanks
Riyad

You don’t really need Clang for something as simple as that, whatever you code in next 5 minutes will likely work in almost all circumstance :slight_smile:
PPCallback is what you’d use in Clang, I’m not sure if that’s accessible through Python, hopefully someone who know will chime in.

I admit it’s simple, can be doable without Clang. Basically, I’m developing a refactoring tool which do some analysis on source and then decide whether to include a header file or not. So it would be nice if I can do this in one tool.

I realize this can’t be done via Python bindings. Any one has any idea how I can do this using Clang refactoring lib?

Thanks
Riyad