[clang] [Clang] [C++26] Iterating expansion statements using string injection (PR #208877)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 14 02:12:27 PDT 2026
================
@@ -1202,6 +1202,55 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
continue;
}
+ // Annotation token that tells the parser to build the 'begin' and 'end'
+ // declarations for an iterating expansion statement; this is used inside
+ // the lambda that computes the expansion size (see also
+ // Sema::ComputeExpansionSize()).
+ //
+ // The annotation token is followed by 2 identifier tokens, which indicate
+ // the variable names for the begin and end variable, respectively.
+ //
+ // We handle this here because this results in *two* statements, not one,
+ // and moreover, this annotation token shouldn't appear in any other context
+ // anyway.
+ //
+ // The reason this is a single annotation token is that the code that builds
+ // 'begin' and 'end' only supports building both at once.
+ if (Tok.is(tok::annot_expansion_stmt_declare_begin_end)) {
+ auto *RangeVarDecl = static_cast<VarDecl *>(Tok.getAnnotationValue());
----------------
cor3ntin wrote:
why isn't that just reusing `annotation_value_decl` ?
https://github.com/llvm/llvm-project/pull/208877
More information about the cfe-commits
mailing list