https://github.com/asudarsa-qti updated 
https://github.com/llvm/llvm-project/pull/225861

>From ed315a10c9c2615d9737a1966db137b14242e8ed Mon Sep 17 00:00:00 2001
From: Arvind Sudarsanam <[email protected]>
Date: Wed, 23 Sep 2026 13:26:54 -0400
Subject: [PATCH 1/3] Fix for a clang-repl crash when passing non-existent file
 to --Xcc

---
 clang/include/clang/Interpreter/Interpreter.h   | 3 +++
 clang/lib/Interpreter/Interpreter.cpp           | 5 ++++-
 clang/test/Interpreter/nonexistent-xcc-file.cpp | 7 +++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Interpreter/nonexistent-xcc-file.cpp

diff --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index c2622b23d5d9c..415cef67c611f 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -127,6 +127,9 @@ class Interpreter {
   /// An optional compiler instance for CUDA offloading
   std::unique_ptr<CompilerInstance> DeviceCI;
 
+  /// This member is set when source file has been successfully created. It
+  /// will be used to gate 'ending' this file when the object is destroyed.
+  bool SourceFileCreated = false;
 protected:
   // Derived classes can use an extended interface of the Interpreter.
   Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 092f3ede771f6..bdf35b1adb723 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -403,7 +403,8 @@ Interpreter::Interpreter(std::unique_ptr<CompilerInstance> 
Instance,
 
 Interpreter::~Interpreter() {
   IncrParser.reset();
-  Act->FinalizeAction();
+  if (SourceFileCreated)
+    Act->FinalizeAction();
   if (DeviceParser)
     DeviceParser.reset();
   if (DeviceAct)
@@ -469,6 +470,8 @@ llvm::Expected<std::unique_ptr<Interpreter>> 
Interpreter::create(
 
   Interp->markUserCodeStart();
 
+  Interp->SourceFileCreated = true;
+
   return std::move(Interp);
 }
 
diff --git a/clang/test/Interpreter/nonexistent-xcc-file.cpp 
b/clang/test/Interpreter/nonexistent-xcc-file.cpp
new file mode 100644
index 0000000000000..7e3322787c931
--- /dev/null
+++ b/clang/test/Interpreter/nonexistent-xcc-file.cpp
@@ -0,0 +1,7 @@
+// RUN: not clang-repl --Xcc=%t/nonexistent.cpp 2>&1 | FileCheck %s
+
+// CHECK: error: error reading '{{.*}}nonexistent.cpp': No such file or 
directory
+// CHECK-NOT: Compiler instance not registered
+// CHECK-NOT: Assertion
+// CHECK-NOT: segmentation fault
+// CHECK-NOT: core dumped

>From 4c0a66d7db9476d85bbc9d195fa124abca21b55f Mon Sep 17 00:00:00 2001
From: Arvind Sudarsanam <[email protected]>
Date: Wed, 23 Sep 2026 13:40:33 -0400
Subject: [PATCH 2/3] Minor clang-format issue

---
 clang/include/clang/Interpreter/Interpreter.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index 415cef67c611f..16cf2c70b7287 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -130,6 +130,7 @@ class Interpreter {
   /// This member is set when source file has been successfully created. It
   /// will be used to gate 'ending' this file when the object is destroyed.
   bool SourceFileCreated = false;
+
 protected:
   // Derived classes can use an extended interface of the Interpreter.
   Interpreter(std::unique_ptr<CompilerInstance> Instance, llvm::Error &Err,

>From 2e8bfb35be9033183371a8397cda4a1796ccd72a Mon Sep 17 00:00:00 2001
From: Arvind Sudarsanam <[email protected]>
Date: Wed, 23 Sep 2026 19:57:02 -0400
Subject: [PATCH 3/3] Account for case-sensitive error message

---
 clang/test/Interpreter/nonexistent-xcc-file.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Interpreter/nonexistent-xcc-file.cpp 
b/clang/test/Interpreter/nonexistent-xcc-file.cpp
index 7e3322787c931..7b1bb8abd94ce 100644
--- a/clang/test/Interpreter/nonexistent-xcc-file.cpp
+++ b/clang/test/Interpreter/nonexistent-xcc-file.cpp
@@ -1,4 +1,4 @@
-// RUN: not clang-repl --Xcc=%t/nonexistent.cpp 2>&1 | FileCheck %s
+// RUN: not clang-repl --Xcc=%t/nonexistent.cpp 2>&1 | FileCheck --ignore-case 
%s
 
 // CHECK: error: error reading '{{.*}}nonexistent.cpp': No such file or 
directory
 // CHECK-NOT: Compiler instance not registered

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to