<div dir="ltr"><div><span style="font-size:12.8000001907349px">Hi All,</span></div><div><span style="font-size:12.8000001907349px"><br></span></div><span style="font-size:12.8000001907349px">I developed a clang plugin which uses AST matchers to find interesting record declarations and automatically inserts a function (lets say newfn()) along with some boiler plate code.</span><div style="font-size:12.8000001907349px"><br class=""><span style="font-size:12.8000001907349px">//original code</span><br></div><div style="font-size:12.8000001907349px">class A{</div><div style="font-size:12.8000001907349px">....</div><div style="font-size:12.8000001907349px">};</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">//modified code after plugin is run</div><div style="font-size:12.8000001907349px">class A{</div><div style="font-size:12.8000001907349px">  void newfn() {...<span style="font-size:12.8000001907349px">}</span></div><div style="font-size:12.8000001907349px">};</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">This works fine as long as there are no compile errors. But there are cases when the absence of the</div><div style="font-size:12.8000001907349px">function is causing the compilation to fail. E.g., the following code which expects class A to contain the function.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">template<typename T></div><div style="font-size:12.8000001907349px">class B{</div><div style="font-size:12.8000001907349px">  T t;</div><div style="font-size:12.8000001907349px">  B() {</div><div style="font-size:12.8000001907349px">    t.newfn();</div><div style="font-size:12.8000001907349px">  }</div><div style="font-size:12.8000001907349px">};</div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"><br></span></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">Due to the compilation errors, my plugin is not executed.</span></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"><br></span></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">So the compilation wont proceed unless the function is already present and the function can't be added unless compilation succeeds.</span><br></div><div style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"><br></span></div><div style="font-size:12.8000001907349px">Is there a way to solve this?</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks,</div><div style="font-size:12.8000001907349px">Chaitanya</div></div>