This is an archive of the discontinued LLVM Phabricator instance.

Template class: emit better diagnostic in case of missing template argument list
AbandonedPublic

Authored by davide on Oct 18 2015, 8:43 PM.

Details

Reviewers
rsmith
Summary

Richard, this implements what you proposed in https://llvm.org/bugs/show_bug.cgi?id=25223 , hopefully in the correct way.
This is what we emit now:

template.cpp:7:3: error: missing template argument list for class template 'X'
T X::foo(void)

^
X<T, Q>

template.cpp:2:7: note: 'X' declared here
class X {

^

1 error generated.

I will tackle the case where we emit a terrible diagnostic for ambigous lookup separately.

Diff Detail

Event Timeline

davide updated this revision to Diff 37716.Oct 18 2015, 8:43 PM
davide retitled this revision from to Template class: emit better diagnostic in case of missing template argument list.
davide updated this object.
davide added a reviewer: rsmith.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: cfe-commits.
davide added a comment.Nov 1 2015, 8:57 AM

Gentle ping.

Gentle Monday morning ping :)

rsmith added inline comments.Nov 9 2015, 5:58 PM
lib/Sema/SemaCXXScopeSpec.cpp
775–787

This isn't quite the right thing to do; it's looking at the template parameters of the class template rather than the current template parameters, and they could be quite different. Instead, you should do something like:

  1. Check that the Scope (S) is a TemplateParamScope
  2. Walk that scope, extract all of its declarations, and check that they match in type and kind the template parameters of CTD
  3. If so, produce a suggestion using the names of those template parameters, as found in the scope
789

A FixItHint should only be attached to an error or warning diagnostic if we recover as if the fix-it were applied. Maybe move this to a separate note diagnostic instead?

790

You don't need to do this; ND will always be the same as CTD here.

791

Just pass CTD in here instead of using &Identifier.

792–793

No newline between } and else, please.

796

Likewise.

davide abandoned this revision.Sep 9 2016, 1:45 PM