Clang contains a library called "CIndex", which I suppose was designed to run code in the IDE. It can also be used for parsing C ++ and navigating through AST, but has no way to refactor it. See Eli Bendersky's article here .
I recently launched such a project: cmonster . This is a Python-based API for C ++ parsing (using libclang), AST parsing, with an interface for "rewriting" (i.e., Insert / delete / change source ranges). There is no good way (yet) for doing things like changing the names of functions and converting them to the original modifications, but it would not be so difficult to do.
I have not created an issue with this functionality yet (although this is also in the github repo), since I am waiting for llvm / clang 3.0 to be released.
In addition, I have to point out a few things:
- The code is very rude, calling it alpha might be generous.
- I am by no means an expert on this issue (in contrast, say, Dr. Ira Baxter).
Adjust your expectations accordingly.
Update: cmonster 0.2 has been released, which includes the features described. Check out on github .
axw Nov 02 2018-11-11T00: 00Z
source share