Skip to content

Commit b7f7147

Browse files
committed
[Clang] [C++26] Expansion Statements (Part 4)
1 parent ad76ea8 commit b7f7147

File tree

2 files changed

+313
-224
lines changed

2 files changed

+313
-224
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11066,6 +11066,37 @@ class Sema final : public SemaBase {
1106611066
BuildForRangeKind Kind,
1106711067
ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps = {});
1106811068

11069+
/// Set the type of a for-range declaration whose for-range or expansion
11070+
/// initialiser is dependent.
11071+
void ActOnDependentForRangeInitializer(VarDecl *LoopVar,
11072+
BuildForRangeKind BFRK);
11073+
11074+
/// Holds the 'begin' and 'end' variables of a range-based for loop or
11075+
/// expansion statement; begin-expr and end-expr are also provided; the
11076+
/// latter are used in some diagnostics.
11077+
struct ForRangeBeginEndInfo {
11078+
VarDecl *BeginVar = nullptr;
11079+
VarDecl *EndVar = nullptr;
11080+
Expr *BeginExpr = nullptr;
11081+
Expr *EndExpr = nullptr;
11082+
bool isValid() const { return BeginVar != nullptr && EndVar != nullptr; }
11083+
};
11084+
11085+
/// Determine begin-expr and end-expr and build variable declarations for
11086+
/// them as per [stmt.ranged].
11087+
ForRangeBeginEndInfo BuildCXXForRangeBeginEndVars(
11088+
Scope *S, VarDecl *RangeVar, SourceLocation ColonLoc,
11089+
SourceLocation CoawaitLoc,
11090+
ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps,
11091+
BuildForRangeKind Kind, bool ForExpansionStmt,
11092+
StmtResult *RebuildResult = nullptr,
11093+
llvm::function_ref<StmtResult()> RebuildWithDereference = {});
11094+
11095+
/// Build the range variable of a range-based for loop or iterating
11096+
/// expansion statement and return its DeclStmt.
11097+
StmtResult BuildCXXForRangeRangeVar(Scope *S, Expr *Range,
11098+
bool ForExpansionStmt);
11099+
1106911100
/// FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
1107011101
/// This is a separate step from ActOnCXXForRangeStmt because analysis of the
1107111102
/// body cannot be performed until after the type of the range variable is
@@ -11207,6 +11238,9 @@ class Sema final : public SemaBase {
1120711238
SourceLocation Loc,
1120811239
unsigned NumParams);
1120911240

11241+
void ApplyForRangeOrExpansionStatementLifetimeExtension(
11242+
VarDecl *RangeVar, ArrayRef<MaterializeTemporaryExpr *> Temporaries);
11243+
1121011244
private:
1121111245
/// Check whether the given statement can have musttail applied to it,
1121211246
/// issuing a diagnostic and returning false if not.

0 commit comments

Comments
 (0)