Disable

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Disable

Andrey Tarasevich
Hello

I'm doing some source-to-source manipulations. Is it possible to disable lexical analyzing during parsing? I mean, if there is an error during parsing, for instance consider following code sample

void main()
{
    int *a = NULL;
    int b = 0;
    b++;
}

clang will indicate error for a NULL, since stdlib.h is not included. And that statement will be ignored for the AST generation. Is it possible to make clang ignore such errors and generate AST as there are no errors?

With best regards,
Andrey Tarasevich

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Disable

Douglas Gregor

On Apr 6, 2011, at 11:55 AM, Andrey Tarasevich wrote:

> Hello
>
> I'm doing some source-to-source manipulations. Is it possible to disable lexical analyzing during parsing? I mean, if there is an error during parsing, for instance consider following code sample
>
> void main()
> {
>     int *a = NULL;
>     int b = 0;
>     b++;
> }
>
> clang will indicate error for a NULL, since stdlib.h is not included. And that statement will be ignored for the AST generation. Is it possible to make clang ignore such errors and generate AST as there are no errors?

No. Clang (intentionally) drops ill-formed ASTs, so that the ASTs it does create meet certain invariants, which makes Clang itself more robust in the face of errors.

Besides, if you're doing source-to-source transformations on ill-formed code, how do you know whether the resulting, transformed code is still correct?

        - Doug

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev