[PATCH] D21502: Fix heuristics skipping invalid ctor-initializers with C++11

Olivier Goffart via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 28 01:55:49 PDT 2016

ogoffart added a comment.


The problem i'm fixing here is how we recover invalid code in the ctor-init part as we skip the function body. 
In particular, we want to know if the '{' is the begining of the body or not. In C++03, we always consider it as the beginng of the body.  The problem was that in C++11 we don't, making the code skip too much, causing worse parse error later.

So what this patch is doing is finding heuristics to know if the '{' is starting a function body or not.
The rules are the following:  If we are not in a template argument, anf that the previous tokens are not an identifier, or a > , then it is much more likely to be the function body.  We verify that further by checking that the token after the matching '}'

I also changed the code to just ignore the code_completion token at this point. The previous code was making it thinking that it would then be a template argument. But this is not likely.


More information about the cfe-commits mailing list