Workaround for issue#32

PiperOrigin-RevId: 321154163
Change-Id: Ida6defa3d5586b39e69e958524cee7579085826f
This commit is contained in:
Wiktor Garbacz 2020-07-14 07:27:51 -07:00 committed by Copybara-Service
parent b7d137721a
commit 405cc00683

View File

@ -578,6 +578,13 @@ class _TranslationUnit(object):
# TODO(szwl): for d in translation_unit.diagnostics:, handle that
for i, cursor in enumerate(self._walk_preorder()):
# Workaround for issue#32
try:
cursor.kind
except ValueError:
if cursor._kind_id >= 440: # pylint: disable=protected-access
continue
raise
# naive way to order types: they should be ordered when walking the tree
if cursor.kind.is_declaration():
self.order[cursor.hash] = i