Summary:
Prepare to store requires-clause expression for access via
TemplateParameterList.
Reviewers: aaron.ballman, faisalv, rsmith
Subscribers: cfe-commits, nwilson
Differential Revision: http://reviews.llvm.org/D19220
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268081
91177308-0d34-0410-b5e6-
96231b3b80d8
SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ArrayRef<Decl *> Params,
- SourceLocation RAngleLoc);
+ SourceLocation RAngleLoc,
+ Expr *RequiresClause);
/// \brief The context in which we are checking a template parameter list.
enum TemplateParamListContext {
TemplateParameterLists FakedParamLists;
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
- LAngleLoc));
+ LAngleLoc, nullptr));
ThisDecl =
Actions.ActOnTemplateDeclarator(getCurScope(), FakedParamLists, D);
// template specialization.
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
- LAngleLoc));
+ LAngleLoc, nullptr));
TemplateParams = &FakedParamLists;
}
}
return nullptr;
}
- ParamLists.push_back(
- Actions.ActOnTemplateParameterList(CurTemplateDepthTracker.getDepth(),
- ExportLoc,
- TemplateLoc, LAngleLoc,
- TemplateParams, RAngleLoc));
-
+ ExprResult OptionalRequiresClauseConstraintER;
if (!TemplateParams.empty()) {
isSpecialization = false;
++CurTemplateDepthTracker;
if (TryConsumeToken(tok::kw_requires)) {
- ExprResult ER =
+ OptionalRequiresClauseConstraintER =
Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression());
- if (!ER.isUsable()) {
+ if (!OptionalRequiresClauseConstraintER.isUsable()) {
// Skip until the semi-colon or a '}'.
SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
TryConsumeToken(tok::semi);
} else {
LastParamListWasEmpty = true;
}
+
+ ParamLists.push_back(Actions.ActOnTemplateParameterList(
+ CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
+ TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.get()));
} while (Tok.isOneOf(tok::kw_export, tok::kw_template));
unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
TemplateParameterLists FakedParamLists;
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
- LAngleLoc));
+ LAngleLoc, nullptr));
return ParseFunctionDefinition(
DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
Actions.ActOnTemplateParameterList(Depth, SourceLocation(),
TemplateLoc, LAngleLoc,
TemplateParams,
- RAngleLoc);
+ RAngleLoc, nullptr);
// Grab a default argument (if available).
// Per C++0x [basic.scope.pdecl]p9, we parse the default argument before
return Param;
}
-/// ActOnTemplateParameterList - Builds a TemplateParameterList that
-/// contains the template parameters in Params/NumParams.
+/// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
+/// constrained by RequiresClause, that contains the template parameters in
+/// Params.
TemplateParameterList *
Sema::ActOnTemplateParameterList(unsigned Depth,
SourceLocation ExportLoc,
SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ArrayRef<Decl *> Params,
- SourceLocation RAngleLoc) {
+ SourceLocation RAngleLoc,
+ Expr *RequiresClause) {
if (ExportLoc.isValid())
Diag(ExportLoc, diag::warn_template_export_unsupported);
+ // FIXME: store RequiresClause
return TemplateParameterList::Create(
Context, TemplateLoc, LAngleLoc,
llvm::makeArrayRef((NamedDecl *const *)Params.data(), Params.size()),