[cfe-dev] Keeping invalid AST nodes

Sean Silva silvas at purdue.edu
Mon Nov 5 10:25:50 PST 2012


> No, there's no way to keep them, and AFAIK nobody is working on this.
> I'm also not sure it's worthwhile: it's a ton of work for a use case
> which doesn't seem very important, given that the vast majority of
> code people care about is valid.

However, there is an important use case where the code is almost
always invalid: IDE "intellisense" while you are typing new code.

Xcode seems to handle this fairly well. I wonder how it does it?

-- Sean Silva

On Mon, Nov 5, 2012 at 1:02 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Mon, Nov 5, 2012 at 4:18 AM, Erik Verbruggen <erik.verbruggen at me.com> wrote:
>> 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?
>
> No, there's no way to keep them, and AFAIK nobody is working on this.
> I'm also not sure it's worthwhile: it's a ton of work for a use case
> which doesn't seem very important, given that the vast majority of
> code people care about is valid.
>
> -Eli
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list