This is an archive of the discontinued LLVM Phabricator instance.

improve diagnostics for missing 'template' keyword
ClosedPublic

Authored by rsmith on Jun 25 2018, 2:57 PM.

Details

Summary

We track when we see a name-shaped expression followed by a < token that we parse as a comparison. Then:

  • if we see a token sequence that cannot possibly be an expression but can be a template argument (in particular, a type-id) that follows either a , or the <, diagnose that the < was supposed to start a template argument list
  • if we see <>, diagnose that the <> was supposed to be a template argument list
  • if we see >(), diagnose that the <[...]> was supposed to be a template argument list

This only changes the diagnostic for error cases, and in practice appears to catch the most common cases where a missing template keyword leads to parse errors within a template.

Diff Detail

Repository
rL LLVM

Event Timeline

rsmith created this revision.Jun 25 2018, 2:57 PM
This revision was not accepted when it landed; it landed in state Needs Review.Jun 26 2018, 11:48 AM
This revision was automatically updated to reflect the committed changes.
kparzysz reopened this revision.Jun 26 2018, 12:10 PM
kparzysz added a subscriber: kparzysz.

This needs to be restored to the original form. A mistake in a commit message closed this review by accident.

kparzysz commandeered this revision.Jun 26 2018, 12:59 PM
kparzysz updated this revision to Diff 152946.
kparzysz added a reviewer: rsmith.

Restored the original patch.

Please take over, I commandeered to restore the patch.

rsmith commandeered this revision.Jun 26 2018, 1:33 PM
rsmith edited reviewers, added: kparzysz; removed: rsmith.
dblaikie accepted this revision.Jun 26 2018, 3:04 PM

Looks pretty good to me - nice work!

This revision is now accepted and ready to land.Jun 26 2018, 3:04 PM
This revision was automatically updated to reflect the committed changes.