<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - libclang python bindings does not reparse file"
href="https://llvm.org/bugs/show_bug.cgi?id=24471">24471</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>libclang python bindings does not reparse file
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>libclang
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jeanmarc.leroux@aerys.in
</td>
</tr>
<tr>
<th>CC</th>
<td>klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I'm trying tu use liblcang to list all the setters of my C++ headers. I'm using
the Python bindings and libclang.so.3.6.
def parse(self, flags):
self._index = clang.cindex.Index.create()
self._clangSource = self._index.parse(self._path, args=flags)
self._class =
self._get_minko_script_classes(self._clangSource.cursor)[0]
print(self._class)
self._name = self._class.spelling
self._props = self._get_class_setters(self._class)
def _get_minko_script_classes(self, root, cursors=[]):
for cursor in root.get_children():
if cursor.kind == clang.cindex.CursorKind.CLASS_DECL:
for c in cursor.get_children():
if c.kind == clang.cindex.CursorKind.CXX_BASE_SPECIFIER:
if c.displayname == "minko::component::AbstractScript":
cursors.append(cursor)
else:
self._get_minko_script_classes(cursor, cursors)
return cursors
def _get_class_setters(self, cursor):
setters = {}
for child in cursor.get_children():
if (child.kind == clang.cindex.CursorKind.CXX_METHOD
and child.access_specifier ==
clang.cindex.AccessSpecifier.PUBLIC
and child.result_type.spelling == 'void'):
args = list(child.get_arguments())
if len(args) == 1 and args[0].type.spelling in
MinkoScript.setter_types:
setters[child.spelling] = args[0].type.spelling
return setters
Those 3 methods work just fine and `self._props` will be filled with a
(setter_name, setter_type) dict.
Now when the C++ header is edited - to add a setter for example - I need to
update `self._props`.
So I call `parse` again. It re-creates everything it possibly could about
libclang (index, translation unit...). But the result is exactly the same as
the 1st time. It still takes some time though: it looks like it's actually
doing the job. But it gives the exact same result.
To prove it, I print the class declaration `Cursor` object, and every call to
`parse` will give the same output (so I'm exact it's the exact same `Cursor`
object. For example, calling `parse` twice will give:
<clang.cindex.Cursor object at 0x7f77105572f0>
<clang.cindex.Cursor object at 0x7f77105572f0>
I've tried:
- using the libclang `reparse` function: the problem is the same.
- copying the file in a temporary file and re-parsing it: the problem is the
same (I'm guessing I should change the file name to, and not just it's path...
but still).
Re-starting my Python app (Blender in this case) is the only way to actually
reparse the file. So I'vre tried reloading the module with `importlib.reload`.
But it makes libclang unusable with weird errors such as "expected Cursor
instance, got Cursor".
So I think it's a bug.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>