CallInst 构造函数是私有的?
CallInst constructor is private?
我正在尝试构建一个简单版本的代码分析工具 LLVM.I 有几个 .ll 文件包含某些程序的中间 LLVM 表示,我正在尝试获取函数列表在程序的每个函数中执行的调用。
这是我的代码,感谢我之前post.
的回答
void getFunctionCalls(const Module *M)
{
for (const Function &F : *M) {
for (const BasicBlock &BB : F) {
for (const Instruction &I : BB) {
if (CallInst callInst = dyn_cast<CallInst>(I)) {
if (Function *calledFunction = callInst->getCalledFunction()) {
if (calledFunction->getName().startswith("llvm.dbg.declare")) {
// Do something
}
}
}
}
}
}
}
当我编译它时,我收到一条错误消息:
home/kike/llvm-3.9.0.src/include/llvm/IR/Instructions.h: In function ‘void getFunctionCalls(const llvm::Module*)’:
/home/kike/llvm-3.9.0.src/include/llvm/IR/Instructions.h:1357:3: error: ‘llvm::CallInst::CallInst(const llvm::CallInst&)’ is private
这意味着CallInst构造函数是私有的?这种情况下,如何获取函数调用列表?
[编辑 1]:
我也试过把我作为参考,像这样:
void getFunctionCalls(const Module *M)
{
for (const Function &F : *M) {
for (const BasicBlock &BB : F) {
for (const Instruction &I : BB) {
if (CallInst * callInst = dyn_cast<CallInst>(&I)) {
if (Function *calledFunction = callInst->getCalledFunction()) {
if (calledFunction->getName().startswith("llvm.dbg.declare")) {
// Do something
}
}
}
}
}
}
}
我得到这个错误:
invalid conversion from ‘llvm::cast_retty<llvm::CallInst, const llvm::Instruction*>::ret_type {aka const llvm::CallInst*}’ to ‘llvm::CallInst*’
CallInst 没有复制构造函数,因为它不是按值传递的。使用
const CallInst* callInst = dyn_cast<CallInst>(&I)
而不是
CallInst callInst = dyn_cast<CallInst>(I)
我正在尝试构建一个简单版本的代码分析工具 LLVM.I 有几个 .ll 文件包含某些程序的中间 LLVM 表示,我正在尝试获取函数列表在程序的每个函数中执行的调用。
这是我的代码,感谢我之前post
void getFunctionCalls(const Module *M)
{
for (const Function &F : *M) {
for (const BasicBlock &BB : F) {
for (const Instruction &I : BB) {
if (CallInst callInst = dyn_cast<CallInst>(I)) {
if (Function *calledFunction = callInst->getCalledFunction()) {
if (calledFunction->getName().startswith("llvm.dbg.declare")) {
// Do something
}
}
}
}
}
}
}
当我编译它时,我收到一条错误消息:
home/kike/llvm-3.9.0.src/include/llvm/IR/Instructions.h: In function ‘void getFunctionCalls(const llvm::Module*)’:
/home/kike/llvm-3.9.0.src/include/llvm/IR/Instructions.h:1357:3: error: ‘llvm::CallInst::CallInst(const llvm::CallInst&)’ is private
这意味着CallInst构造函数是私有的?这种情况下,如何获取函数调用列表?
[编辑 1]:
我也试过把我作为参考,像这样:
void getFunctionCalls(const Module *M)
{
for (const Function &F : *M) {
for (const BasicBlock &BB : F) {
for (const Instruction &I : BB) {
if (CallInst * callInst = dyn_cast<CallInst>(&I)) {
if (Function *calledFunction = callInst->getCalledFunction()) {
if (calledFunction->getName().startswith("llvm.dbg.declare")) {
// Do something
}
}
}
}
}
}
}
我得到这个错误:
invalid conversion from ‘llvm::cast_retty<llvm::CallInst, const llvm::Instruction*>::ret_type {aka const llvm::CallInst*}’ to ‘llvm::CallInst*’
CallInst 没有复制构造函数,因为它不是按值传递的。使用
const CallInst* callInst = dyn_cast<CallInst>(&I)
而不是
CallInst callInst = dyn_cast<CallInst>(I)