From 336839dda86f60c3cf69853f1ab704914d1a819c Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Tue, 20 Oct 2020 22:56:27 +0200
Subject: [PATCH] [Analysis-scripts] add warning about assembly; fix bug
 related to ids in C11 but not POSIX

---
 share/analysis-scripts/estimate_difficulty.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/share/analysis-scripts/estimate_difficulty.py b/share/analysis-scripts/estimate_difficulty.py
index 8f5e89b3354..fe4a2b78c49 100755
--- a/share/analysis-scripts/estimate_difficulty.py
+++ b/share/analysis-scripts/estimate_difficulty.py
@@ -150,8 +150,12 @@ for callee in sorted(callees):
         used_headers.add(posix_identifiers[callee]["header"])
     if callee in c11_functions:
         # check that the callee is not a macro or type (e.g. va_arg)
-        if posix_identifiers[callee]["id_type"] != "function":
+        if callee not in posix_identifiers:
+            # a few functions, such as strcpy_s, are in C11 but not in POSIX
             continue
+        else:
+            if posix_identifiers[callee]["id_type"] != "function":
+                continue
         #print(f"C11 function: {callee}")
         if callee in libc_specified_functions:
             if verbose or debug:
@@ -241,5 +245,10 @@ for keyword in c11_unsupported:
         n = len(lines)
         print(f"- warning: found {n} line{'s' if n > 1 else ''} with occurrences of unsupported C11 construct '{keyword}'")
 
+# assembly code
+
+if "asm" in callees or "__asm" in callees or "__asm__" in callees:
+    print(f"- warning: code seems to contain inline assembly ('asm(...)')")
+
 # TODO:
 # - detect absence of 'main' function (library)
-- 
GitLab