@@ -11651,6 +11651,33 @@ class Sema final : public SemaBase {
1165111651 CTAK_DeducedFromArrayBound
1165211652 };
1165311653
11654+ struct CheckTemplateArgumentInfo {
11655+ explicit CheckTemplateArgumentInfo(bool PartialOrdering = false,
11656+ bool MatchingTTP = false)
11657+ : PartialOrdering(PartialOrdering), MatchingTTP(MatchingTTP) {}
11658+ CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &) = delete;
11659+ CheckTemplateArgumentInfo &
11660+ operator=(const CheckTemplateArgumentInfo &) = delete;
11661+
11662+ /// The checked, converted argument will be added to the
11663+ /// end of these vectors.
11664+ SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted;
11665+
11666+ /// The check is being performed in the context of partial ordering.
11667+ bool PartialOrdering;
11668+
11669+ /// If true, assume these template arguments are
11670+ /// the injected template arguments for a template template parameter.
11671+ /// This will relax the requirement that all its possible uses are valid:
11672+ /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11673+ /// during instantiation.
11674+ bool MatchingTTP;
11675+
11676+ /// Is set to true when, in the context of TTP matching, a pack parameter
11677+ /// matches non-pack arguments.
11678+ bool MatchedPackOnParmToNonPackOnArg = false;
11679+ };
11680+
1165411681 /// Check that the given template argument corresponds to the given
1165511682 /// template parameter.
1165611683 ///
@@ -11670,22 +11697,16 @@ class Sema final : public SemaBase {
1167011697 /// \param ArgumentPackIndex The index into the argument pack where this
1167111698 /// argument will be placed. Only valid if the parameter is a parameter pack.
1167211699 ///
11673- /// \param Converted The checked, converted argument will be added to the
11674- /// end of this small vector.
11675- ///
1167611700 /// \param CTAK Describes how we arrived at this particular template argument:
1167711701 /// explicitly written, deduced, etc.
1167811702 ///
1167911703 /// \returns true on error, false otherwise.
11680- bool
11681- CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11682- NamedDecl *Template, SourceLocation TemplateLoc,
11683- SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11684- SmallVectorImpl<TemplateArgument> &SugaredConverted,
11685- SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11686- CheckTemplateArgumentKind CTAK, bool PartialOrdering,
11687- bool PartialOrderingTTP,
11688- bool *MatchedPackOnParmToNonPackOnArg);
11704+ bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11705+ NamedDecl *Template, SourceLocation TemplateLoc,
11706+ SourceLocation RAngleLoc,
11707+ unsigned ArgumentPackIndex,
11708+ CheckTemplateArgumentInfo &CTAI,
11709+ CheckTemplateArgumentKind CTAK);
1168911710
1169011711 /// Check that the given template arguments can be provided to
1169111712 /// the given template, converting the arguments along the way.
@@ -11718,22 +11739,15 @@ class Sema final : public SemaBase {
1171811739 /// \param DefaultArgs any default arguments from template specialization
1171911740 /// deduction.
1172011741 ///
11721- /// \param PartialOrderingTTP If true, assume these template arguments are
11722- /// the injected template arguments for a template template parameter.
11723- /// This will relax the requirement that all its possible uses are valid:
11724- /// TTP checking is loose, and assumes that invalid uses will be diagnosed
11725- /// during instantiation.
11726- ///
1172711742 /// \returns true if an error occurred, false otherwise.
11728- bool CheckTemplateArgumentList(
11729- TemplateDecl *Template, SourceLocation TemplateLoc,
11730- TemplateArgumentListInfo &TemplateArgs,
11731- const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
11732- SmallVectorImpl<TemplateArgument> &SugaredConverted,
11733- SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11734- bool UpdateArgsWithConversions = true,
11735- bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11736- bool *MatchedPackOnParmToNonPackOnArg = nullptr);
11743+ bool CheckTemplateArgumentList(TemplateDecl *Template,
11744+ SourceLocation TemplateLoc,
11745+ TemplateArgumentListInfo &TemplateArgs,
11746+ const DefaultArguments &DefaultArgs,
11747+ bool PartialTemplateArgs,
11748+ CheckTemplateArgumentInfo &CTAI,
11749+ bool UpdateArgsWithConversions = true,
11750+ bool *ConstraintsNotSatisfied = nullptr);
1173711751
1173811752 bool CheckTemplateTypeArgument(
1173911753 TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
@@ -11758,7 +11772,7 @@ class Sema final : public SemaBase {
1175811772 QualType InstantiatedParamType, Expr *Arg,
1175911773 TemplateArgument &SugaredConverted,
1176011774 TemplateArgument &CanonicalConverted,
11761- bool PartialOrderingTTP ,
11775+ bool MatchingTTP ,
1176211776 CheckTemplateArgumentKind CTAK);
1176311777
1176411778 /// Check a template argument against its corresponding
@@ -11780,6 +11794,9 @@ class Sema final : public SemaBase {
1178011794 /// declaration and the type of its corresponding non-type template
1178111795 /// parameter, produce an expression that properly refers to that
1178211796 /// declaration.
11797+ /// FIXME: This is used in some contexts where the resulting expression
11798+ /// doesn't need to live too long. It would be useful if this function
11799+ /// could return a temporary expression.
1178311800 ExprResult BuildExpressionFromDeclTemplateArgument(
1178411801 const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc,
1178511802 NamedDecl *TemplateParam = nullptr);
0 commit comments