Writing AST plugins
In the previous section, we learned how AST is represented in Clang and learned what its in-memory classes look like. We also learned about some useful skills we can use to perform pattern matching on Clang AST. In this section, we will learn how to write plugins that allow you to insert custom AST processing logic into Clang's compilation pipeline.
This section will be divided into three parts:
- Project overview: The goal and overview of the demo project we are going to create in this section.
- Printing diagnostic messages: Before we dive into the core of developing a plugin, we are going to learn how to use Clang's
DiagnosticsEngine
, a powerful subsystem that helps you print out well-formatted and meaningful diagnostic messages. This will make our demo project more applicable to real-world scenarios. - Creating the AST plugin: This section will show you how to create an AST plugin from scratch, fill in all the implementation details, and...