[cfe-dev] can Clang Plugin modify the AST and send it back to the next step of compliation?

Miklos Vajna via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 2 02:24:51 PDT 2020


Hi,

On Wed, Sep 02, 2020 at 02:36:38PM +0800, Yafei Liu via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> All the examples of Clang plugin and FrontendActions I've read are to get
> the AST and print some information, I'm curious if I can modify the AST to
> make some dialect C++ language?
> 
> I got some examples I think is easy to do if AST could be modified:
> 1. make all subclasses inherit baseclasses' friend class
> 2. make all method virtual (like Java)

The typical workflow is to emit fixits/replacements and then apply them,
rather than modifying the AST. clang-tidy has plenty of checks which do
this already.

Regards,

Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200902/467f9756/attachment.sig>


More information about the cfe-dev mailing list