@@ -206,6 +206,7 @@ def _extract_information(self):
206
206
param_list_node = child
207
207
208
208
# Handle the full name
209
+ # Extract the scope that the function is defined in
209
210
logger .info ('Iterating parents' )
210
211
tmp_root = self .root
211
212
full_name = ''
@@ -218,11 +219,14 @@ def _extract_information(self):
218
219
full_name = new_parent .child_by_field_name (
219
220
'name' ).text .decode () + '::' + full_name
220
221
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
223
226
tmp_root = new_parent
224
227
logger .debug ('Full function scope not from name: %s' , full_name )
225
228
229
+ # Extract the name from the function declarator
226
230
tmp_name = ''
227
231
tmp_node = self .root .child_by_field_name ('declarator' )
228
232
scope_to_add = ''
@@ -236,6 +240,9 @@ def _extract_information(self):
236
240
if tmp_node .type == 'identifier' :
237
241
tmp_name = tmp_node .text .decode ()
238
242
break
243
+ if tmp_node .type == 'field_identifier' :
244
+ tmp_name = tmp_node .text .decode ()
245
+ break
239
246
if tmp_node .child_by_field_name (
240
247
'name' ) is not None and tmp_node .child_by_field_name (
241
248
'name' ).type == 'identifier' :
@@ -456,6 +463,9 @@ def _process_callsites(self, stmt: Node,
456
463
var_type = ''
457
464
var_type_obj = stmt .child_by_field_name ('type' )
458
465
466
+ if var_type_obj is None :
467
+ return []
468
+
459
469
if var_type_obj .type == 'primitive_type' or var_type_obj .type == 'sized_type_specifier' :
460
470
logger .debug ('Skipping.' )
461
471
return []
@@ -464,8 +474,11 @@ def _process_callsites(self, stmt: Node,
464
474
if var_type_obj is None :
465
475
return []
466
476
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 += '::'
469
482
var_type_obj = var_type_obj .child_by_field_name ('name' )
470
483
471
484
if var_type_obj .type == 'template_type' :
@@ -650,10 +663,12 @@ def extract_calltree(self,
650
663
"""Extracts calltree string of a calltree so that FI core can use it."""
651
664
# Create calltree from a given function
652
665
# Find the function in the source code
666
+ logger .debug ('Extracting calltree for %s' , str (function ))
653
667
if not visited_functions :
654
668
visited_functions = set ()
655
669
656
670
if not function :
671
+ logger .debug ('No function' )
657
672
return ''
658
673
659
674
if not source_code :
@@ -676,6 +691,7 @@ def extract_calltree(self,
676
691
logger .debug ('Found no function node' )
677
692
func_name = function
678
693
else :
694
+ logger .debug ('Could not find function' )
679
695
return ''
680
696
681
697
line_to_print = ' ' * depth
@@ -689,9 +705,11 @@ def extract_calltree(self,
689
705
line_to_print += '\n '
690
706
691
707
if function in visited_functions or not func_node or not source_code :
708
+ logger .debug ('Function visited or no function node' )
692
709
return line_to_print
693
710
694
711
visited_functions .add (function )
712
+ logger .debug ('Iterating %s callsites' , len (func_node .base_callsites ))
695
713
for cs , line in func_node .base_callsites :
696
714
logger .debug ('Callsites: %s' , cs )
697
715
line_to_print += self .extract_calltree (
0 commit comments