building a custom plugin

Hi LLVM Devs,

I am in the process of building my own plugin for Clang/LLVM in Windows
on Visual Studio. I am having difficulty generating the .dll shared file to use
at compile time. How have the .dlls corresponding to the example plugins
been built?

This works:

clang -fplugin=C:/Users/User/llvm-project/build/Release/bin/PrintFunctionNames.dll -Xclang -plugin -Xclang print-fns test.c

This doesn’t

clang -fplugin=C:/Users/User/llvm-project/build/Release/bin/MyPlugin.dll -Xclang -plugin -Xclang my-plugin test.c



The code for building the PrintFunctionNames plugin is available here:


Hey LLVM Devs,

I am trying to see if I can use clang plugins to edit
the AST and change the executable output. Any pointers on
whether I’m doing this correctly?

running my plugin:

clang -Xclang -load -Xclang C:\Users\User\llvm-project\build\Release\bin\MyPlugin.dll -Xclang -add-plugin -Xclang my-plugin test.c -o test.exe

how i’m editing the AST (in my Visitor class):

Note: The test.exe generated in the above process does not appear to be affected by any changes made to the AST by the plugin



Source1.cpp (1.96 KB)