https://github.com/TApplencourt updated 
https://github.com/llvm/llvm-project/pull/172373

>From 617d153250fb2a62a1a78e923cc7c4b205aa6e9c Mon Sep 17 00:00:00 2001
From: tapplencourt <[email protected]>
Date: Mon, 15 Dec 2025 21:35:36 +0000
Subject: [PATCH 1/4] Add check for reparsing

---
 clang/bindings/python/clang/cindex.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index d352373e85c60..ad1dcb56defab 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -3602,6 +3602,9 @@ def reparse(self, unsaved_files=None, options=0):
             self, len(unsaved_files), unsaved_files_array, options
         )
 
+        if not ptr:
+            raise TranslationUnitLoadError("Error reparsing translation unit.")
+
     def save(self, filename):
         """Saves the TranslationUnit to a file.
 

>From 8d55d8b5a1a0a0e6dac5fb2b2b04f09248b48104 Mon Sep 17 00:00:00 2001
From: Thomas Applencourt <[email protected]>
Date: Tue, 16 Dec 2025 16:13:15 +0000
Subject: [PATCH 2/4] Fix error checking

---
 clang/bindings/python/clang/cindex.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index ad1dcb56defab..745cb59e2299f 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -3598,11 +3598,12 @@ def reparse(self, unsaved_files=None, options=0):
             unsaved_files = []
 
         unsaved_files_array = self.process_unsaved_files(unsaved_files)
-        ptr = conf.lib.clang_reparseTranslationUnit(
-            self, len(unsaved_files), unsaved_files_array, options
+        result = int(
+            conf.lib.clang_reparseTranslationUnit(
+                self, len(unsaved_files), unsaved_files_array, options
+            )
         )
-
-        if not ptr:
+        if result != 0:
             raise TranslationUnitLoadError("Error reparsing translation unit.")
 
     def save(self, filename):

>From b72b691cd3787f14eca06cb677ca7ec3f5554feb Mon Sep 17 00:00:00 2001
From: tapplencourt <[email protected]>
Date: Wed, 17 Dec 2025 20:29:36 +0000
Subject: [PATCH 3/4] Improving error message

---
 clang/bindings/python/clang/cindex.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 745cb59e2299f..96704309b9c6c 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -3604,7 +3604,8 @@ def reparse(self, unsaved_files=None, options=0):
             )
         )
         if result != 0:
-            raise TranslationUnitLoadError("Error reparsing translation unit.")
+            msg = "Error reparsing translation unit: \n" + str(e)
+            raise TranslationUnitLoadError(msg)
 
     def save(self, filename):
         """Saves the TranslationUnit to a file.

>From 526e54d0551ce21d6617238d2fd156dba655cc53 Mon Sep 17 00:00:00 2001
From: tapplencourt <[email protected]>
Date: Wed, 17 Dec 2025 20:38:54 +0000
Subject: [PATCH 4/4] Fix previous fix...

---
 clang/bindings/python/clang/cindex.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 96704309b9c6c..1619a55d81344 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -3604,7 +3604,7 @@ def reparse(self, unsaved_files=None, options=0):
             )
         )
         if result != 0:
-            msg = "Error reparsing translation unit: \n" + str(e)
+            msg = "Error reparsing translation unit. Error code: " + 
str(result)
             raise TranslationUnitLoadError(msg)
 
     def save(self, filename):

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

Reply via email to