[PATCH] D26350: Keep invalid Switch in the AST

Olivier Goffart via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 14 06:27:46 PDT 2017


ogoffart added a comment.

The problem i'm trying to solve is precisely to keep as much as possible of the valid AST in the main AST, despite errors.
I've already done some work with r249982, r272962 and more, and there is still a lot to do. But the goal is to keep as much as possible of it.

The reason i'm working on this is highlighting of code where some code might be potentially invalid (because you are editing it, or because the tool don't have access to all headers)
Things like if statement from my previous patch, or switch statement like this patch are the things which have the more impact, because not keeping them removes highlighting for potentially big blocks of code.

This is useful for example for IDE such as KDevelop which use clang for highlighting, or my own tool [code.woboq.org]

A random example is https://code.woboq.org/linux/linux/arch/arm/kernel/module.c.html?style=kdevelop#101
(generated with this patch applied.) There are errors because this is an arm file built with the option for an intel kernel. Yet, most of the file is properly highlighted. If this patch was not applied, the whole switch statement would be removed from the AST and nothing within would be hightlighted, only because some case label are invalid.


https://reviews.llvm.org/D26350





More information about the cfe-commits mailing list