================ @@ -0,0 +1,81 @@ +//===-- SemaExpand.cpp - Semantic Analysis for Expansion Statements--------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements semantic analysis for C++26 expansion statements, +// aka 'template for'. +// +//===----------------------------------------------------------------------===// + +#include "clang/AST/DeclCXX.h" +#include "clang/AST/ExprCXX.h" +#include "clang/AST/StmtCXX.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Sema/EnterExpressionEvaluationContext.h" +#include "clang/Sema/Lookup.h" +#include "clang/Sema/Overload.h" +#include "clang/Sema/Sema.h" +#include "clang/Sema/Template.h" + +using namespace clang; +using namespace sema; + + +CXXExpansionStmtDecl * +Sema::ActOnCXXExpansionStmtDecl(unsigned TemplateDepth, + SourceLocation TemplateKWLoc) { + // Create a template parameter '__N'. This will be used to denote the index + // of the element that we're instantiating. CWG 3044 requires this type to + // be 'ptrdiff_t' for iterating expansion statements, so use that in all + // cases. + IdentifierInfo *ParmName = &Context.Idents.get("__N"); + QualType ParmTy = Context.getPointerDiffType(); + TypeSourceInfo *ParmTI = + Context.getTrivialTypeSourceInfo(ParmTy, TemplateKWLoc); + + auto *TParam = NonTypeTemplateParmDecl::Create( + Context, Context.getTranslationUnitDecl(), TemplateKWLoc, TemplateKWLoc, + TemplateDepth, /*Position=*/0, ParmName, ParmTy, /*ParameterPack=*/false, + ParmTI); + + return BuildCXXExpansionStmtDecl(CurContext, TemplateKWLoc, TParam); +} + +CXXExpansionStmtDecl * +Sema::BuildCXXExpansionStmtDecl(DeclContext *Ctx, SourceLocation TemplateKWLoc, + NonTypeTemplateParmDecl *NTTP) { + auto *TParamList = TemplateParameterList::Create( + Context, TemplateKWLoc, TemplateKWLoc, {NTTP}, TemplateKWLoc, + /*RequiresClause=*/nullptr); + auto *Result = + CXXExpansionStmtDecl::Create(Context, Ctx, TemplateKWLoc, TParamList); + Ctx->addDecl(Result); + return Result; +} + +ExprResult Sema::ActOnCXXExpansionInitList(MultiExprArg SubExprs, + SourceLocation LBraceLoc, + SourceLocation RBraceLoc) { + return CXXExpansionInitListExpr::Create(Context, SubExprs, LBraceLoc, + RBraceLoc); +} + +StmtResult Sema::ActOnCXXExpansionStmtPattern( + CXXExpansionStmtDecl *ESD, Stmt *Init, Stmt *ExpansionVarStmt, + Expr *ExpansionInitializer, SourceLocation LParenLoc, + SourceLocation ColonLoc, SourceLocation RParenLoc, + ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) { + Diag(ESD->getLocation(), diag::err_expansion_statements_todo); + return StmtError(); +} + +StmtResult Sema::FinishCXXExpansionStmt(Stmt *Exp, Stmt *Body) { + if (!Exp || !Body) + return StmtError(); + + llvm_unreachable("TODO"); ---------------- Sirraide wrote:
That’s also removed later; basically all the TODOs in the entire patch series are removed at some point (and if they aren’t, it’s because I missed one and we don’t have enough tests, but there _shouldn’t_ be any left by the end) https://github.com/llvm/llvm-project/pull/169681 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
