[PATCH] D158055: [clang][AST] Added some missing setter methods

Timo Stripf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 17 03:01:42 PDT 2023


strimo378 added a comment.

Yes, I have a need for these setters :) but I cannot decide if the LLVM project in general or other people could profit from it.

I am working on a C++-to-C transpiler based on clang. Other clang-based tool typically modify the intput file based on FileLocation information. In contrast, I follow a constructive approach with AST print. The transpiler is organized in many small passes that transform the clang AST until at the end I can output the C code via AST print. Some notable passes are

- Remove unused AST decls (simplifies AST for non-trivial input)
- Resolve templates (is also useful standalone to remove templates from a C++ program)
- Resolve namespaces
- Move nested records
- Convert methods to functions
- etc.

For transforming the AST, I often need to replace Types and regenerate the corresponding TypeLoc. I tried for over one year to recreate AST nodes when a setter methods that was missing but that caused a lot of work and instabilities for maintaining cross references. For that reason, I now insert a new setter method when needed and until now surprising less setter methods are missing.

For me it takes 5-10 min per version upgrade to port the changes, so it is not a big deal for me if you refuse them. I have some other AST modification in place for removing templates information but nothing complex...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158055/new/

https://reviews.llvm.org/D158055



More information about the cfe-commits mailing list