
On Tue, Sep 7, 2010 at 7:16 AM, Thomas Klimpel <Thomas.Klimpel@synopsys.com> wrote:
Doug Gregor wrote:
Dave Abrahams wrote:
Now it's my turn to be a little skeptical. I can't imagine a compiler would ever try to do error recovery by throwing out all the information from #include files you had already processed.
Heck no! But in the absence of information (e.g., an #include couldn't be found, or an identifier is horribly mis-typed), such approaches could drastically improve recovery.
From my naive user point of view, there is a "preprocessing" step, a "compilation" step and a "linking" step. As a compiler user, I would prefer that the compiler doesn't start the "compilation" step in case the "preprocessing" step failed (e.g., an #include couldn't be found). Similar, I would prefer that the compiler doesn't start the "link" step in case the "compilation" step failed.
The right answer often depends on how you're using the parser. As a compiler, Clang stops parsing after a missing #include, because there's rarely any point in continuing the parse. When performing syntax highlighting or code completion, you want results even though the source is never actually going to compile. - Doug