sighingnow / libclang

(Unofficial) Release libclang (clang.cindex) on pypi.
https://pypi.org/project/libclang
Other
81 stars 21 forks source link

Problem after package update #21

Closed MikhailGorobets closed 2 years ago

MikhailGorobets commented 2 years ago

After updating libclang from version 12.0.0 to 13.0.0, this error appeared

Traceback (most recent call last):
  File "cxx_parser.py", line 150, in generate_file
    translation_unit = index.parse(input_filename, args=['-std=c++14'])
  File "C:\Python\lib\site-packages\clang\cindex.py", line 2721, in parse
    return TranslationUnit.from_source(path, args, unsaved_files, options,
  File "C:\Python\lib\site-packages\clang\cindex.py", line 2836, in from_source
    raise TranslationUnitLoadError("Error parsing translation unit.")
clang.cindex.TranslationUnitLoadError: Error parsing translation unit.
sighingnow commented 2 years ago

Which platform you are working with?

Could you provide some snippets that can trigger this issue?

sighingnow commented 2 years ago

I see, you are working on Windows.

sighingnow commented 2 years ago

I cannot reproduce the issue with some complex cpp files (see *.vineyard-mod under https://github.com/v6d-io/v6d/tree/main/modules/basic/ds).

I will try to retest on Windows later. It would be great if you could provide me some minimal examples.

MikhailGorobets commented 2 years ago

@sighingnow Crashes on all platforms (Linux, MacOS, Windows). I'm trying to parse this file https://github.com/DiligentGraphics/DiligentCore/blob/master/Graphics/GraphicsEngine/interface/BlendState.h When I used package version 12.0.0 everything works fine

sighingnow commented 2 years ago

@sighingnow Crashes on all platforms (Linux, MacOS, Windows). I'm trying to parse this file https://github.com/DiligentGraphics/DiligentCore/blob/master/Graphics/GraphicsEngine/interface/BlendState.h When I used package version 12.0.0 everything works fine

Let me take a try..

MikhailGorobets commented 2 years ago

Also I can provide a minimal example of python code if you need it.

sighingnow commented 2 years ago

Graphics/GraphicsEngine/interface/BlendState.h

Could you provide your python code? I cannot reproduce the issue with both version of libclang on Mac.

sighingnow commented 2 years ago

Graphics/GraphicsEngine/interface/BlendState.h

Could you provide your python code? I cannot reproduce the issue with both version of libclang on Mac.

I can reproduce the issue now.

sighingnow commented 2 years ago

Could you try if

index.parse(input_filename, args=['-x', 'c++', '-std=c++14'])

solve your issue?

sighingnow commented 2 years ago

I think it is because -std=c++14 requires it be a C++ source file. There might some changes on the command line flags in clang 13.

MikhailGorobets commented 2 years ago

Could you try if

index.parse(input_filename, args=['-x', 'c++', '-std=c++14'])

solve your issue?

Thank you. This solves my problem. Before I passed arguments like this

index.parse(input_filename, args=['-std=c++14'])