Skip to content

Commit 95d94a6

Browse files
author
Erich Keane
committed
Revert "Re-apply "Deferred Concept Instantiation Implementation"""
This reverts commit d483730. This allegedly breaks a significant part of facebooks internal build. Reverting while we wait for them to provide a reproducer of this from @wlei.
1 parent bc53832 commit 95d94a6

19 files changed

+195
-1522
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,6 @@ C++ Language Changes in Clang
149149

150150
C++20 Feature Support
151151
^^^^^^^^^^^^^^^^^^^^^
152-
- Clang now correctly delays the instantiation of function constraints until
153-
the time of checking, which should now allow the libstdc++ ranges implementation
154-
to work for at least trivial examples. This fixes
155-
`Issue 44178 <https://github.com/llvm/llvm-project/issues/44178>`_.
156152

157153
- Support capturing structured bindings in lambdas
158154
(`P1091R3 <https://wg21.link/p1091r3>`_ and `P1381R1 <https://wg21.link/P1381R1>`).

clang/include/clang/Sema/Sema.h

Lines changed: 16 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -3637,16 +3637,6 @@ class Sema final {
36373637
bool ConsiderCudaAttrs = true,
36383638
bool ConsiderRequiresClauses = true);
36393639

3640-
// Calculates whether the expression Constraint depends on an enclosing
3641-
// template, for the purposes of [temp.friend] p9.
3642-
// TemplateDepth is the 'depth' of the friend function, which is used to
3643-
// compare whether a declaration reference is referring to a containing
3644-
// template, or just the current friend function. A 'lower' TemplateDepth in
3645-
// the AST refers to a 'containing' template. As the constraint is
3646-
// uninstantiated, this is relative to the 'top' of the TU.
3647-
bool ConstraintExpressionDependsOnEnclosingTemplate(unsigned TemplateDepth,
3648-
const Expr *Constraint);
3649-
36503640
enum class AllowedExplicit {
36513641
/// Allow no explicit functions to be used.
36523642
None,
@@ -7119,21 +7109,6 @@ class Sema final {
71197109
LocalInstantiationScope &Scope,
71207110
const MultiLevelTemplateArgumentList &TemplateArgs);
71217111

7122-
/// used by SetupConstraintCheckingTemplateArgumentsAndScope to recursively(in
7123-
/// the case of lambdas) set up the LocalInstantiationScope of the current
7124-
/// function.
7125-
bool SetupConstraintScope(
7126-
FunctionDecl *FD, llvm::Optional<ArrayRef<TemplateArgument>> TemplateArgs,
7127-
MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope);
7128-
7129-
/// Used during constraint checking, sets up the constraint template arguemnt
7130-
/// lists, and calls SetupConstraintScope to set up the
7131-
/// LocalInstantiationScope to have the proper set of ParVarDecls configured.
7132-
llvm::Optional<MultiLevelTemplateArgumentList>
7133-
SetupConstraintCheckingTemplateArgumentsAndScope(
7134-
FunctionDecl *FD, llvm::Optional<ArrayRef<TemplateArgument>> TemplateArgs,
7135-
LocalInstantiationScope &Scope);
7136-
71377112
public:
71387113
const NormalizedConstraint *
71397114
getNormalizedAssociatedConstraints(
@@ -7176,39 +7151,6 @@ class Sema final {
71767151
bool CheckConstraintSatisfaction(
71777152
const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
71787153
const MultiLevelTemplateArgumentList &TemplateArgLists,
7179-
SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
7180-
llvm::SmallVector<Expr *, 4> Converted;
7181-
return CheckConstraintSatisfaction(Template, ConstraintExprs, Converted,
7182-
TemplateArgLists, TemplateIDRange,
7183-
Satisfaction);
7184-
}
7185-
7186-
/// \brief Check whether the given list of constraint expressions are
7187-
/// satisfied (as if in a 'conjunction') given template arguments.
7188-
/// Additionally, takes an empty list of Expressions which is populated with
7189-
/// the instantiated versions of the ConstraintExprs.
7190-
/// \param Template the template-like entity that triggered the constraints
7191-
/// check (either a concept or a constrained entity).
7192-
/// \param ConstraintExprs a list of constraint expressions, treated as if
7193-
/// they were 'AND'ed together.
7194-
/// \param ConvertedConstraints a out parameter that will get populated with
7195-
/// the instantiated version of the ConstraintExprs if we successfully checked
7196-
/// satisfaction.
7197-
/// \param TemplateArgList the multi-level list of template arguments to
7198-
/// substitute into the constraint expression. This should be relative to the
7199-
/// top-level (hence multi-level), since we need to instantiate fully at the
7200-
/// time of checking.
7201-
/// \param TemplateIDRange The source range of the template id that
7202-
/// caused the constraints check.
7203-
/// \param Satisfaction if true is returned, will contain details of the
7204-
/// satisfaction, with enough information to diagnose an unsatisfied
7205-
/// expression.
7206-
/// \returns true if an error occurred and satisfaction could not be checked,
7207-
/// false otherwise.
7208-
bool CheckConstraintSatisfaction(
7209-
const NamedDecl *Template, ArrayRef<const Expr *> ConstraintExprs,
7210-
llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
7211-
const MultiLevelTemplateArgumentList &TemplateArgList,
72127154
SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
72137155

72147156
/// \brief Check whether the given non-dependent constraint expression is
@@ -7228,8 +7170,8 @@ class Sema final {
72287170
/// \returns true if an error occurred, false otherwise.
72297171
bool CheckFunctionConstraints(const FunctionDecl *FD,
72307172
ConstraintSatisfaction &Satisfaction,
7231-
SourceLocation UsageLoc = SourceLocation(),
7232-
bool ForOverloadResolution = false);
7173+
SourceLocation UsageLoc = SourceLocation());
7174+
72337175

72347176
/// \brief Ensure that the given template arguments satisfy the constraints
72357177
/// associated with the given template, emitting a diagnostic if they do not.
@@ -8985,8 +8927,7 @@ class Sema final {
89858927

89868928
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(
89878929
const NamedDecl *D, const TemplateArgumentList *Innermost = nullptr,
8988-
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
8989-
bool LookBeyondLambda = false, bool IncludeContainingStruct = false);
8930+
bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr);
89908931

89918932
/// A context in which code is being synthesized (where a source location
89928933
/// alone is not sufficient to identify the context). This covers template
@@ -9694,21 +9635,23 @@ class Sema final {
96949635
const MultiLevelTemplateArgumentList &TemplateArgs,
96959636
SourceLocation Loc, DeclarationName Entity);
96969637

9697-
TypeSourceInfo *SubstFunctionDeclType(
9698-
TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs,
9699-
SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
9700-
Qualifiers ThisTypeQuals, bool EvaluateConstraints = true);
9638+
TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
9639+
const MultiLevelTemplateArgumentList &TemplateArgs,
9640+
SourceLocation Loc,
9641+
DeclarationName Entity,
9642+
CXXRecordDecl *ThisContext,
9643+
Qualifiers ThisTypeQuals);
97019644
void SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
97029645
const MultiLevelTemplateArgumentList &Args);
97039646
bool SubstExceptionSpec(SourceLocation Loc,
97049647
FunctionProtoType::ExceptionSpecInfo &ESI,
97059648
SmallVectorImpl<QualType> &ExceptionStorage,
97069649
const MultiLevelTemplateArgumentList &Args);
9707-
ParmVarDecl *
9708-
SubstParmVarDecl(ParmVarDecl *D,
9709-
const MultiLevelTemplateArgumentList &TemplateArgs,
9710-
int indexAdjustment, Optional<unsigned> NumExpansions,
9711-
bool ExpectParameterPack, bool EvaluateConstraints = true);
9650+
ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
9651+
const MultiLevelTemplateArgumentList &TemplateArgs,
9652+
int indexAdjustment,
9653+
Optional<unsigned> NumExpansions,
9654+
bool ExpectParameterPack);
97129655
bool SubstParmTypes(SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
97139656
const FunctionProtoType::ExtParameterInfo *ExtParamInfos,
97149657
const MultiLevelTemplateArgumentList &TemplateArgs,
@@ -9718,25 +9661,6 @@ class Sema final {
97189661
ExprResult SubstExpr(Expr *E,
97199662
const MultiLevelTemplateArgumentList &TemplateArgs);
97209663

9721-
// A RAII type used by the TemplateDeclInstantiator and TemplateInstantiator
9722-
// to disable constraint evaluation, then restore the state.
9723-
template <typename InstTy> struct ConstraintEvalRAII {
9724-
InstTy &TI;
9725-
bool OldValue;
9726-
9727-
ConstraintEvalRAII(InstTy &TI)
9728-
: TI(TI), OldValue(TI.getEvaluateConstraints()) {
9729-
TI.setEvaluateConstraints(false);
9730-
}
9731-
~ConstraintEvalRAII() { TI.setEvaluateConstraints(OldValue); }
9732-
};
9733-
9734-
// Unlike the above, this evaluates constraints, which should only happen at
9735-
// 'constraint checking' time.
9736-
ExprResult
9737-
SubstConstraintExpr(Expr *E,
9738-
const MultiLevelTemplateArgumentList &TemplateArgs);
9739-
97409664
/// Substitute the given template arguments into a list of
97419665
/// expressions, expanding pack expansions if required.
97429666
///
@@ -9766,6 +9690,7 @@ class Sema final {
97669690
const MultiLevelTemplateArgumentList &TemplateArgs,
97679691
TemplateArgumentListInfo &Outputs);
97689692

9693+
97699694
Decl *SubstDecl(Decl *D, DeclContext *Owner,
97709695
const MultiLevelTemplateArgumentList &TemplateArgs);
97719696

@@ -9856,8 +9781,7 @@ class Sema final {
98569781
const MultiLevelTemplateArgumentList &TemplateArgs);
98579782

98589783
bool SubstTypeConstraint(TemplateTypeParmDecl *Inst, const TypeConstraint *TC,
9859-
const MultiLevelTemplateArgumentList &TemplateArgs,
9860-
bool EvaluateConstraint);
9784+
const MultiLevelTemplateArgumentList &TemplateArgs);
98619785

98629786
bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD,
98639787
ParmVarDecl *Param);

clang/include/clang/Sema/Template.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ enum class TemplateSubstitutionKind : char {
503503
const MultiLevelTemplateArgumentList &TemplateArgs;
504504
Sema::LateInstantiatedAttrVec* LateAttrs = nullptr;
505505
LocalInstantiationScope *StartingScope = nullptr;
506-
bool EvaluateConstraints = true;
507506

508507
/// A list of out-of-line class template partial
509508
/// specializations that will need to be instantiated after the
@@ -527,13 +526,6 @@ enum class TemplateSubstitutionKind : char {
527526
SubstIndex(SemaRef, SemaRef.ArgumentPackSubstitutionIndex),
528527
Owner(Owner), TemplateArgs(TemplateArgs) {}
529528

530-
void setEvaluateConstraints(bool B) {
531-
EvaluateConstraints = B;
532-
}
533-
bool getEvaluateConstraints() {
534-
return EvaluateConstraints;
535-
}
536-
537529
// Define all the decl visitors using DeclNodes.inc
538530
#define DECL(DERIVED, BASE) \
539531
Decl *Visit ## DERIVED ## Decl(DERIVED ## Decl *D);

0 commit comments

Comments
 (0)