commit 0519ff959476d77c1f650914e19d2b7aace37dcf Author: David Malcolm dmalcolm@redhat.com Date: Thu Mar 29 21:19:43 2012 -0400
expose the cfg edge flags needed by the python plugin
With this commit, the python plugin's full test suite passes
generate-cfg-c.py | 13 +++++-------- proposed-plugin-api/gcc-cfg.c | 11 ++++++++--- proposed-plugin-api/gcc-cfg.h | 14 ++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) --- diff --git a/generate-cfg-c.py b/generate-cfg-c.py index dc69165..ea16843 100644 --- a/generate-cfg-c.py +++ b/generate-cfg-c.py @@ -50,19 +50,16 @@ def generate_edge(): 'The destination gcc.BasicBlock of this edge')], identifier_prefix = 'gcc_Edge', typename = 'PyGccEdge') - """ - for flag in ('EDGE_FALLTHRU', 'EDGE_ABNORMAL', 'EDGE_ABNORMAL_CALL', - 'EDGE_EH', 'EDGE_FAKE', 'EDGE_DFS_BACK', 'EDGE_CAN_FALLTHRU', - 'EDGE_IRREDUCIBLE_LOOP', 'EDGE_SIBCALL', 'EDGE_LOOP_EXIT', - 'EDGE_TRUE_VALUE', 'EDGE_FALSE_VALUE', 'EDGE_EXECUTABLE', - 'EDGE_CROSSING'): + + # We only expose the subset of the flags exposed by the plugin API: + for flag in ('EDGE_TRUE_VALUE', 'EDGE_FALSE_VALUE'): assert flag.startswith('EDGE_') flagname = flag[5:].lower() getsettable.add_simple_getter(cu, flagname, - 'PyBool_FromLong(gcc_edge_is_%s(self->e))' % flagname, + 'PyBool_FromLong(GccCfgEdgeI_Is%s(self->e))' % camel_case(flagname), 'Boolean, corresponding to flag %s' % flag) - """ + cu.add_defn(getsettable.c_defn())
pytype = PyGccWrapperTypeObject(identifier = 'gcc_EdgeType', diff --git a/proposed-plugin-api/gcc-cfg.c b/proposed-plugin-api/gcc-cfg.c index 0e98bc3..0ff948c 100644 --- a/proposed-plugin-api/gcc-cfg.c +++ b/proposed-plugin-api/gcc-cfg.c @@ -232,12 +232,17 @@ GccCfgEdgeI_GetDest(GccCfgEdgeI edge) return GccPrivate_make_CfgBlockI(edge.inner->dest); }
-GCC_IMPLEMENT_PUBLIC_API(bool) -GccCfgEdgeI_IsFallthru(GccCfgEdgeI edge) +GCC_PUBLIC_API(bool) +GccCfgEdgeI_IsTrueValue(GccCfgEdgeI edge) { - return edge.inner->flags & EDGE_FALLTHRU; + return (edge.inner->flags & EDGE_TRUE_VALUE) == EDGE_TRUE_VALUE; }
+GCC_PUBLIC_API(bool) +GccCfgEdgeI_IsFalseValue(GccCfgEdgeI edge) +{ + return (edge.inner->flags & EDGE_FALSE_VALUE) == EDGE_FALSE_VALUE; +}
/* PEP-7 diff --git a/proposed-plugin-api/gcc-cfg.h b/proposed-plugin-api/gcc-cfg.h index c06ab74..925dcdb 100644 --- a/proposed-plugin-api/gcc-cfg.h +++ b/proposed-plugin-api/gcc-cfg.h @@ -98,15 +98,13 @@ GccCfgEdgeI_GetDest(GccCfgEdgeI edge); GCC_PUBLIC_API(void) GccCfgEdgeI_MarkInUse(GccCfgEdgeI edge);
-/* - for flag in ('EDGE_FALLTHRU', 'EDGE_ABNORMAL', 'EDGE_ABNORMAL_CALL', - 'EDGE_EH', 'EDGE_FAKE', 'EDGE_DFS_BACK', 'EDGE_CAN_FALLTHRU', - 'EDGE_IRREDUCIBLE_LOOP', 'EDGE_SIBCALL', 'EDGE_LOOP_EXIT', - 'EDGE_TRUE_VALUE', 'EDGE_FALSE_VALUE', 'EDGE_EXECUTABLE', - 'EDGE_CROSSING'): -*/ +/* How many of the flags do we want to expose? */ GCC_PUBLIC_API(bool) -GccCfgEdgeI_IsFallthru(GccCfgEdgeI edge); +GccCfgEdgeI_IsTrueValue(GccCfgEdgeI edge); + +GCC_PUBLIC_API(bool) +GccCfgEdgeI_IsFalseValue(GccCfgEdgeI edge); + /* etc */
/*