Skip to content

Commit

Permalink
Record externs in the functions map so that --callee can find them.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Davies <jeremy@davies.name>
  • Loading branch information
esky-software committed Dec 7, 2023
1 parent d132fa5 commit 3c7b06c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cally.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ def full_call_graph(functions, **kwargs):

print_buf(std_buf, '"{}" -> "{}";'.format(func, caller))

if caller not in functions:
if caller not in functions or \
len(functions[caller]["files"]) == 0:
print_buf(std_buf, '"{}" [style=dashed]'.
format(caller))

Expand Down Expand Up @@ -648,9 +649,10 @@ def main():
match = re.match(function, line)
if match is not None:
function_name = match.group("function")
if function_name in functions:
if function_name in functions and \
functions[function_name]["files"]:
if not config.no_warnings:
print_err("WARNING: Function {} defined in multiple"
print_err("WARNING: Function {} defined in multiple "
"files \"{}\"!".
format(function_name,
', '.join(map(
Expand All @@ -673,6 +675,13 @@ def main():
match = re.match(call, line)
if match is not None:
target = match.group("target")
if not config.no_externs and target not in functions:
functions[target] = dict()
functions[target]["files"] = list()
functions[target]["calls"] = dict()
functions[target]["refs"] = dict()
functions[target]["callee_calls"] = dict()
functions[target]["callee_refs"] = dict()
if target not in functions[function_name]["calls"]:
functions[function_name]["calls"][target] = True
else:
Expand Down

0 comments on commit 3c7b06c

Please sign in to comment.