[C++17] Fix PR34970 - tweak overload resolution for class template deduction-guides...
authorFaisal Vali <faisalv@yahoo.com>
Sun, 22 Oct 2017 14:45:08 +0000 (14:45 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Sun, 22 Oct 2017 14:45:08 +0000 (14:45 +0000)
commit81b756e6a3e491d43ac18ed39a9ffb13f45b9ea4
tree762ec03f44a2797d6b752817939e266589ef56db
parent7ab2d0bdcdc218d83faa90751a2cf2f34587ccc1
[C++17] Fix PR34970 - tweak overload resolution for class template deduction-guides in line with WG21's p0620r0.

In order to identify the copy deduction candidate, I considered two approaches:
  - attempt to determine whether an implicit guide is a copy deduction candidate by checking certain properties of its subsituted parameter during overload-resolution.
  - using one of the many bits (WillHaveBody) from FunctionDecl (that CXXDeductionGuideDecl inherits from) that are otherwise irrelevant for deduction guides

After some brittle gymnastics w the first strategy, I settled on the second, although to avoid confusion and to give that bit a better name, i turned it into a member of an anonymous union.

Given this identification 'bit', the tweak to overload resolution was a simple reordering of the deduction guide checks (in SemaOverload.cpp::isBetterOverloadCandidate), in-line with Jason Merrill's p0620r0 drafting which made it into the working paper.  Concordant with that, I made sure the copy deduction candidate is always added.

References:
See https://bugs.llvm.org/show_bug.cgi?id=34970
See http://wg21.link/p0620r0

llvm-svn: 316292
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CXX/over/over.match/over.match.best/p1.cpp
clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp