[clang] [Clang][C++26] Implement Pack Indexing (P2662R3). (PR #72644)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 10:21:20 PST 2024
================
@@ -1061,6 +1070,59 @@ ExprResult Sema::ActOnSizeofParameterPackExpr(Scope *S,
RParenLoc);
}
+static bool isParameterPack(Expr *PackExpression) {
+ if (auto D = dyn_cast<DeclRefExpr>(PackExpression); D) {
+ ValueDecl *VD = D->getDecl();
+ return VD->isParameterPack();
+ }
+ return false;
+}
+
+ExprResult Sema::ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
+ SourceLocation EllipsisLoc,
+ SourceLocation LSquareLoc,
+ Expr *IndexExpr,
+ SourceLocation RSquareLoc) {
+ bool isParameterPack = ::isParameterPack(PackExpression);
+ if (!isParameterPack) {
+ CorrectDelayedTyposInExpr(IndexExpr);
+ Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
+ << PackExpression;
+ return ExprError();
+ }
+ return BuildPackIndexingExpr(PackExpression, EllipsisLoc, IndexExpr,
+ RSquareLoc);
+}
+
+ExprResult
+Sema::BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc,
+ Expr *IndexExpr, SourceLocation RSquareLoc,
+ ArrayRef<Expr *> ExpandedExprs, bool EmptyPack) {
+
+ std::optional<int64_t> Index;
+ if (!IndexExpr->isValueDependent() && !IndexExpr->isTypeDependent()) {
----------------
erichkeane wrote:
isn't this just `isInstantiationDependent`?
https://github.com/llvm/llvm-project/pull/72644
More information about the cfe-commits
mailing list