I ran the checker against gdb and got an error:
Traceback (most recent call last):
File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/__init__.py",
line 33, in on_pass_execution
check_pyargs(fun)
File
"/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/PyArg_ParseTuple.py",
line 469, in check_pyargs
if stmt.fndecl.name == 'PyArg_ParseTuple':
AttributeError: 'NoneType' object has no attribute 'name'
../../archer/gdb/cli/cli-dump.c: In function ‘call_dump_func’:
../../archer/gdb/cli/cli-dump.c:787:1: fatal error: Unhandled Python exception raised
within callback
compilation terminated.
I am not certain, but perhaps this happens due to a call via a function
pointer.
The appended patch worked for me, at least in the sense that it removed
the error.
Also, the error location could be better here. E.g., in this case, if
it used the location of the call statement, I could more easily see what
exactly the problem is. As it is the location refers to the closing
brace of the function.
Tom
diff --git a/libcpychecker/PyArg_ParseTuple.py b/libcpychecker/PyArg_ParseTuple.py
index 13efbf1..2908460 100644
--- a/libcpychecker/PyArg_ParseTuple.py
+++ b/libcpychecker/PyArg_ParseTuple.py
@@ -466,7 +466,9 @@ def check_pyargs(fun):
if isinstance(stmt, gcc.GimpleCall):
#log('stmt.fn: %s %r' % (stmt.fn, stmt.fn))
#log('stmt.fndecl: %s %r' % (stmt.fndecl, stmt.fndecl))
- if stmt.fndecl.name == 'PyArg_ParseTuple':
+ if not hasattr(stmt.fndecl, 'name'):
+ pass
+ elif stmt.fndecl.name == 'PyArg_ParseTuple':
check_callsite(stmt, 'PyArg_ParseTuple', 1, 2)
elif stmt.fndecl.name == 'PyArg_ParseTupleAndKeywords':
check_callsite(stmt, 'PyArg_ParseTupleAndKeywords',
2, 4)