On 02/07/2022 08:33, Alberto Faria wrote: Alberto, hello. I was testing this patch as follows:
./static-analyzer.py build target/ppc/mmu-hash64.c <snip>
@@ -627,9 +744,31 @@ def is_coroutine_fn(node: Cursor) -> bool: else: break - return node.kind == CursorKind.FUNCTION_DECL and is_annotated_with( - node, "coroutine_fn" - ) + if node.kind in [CursorKind.DECL_REF_EXPR, CursorKind.MEMBER_REF_EXPR]: + node = node.referenced + + # --- + + if node.kind == CursorKind.FUNCTION_DECL:
And I receive an exception on the line above saying that node is of type NoneType. Seems that `node = node.referenced` is setting `node` to None in this case. I was unable to understand the root cause of it. Is this an incorrect usage of the tool from my part? Full error message below Traceback (most recent call last): File "./static-analyzer.py", line 327, in analyze_translation_unit checker(tu, context.absolute_path, log) File "./static-analyzer.py", line 613, in check_coroutine_pointers and is_coroutine_fn(right) File "./static-analyzer.py", line 781, in is_coroutine_fn if node.kind == CursorKind.FUNCTION_DECL: AttributeError: 'NoneType' object has no attribute 'kind' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3.8/multiprocessing/pool.py", line 125, in worker result = (True, func(*args, **kwds)) File "/usr/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar return list(map(*args)) File "./static-analyzer.py", line 329, in analyze_translation_unit raise RuntimeError(f"Error analyzing {relative_path}") from e RuntimeError: Error analyzing target/ppc/mmu-hash64.c """ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./static-analyzer.py", line 893, in <module> main() File "./static-analyzer.py", line 123, in main analyze_translation_units(args, contexts) File "./static-analyzer.py", line 240, in analyze_translation_units results = pool.map(analyze_translation_unit, contexts) File "/usr/lib/python3.8/multiprocessing/pool.py", line 364, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/lib/python3.8/multiprocessing/pool.py", line 771, in get raise self._value RuntimeError: Error analyzing target/ppc/mmu-hash64.c > + return is_annotated_with(node, "coroutine_fn")
+ + if node.kind in [ + CursorKind.FIELD_DECL, + CursorKind.VAR_DECL, + CursorKind.PARM_DECL, + ]: + + if is_annotated_with(node, "coroutine_fn"): + return True + + # TODO: If type is typedef or pointer to typedef, follow typedef. + + return False + + if node.kind == CursorKind.TYPEDEF_DECL: + return is_annotated_with(node, "coroutine_fn") + + return False
Best regards, -- Víctor Cora Colombo Instituto de Pesquisas ELDORADO Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>