Skip to content

Commit 615d6c6

Browse files
committed
[clang] Reuse ContextRAII for ContextAndScopeRAII
1 parent 5319c89 commit 615d6c6

File tree

1 file changed

+5
-23
lines changed
  • interpreter/llvm-project/clang/include/clang/Sema

1 file changed

+5
-23
lines changed

interpreter/llvm-project/clang/include/clang/Sema/Sema.h

+5-23
Original file line numberDiff line numberDiff line change
@@ -1048,39 +1048,21 @@ class Sema final {
10481048
class ContextAndScopeRAII {
10491049
private:
10501050
Sema &S;
1051-
DeclContext *SavedContext;
1051+
ContextRAII SavedContext;
10521052
Scope *SavedScope;
1053-
ProcessingContextState SavedContextState;
1054-
QualType SavedCXXThisTypeOverride;
1055-
unsigned SavedFunctionScopesStart;
1056-
unsigned SavedInventedParameterInfosStart;
10571053

10581054
public:
10591055
ContextAndScopeRAII(Sema &S, DeclContext *ContextToPush, Scope *ScopeToPush)
1060-
: S(S), SavedContext(S.CurContext), SavedScope(S.CurScope),
1061-
SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
1062-
SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
1063-
SavedFunctionScopesStart(S.FunctionScopesStart),
1064-
SavedInventedParameterInfosStart(S.InventedParameterInfosStart)
1056+
: S(S), SavedContext(S, ContextToPush), SavedScope(S.CurScope)
10651057
{
1066-
assert(ContextToPush && "pushing null context");
1067-
S.CurContext = ContextToPush;
10681058
S.CurScope = ScopeToPush;
1069-
// Any saved FunctionScopes do not refer to this context.
1070-
S.FunctionScopesStart = S.FunctionScopes.size();
1071-
S.InventedParameterInfosStart = S.InventedParameterInfos.size();
10721059
}
10731060

10741061
void pop() {
1075-
if (!SavedContext) return;
1076-
S.CurContext = SavedContext;
1062+
SavedContext.pop();
1063+
if (!SavedScope) return;
10771064
S.CurScope = SavedScope;
1078-
S.DelayedDiagnostics.popUndelayed(SavedContextState);
1079-
S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
1080-
S.FunctionScopesStart = SavedFunctionScopesStart;
1081-
S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
1082-
SavedContext = 0;
1083-
SavedScope = 0;
1065+
SavedScope = nullptr;
10841066
}
10851067

10861068
~ContextAndScopeRAII() {

0 commit comments

Comments
 (0)