Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: frontends: cpp: refine CFG #2020

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading