[cfe-dev] Disable
Douglas Gregor
dgregor at apple.com
Mon Apr 11 17:39:44 PDT 2011
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
More information about the cfe-dev
mailing list