Disable

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

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