================
@@ -3598,9 +3598,13 @@ 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 result != 0:
+ raise TranslationUnitLoadError("Error reparsing translation unit.")
----------------
TApplencourt wrote:
They enum
[CXErrorCode](https://clang.llvm.org/doxygen/CXErrorCode_8h.html#adba17f287f8184fc266f2db4e669bf0f)
is not exposed to the binding AFAIK. And the eror class
```
class TranslationUnitLoadError(Exception):
"""Represents an error that occurred when loading a TranslationUnit.
This is raised in the case where a TranslationUnit could not be
instantiated due to failure in the libclang library.
FIXME: Make libclang expose additional error information in this scenario.
"""
pass
```
I'm unclear how the `enum` are exposed. So you propose to extend this class
with the value of the enum and do the same as in `TranslationUnitSaveError`?
(`from_source` raise `TranslationUnitLoadError` but the function doesn't return
any error, so I guess one need to deal with those side effect.)
Or just do `str(e) + "Error reparsing translation unit."`?
----
Now that I think more, it's kind of weird that `clang_reparseTranslationUnit()`
return an `int` and not an `enum CXErrorCode`
https://github.com/llvm/llvm-project/pull/172373
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits