[clang] [libclang/python] Expose Rewriter to the python binding (PR #77269)

Jimmy Z via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 23 07:57:06 PST 2024


jimmy-zx wrote:

Added flush before calling `writeMainFileToStdOut`.

Personally I didn't find this function particularly useful: I was hoping to perform rewriting without creating new files, but seems like capturing stdout from a shared library requires some complex operation (`dup2` stuff).

`Rewriter::getRewrittenText()` might be a more interesting interface to interact with, which returns the rewritten content as a string. (This is defined in clang but not exposed by libclang yet).

https://github.com/llvm/llvm-project/blob/179ba129f50aefe6e670800aec7091d958aa6f90/clang/lib/Rewrite/Rewriter.cpp#L180

https://github.com/llvm/llvm-project/pull/77269


More information about the cfe-commits mailing list