[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 25 04:49:07 PDT 2024
================
@@ -10339,24 +10339,53 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
if (Previous.empty()) {
// Nowhere to look anyway.
} else if (FunctionDecl *Function = dyn_cast<FunctionDecl>(Member)) {
+ SmallVector<FunctionDecl *> Candidates;
+ bool Ambiguous = false;
for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
I != E; ++I) {
- NamedDecl *D = (*I)->getUnderlyingDecl();
- if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
- QualType Adjusted = Function->getType();
- if (!hasExplicitCallingConv(Adjusted))
- Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
- // This doesn't handle deduced return types, but both function
- // declarations should be undeduced at this point.
- if (Context.hasSameType(Adjusted, Method->getType())) {
- FoundInstantiation = *I;
- Instantiation = Method;
- InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
- MSInfo = Method->getMemberSpecializationInfo();
- break;
- }
+ CXXMethodDecl *Method =
+ dyn_cast<CXXMethodDecl>((*I)->getUnderlyingDecl());
+ if (!Method)
+ continue;
+ QualType Adjusted = Function->getType();
+ if (!hasExplicitCallingConv(Adjusted))
+ Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
+ // This doesn't handle deduced return types, but both function
+ // declarations should be undeduced at this point.
+ if (!Context.hasSameType(Adjusted, Method->getType()))
+ continue;
+ if (ConstraintSatisfaction Satisfaction;
+ Method->getTrailingRequiresClause() &&
+ (CheckFunctionConstraints(Method, Satisfaction,
+ /*UsageLoc=*/Member->getLocation(),
+ /*ForOverloadResolution=*/true) ||
+ !Satisfaction.IsSatisfied))
+ continue;
+ Candidates.push_back(Method);
+ FunctionDecl *MoreConstrained =
+ Instantiation ? getMoreConstrainedFunction(
+ Method, cast<FunctionDecl>(Instantiation))
+ : Method;
+ if (!MoreConstrained) {
+ Ambiguous = true;
+ continue;
+ }
+ if (MoreConstrained == Method) {
+ Ambiguous = false;
----------------
sdkrystian wrote:
Whoops, good catch! I'll open a patch to fix this :)
https://github.com/llvm/llvm-project/pull/88963
More information about the cfe-commits
mailing list