banach-space / clang-tutor

A collection of out-of-tree Clang plugins for teaching and learning
The Unlicense
692 stars 62 forks source link

Example for instrumenting source code #1

Open ArchanaaSK opened 4 years ago

ArchanaaSK commented 4 years ago

Thank you! This is very helpful. Do you have any example plugins for adding functions to source code? I would like an example for adding a new function, with simple and complex variables(like structures ), which also uses inputs form the original source code. For example, an example plugin to ASTMatcher and Rewriter/Refactoring/Replacement tools in a plugin.

banach-space commented 4 years ago

Hi @ArchanaaSK,

Thank you for visiting and for your question!

Do you have any example plugins for adding functions to source code?

No, I've not tried implementing anything like that for Clang. Do you have a motivating example? This could be an interesting thing to try! Although, to be perfectly honest, I'm not sure where such function should be defined.

I did implement something similar for LLVM IR. See here and here.