Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix support of clang-15 #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions bindgen/translation_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from clang.cindex import TranslationUnit as TU

from .utils import get_index, get_includes
from .utils import get_index, get_includes, get_clang_version



Expand Down Expand Up @@ -34,7 +34,8 @@ def parse_tu(path,
# if clang is configured with a system-wide config file, then some additional
# unexpected headers might be added by the indexer during parsing and those ones will
# have a None filename location
args.append('--no-default-config')
if get_clang_version() > 15 :
args.append('--no-default-config')

ix = get_index()

Expand All @@ -54,4 +55,4 @@ def parse_tu(path,

tr_unit.path = ('dummy.cxx',path.name)

return tr_unit
return tr_unit
21 changes: 18 additions & 3 deletions bindgen/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from clang.cindex import Config, Index, Cursor
from clang.cindex import Config, Index, Cursor, _CXString, register_function
from clang.cindex import conf as confClang
from ctypes import c_uint
from path import Path
from os import getenv
Expand All @@ -8,7 +9,7 @@

initialized = False
ix = None

clangVersion = None

def current_platform():

Expand Down Expand Up @@ -49,9 +50,19 @@ def get_includes(rv=[]):

return rv

def get_clang_version() :

global initialized,clangVersion

if not initialized: init_clang()

# clangVersion should be a string like "clang version MAJOR.MINOR.PATCH"
return int(clangVersion.split()[-1].split(".")[0])


def init_clang(path=None):

global initialized,ix
global clangVersion,initialized,ix

if not initialized:
conda_prefix = Path(getenv('CONDA_PREFIX', ''))
Expand All @@ -67,6 +78,10 @@ def init_clang(path=None):

Config.set_library_file(path)

item = ("clang_getClangVersion", [], _CXString, _CXString.from_result)
register_function(confClang.lib, item, False)
clangVersion = confClang.lib.clang_getClangVersion()

# Monkeypatch clang
monkeypatch_cursor('is_virtual',
'clang_isVirtualBase',
Expand Down
Loading