This is an archive of the discontinued LLVM Phabricator instance.

[Parser] Avoid spurious 'missing template' error in presence of typos
ClosedPublic

Authored by hokein on Aug 1 2019, 10:28 AM.

Details

Summary

Suppress those diagnostics if lhs of a member expression contains
errors. Typo correction produces dependent expressions even in
non-template code, that led to spurious diagnostics before.

Also includes a small refactoring to improve code calling
ParseUnqualifiedId and ParseOptionalCXXScopeSpecifier in the common case
when ObjectType is null. This allows to avoid boiler plate required to
propagate whether lhs of a member expression had any errors in the
common code path.

previous:

/tmp/t.cpp:6:17: error: use 'template' keyword to treat 'f' as a dependent template name
auto a = bilder.f<int>();
                ^
                template
/tmp/t.cpp:6:10: error: use of undeclared identifier 'bilder'; did you mean 'builder'?
auto a = bilder.f<int>();
         ^~~~~~
         builder

vs now:

/tmp/t.cpp:6:10: error: use of undeclared identifier 'bilder'; did you mean 'builder'?
auto a = bilder.f<int>();
         ^~~~~~
         builder

Diff Detail

Event Timeline

ilya-biryukov created this revision.Aug 1 2019, 10:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2019, 10:28 AM
nridge added a subscriber: nridge.Mar 12 2020, 6:54 AM
hokein updated this revision to Diff 250183.Mar 13 2020, 5:34 AM
hokein added a subscriber: hokein.
  • rebase to master
  • update some comments
hokein commandeered this revision.Mar 13 2020, 5:37 AM
hokein added a reviewer: ilya-biryukov.
hokein updated this revision to Diff 250184.Mar 13 2020, 5:41 AM

remove an accident change.

hokein edited the summary of this revision. (Show Details)Mar 13 2020, 5:42 AM
hokein added a reviewer: sammccall.
Harbormaster completed remote builds in B49128: Diff 250184.
hokein updated this revision to Diff 251303.Mar 19 2020, 1:13 AM

rebase to master.

sammccall accepted this revision.Mar 19 2020, 4:22 AM

Nice!

I don't love adding those overloads, but not clear there's something better.

clang/lib/Parse/ParseExprCXX.cpp
2973

I'd consider inlining these convenience overloads

clang/lib/Parse/ParseTemplate.cpp
685

nit: ObjectHadErrors=

685

this can use the simple overload, ParsedType() is the same as nullptr

This revision is now accepted and ready to land.Mar 19 2020, 4:22 AM
hokein updated this revision to Diff 251379.Mar 19 2020, 7:35 AM

address review comments, remove the overload.

This revision was automatically updated to reflect the committed changes.