[llvm-branch-commits] [clang] 2181986 - Revert "[clang-repl] Fix crashing on unusable top-level declarations (#230054)"

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 9 21:50:02 PDT 2026


Author: Douglas Yung
Date: 2026-10-09T21:49:56-07:00
New Revision: 218198690322b27dc2386759ad3e660551d286db

URL: https://github.com/llvm/llvm-project/commit/218198690322b27dc2386759ad3e660551d286db
DIFF: https://github.com/llvm/llvm-project/commit/218198690322b27dc2386759ad3e660551d286db.diff

LOG: Revert "[clang-repl] Fix crashing on unusable top-level declarations (#230054)"

This reverts commit 6e92994f7a95d11cf450f6bec62104a0028b83cb.

Added: 
    

Modified: 
    clang/lib/Parse/ParseDecl.cpp
    clang/test/Interpreter/execute.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a3567d618cfa52..2f326451c3f13d 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5873,10 +5873,8 @@ Parser::DeclGroupPtrTy Parser::ParseTopLevelStmtDecl() {
   TopLevelStmtDecl *TLSD = Actions.ActOnStartTopLevelStmtDecl(getCurScope());
   StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx);
   Actions.ActOnFinishTopLevelStmtDecl(TLSD, R.get());
-  if (!R.isUsable()) {
+  if (!R.isUsable())
     R = Actions.ActOnNullStmt(Tok.getLocation());
-    TLSD->setStmt(R.get());
-  }
 
   if (Tok.is(tok::annot_repl_input_end) &&
       Tok.getAnnotationValue() != nullptr) {

diff  --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp
index 65dbc2d70a90f1..82cd70a93980a7 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -19,7 +19,3 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long
 
 inline int foo() { return 42; }
 int r3 = foo();
-
-return;
-printf("not crashed\n");
-// CHECK-NEXT: not crashed


        


More information about the llvm-branch-commits mailing list