aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDevajith <devajith.valaparambil.sreeramaswamy@cern.ch>2025-07-23 17:03:07 +0200
committerGitHub <noreply@github.com>2025-07-23 17:03:07 +0200
commit38a977d00c4e22f4a2a21e5f577c57df2053872e (patch)
tree10f5caaea2c1ea96550b608061e05152cecc63c2 /clang/lib/Sema
parentd2dedcd11f51c23d8401b7e5eff11b23faea652b (diff)
downloadllvm-38a977d00c4e22f4a2a21e5f577c57df2053872e.zip
llvm-38a977d00c4e22f4a2a21e5f577c57df2053872e.tar.gz
llvm-38a977d00c4e22f4a2a21e5f577c57df2053872e.tar.bz2
[clang-repl] Always clean up scope and context for TopLevelStmtDecl (#150215)
This fixes an issue introduced by https://github.com/llvm/llvm-project/pull/84150, where failing to pop compound scope, function scope info, and decl context after a failed statement could lead to an inconsistent internal state.
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index fd22e01..6e66698 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -20573,7 +20573,8 @@ TopLevelStmtDecl *Sema::ActOnStartTopLevelStmtDecl(Scope *S) {
}
void Sema::ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement) {
- D->setStmt(Statement);
+ if (Statement)
+ D->setStmt(Statement);
PopCompoundScope();
PopFunctionScopeInfo();
PopDeclContext();