65
65
#include "clang/Sema/Redeclaration.h"
66
66
#include "clang/Sema/Scope.h"
67
67
#include "clang/Sema/SemaBase.h"
68
- #include "clang/Sema/SemaConcept.h"
69
68
#include "clang/Sema/TypoCorrection.h"
70
69
#include "clang/Sema/Weak.h"
71
70
#include "llvm/ADT/APInt.h"
@@ -11695,9 +11694,8 @@ class Sema final : public SemaBase {
11695
11694
ExprResult
11696
11695
CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
11697
11696
const DeclarationNameInfo &ConceptNameInfo,
11698
- NamedDecl *FoundDecl, TemplateDecl *NamedConcept,
11699
- const TemplateArgumentListInfo *TemplateArgs,
11700
- bool DoCheckConstraintSatisfaction = true);
11697
+ NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
11698
+ const TemplateArgumentListInfo *TemplateArgs);
11701
11699
11702
11700
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc);
11703
11701
void diagnoseMissingTemplateArguments(const CXXScopeSpec &SS,
@@ -12027,13 +12025,6 @@ class Sema final : public SemaBase {
12027
12025
bool UpdateArgsWithConversions = true,
12028
12026
bool *ConstraintsNotSatisfied = nullptr);
12029
12027
12030
- bool CheckTemplateArgumentList(
12031
- TemplateDecl *Template, TemplateParameterList *Params,
12032
- SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs,
12033
- const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
12034
- CheckTemplateArgumentInfo &CTAI, bool UpdateArgsWithConversions = true,
12035
- bool *ConstraintsNotSatisfied = nullptr);
12036
-
12037
12028
bool CheckTemplateTypeArgument(
12038
12029
TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
12039
12030
SmallVectorImpl<TemplateArgument> &SugaredConverted,
@@ -12792,18 +12783,6 @@ class Sema final : public SemaBase {
12792
12783
void MarkUsedTemplateParameters(const Expr *E, bool OnlyDeduced,
12793
12784
unsigned Depth, llvm::SmallBitVector &Used);
12794
12785
12795
- /// Mark which template parameters are named in a given expression.
12796
- ///
12797
- /// Unlike MarkUsedTemplateParameters, this excludes parameter that
12798
- /// are used but not directly named by an expression - i.e. it excludes
12799
- /// any template parameter that denotes the type of a referenced NTTP.
12800
- ///
12801
- /// \param Used a bit vector whose elements will be set to \c true
12802
- /// to indicate when the corresponding template parameter will be
12803
- /// deduced.
12804
- void MarkUsedTemplateParametersForSubsumptionParameterMapping(
12805
- const Expr *E, unsigned Depth, llvm::SmallBitVector &Used);
12806
-
12807
12786
/// Mark which template parameters can be deduced from a given
12808
12787
/// template argument list.
12809
12788
///
@@ -12820,9 +12799,6 @@ class Sema final : public SemaBase {
12820
12799
void MarkUsedTemplateParameters(ArrayRef<TemplateArgument> TemplateArgs,
12821
12800
unsigned Depth, llvm::SmallBitVector &Used);
12822
12801
12823
- void MarkUsedTemplateParameters(ArrayRef<TemplateArgumentLoc> TemplateArgs,
12824
- unsigned Depth, llvm::SmallBitVector &Used);
12825
-
12826
12802
void
12827
12803
MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate,
12828
12804
llvm::SmallBitVector &Deduced) {
@@ -13120,9 +13096,6 @@ class Sema final : public SemaBase {
13120
13096
/// Whether we're substituting into constraints.
13121
13097
bool InConstraintSubstitution;
13122
13098
13123
- /// Whether we're substituting into the parameter mapping of a constraint.
13124
- bool InParameterMappingSubstitution;
13125
-
13126
13099
/// The point of instantiation or synthesis within the source code.
13127
13100
SourceLocation PointOfInstantiation;
13128
13101
@@ -13173,10 +13146,8 @@ class Sema final : public SemaBase {
13173
13146
CodeSynthesisContext()
13174
13147
: Kind(TemplateInstantiation),
13175
13148
SavedInNonInstantiationSFINAEContext(false),
13176
- InConstraintSubstitution(false),
13177
- InParameterMappingSubstitution(false), Entity(nullptr),
13178
- Template(nullptr), TemplateArgs(nullptr), NumTemplateArgs(0),
13179
- DeductionInfo(nullptr) {}
13149
+ InConstraintSubstitution(false), Entity(nullptr), Template(nullptr),
13150
+ TemplateArgs(nullptr), NumTemplateArgs(0), DeductionInfo(nullptr) {}
13180
13151
13181
13152
/// Determines whether this template is an actual instantiation
13182
13153
/// that should be counted toward the maximum instantiation depth.
@@ -13388,11 +13359,6 @@ class Sema final : public SemaBase {
13388
13359
const MultiLevelTemplateArgumentList &TemplateArgs,
13389
13360
TemplateArgumentListInfo &Outputs);
13390
13361
13391
- bool SubstTemplateArgumentsInParameterMapping(
13392
- ArrayRef<TemplateArgumentLoc> Args, SourceLocation BaseLoc,
13393
- const MultiLevelTemplateArgumentList &TemplateArgs,
13394
- TemplateArgumentListInfo &Out, bool BuildPackExpansionTypes);
13395
-
13396
13362
/// Retrieve the template argument list(s) that should be used to
13397
13363
/// instantiate the definition of the given declaration.
13398
13364
///
@@ -13854,12 +13820,6 @@ class Sema final : public SemaBase {
13854
13820
CodeSynthesisContexts.back().InConstraintSubstitution;
13855
13821
}
13856
13822
13857
- bool inParameterMappingSubstitution() const {
13858
- return !CodeSynthesisContexts.empty() &&
13859
- CodeSynthesisContexts.back().InParameterMappingSubstitution &&
13860
- !inConstraintSubstitution();
13861
- }
13862
-
13863
13823
using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13864
13824
13865
13825
/// \brief create a Requirement::SubstitutionDiagnostic with only a
@@ -14744,10 +14704,6 @@ class Sema final : public SemaBase {
14744
14704
SatisfactionStack.swap(NewSS);
14745
14705
}
14746
14706
14747
- using ConstrainedDeclOrNestedRequirement =
14748
- llvm::PointerUnion<const NamedDecl *,
14749
- const concepts::NestedRequirement *>;
14750
-
14751
14707
/// Check whether the given expression is a valid constraint expression.
14752
14708
/// A diagnostic is emitted if it is not, false is returned, and
14753
14709
/// PossibleNonPrimary will be set to true if the failure might be due to a
@@ -14772,12 +14728,44 @@ class Sema final : public SemaBase {
14772
14728
/// \returns true if an error occurred and satisfaction could not be checked,
14773
14729
/// false otherwise.
14774
14730
bool CheckConstraintSatisfaction(
14775
- ConstrainedDeclOrNestedRequirement Entity ,
14731
+ const NamedDecl *Template ,
14776
14732
ArrayRef<AssociatedConstraint> AssociatedConstraints,
14777
14733
const MultiLevelTemplateArgumentList &TemplateArgLists,
14778
- SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction,
14779
- const ConceptReference *TopLevelConceptId = nullptr,
14780
- Expr **ConvertedExpr = nullptr);
14734
+ SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction) {
14735
+ llvm::SmallVector<Expr *, 4> Converted;
14736
+ return CheckConstraintSatisfaction(Template, AssociatedConstraints,
14737
+ Converted, TemplateArgLists,
14738
+ TemplateIDRange, Satisfaction);
14739
+ }
14740
+
14741
+ /// \brief Check whether the given list of constraint expressions are
14742
+ /// satisfied (as if in a 'conjunction') given template arguments.
14743
+ /// Additionally, takes an empty list of Expressions which is populated with
14744
+ /// the instantiated versions of the ConstraintExprs.
14745
+ /// \param Template the template-like entity that triggered the constraints
14746
+ /// check (either a concept or a constrained entity).
14747
+ /// \param ConstraintExprs a list of constraint expressions, treated as if
14748
+ /// they were 'AND'ed together.
14749
+ /// \param ConvertedConstraints a out parameter that will get populated with
14750
+ /// the instantiated version of the ConstraintExprs if we successfully checked
14751
+ /// satisfaction.
14752
+ /// \param TemplateArgList the multi-level list of template arguments to
14753
+ /// substitute into the constraint expression. This should be relative to the
14754
+ /// top-level (hence multi-level), since we need to instantiate fully at the
14755
+ /// time of checking.
14756
+ /// \param TemplateIDRange The source range of the template id that
14757
+ /// caused the constraints check.
14758
+ /// \param Satisfaction if true is returned, will contain details of the
14759
+ /// satisfaction, with enough information to diagnose an unsatisfied
14760
+ /// expression.
14761
+ /// \returns true if an error occurred and satisfaction could not be checked,
14762
+ /// false otherwise.
14763
+ bool CheckConstraintSatisfaction(
14764
+ const NamedDecl *Template,
14765
+ ArrayRef<AssociatedConstraint> AssociatedConstraints,
14766
+ llvm::SmallVectorImpl<Expr *> &ConvertedConstraints,
14767
+ const MultiLevelTemplateArgumentList &TemplateArgList,
14768
+ SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction);
14781
14769
14782
14770
/// \brief Check whether the given non-dependent constraint expression is
14783
14771
/// satisfied. Returns false and updates Satisfaction with the satisfaction
@@ -14843,17 +14831,16 @@ class Sema final : public SemaBase {
14843
14831
/// \param First whether this is the first time an unsatisfied constraint is
14844
14832
/// diagnosed for this error.
14845
14833
void DiagnoseUnsatisfiedConstraint(const ConstraintSatisfaction &Satisfaction,
14846
- SourceLocation Loc = {},
14847
14834
bool First = true);
14848
14835
14849
14836
/// \brief Emit diagnostics explaining why a constraint expression was deemed
14850
14837
/// unsatisfied.
14851
14838
void
14852
- DiagnoseUnsatisfiedConstraint(const ConceptSpecializationExpr *ConstraintExpr ,
14839
+ DiagnoseUnsatisfiedConstraint(const ASTConstraintSatisfaction &Satisfaction ,
14853
14840
bool First = true);
14854
14841
14855
14842
const NormalizedConstraint *getNormalizedAssociatedConstraints(
14856
- ConstrainedDeclOrNestedRequirement Entity ,
14843
+ const NamedDecl *ConstrainedDecl ,
14857
14844
ArrayRef<AssociatedConstraint> AssociatedConstraints);
14858
14845
14859
14846
/// \brief Check whether the given declaration's associated constraints are
@@ -14878,15 +14865,6 @@ class Sema final : public SemaBase {
14878
14865
const NamedDecl *D1, ArrayRef<AssociatedConstraint> AC1,
14879
14866
const NamedDecl *D2, ArrayRef<AssociatedConstraint> AC2);
14880
14867
14881
- /// Cache the satisfaction of an atomic constraint.
14882
- /// The key is based on the unsubstituted expression and the parameter
14883
- /// mapping. This lets us not substituting the mapping more than once,
14884
- /// which is (very!) expensive.
14885
- /// FIXME: this should be private.
14886
- llvm::DenseMap<llvm::FoldingSetNodeID,
14887
- UnsubstitutedConstraintSatisfactionCacheResult>
14888
- UnsubstitutedConstraintSatisfactionCache;
14889
-
14890
14868
private:
14891
14869
/// Caches pairs of template-like decls whose associated constraints were
14892
14870
/// checked for subsumption and whether or not the first's constraints did in
@@ -14897,11 +14875,8 @@ class Sema final : public SemaBase {
14897
14875
/// constrained declarations). If an error occurred while normalizing the
14898
14876
/// associated constraints of the template or concept, nullptr will be cached
14899
14877
/// here.
14900
- llvm::DenseMap<ConstrainedDeclOrNestedRequirement, NormalizedConstraint *>
14901
- NormalizationCache;
14878
+ llvm::DenseMap<const NamedDecl *, NormalizedConstraint *> NormalizationCache;
14902
14879
14903
- /// Cache whether the associated constraint of a declaration
14904
- /// is satisfied.
14905
14880
llvm::ContextualFoldingSet<ConstraintSatisfaction, const ASTContext &>
14906
14881
SatisfactionCache;
14907
14882
0 commit comments