求助llvm:新建AllocaInst类报错的问题

cs1612900 2018-11-27 08:29:23
这是出错的代码部分
AllocaInst *alloc = new AllocaInst(typeOf(type), id.name.c_str(), "", context.currentBlock());
报错内容是 id.name.c_str(),const char*类型不能转为unsingned int
构造函数是这样的,
AllocaInst::AllocaInst ( Type * Ty,
unsigned AddrSpace,
const Twine & Name,
BasicBlock * InsertAtEnd
)
,但是其他的如 llvm::Function::Create ( FunctionType * Ty,
LinkageTypes Linkage,
unsigned AddrSpace,
const Twine & N = "",
Module * M = nullptr
)
在第三个参数位置使用同样的函数却没有报这样的错误
报错信息是这样的
codegen.cpp:171:64: error: invalid conversion from ‘const char*’ to ‘unsigned int’ [-fpermissive]
AllocaInst *alloc = new AllocaInst(typeOf(type), id.name.c_str(), "", context.
^
In file included from codegen.h:9:0,
from codegen.cpp:2:
/home/xingwj/LLVM/include/llvm/IR/Instructions.h:79:3: note: initializing argument 2 of ‘llvm::AllocaInst::AllocaInst(llvm::Type*, unsigned int, const llvm::Twine&, llvm::BasicBlock*)’
AllocaInst(Type *Ty, unsigned AddrSpace,
^
Makefile:27: recipe for target 'codegen.o' failed
make: *** [codegen.o] Error 1

跪求大佬指导
...全文
159 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧