Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/SemaConcept.cpp
Show First 20 Lines • Show All 698 Lines • ▼ Show 20 Lines | bool Sema::CheckFunctionConstraints(const FunctionDecl *FD, | ||||
Qualifiers ThisQuals; | Qualifiers ThisQuals; | ||||
CXXRecordDecl *Record = nullptr; | CXXRecordDecl *Record = nullptr; | ||||
if (auto *Method = dyn_cast<CXXMethodDecl>(FD)) { | if (auto *Method = dyn_cast<CXXMethodDecl>(FD)) { | ||||
ThisQuals = Method->getMethodQualifiers(); | ThisQuals = Method->getMethodQualifiers(); | ||||
Record = const_cast<CXXRecordDecl *>(Method->getParent()); | Record = const_cast<CXXRecordDecl *>(Method->getParent()); | ||||
} | } | ||||
CXXThisScopeRAII ThisScope(*this, Record, ThisQuals, Record != nullptr); | CXXThisScopeRAII ThisScope(*this, Record, ThisQuals, Record != nullptr); | ||||
// We substitute with empty arguments in order to rebuild the atomic | return CheckConstraintSatisfaction( | ||||
// constraint in a constant-evaluated context. | FD, {FD->getTrailingRequiresClause()}, *MLTAL, | ||||
// FIXME: Should this be a dedicated TreeTransform? | |||||
const Expr *RC = FD->getTrailingRequiresClause(); | |||||
llvm::SmallVector<Expr *, 1> Converted; | |||||
if (CheckConstraintSatisfaction( | |||||
FD, {RC}, Converted, *MLTAL, | |||||
SourceRange(UsageLoc.isValid() ? UsageLoc : FD->getLocation()), | SourceRange(UsageLoc.isValid() ? UsageLoc : FD->getLocation()), | ||||
Satisfaction)) | Satisfaction); | ||||
return true; | |||||
// FIXME: we need to do this for the function constraints for | |||||
// comparison of constraints to work, but do we also need to do it for | |||||
// CheckInstantiatedFunctionConstraints? That one is more difficult, but we | |||||
// seem to always just pick up the constraints from the primary template. | |||||
assert(Converted.size() <= 1 && "Got more expressions converted?"); | |||||
if (!Converted.empty() && Converted[0] != nullptr) | |||||
const_cast<FunctionDecl *>(FD)->setTrailingRequiresClause(Converted[0]); | |||||
return false; | |||||
} | } | ||||
// Figure out the to-translation-unit depth for this function declaration for | // Figure out the to-translation-unit depth for this function declaration for | ||||
// the purpose of seeing if they differ by constraints. This isn't the same as | // the purpose of seeing if they differ by constraints. This isn't the same as | ||||
// getTemplateDepth, because it includes already instantiated parents. | // getTemplateDepth, because it includes already instantiated parents. | ||||
static unsigned | static unsigned | ||||
CalculateTemplateDepthForConstraints(Sema &S, const NamedDecl *ND, | CalculateTemplateDepthForConstraints(Sema &S, const NamedDecl *ND, | ||||
▲ Show 20 Lines • Show All 878 Lines • Show Last 20 Lines |