Hi! This is my first time submitting a patch to LLVM/Clang, so apologies if I'm doing anything wrong. Eager to learn.
This patch exposes some additional Rewriter methods in libclang and the Python bindings, making it possible to write simple transformations in Python. This patch modifies the ABI signature of clang_CXRewriter_insertTextBefore. I do not know what the policy is regarding the modification of an existing API function in libclang, so you have been warned.
- Added clang_CXRewriter_getMainFileContents
- Added clang_CXRewriter_insertTextAfter
- Added a parameter to clang_CXRewriter_insertTextBefore to control indentation
- Modified clang_CXRewriter_insertTextBefore to accept an additional InsertIndent argument
- Added a Rewriter class in the Python bindings
- Added test_rewriter.py with some unit tests for the new Python bindings
- Applied clang-format@HEAD to the modified C++ files, which caused some of the existing lines to change
I did not discuss this change over at cfe-dev because I thought the change is fairly trivial. If all changes are required to go through cfe-dev first do let me know.