Skip to content

Commit 4387c95

Browse files
committed
[clang] NFC: cleanup check template argument
1 parent e8ded39 commit 4387c95

File tree

5 files changed

+307
-301
lines changed

5 files changed

+307
-301
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11650,6 +11650,33 @@ class Sema final : public SemaBase {
1165011650
CTAK_DeducedFromArrayBound
1165111651
};
1165211652

11653+
struct CheckTemplateArgumentInfo {
11654+
explicit CheckTemplateArgumentInfo(bool PartialOrdering = false,
11655+
bool MatchingTTP = false)
11656+
: PartialOrdering(PartialOrdering), MatchingTTP(MatchingTTP) {}
11657+
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &) = delete;
11658+
CheckTemplateArgumentInfo &
11659+
operator=(const CheckTemplateArgumentInfo &) = delete;
11660+
11661+
/// The checked, converted argument will be added to the
11662+
/// end of these vectors.
11663+
SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted;
11664+
11665+
/// The check is being performed in the context of partial ordering.
11666+
bool PartialOrdering;
11667+
11668+
/// If true, assume these template arguments are
11669+
/// the injected template arguments for a template template parameter.
11670+
/// This will relax the requirement that all its possible uses are valid:
11671+
/// TTP checking is loose, and assumes that invalid uses will be diagnosed
11672+
/// during instantiation.
11673+
bool MatchingTTP;
11674+
11675+
/// Is set to true when, in the context of TTP matching, a pack parameter
11676+
/// matches non-pack arguments.
11677+
bool MatchedPackOnParmToNonPackOnArg;
11678+
};
11679+
1165311680
/// Check that the given template argument corresponds to the given
1165411681
/// template parameter.
1165511682
///
@@ -11669,22 +11696,16 @@ class Sema final : public SemaBase {
1166911696
/// \param ArgumentPackIndex The index into the argument pack where this
1167011697
/// argument will be placed. Only valid if the parameter is a parameter pack.
1167111698
///
11672-
/// \param Converted The checked, converted argument will be added to the
11673-
/// end of this small vector.
11674-
///
1167511699
/// \param CTAK Describes how we arrived at this particular template argument:
1167611700
/// explicitly written, deduced, etc.
1167711701
///
1167811702
/// \returns true on error, false otherwise.
11679-
bool
11680-
CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11681-
NamedDecl *Template, SourceLocation TemplateLoc,
11682-
SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11683-
SmallVectorImpl<TemplateArgument> &SugaredConverted,
11684-
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11685-
CheckTemplateArgumentKind CTAK, bool PartialOrdering,
11686-
bool PartialOrderingTTP,
11687-
bool *MatchedPackOnParmToNonPackOnArg);
11703+
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11704+
NamedDecl *Template, SourceLocation TemplateLoc,
11705+
SourceLocation RAngleLoc,
11706+
unsigned ArgumentPackIndex,
11707+
CheckTemplateArgumentInfo &CTAI,
11708+
CheckTemplateArgumentKind CTAK);
1168811709

1168911710
/// Check that the given template arguments can be provided to
1169011711
/// the given template, converting the arguments along the way.
@@ -11717,22 +11738,15 @@ class Sema final : public SemaBase {
1171711738
/// \param DefaultArgs any default arguments from template specialization
1171811739
/// deduction.
1171911740
///
11720-
/// \param PartialOrderingTTP If true, assume these template arguments are
11721-
/// the injected template arguments for a template template parameter.
11722-
/// This will relax the requirement that all its possible uses are valid:
11723-
/// TTP checking is loose, and assumes that invalid uses will be diagnosed
11724-
/// during instantiation.
11725-
///
1172611741
/// \returns true if an error occurred, false otherwise.
11727-
bool CheckTemplateArgumentList(
11728-
TemplateDecl *Template, SourceLocation TemplateLoc,
11729-
TemplateArgumentListInfo &TemplateArgs,
11730-
const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
11731-
SmallVectorImpl<TemplateArgument> &SugaredConverted,
11732-
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11733-
bool UpdateArgsWithConversions = true,
11734-
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11735-
bool *MatchedPackOnParmToNonPackOnArg = nullptr);
11742+
bool CheckTemplateArgumentList(TemplateDecl *Template,
11743+
SourceLocation TemplateLoc,
11744+
TemplateArgumentListInfo &TemplateArgs,
11745+
const DefaultArguments &DefaultArgs,
11746+
bool PartialTemplateArgs,
11747+
CheckTemplateArgumentInfo &CTAI,
11748+
bool UpdateArgsWithConversions = true,
11749+
bool *ConstraintsNotSatisfied = nullptr);
1173611750

1173711751
bool CheckTemplateTypeArgument(
1173811752
TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
@@ -11757,7 +11771,7 @@ class Sema final : public SemaBase {
1175711771
QualType InstantiatedParamType, Expr *Arg,
1175811772
TemplateArgument &SugaredConverted,
1175911773
TemplateArgument &CanonicalConverted,
11760-
bool PartialOrderingTTP,
11774+
bool MatchingTTP,
1176111775
CheckTemplateArgumentKind CTAK);
1176211776

1176311777
/// Check a template argument against its corresponding

clang/lib/Sema/SemaLookup.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,13 +3671,11 @@ Sema::LookupLiteralOperator(Scope *S, LookupResult &R,
36713671
// is a well-formed template argument for the template parameter.
36723672
if (StringLit) {
36733673
SFINAETrap Trap(*this);
3674-
SmallVector<TemplateArgument, 1> SugaredChecked, CanonicalChecked;
3674+
CheckTemplateArgumentInfo CTAI;
36753675
TemplateArgumentLoc Arg(TemplateArgument(StringLit), StringLit);
36763676
if (CheckTemplateArgument(
36773677
Params->getParam(0), Arg, FD, R.getNameLoc(), R.getNameLoc(),
3678-
0, SugaredChecked, CanonicalChecked, CTAK_Specified,
3679-
/*PartialOrdering=*/false, /*PartialOrderingTTP=*/false,
3680-
/*MatchedPackOnParmToNonPackOnArg=*/nullptr) ||
3678+
/*ArgumentPackIndex=*/0, CTAI, CTAK_Specified) ||
36813679
Trap.hasErrorOccurred())
36823680
IsTemplate = false;
36833681
}

0 commit comments

Comments
 (0)