我正在将旧项目从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 'BasicBlock::iterator'(aka 'ilist_iterator<node_options<llvm::Instruction,
extract_sentinel_tracking<>::value, extract_sentinel_tracking<>::is_explicit, void>, false,
false>') to 'llvm::Instruction *' for 4th argument
Run Code Online (Sandbox Code Playgroud)
但是以下代码编译得很好,并且知道这&*i是一个instruction*:
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)
我环顾四周,但没有找到关于此更改的充分说明。谁能提供一些见识?
| 归档时间: |
|
| 查看次数: |
48 次 |
| 最近记录: |