[PATCH] D108283: [flang][driver] Add documentation for Plugins

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 20 02:51:49 PDT 2021


kiranchandramohan added subscribers: klausler, kiranchandramohan.
kiranchandramohan added a comment.

Can you clarify where the plugins should reside? I am guessing that the examples directory is just for examples. Is it in tools? Or can it be anywhere including out of tree?

In Flang the frontend consists of a parse-tree as well as a high-level IR. For clarity should we specify that this is for Parse Tree plugins? Should we further clarify that we are enabling the plugins after semantic checks?



================
Comment at: flang/docs/FlangDriver.md:289
+## Creating the Plugin
+The two parts required for Plugins to work are:
+1. A main class that inherits from `PluginParseTreeAction`
----------------
awarzynski wrote:
> I would expand this into 3 parts (copying code from https://reviews.llvm.org/D107089, every item is one part):
> * `class PrintFunctionNamesAction : public PluginParseTreeAction` that wraps everything together and represents the frontend action class corresponding to your plugin
> * `PrintFunctionNamesAction::ExecuteAction` that implements the actual action (i.e. **what** it does)
> * `static FrontendPluginRegistry::Add<PrintFunctionNamesAction> X` that registers the plugin
> 
> It would also be worthwhile to mention `struct ParseTreeVisitor` (and `Pre` and `Post` methods). No need to go into too much detail - you can provide links to the relevant docs/implementation.
As @awarzynski says it will be beneficial to mention the mechanism used to traverse the parse-tree. The clang plugins page calls out the RecursiveAstVisitor.
https://clang.llvm.org/docs/ClangPlugins.html#introduction

Since this is the API (Visitor class with Pre and Post functions) that we are exposing for traversing, it will also be good to get approval from @klausler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108283



More information about the llvm-commits mailing list