[cfe-dev] Is there a way to run ASTConsumer plugin inspite of compile errors?
chaitanya vadrevu
chaitanya973 at gmail.com
Sun Apr 19 13:19:54 PDT 2015
Thanks Nikola. I don't mind doing multiple passes but yes, I don't know if
even that is possible.
Is there any other way to solve this problem using plugins (maybe insert
code as soon as a class definition is found during parsing stage itself)?
Thanks,
Chaitanya
On Fri, Apr 17, 2015 at 11:51 PM, Nikola Smiljanic <popizdeh at gmail.com>
wrote:
> In general clang produces ast only for valid code. I don't think you'll be
> able to get this working if your starting point is code that doesn't
> compile. In the example you gave you might be able to get away with it so
> long as you don't compile the instantiation of B<A> as that's what produces
> the error. But this essentially means having code that compiles...
>
> The only other thing that comes to my mind is having multiple passes in
> the hope that each insertion you perform removes errors and allows you to
> continue. I have no idea how feasible this would be.
>
> On Fri, Apr 10, 2015 at 11:15 AM, chaitanya vadrevu <
> chaitanya973 at gmail.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150419/9e2ab31e/attachment.html>
More information about the cfe-dev
mailing list