Skip to content

Commit 8da8d81

Browse files
author
Yihao Wu
committed
Add current_function_decl
This is very frequently used when working in all different callbacks. Signed-off-by: Yihao Wu <[email protected]>
1 parent 5caf385 commit 8da8d81

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

gcc-python.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "gcc-c-api/gcc-declaration.h"
2929
#include "gcc-c-api/gcc-diagnostics.h"
3030
#include "gcc-c-api/gcc-option.h"
31+
#include "gcc-c-api/gcc-function.h"
3132

3233
int plugin_is_GPL_compatible;
3334

@@ -154,6 +155,12 @@ PyGcc_set_location(PyObject *self, PyObject *args)
154155
Py_RETURN_NONE;
155156
}
156157

158+
static PyObject *
159+
PyGcc_get_current_function(PyObject *self, PyObject *args)
160+
{
161+
return PyGccFunction_New(gcc_get_current_function());
162+
}
163+
157164
static bool add_option_to_list(gcc_option opt, void *user_data)
158165
{
159166
PyObject *result = (PyObject*)user_data;
@@ -458,6 +465,10 @@ static PyMethodDef GccMethods[] = {
458465
(PyCFunction)PyGcc_set_location,
459466
METH_VARARGS,
460467
("Temporarily set the default location for error reports\n")},
468+
{"get_current_function",
469+
(PyCFunction)PyGcc_get_current_function,
470+
METH_VARARGS,
471+
("Get the current function declaration\n")},
461472

462473
/* Options: */
463474
{"get_option_list",

0 commit comments

Comments
 (0)