@@ -620,13 +620,32 @@ class Sema final {
620620 /// function, block, and method scopes that are currently active.
621621 SmallVector<sema::FunctionScopeInfo *, 4> FunctionScopes;
622622
623+ /// The index of the first FunctionScope that corresponds to the current
624+ /// context.
625+ unsigned FunctionScopesStart = 0;
626+
627+ ArrayRef<sema::FunctionScopeInfo*> getFunctionScopes() const {
628+ return llvm::makeArrayRef(FunctionScopes.begin() + FunctionScopesStart,
629+ FunctionScopes.end());
630+ }
631+
623632 /// Stack containing information needed when in C++2a an 'auto' is encountered
624633 /// in a function declaration parameter type specifier in order to invent a
625634 /// corresponding template parameter in the enclosing abbreviated function
626635 /// template. This information is also present in LambdaScopeInfo, stored in
627636 /// the FunctionScopes stack.
628637 SmallVector<InventedTemplateParameterInfo, 4> InventedParameterInfos;
629638
639+ /// The index of the first InventedParameterInfo that refers to the current
640+ /// context.
641+ unsigned InventedParameterInfosStart = 0;
642+
643+ ArrayRef<InventedTemplateParameterInfo> getInventedParameterInfos() const {
644+ return llvm::makeArrayRef(InventedParameterInfos.begin() +
645+ InventedParameterInfosStart,
646+ InventedParameterInfos.end());
647+ }
648+
630649 typedef LazyVector<TypedefNameDecl *, ExternalSemaSource,
631650 &ExternalSemaSource::ReadExtVectorDecls, 2, 2>
632651 ExtVectorDeclsType;
@@ -800,24 +819,33 @@ class Sema final {
800819 DeclContext *SavedContext;
801820 ProcessingContextState SavedContextState;
802821 QualType SavedCXXThisTypeOverride;
822+ unsigned SavedFunctionScopesStart;
823+ unsigned SavedInventedParameterInfosStart;
803824
804825 public:
805826 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
806827 : S(S), SavedContext(S.CurContext),
807828 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
808- SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
829+ SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
830+ SavedFunctionScopesStart(S.FunctionScopesStart),
831+ SavedInventedParameterInfosStart(S.InventedParameterInfosStart)
809832 {
810833 assert(ContextToPush && "pushing null context");
811834 S.CurContext = ContextToPush;
812835 if (NewThisContext)
813836 S.CXXThisTypeOverride = QualType();
837+ // Any saved FunctionScopes do not refer to this context.
838+ S.FunctionScopesStart = S.FunctionScopes.size();
839+ S.InventedParameterInfosStart = S.InventedParameterInfos.size();
814840 }
815841
816842 void pop() {
817843 if (!SavedContext) return;
818844 S.CurContext = SavedContext;
819845 S.DelayedDiagnostics.popUndelayed(SavedContextState);
820846 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
847+ S.FunctionScopesStart = SavedFunctionScopesStart;
848+ S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
821849 SavedContext = nullptr;
822850 }
823851
@@ -4923,8 +4951,10 @@ class Sema final {
49234951 LabelDecl *TheDecl);
49244952
49254953 void ActOnStartStmtExpr();
4926- ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4927- SourceLocation RPLoc); // "({..})"
4954+ ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
4955+ SourceLocation RPLoc);
4956+ ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4957+ SourceLocation RPLoc, unsigned TemplateDepth);
49284958 // Handle the final expression in a statement expression.
49294959 ExprResult ActOnStmtExprResult(ExprResult E);
49304960 void ActOnStmtExprError();
@@ -11924,6 +11954,13 @@ class Sema final {
1192411954 return DC;
1192511955 }
1192611956
11957+ /// Determine the number of levels of enclosing template parameters. This is
11958+ /// only usable while parsing. Note that this does not include dependent
11959+ /// contexts in which no template parameters have yet been declared, such as
11960+ /// in a terse function template or generic lambda before the first 'auto' is
11961+ /// encountered.
11962+ unsigned getTemplateDepth(Scope *S) const;
11963+
1192711964 /// To be used for checking whether the arguments being passed to
1192811965 /// function exceeds the number of parameters expected for it.
1192911966 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
0 commit comments