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

Craig Hesling via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 27 15:00:19 PST 2024


linux4life798 wrote:

> Added flush before calling `writeMainFileToStdOut`.

I think that's reasonable.

> 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

I agree. This should probably be exposed to libclang (and then to this python binding).

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


More information about the cfe-commits mailing list