Skip to content

Commit 8e9e1ae

Browse files
committed
[clang] Reuse ContextRAII for ContextAndScopeRAII
(cherry picked from commit 07021ea, it was lost during the upgrade to LLVM 18)
1 parent a226dd4 commit 8e9e1ae

File tree

1 file changed

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

1 file changed

+6
-23
lines changed

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

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,38 +1075,21 @@ class Sema final {
10751075
class ContextAndScopeRAII {
10761076
private:
10771077
Sema &S;
1078-
DeclContext *SavedContext;
1078+
ContextRAII SavedContext;
10791079
Scope *SavedScope;
1080-
ProcessingContextState SavedContextState;
1081-
QualType SavedCXXThisTypeOverride;
1082-
unsigned SavedFunctionScopesStart;
1083-
unsigned SavedInventedParameterInfosStart;
10841080

10851081
public:
10861082
ContextAndScopeRAII(Sema &S, DeclContext *ContextToPush, Scope *ScopeToPush)
1087-
: S(S), SavedContext(S.CurContext), SavedScope(S.CurScope),
1088-
SavedContextState(S.DelayedDiagnostics.pushUndelayed()),
1089-
SavedCXXThisTypeOverride(S.CXXThisTypeOverride),
1090-
SavedFunctionScopesStart(S.FunctionScopesStart),
1091-
SavedInventedParameterInfosStart(S.InventedParameterInfosStart) {
1092-
assert(ContextToPush && "pushing null context");
1093-
S.CurContext = ContextToPush;
1083+
: S(S), SavedContext(S, ContextToPush), SavedScope(S.CurScope) {
10941084
S.CurScope = ScopeToPush;
1095-
// Any saved FunctionScopes do not refer to this context.
1096-
S.FunctionScopesStart = S.FunctionScopes.size();
1097-
S.InventedParameterInfosStart = S.InventedParameterInfos.size();
10981085
}
10991086

11001087
void pop() {
1101-
if (!SavedContext) return;
1102-
S.CurContext = SavedContext;
1088+
SavedContext.pop();
1089+
if (!SavedScope)
1090+
return;
11031091
S.CurScope = SavedScope;
1104-
S.DelayedDiagnostics.popUndelayed(SavedContextState);
1105-
S.CXXThisTypeOverride = SavedCXXThisTypeOverride;
1106-
S.FunctionScopesStart = SavedFunctionScopesStart;
1107-
S.InventedParameterInfosStart = SavedInventedParameterInfosStart;
1108-
SavedContext = 0;
1109-
SavedScope = 0;
1092+
SavedScope = nullptr;
11101093
}
11111094

11121095
~ContextAndScopeRAII() {

0 commit comments

Comments
 (0)