【发布时间】:2017-04-01 18:33:44
【问题描述】:
我正在尝试使用 LLVM 构建一个简单版本的代码分析工具。
我有一些 .ll 文件,其中包含某些程序的中间 LLVM 表示。
如何从 LLVM 的中间表示中获取在程序的每个函数中执行的函数调用列表?
我的输入参数是 LLVM 的一个实例:代表程序的模块类。然后,我用函数 getFunctionList() 得到程序中存在的函数列表。
void getFunctionCalls(const Module *M)
{
// Iterate functions in program
for (auto curFref = M->getFunctionList().begin(), endFref = M->getFunctionList().end();
curFref != endFref; ++curFref) {
// For each function
// Get list of function calls
}
}
【问题讨论】: