[cfe-commits] [PATCH] PR4111, PR5925, PR13210: Make tentative parsing smarter in the presence of undeclared identifiers

Richard Smith richard at metafoo.co.uk
Wed Jul 25 15:14:31 PDT 2012


Ping.

On Thu, Jul 19, 2012 at 4:05 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> Doug, would you mind looking over this when you have time? It's a bit of a
> new direction for tentative parsing.
>
>
> On Fri, Jul 13, 2012 at 12:19 AM, Sean Silva <silvas at purdue.edu> wrote:
>
>> If you're waiting on me, go ahead. My suggestion was just a "peephole"
>> suggestion.
>>
>> --Sean Silva
>>
>> On Thu, Jul 12, 2012 at 9:18 PM, Richard Smith <richard at metafoo.co.uk>
>> wrote:
>> > Patch rebased to ToT.
>> >
>> >
>> > On Sun, Jul 8, 2012 at 2:11 PM, Richard Smith <richard at metafoo.co.uk>
>> wrote:
>> >>
>> >> Ping.
>> >>
>> >>
>> >> On Fri, Jun 29, 2012 at 12:49 PM, Richard Smith <richard at metafoo.co.uk
>> >
>> >> wrote:
>> >>>
>> >>> On Fri, Jun 29, 2012 at 11:46 AM, Sean Silva <silvas at purdue.edu>
>> wrote:
>> >>>>
>> >>>> +      case ANK_TentativeDecl:
>> >>>> +      case ANK_TemplateName:
>> >>>> +        // These two shouldn't happen.
>> >>>> +      case ANK_Unresolved:
>> >>>>         break;
>> >>>>
>> >>>> assert?
>> >>>
>> >>>
>> >>> Sorry, I forgot to update that comment after some refactoring. The
>> second
>> >>> case is possible (but only for ill-formed code), and the first case is
>> >>> completely harmless. I've updated and simplified this code to remove
>> the
>> >>> switch entirely:
>> >>>
>> >>>   case tok::identifier: {
>> >>>     Token Next = NextToken();
>> >>>     if (Next.is(tok::colon)) { // C99 6.8.1: labeled-statement
>> >>>       // identifier ':' statement
>> >>>       return ParseLabeledStatement(Attrs);
>> >>>     }
>> >>>
>> >>>     // Look up the identifier, and typo-correct it to a keyword if
>> it's
>> >>> not
>> >>>     // found.
>> >>>     if (Next.isNot(tok::coloncolon)) {
>> >>>       // CorrectionCandidateCallback by default allows
>> typo-correction to
>> >>>       // anything which can appear at the start of a statement.
>> >>>       CorrectionCandidateCallback DefaultValidator;
>> >>>       if (TryAnnotateName(/*IsAddressOfOperand*/false,
>> &DefaultValidator)
>> >>>             == ANK_Error) {
>> >>>         // Handle errors here by skipping up to the next semicolon or
>> >>> '}', and
>> >>>         // eat the semicolon if that's what stopped us.
>> >>>         SkipUntil(tok::r_brace, /*StopAtSemi=*/true,
>> >>> /*DontConsume=*/true);
>> >>>         if (Tok.is(tok::semi))
>> >>>           ConsumeToken();
>> >>>         return StmtError();
>> >>>       }
>> >>>
>> >>>       // If the identifier was typo-corrected, try again.
>> >>>       if (Tok.isNot(tok::identifier))
>> >>>         goto Retry;
>> >>>     }
>> >>>
>> >>>     // Fall through
>> >>>   }
>> >>>
>> >>
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120725/9a096c39/attachment.html>


More information about the cfe-commits mailing list