commit 181b59d44462a266279391798ff3dee6cea8cf1d
Author: David Malcolm <dmalcolm(a)redhat.com>
Date: Wed Oct 26 20:46:13 2011 -0400
use gcc-with-cpychecker's attributes on ourselves
Mark "gcc_python_finish_invoking_callback" as stealing a reference so that
when we compile the plugin with itself (with gcc-with-cpychecker), we don't
get false warnings about reference-counting issues.
gcc-python.c | 6 ++++++
gcc-python.h | 19 +++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/gcc-python.c b/gcc-python.c
index 7c39fee..d327169 100644
--- a/gcc-python.c
+++ b/gcc-python.c
@@ -170,6 +170,12 @@ static void
gcc_python_finish_invoking_callback(PyGILState_STATE gstate,
int expect_wrapped_data, PyObject *wrapped_gcc_data,
void *user_data)
+ CPYCHECKER_STEALS_REFERENCE_TO_ARG(3) /* wrapped_gcc_data */ ;
+
+static void
+gcc_python_finish_invoking_callback(PyGILState_STATE gstate,
+ int expect_wrapped_data, PyObject *wrapped_gcc_data,
+ void *user_data)
{
struct callback_closure *closure = (struct callback_closure *)user_data;
PyObject *args = NULL;
diff --git a/gcc-python.h b/gcc-python.h
index 55af6fa..99d552b 100644
--- a/gcc-python.h
+++ b/gcc-python.h
@@ -29,6 +29,25 @@
#define GCC_PYTHON_PLUGIN_BAD_EVENT (0xffff)
/*
+ Define some macros to allow us to use cpychecker's custom attributes when
+ compiling the plugin using itself (gcc-with-cpychecker), but also to turn
+ them off when compiling with vanilla gcc (and other compilers).
+*/
+#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)
+ #define CPYCHECKER_RETURNS_BORROWED_REF \
+ __attribute__((cpychecker_returns_borrowed_ref))
+#else
+ #define CPYCHECKER_RETURNS_BORROWED_REF
+#endif
+
+#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)
+ #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \
+ __attribute__((cpychecker_steals_reference_to_arg(n)))
+#else
+ #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)
+#endif
+
+/*
Macro DECLARE_SIMPLE_WRAPPER():
ARG_structname:
the struct tag for the resulting python wrapper class,