Page MenuHomePhabricator

Modules: Search for a visible definition of the decl context when computing visibility of a default template parameter

Authored by dblaikie on Apr 18 2019, 3:45 PM.



The code is/was already correct for the case where a parameter is a
parameter of its enclosing lexical DeclContext (functions and classes).
But for other templates (alias and variable templates) they don't create
their own scope to be members of - in those cases, they parameter should
be considered visible if any definition of the lexical decl context is

[this should cleanup the failure on the libstdc++ modules buildbot]
[this doesn't actually fix the variable template case for a
secondary/compounding reason (its lexical decl context is incorrectly
considered to be the translation unit)]

Test covers all 4 kinds of templates with default args, including a
regression test for the still broken variable template case.

Event Timeline

dblaikie created this revision.Apr 18 2019, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2019, 3:45 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rsmith accepted this revision.Apr 19 2019, 3:17 PM

LGTM, with a possible optimization. Thank you! I know this bug was incredibly hard to track down. =)

1551 ↗(On Diff #195825)

You can avoid the linear search with:

SearchDefinitions = D->getIndex() >= TPL->size() || TPL->getParam(D->getIndex()) != D;
This revision is now accepted and ready to land.Apr 19 2019, 3:17 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2019, 4:01 PM