The following Python code is supposed to parse C++ code:
import clang.cindex
index = clang.cindex.Index.create()
translation_unit = index.parse(cpp_source_filename, args=['-std=c++20'])
Problems start if function parse raises a TranslationUnitLoadError. If I catch and print the TranslationUnitLoadError instance, I only get "Error parsing translation unit."
How to get a decent compiler error message, or at least the location of the error in the source file?
Web search yields the advise to look into translation_unit.diagnostics - but this is not pertinent here because the error is raised before translation_unit is set.
The following Python code is supposed to parse C++ code:
Problems start if function
parseraises aTranslationUnitLoadError. If I catch and print theTranslationUnitLoadErrorinstance, I only get "Error parsing translation unit."How to get a decent compiler error message, or at least the location of the error in the source file?
Web search yields the advise to look into
translation_unit.diagnostics- but this is not pertinent here because the error is raised beforetranslation_unitis set.