如何在clang Python绑定中公开ImplicitCastExpr节点?

问题描述

我有C代码

int func4b(float *x,int (*fp)(int *hello,float *goodbye));

int hello(int *x,float *y) {
  return 0;
}

void callerb() {
  float x=6.0;
  func4b(&x,&hello);   // This is line 28
}

clang-12  -cc1 -ast-dump t2_calls.c 
provides:
   ...
   ...
   `-CallExpr 0x55ee03be4d68 <line:28:3,col:20> 'int'
      |-ImplicitCastExpr 0x55ee03be4d50 <col:3> 'int (*)(float *,int (*)(int *,float *))' <FunctionToPointerDecay>

使用Clang的python绑定,我在第28行调用函数

CursorKind.CALL_EXPR func4b line=28 col=3
CursorKind.UNEXPOSED_EXPR func4b line=28 col=3

在我的python代码中,我有兴趣了解两者

  1. 这是节点类型“ ImplicitCastExpr”,并且
  2. functionCall的参数签名为'int(*)(float ,int()(int *,float *))'

这是可以通过几个小时的工作实现的吗?我一直在阅读:

https://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang,但是已经有9年的历史了,我希望python绑定现在可以更完整一些。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)