Skip to content

Commit 9d40864

Browse files
committed
[FOLD] move getMoreConstrainedFunction to SemaTemplateDeduction.cpp
1 parent 392ff1b commit 9d40864

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10312,29 +10312,6 @@ bool Sema::CheckFunctionTemplateSpecialization(
1031210312
return false;
1031310313
}
1031410314

10315-
FunctionDecl *Sema::getMoreConstrainedFunction(FunctionDecl *FD1,
10316-
FunctionDecl *FD2) {
10317-
assert(!FD1->getDescribedTemplate() && !FD2->getDescribedTemplate() &&
10318-
"not for function templates");
10319-
FunctionDecl *F1 = FD1;
10320-
if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
10321-
F1 = MF;
10322-
FunctionDecl *F2 = FD2;
10323-
if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
10324-
F2 = MF;
10325-
llvm::SmallVector<const Expr *, 3> AC1, AC2;
10326-
F1->getAssociatedConstraints(AC1);
10327-
F2->getAssociatedConstraints(AC2);
10328-
bool AtLeastAsConstrained1, AtLeastAsConstrained2;
10329-
if (IsAtLeastAsConstrained(F1, AC1, F2, AC2, AtLeastAsConstrained1))
10330-
return nullptr;
10331-
if (IsAtLeastAsConstrained(F2, AC2, F1, AC1, AtLeastAsConstrained2))
10332-
return nullptr;
10333-
if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
10334-
return nullptr;
10335-
return AtLeastAsConstrained1 ? FD1 : FD2;
10336-
}
10337-
1033810315
/// Perform semantic analysis for the given non-template member
1033910316
/// specialization.
1034010317
///

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5852,6 +5852,38 @@ UnresolvedSetIterator Sema::getMostSpecialized(
58525852
return SpecEnd;
58535853
}
58545854

5855+
/// Returns the more constrained function according to the rules of
5856+
/// partial ordering by constraints (C++ [temp.constr.order]).
5857+
///
5858+
/// \param FD1 the first function
5859+
///
5860+
/// \param FD2 the second function
5861+
///
5862+
/// \returns the more constrained function. If neither function is
5863+
/// more constrained, returns NULL.
5864+
FunctionDecl *Sema::getMoreConstrainedFunction(FunctionDecl *FD1,
5865+
FunctionDecl *FD2) {
5866+
assert(!FD1->getDescribedTemplate() && !FD2->getDescribedTemplate() &&
5867+
"not for function templates");
5868+
FunctionDecl *F1 = FD1;
5869+
if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
5870+
F1 = MF;
5871+
FunctionDecl *F2 = FD2;
5872+
if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
5873+
F2 = MF;
5874+
llvm::SmallVector<const Expr *, 3> AC1, AC2;
5875+
F1->getAssociatedConstraints(AC1);
5876+
F2->getAssociatedConstraints(AC2);
5877+
bool AtLeastAsConstrained1, AtLeastAsConstrained2;
5878+
if (IsAtLeastAsConstrained(F1, AC1, F2, AC2, AtLeastAsConstrained1))
5879+
return nullptr;
5880+
if (IsAtLeastAsConstrained(F2, AC2, F1, AC1, AtLeastAsConstrained2))
5881+
return nullptr;
5882+
if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
5883+
return nullptr;
5884+
return AtLeastAsConstrained1 ? FD1 : FD2;
5885+
}
5886+
58555887
/// Determine whether one partial specialization, P1, is at least as
58565888
/// specialized than another, P2.
58575889
///

0 commit comments

Comments
 (0)