This is an archive of the discontinued LLVM Phabricator instance.

[ASTContext] Fix part of DR224 for nontype template arguments
AbandonedPublic

Authored by mgehre on Jul 20 2016, 1:25 PM.

Details

Summary

Look through expressions to determine if a nontype template argument has been given the value of the template parameter.

Diff Detail

Event Timeline

mgehre updated this revision to Diff 64746.Jul 20 2016, 1:25 PM
mgehre retitled this revision from to [ASTContext] Fix part of DR224 for nontype template arguments.
mgehre updated this object.
mgehre added reviewers: klimek, aaron.ballman, rsmith.
mgehre added a subscriber: cfe-commits.
aaron.ballman edited edge metadata.Jul 21 2016, 8:49 AM

Generally LGTM with a small nit.

lib/AST/ASTContext.cpp
4456

const auto * (and propagate it to other declarations)?

mgehre added inline comments.Jul 21 2016, 2:34 PM
lib/AST/ASTContext.cpp
4456

Unfortunately, the TemplateArgument constructor in

return TemplateArgument(DeclRef);

takes a Expr* (and not a const Expr*).

rsmith edited edge metadata.Aug 9 2016, 5:03 PM

Discussion on the core reflector suggests that we should use odr-style equivalence when identifying the current instantiation, and not look through static const member initializers as the example in the standard suggests. Let's hold off on this until CWG has a chance to discuss it in person.

I'm sorry if this sounds dumb, but is there a way for me to follow that particular discussion?

mgehre marked an inline comment as done.Jan 24 2017, 2:34 PM

I'm sorry if this sounds dumb, but is there a way for me to follow that particular discussion?

Only if you have access to the C++ committee's internal reflectors. Sadly this is not on the issues list yet either (it only lists issues reported up to the end of June 2016, and this was filed in July). The suggestion from the end of the discussion thread was that the right rule for recognising an injected-class-name is that the template argument must be equivalent to the template parameter for the primary template / template argument for a partial specialization, using the rules in [temp.over.link] to determine equivalence. (Thus not even parentheses surrounding a non-type template argument are permitted.) There seems to be consensus that dr224 was a mistake.

mgehre abandoned this revision.Mar 1 2017, 12:39 PM