c - 如何将取消引用的指针与 CIL 模块完全匹配?
问题描述
我正在使用 https://people.eecs.berkeley.edu/~necula/cil/api/Cil.html
并想匹配指针并在某个表达式中提取变量名
示例(假设这是正确的)
int **p0,*p1,**p2,***p3;
我的表达:**p0 + *p1 + **p2 + **p3
我想匹配整个取消引用的指针,如:**p0, **p2, **p3
而不是部分匹配:(*p0, *p2, *p3
这就是我的代码所做的,因此它只会*p1
根据需要匹配)
class lvalVisitor ctx = object (*f d as params*)
inherit nopCilVisitor
method vlval lval =
match lval with
(*this will match only *pointer and not **pointer or ***pointer *)
| Mem (Lval (Var v, _)), _ -> printf "derefed. var %s" v.vname
SkipChildren
| Mem e, _ -> DoChildren
| _ -> DoChildren
end
TL;DR我想知道一个指针是否完全取消引用(计算它的星星不是一个好的选择)
解决方案
我不熟悉 CIL Api,但是递归方法不能完成这项工作吗?
例如:
class lvalVisitor ctx = object (self)
inherit nopCilVisitor
method vlval lval =
match lval with
(*this will match only *pointer and not **pointer or ***pointer *)
| Mem (Lval (Var v, _)), _ ->
Format.printf "derefed. var %s" v.vname;
SkipChildren
| Mem (Lval e), _ -> self#vlval e
| _ -> DoChildren
end;;
推荐阅读
- redirect - 调用重定向的 websphere 应用程序服务器会导致创建新会话
- python - 如何在python3中以二进制模式将多个数据类型的值保存在.txt文件中?
- javascript - Shadow Dom 支持制表符表
- google-cloud-platform - 将 GCP Cloud IAM 自定义角色的访问权限仅限于存储桶
- css - 在 Angular (CSS) 中使用网格
- facebook-graph-api - 有没有办法使用 facebook API 获取用户的工作历史记录?
- django - 如何在 django 中保存生成 otp 代码
- git - 在本地删除特定的提交
- r - 映射列并应用自定义函数
- reactjs - 有没有办法更改组件中的排版默认值?