[cfe-dev] How to go about generating wrapper functions when a particular attribute is seen?

Seth Goldstein via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 15 19:32:13 PST 2017


I am wondering what the best approach would be to generate a wrapper
function for functions with a particular attribute.  I.e.,

When the compiler sees

__attribute__ ((wrapthis)) int foo(args) {}

I want to generate foo as usual and also generate a function

int
foo_wrapper(args)
{
// do some stuff here
int result = foo(args);
// do some more stuff here
return result;
}

I am not sure where to generate the wrapper function, e.g., in clang,
in llvm?  And, what pass could I look at that might provide me with
some hints about how to go about this.  Any help would be appreciated.

Thanks,

seth



--------------
Seth Copen Goldstein
Carnegie Mellon University
Computer Science Dept
7111 GHC
412-268-3828
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171115/024639b4/attachment.html>


More information about the cfe-dev mailing list