Skip to content

Commit 6c14b67

Browse files
committed
[FOLD] move getMoreConstrainedFunction to SemaTemplateDeduction.cpp
1 parent 1249b56 commit 6c14b67

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
@@ -10354,29 +10354,6 @@ bool Sema::CheckFunctionTemplateSpecialization(
1035410354
return false;
1035510355
}
1035610356

10357-
FunctionDecl *Sema::getMoreConstrainedFunction(FunctionDecl *FD1,
10358-
FunctionDecl *FD2) {
10359-
assert(!FD1->getDescribedTemplate() && !FD2->getDescribedTemplate() &&
10360-
"not for function templates");
10361-
FunctionDecl *F1 = FD1;
10362-
if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
10363-
F1 = MF;
10364-
FunctionDecl *F2 = FD2;
10365-
if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
10366-
F2 = MF;
10367-
llvm::SmallVector<const Expr *, 3> AC1, AC2;
10368-
F1->getAssociatedConstraints(AC1);
10369-
F2->getAssociatedConstraints(AC2);
10370-
bool AtLeastAsConstrained1, AtLeastAsConstrained2;
10371-
if (IsAtLeastAsConstrained(F1, AC1, F2, AC2, AtLeastAsConstrained1))
10372-
return nullptr;
10373-
if (IsAtLeastAsConstrained(F2, AC2, F1, AC1, AtLeastAsConstrained2))
10374-
return nullptr;
10375-
if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
10376-
return nullptr;
10377-
return AtLeastAsConstrained1 ? FD1 : FD2;
10378-
}
10379-
1038010357
/// Perform semantic analysis for the given non-template member
1038110358
/// specialization.
1038210359
///

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,6 +5878,38 @@ UnresolvedSetIterator Sema::getMostSpecialized(
58785878
return SpecEnd;
58795879
}
58805880

5881+
/// Returns the more constrained function according to the rules of
5882+
/// partial ordering by constraints (C++ [temp.constr.order]).
5883+
///
5884+
/// \param FD1 the first function
5885+
///
5886+
/// \param FD2 the second function
5887+
///
5888+
/// \returns the more constrained function. If neither function is
5889+
/// more constrained, returns NULL.
5890+
FunctionDecl *Sema::getMoreConstrainedFunction(FunctionDecl *FD1,
5891+
FunctionDecl *FD2) {
5892+
assert(!FD1->getDescribedTemplate() && !FD2->getDescribedTemplate() &&
5893+
"not for function templates");
5894+
FunctionDecl *F1 = FD1;
5895+
if (FunctionDecl *MF = FD1->getInstantiatedFromMemberFunction())
5896+
F1 = MF;
5897+
FunctionDecl *F2 = FD2;
5898+
if (FunctionDecl *MF = FD2->getInstantiatedFromMemberFunction())
5899+
F2 = MF;
5900+
llvm::SmallVector<const Expr *, 3> AC1, AC2;
5901+
F1->getAssociatedConstraints(AC1);
5902+
F2->getAssociatedConstraints(AC2);
5903+
bool AtLeastAsConstrained1, AtLeastAsConstrained2;
5904+
if (IsAtLeastAsConstrained(F1, AC1, F2, AC2, AtLeastAsConstrained1))
5905+
return nullptr;
5906+
if (IsAtLeastAsConstrained(F2, AC2, F1, AC1, AtLeastAsConstrained2))
5907+
return nullptr;
5908+
if (AtLeastAsConstrained1 == AtLeastAsConstrained2)
5909+
return nullptr;
5910+
return AtLeastAsConstrained1 ? FD1 : FD2;
5911+
}
5912+
58815913
/// Determine whether one partial specialization, P1, is at least as
58825914
/// specialized than another, P2.
58835915
///

0 commit comments

Comments
 (0)