Skip to content

Commit b947e82

Browse files
committed
Fix cindex.py compatibility with older libclang.so
The issue is that we were calling clang_getCompletionBriefComment unconditionally. New we check if this function is available before calling it. llvm-svn: 164464
1 parent a7b9698 commit b947e82

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

clang/bindings/python/clang/cindex.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,9 @@ def availability(self):
17371737

17381738
@property
17391739
def briefComment(self):
1740-
return conf.lib.clang_getCompletionBriefComment(self.obj)
1740+
if conf.function_exists("clang_getCompletionBriefComment"):
1741+
return conf.lib.clang_getCompletionBriefComment(self.obj)
1742+
return _CXString()
17411743

17421744
def __repr__(self):
17431745
return " | ".join([str(a) for a in self]) \
@@ -3097,6 +3099,13 @@ def get_cindex_library(self):
30973099

30983100
return library
30993101

3102+
def function_exists(self, name):
3103+
try:
3104+
getattr(self.lib, name)
3105+
except AttributeError:
3106+
return False
3107+
3108+
return True
31003109

31013110
def register_enumerations():
31023111
for name, value in clang.enumerations.TokenKinds:

0 commit comments

Comments
 (0)