Skip to content

Commit

Permalink
core: frontends: cpp: refine CFG (#2020)
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <david@adalogics.com>
  • Loading branch information
DavidKorczynski authored Jan 23, 2025
1 parent 796a42c commit 353a752
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/fuzz_introspector/frontends/frontend_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def _process_namespace_node(self, node: Node, namespace: str = ''):

def _process_function_node(self, node: Node, namespace: str = ''):
"""Internal helper for processing function node."""

self.func_defs.append(
FunctionDefinition(node, self.tree_sitter_lang, self, namespace))

Expand Down Expand Up @@ -225,6 +226,13 @@ def _extract_information(self):
while True:
if tmp_node is None:
break
if tmp_node.type == 'reference_declarator':
for child in tmp_node.children:
if child.type == 'function_declarator':
if child.child_by_field_name(
'declarator').type == 'identifier':
tmp_name = child.child_by_field_name(
'declarator').text.decode()
if tmp_node.child_by_field_name('scope') is not None:
scope_to_add = tmp_node.child_by_field_name(
'scope').text.decode() + '::'
Expand Down Expand Up @@ -353,6 +361,7 @@ def _process_invoke(self, expr: Node,
"""Internal helper for processing the function invocation statement."""
# logger.debug('Handling invoke statmenet: %s', expr.text.decode())
# logger.debug('Current namespace: %s', self.namespace_or_class)
logger.debug('Processing invoke: %s', expr.text.decode())
callsites = []
target_name: str = ''

Expand Down Expand Up @@ -466,6 +475,7 @@ def _process_field_expr_return_type(self, field_expr: Node,
def _process_callsites(self, stmt: Node,
project) -> list[tuple[str, int, int]]:
"""Process and store the callsites of the function."""
logger.debug('Processing callsite: %s', stmt.text.decode())
callsites = []

# Call statement
Expand Down Expand Up @@ -526,7 +536,7 @@ def _process_callsites(self, stmt: Node,
return []

logger.debug('Extracted declaration: Type `%s` : Name `%s`',
var_type, var_name)
var_type, var_name.text.decode())
# Handles implicit default constructor call
if var_name.type == 'identifier':
# We're looking for a constructor, so add the name as it
Expand Down

0 comments on commit 353a752

Please sign in to comment.