Skip to content
Snippets Groups Projects
Commit df7682b1 authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[analysis-scripts] add a few more heuristics for difficulty estimation

parent cbcc7d61
No related branches found
No related tags found
No related merge requests found
......@@ -219,3 +219,27 @@ for header in chevron_includes:
non_posix_headers.append(header)
print(f"- warning: included non-POSIX header <{header}>")
print(f"Header-related warnings: {len(non_posix_headers)}")
# dynamic allocation
dynalloc_functions = set(["malloc", "calloc", "free", "realloc", "alloca", "mmap"])
dyncallees = dynalloc_functions.intersection(callees)
if dyncallees:
print(f"- note: calls to dynamic allocation functions: {', '.join(sorted(dyncallees))}")
# unsupported C11-specific features
c11_unsupported = ["_Alignas", "_Alignof", "_Generic", "_Static_assert"]
for keyword in c11_unsupported:
out = subprocess.Popen(["grep", "-n", '\\b' + keyword + '\\b'] + files + ["/dev/null"],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
lines = out.communicate()[0].decode('utf-8').splitlines()
if lines:
n = len(lines)
print(f"- warning: found {n} line{'s' if n > 1 else ''} with occurrences of unsupported C11 construct '{keyword}'")
# TODO:
# - detect absence of 'main' function (library)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment