You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a function with multiple return statements, they are all combined into
a single gcc.GimpleReturn, with a None for its .loc, which led to the
source-location at a return being reported as fun.end, which is confusing,
see:
https://fedorahosted.org/gcc-python-plugin/ticket/58
Add a "lastgccloc" attribute to absinterp.State, updating this whenever
building a new state with a new stmt that has a non-None location. States
with stmt.loc == None inherit the lastgccloc of the previous state, thus
propagating sane locations, and avoiding the need to use fun.end (I hope):
the return statements are reported as the location of the assignment to the
retval.
Manual inspection of the existing testcase results shows that the reported
locations are now sane. Added a testcase to specifically test for this
behavior:
tests/cpychecker/refcounts/multiple-returns
Fixes https://fedorahosted.org/gcc-python-plugin/ticket/58
Copy file name to clipboardExpand all lines: tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stderr.txt
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
In function 'test':
2
-
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:58:nn: warning: memory leak: ob_refcnt of '*value' is 1 too high [enabled by default]
2
+
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:nn: warning: memory leak: ob_refcnt of '*value' is 1 too high [enabled by default]
3
3
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:nn: note: '*value' was allocated at: value = PyLong_FromLong(1000);
4
-
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:58:nn: note: was expecting final owned ob_refcnt of '*value' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned, 1 borrowed
4
+
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:nn: note: was expecting final owned ob_refcnt of '*value' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned, 1 borrowed
5
5
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:nn: note: when PyDict_New() succeeds at: dict = PyDict_New();
6
6
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:33:nn: note: taking False path at: if (!dict) {
7
7
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:nn: note: reaching: value = PyLong_FromLong(1000);
@@ -13,5 +13,5 @@ tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:nn: note: w
13
13
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:nn: note: ob_refcnt is now refs: 1 owned, 1 borrowed
tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c.test-refcount-errors.html'
Copy file name to clipboardExpand all lines: tests/cpychecker/refcounts/PyList_Append/incorrect-loop/stderr.txt
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
In function 'test':
2
-
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:60:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]
2
+
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:59:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]
3
3
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:nn: note: '*item' was allocated at: item = item_ctor();
4
-
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:60:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned
4
+
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:59:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned
5
5
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:nn: note: when PyList_New() succeeds at: list = PyList_New(0);
6
6
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:35:nn: note: taking False path at: if (!list) {
7
7
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: reaching: for (i = 0; i < n; i++) {
@@ -20,5 +20,5 @@ tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: rea
20
20
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: when considering n == (int)1 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:29 at: for (i = 0; i < n; i++) {
21
21
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: taking False path at: for (i = 0; i < n; i++) {
tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c.test-refcount-errors.html'
Copy file name to clipboardExpand all lines: tests/cpychecker/refcounts/PyList_Append/incorrect/stderr.txt
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
In function 'test':
2
-
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:54:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]
2
+
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:53:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]
3
3
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:nn: note: '*item' was allocated at: item = PyLong_FromLong(42);
4
-
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:54:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned
4
+
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:53:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned
5
5
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:nn: note: when PyList_New() succeeds at: list = PyList_New(0);
6
6
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:33:nn: note: taking False path at: if (!list) {
tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyList_Append/incorrect/input.c.test-refcount-errors.html'
Copy file name to clipboardExpand all lines: tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/stderr.txt
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
In function 'handle_SET_ITEM_macro':
2
-
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:76:nn: warning: memory leak: ob_refcnt of PyLongObject is 1 too high [enabled by default]
2
+
cc1: warning: memory leak: ob_refcnt of PyLongObject is 1 too high [enabled by default]
3
3
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: PyLongObject was allocated at: items[2] = PyLong_FromLong(3000);
4
-
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:76:nn: note: was expecting final owned ob_refcnt of PyLongObject to be 1 due to object being referenced by: ob_item array for PyListObject[2] but final ob_refcnt is refs: 2 owned
4
+
cc1: note: was expecting final owned ob_refcnt of PyLongObject to be 1 due to object being referenced by: ob_item array for PyListObject[2] but final ob_refcnt is refs: 2 owned
5
5
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:nn: note: when PyList_New() succeeds at: list = PyList_New(3);
6
6
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:34:nn: note: taking False path at: if (!list) {
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:66:nn: note: PyLongObject is now referenced by 1 non-stack value(s): ob_item array for PyListObject[2]
19
19
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:71:nn: note: ob_refcnt is now refs: 2 owned
tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:24:nn: note: graphical error report for function 'handle_SET_ITEM_macro' written out to 'tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c.handle_SET_ITEM_macro-refcount-errors.html'
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:51:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]
2
+
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:50:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]
3
3
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34:nn: note: '*item' was allocated at: item = PyLong_FromLong(42);
4
-
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:51:nn: note: was expecting final owned ob_refcnt of '*item' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned
4
+
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:50:nn: note: was expecting final owned ob_refcnt of '*item' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned
5
5
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29:nn: note: when PyList_New() succeeds at: list = PyList_New(1);
6
6
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:30:nn: note: taking False path at: if (!list) {
tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:24:nn: note: graphical error report for function 'handle_SetItem' written out to 'tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c.handle_SetItem-refcount-errors.html'
0 commit comments