我正在将旧项目从LLVM 3.0升级到7.0.0。我在LLVM 4.0.0 Relesae Notes中阅读:
iterator现在存储ilist_node_base*而不是T*。ilist<T>::iterator和之间的隐式转换T*已被删除。客户端可以使用N->getIterator()(如果不是nullptr)或&*I(如果不是end())
现在,我遇到了几个实例,在这些实例中&*i编译器都允许取消对迭代器via的引用,但是我对此完全感到困惑。根据我对指针的理解,应该&*i == i吗?
一个特定的示例(此代码在LLVM 3.0中有效):
for (Function::iterator b = function.begin(), be = function.end(); b != be; b++)
{
for (BasicBlock::iterator i = b->begin(), ie=b->end(); i != ie; i++)
{
...
CallInst::Create(module.getFunction("foo"), args, "", i);
}
}
Run Code Online (Sandbox Code Playgroud)
当使用LLVM 7.0.0运行时,出现错误:
error: no matching function for call 'Create'
/root/llvm-7.0.0/include/llvm/IR/Instructions.h:1941.20: note: candidate function not viable: no known
conversion from …Run Code Online (Sandbox Code Playgroud)