Skip to content

Conversation

@TApplencourt
Copy link
Contributor

Add error checking for reparseTranslationUnit.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:as-a-library libclang and C++ API labels Dec 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 15, 2025

@llvm/pr-subscribers-clang

Author: Thomas Applencourt (TApplencourt)

Changes

Add error checking for reparseTranslationUnit.


Full diff: https://github.com/llvm/llvm-project/pull/172373.diff

1 Files Affected:

  • (modified) clang/bindings/python/clang/cindex.py (+3)
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.
 

@TApplencourt
Copy link
Contributor Author

Oh, broke something. My bad, will have a look tomorrow. I trusted the doc, should have tested locally before submitting a PR. Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:as-a-library libclang and C++ API clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants