[cfe-dev] Keeping invalid AST nodes

Erik Verbruggen erik.verbruggen at me.com
Mon Nov 5 04:18:27 PST 2012


When using libclang for syntax highlighting, I noticed that no AST nodes get built for e.g. invalid expressions. For example, in the following C++ code:

int func(int i) {
    int j = undefinedFunction(i) + i;
    return j;
}

the whole initialisation for int j gets dropped, including the (somewhat) valid references to i. I understand that this is done to keep the AST valid after parsing, but an IDE or refactoring tools cannot help out with fixing the problem in that snippet. My question: is there some way to keep the invalid AST nodes, or is somebody already working on this?

Regards,
Erik.




More information about the cfe-dev mailing list