<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 15, 2017, at 10:32 PM, Seth Goldstein via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I am wondering what the best approach would be to generate a wrapper</div><div class="">function for functions with a particular attribute. I.e.,</div><div class=""><br class=""></div><div class="">When the compiler sees</div><div class=""><br class=""></div><div class="">__attribute__ ((wrapthis)) int foo(args) {}</div><div class=""><br class=""></div><div class="">I want to generate foo as usual and also generate a function</div><div class=""><br class=""></div><div class="">int</div><div class="">foo_wrapper(args)</div><div class="">{</div><div class=""><span style="white-space:pre" class=""> </span>// do some stuff here</div><div class=""><span style="white-space:pre" class=""> </span>int result = foo(args);</div><div class=""><span style="white-space:pre" class=""> </span>// do some more stuff here</div><div class=""><span style="white-space:pre" class=""> </span>return result;</div><div class="">}</div><div class=""><br class=""></div><div class="">I am not sure where to generate the wrapper function, e.g., in clang,</div><div class="">in llvm? And, what pass could I look at that might provide me with</div><div class="">some hints about how to go about this. Any help would be appreciated.</div></div></div></blockquote><div><br class=""></div>A feature like this could be implemented in many different ways, so it's hard to answer</div><div>your question without more basic information. How are you anticipating this wrapper</div><div>function being used? Are all existing uses of the function re-routed to it? Is it important</div><div>that "ignorant" translation units use the wrapper function? Is it important that ignorant</div><div>translation units <i class="">not</i> use the wrapper function? What's the basic goal here?</div><div><br class=""></div><div>John.</div></body></html>