[cfe-dev] Is there a way to run ASTConsumer plugin inspite of compile errors?

chaitanya vadrevu chaitanya973 at gmail.com
Thu Apr 9 18:15:33 PDT 2015


Hi All,

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.

//original code
class A{
....
};

//modified code after plugin is run
class A{
  void newfn() {...}
};

This works fine as long as there are no compile errors. But there are cases
when the absence of the
function is causing the compilation to fail. E.g., the following code which
expects class A to contain the function.

template<typename T>
class B{
  T t;
  B() {
    t.newfn();
  }
};

Due to the compilation errors, my plugin is not executed.

So the compilation wont proceed unless the function is already present and
the function can't be added unless compilation succeeds.

Is there a way to solve this?

Thanks,
Chaitanya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150409/78d5a0c6/attachment.html>


More information about the cfe-dev mailing list