@@ -630,13 +630,32 @@ class Sema final {
630630 /// function, block, and method scopes that are currently active.
631631 SmallVector<sema::FunctionScopeInfo *, 4> FunctionScopes;
632632
633+ /// The index of the first FunctionScope that corresponds to the current
634+ /// context.
635+ unsigned FunctionScopesStart = 0;
636+
637+ ArrayRef<sema::FunctionScopeInfo*> getFunctionScopes() const {
638+ return llvm::makeArrayRef(FunctionScopes.begin() + FunctionScopesStart,
639+ FunctionScopes.end());
640+ }
641+
633642 /// Stack containing information needed when in C++2a an 'auto' is encountered
634643 /// in a function declaration parameter type specifier in order to invent a
635644 /// corresponding template parameter in the enclosing abbreviated function
636645 /// template. This information is also present in LambdaScopeInfo, stored in
637646 /// the FunctionScopes stack.
638647 SmallVector<InventedTemplateParameterInfo, 4> InventedParameterInfos;
639648
649+ /// The index of the first InventedParameterInfo that refers to the current
650+ /// context.
651+ unsigned InventedParameterInfosStart = 0;
652+
653+ ArrayRef<InventedTemplateParameterInfo> getInventedParameterInfos() const {
654+ return llvm::makeArrayRef(InventedParameterInfos.begin() +
655+ InventedParameterInfosStart,
656+ InventedParameterInfos.end());
657+ }
658+
640659 typedef LazyVector<TypedefNameDecl *, ExternalSemaSource,
641660 &ExternalSemaSource::ReadExtVectorDecls, 2, 2>
642661 ExtVectorDeclsType;
@@ -810,24 +829,33 @@ class Sema final {
810829 DeclContext *SavedContext;
811830 ProcessingContextState SavedContextState;
812831 QualType SavedCXXThisTypeOverride;
832+ unsigned SavedFunctionScopesStart;
833+ unsigned SavedInventedParameterInfosStart;
813834
814835 public:
815836 ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true)
816837 : S(S), SavedContext(S.CurContext),
817838 SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
818- SavedCXXThisTypeOverride(S.CXXThisTypeOverride)
839+ SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
840+ SavedFunctionScopesStart(S.FunctionScopesStart),
841+ SavedInventedParameterInfosStart(S.InventedParameterInfosStart)
819842 {
820843 assert(ContextToPush && "pushing null context");
821844 S.CurContext = ContextToPush;
822845 if (NewThisContext)
823846 S.CXXThisTypeOverride = QualType();
847+ // Any saved FunctionScopes do not refer to this context.
848+ S.FunctionScopesStart = S.FunctionScopes.size();
849+ S.InventedParameterInfosStart = S.InventedParameterInfos.size();
824850 }
825851
826852 void pop() {
827853 if (!SavedContext) return;
828854 S.CurContext = SavedContext;
829855 S.DelayedDiagnostics.popUndelayed(SavedContextState);
830856 S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
857+ S.FunctionScopesStart = SavedFunctionScopesStart;
858+ S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
831859 SavedContext = nullptr;
832860 }
833861
@@ -4963,8 +4991,10 @@ class Sema final {
49634991 LabelDecl *TheDecl);
49644992
49654993 void ActOnStartStmtExpr();
4966- ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4967- SourceLocation RPLoc); // "({..})"
4994+ ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt,
4995+ SourceLocation RPLoc);
4996+ ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
4997+ SourceLocation RPLoc, unsigned TemplateDepth);
49684998 // Handle the final expression in a statement expression.
49694999 ExprResult ActOnStmtExprResult(ExprResult E);
49705000 void ActOnStmtExprError();
@@ -12020,6 +12050,13 @@ class Sema final {
1202012050 return DC;
1202112051 }
1202212052
12053+ /// Determine the number of levels of enclosing template parameters. This is
12054+ /// only usable while parsing. Note that this does not include dependent
12055+ /// contexts in which no template parameters have yet been declared, such as
12056+ /// in a terse function template or generic lambda before the first 'auto' is
12057+ /// encountered.
12058+ unsigned getTemplateDepth(Scope *S) const;
12059+
1202312060 /// To be used for checking whether the arguments being passed to
1202412061 /// function exceeds the number of parameters expected for it.
1202512062 static bool TooManyArguments(size_t NumParams, size_t NumArgs,
0 commit comments