This is an archive of the discontinued LLVM Phabricator instance.

Added missing unqualified name lookup of operator overloads for fold expressions
Needs ReviewPublic

Authored by jonathanmeier on Sep 5 2019, 5:22 PM.

Details

Reviewers
rsmith
Group Reviewers
Restricted Project
Summary

Valid operator overloads for fold expressions are not found in the current scope, since unqualified name lookup is not performed.

This is a proposal to fix Bug 30590 (and its duplicates Bug 30738 and Bug 42518). The core issue is that fold expressions get expanded during template instantiation (second phase of name lookup) when the current scope is not available anymore (current scope is available in the first phase of name lookup, i.e. while parsing the template definition).

My approach is to attach to the fold expression the operator overload candidates found by the unqualified name lookup while parsing. During template instantiation these candidates are then considered when the fold expressions are expanded and the actual binary operations are built.

Please comment on whether you deem this a reasonable approach or if you know of a better way of solving the issue.

Diff Detail

Event Timeline

jonathanmeier created this revision.Sep 5 2019, 5:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2019, 5:22 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jonathanmeier changed the repository for this revision from rC Clang to rG LLVM Github Monorepo.
  • Rebased to adapt to the latest changes for spaceship operator and comparison operator rewrite support in rL375305 and rL375306.
  • Added tests for comparison operator rewrites in fold expressions.
  • Changed to using llvm::iterator_range instead of separate begin/end iterators.

ping @rsmith