@@ -206,6 +206,7 @@ def _extract_information(self):
206206 param_list_node = child
207207
208208 # Handle the full name
209+ # Extract the scope that the function is defined in
209210 logger .info ('Iterating parents' )
210211 tmp_root = self .root
211212 full_name = ''
@@ -218,11 +219,14 @@ def _extract_information(self):
218219 full_name = new_parent .child_by_field_name (
219220 'name' ).text .decode () + '::' + full_name
220221 if new_parent .type == 'namespace_definition' :
221- full_name = new_parent .child_by_field_name (
222- 'name' ).text .decode () + '::' + full_name
222+ # Ignore anonymous namespaces
223+ if new_parent .child_by_field_name ('name' ) is not None :
224+ full_name = new_parent .child_by_field_name (
225+ 'name' ).text .decode () + '::' + full_name
223226 tmp_root = new_parent
224227 logger .debug ('Full function scope not from name: %s' , full_name )
225228
229+ # Extract the name from the function declarator
226230 tmp_name = ''
227231 tmp_node = self .root .child_by_field_name ('declarator' )
228232 scope_to_add = ''
@@ -236,6 +240,9 @@ def _extract_information(self):
236240 if tmp_node .type == 'identifier' :
237241 tmp_name = tmp_node .text .decode ()
238242 break
243+ if tmp_node .type == 'field_identifier' :
244+ tmp_name = tmp_node .text .decode ()
245+ break
239246 if tmp_node .child_by_field_name (
240247 'name' ) is not None and tmp_node .child_by_field_name (
241248 'name' ).type == 'identifier' :
@@ -456,6 +463,9 @@ def _process_callsites(self, stmt: Node,
456463 var_type = ''
457464 var_type_obj = stmt .child_by_field_name ('type' )
458465
466+ if var_type_obj is None :
467+ return []
468+
459469 if var_type_obj .type == 'primitive_type' or var_type_obj .type == 'sized_type_specifier' :
460470 logger .debug ('Skipping.' )
461471 return []
@@ -464,8 +474,11 @@ def _process_callsites(self, stmt: Node,
464474 if var_type_obj is None :
465475 return []
466476 if var_type_obj .type == 'qualified_identifier' :
467- var_type += var_type_obj .child_by_field_name (
468- 'scope' ).text .decode () + '::'
477+ # logger.debug('qualified idenfitier: %s', var_type_obj.text.decode())
478+ if var_type_obj .child_by_field_name ('scope' ) is not None :
479+ var_type += var_type_obj .child_by_field_name (
480+ 'scope' ).text .decode ()
481+ var_type += '::'
469482 var_type_obj = var_type_obj .child_by_field_name ('name' )
470483
471484 if var_type_obj .type == 'template_type' :
@@ -650,10 +663,12 @@ def extract_calltree(self,
650663 """Extracts calltree string of a calltree so that FI core can use it."""
651664 # Create calltree from a given function
652665 # Find the function in the source code
666+ logger .debug ('Extracting calltree for %s' , str (function ))
653667 if not visited_functions :
654668 visited_functions = set ()
655669
656670 if not function :
671+ logger .debug ('No function' )
657672 return ''
658673
659674 if not source_code :
@@ -676,6 +691,7 @@ def extract_calltree(self,
676691 logger .debug ('Found no function node' )
677692 func_name = function
678693 else :
694+ logger .debug ('Could not find function' )
679695 return ''
680696
681697 line_to_print = ' ' * depth
@@ -689,9 +705,11 @@ def extract_calltree(self,
689705 line_to_print += '\n '
690706
691707 if function in visited_functions or not func_node or not source_code :
708+ logger .debug ('Function visited or no function node' )
692709 return line_to_print
693710
694711 visited_functions .add (function )
712+ logger .debug ('Iterating %s callsites' , len (func_node .base_callsites ))
695713 for cs , line in func_node .base_callsites :
696714 logger .debug ('Callsites: %s' , cs )
697715 line_to_print += self .extract_calltree (
0 commit comments