This generally looks good except that the last expected-error should be on the following line (not great, since it doesn't appear at the bad token, but nothing new there). Other than that - LGTM.
*vim users celebrate* - David On Wed, Apr 11, 2012 at 1:11 PM, Richard Smith <[email protected]> wrote: > Ping. A slightly modified patch is attached: the r_brace check got lost in > some refactorings. > > > On Tue, Apr 3, 2012 at 1:27 PM, Richard Smith <[email protected]> wrote: >> >> Hi, >> >> Currently, after a malformed declaration, clang skips until it reaches an >> unparenthesized '}' or ';'. One fairly common error (especially among vim >> users) is for the first line of a file to have junk in it. This leads to >> abysmal error recovery, where we skip all 'namespace { ... }' and 'extern >> "C" { ... }' blocks and function definitions until we get to a top-level >> semicolon (which often doesn't arrive until we're past all the #included >> header files and somewhere in the main source file). We then produce a large >> pile of incorrect diagnostics, because we have not seen any declarations >> yet. >> >> The attached patch improves this situation by tweaking the recovery >> heuristic as follows: we skip the shortest sequence of >> brace/bracket/paren-balanced tokens which either ends with a semicolon or a >> close brace[1] (and any following semicolon), or is followed by a namespace >> definition at the start of a line. >> >> In my testing, this seems to be a strict improvement. Does this seem like >> a reasonable change? I'm sure there are other places where this style of >> recovery would be a better option than a simple SkipUntil(tok::r_brace), but >> I don't have evidence of a specific common pattern of errors leading to poor >> recovery elsewhere. >> >> Thanks! >> Richard >> >> [1] If the close brace is followed by ',', '{' or 'try', we could be in >> the initializer-list for a constructor, so we keep skipping. >> >> > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
