Skip to content

Commit

Permalink
condformats_serialization_generate.py: support for aarch64
Browse files Browse the repository at this point in the history
LLVM/Clang on AArch64 will report that most AST nodes are not
definition, which is not true. The following modifies script to
check definition based on location information directly (file, line,
 and column).

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
  • Loading branch information
David Abdurachmanov authored and David Abdurachmanov committed May 22, 2014
1 parent a2aac79 commit 1aa0a14
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
'ROOT', 'edm', 'ora', 'coral', 'CLHEP', 'Geom', 'HepGeom',
])

def is_definition_by_loc(node):
if node.get_definition() is None:
return False
if node.location is None or node.get_definition().location is None:
return False
return node.location == node.get_definition().location

def is_serializable_class(node):
for child in node.get_children():
Expand All @@ -87,7 +93,7 @@ def is_serializable_class(node):

def is_serializable_class_manual(node):
for child in node.get_children():
if child.spelling == 'cond_serialization_manual' and child.kind == clang.cindex.CursorKind.CXX_METHOD and not child.is_definition():
if child.spelling == 'cond_serialization_manual' and child.kind == clang.cindex.CursorKind.CXX_METHOD and not is_definition_by_loc(child):
return True

return False
Expand Down Expand Up @@ -158,7 +164,7 @@ def get_serializable_classes_members(node, all_template_types=None, namespace=''
results.update(get_serializable_classes_members(child, all_template_types, namespace + child.spelling + '::', only_from_path))
continue

if child.kind in [clang.cindex.CursorKind.CLASS_DECL, clang.cindex.CursorKind.STRUCT_DECL, clang.cindex.CursorKind.CLASS_TEMPLATE] and child.is_definition():
if child.kind in [clang.cindex.CursorKind.CLASS_DECL, clang.cindex.CursorKind.STRUCT_DECL, clang.cindex.CursorKind.CLASS_TEMPLATE] and is_definition_by_loc(child):
logging.debug('Found struct/class/template definition: %s', child.spelling if child.spelling else '<anonymous>')

if only_from_path is not None \
Expand Down Expand Up @@ -222,7 +228,7 @@ def get_serializable_classes_members(node, all_template_types=None, namespace=''
base_objects.append(base_object)

# Member variables
elif member.kind == clang.cindex.CursorKind.FIELD_DECL and member.is_definition():
elif member.kind == clang.cindex.CursorKind.FIELD_DECL and is_definition_by_loc(member):
# While clang 3.3 does not ignore unrecognized attributes
# (see http://llvm.org/viewvc/llvm-project?revision=165082&view=revision )
# for some reason they do not appear in the bindings yet
Expand Down

0 comments on commit 1aa0a14

Please sign in to comment.