从doxygen中提取,ClonedCodeInfo
该类可用于获取有关您刚刚克隆的函数的信息,即该函数是否包含调用或动态 alloca 指令。
文档再次告诉我们它是ValueMapTypeRemapper
一个抽象基类,需要任何子类实现其remapType()
方法。顾名思义,这可用于将函数中的某些类型替换为其他类型。
这是一些示例代码:
class MessageUpdater: public ValueMapTypeRemapper
{
public:
Type *remapType(Type *SrcTy)
{
std::map<Type *, Type *>::iterator i, e;
for (i = foo.begin(), e = foo.end(); i != e; ++i) {
if (SrcTy == i->first) {
return i->second;
}
}
assert(0 && "Type not found in map!");
return 0;
}
std::map<Type *, Type *> foo;
};
你可以这样称呼它:
MessageUpdater foobar;
foobar.foo.insert(std::make_pair(fromStruct, toStruct));
foobar.foo.insert(std::make_pair(fromStructPtr, toStructPtr));
foobar.foo.insert(std::make_pair(fromStructPtrPtr, toStructPtrPtr));
for (inst_iterator I = inst_begin(f), E = inst_end(f); I != E; ++I) {
foobar.foo.insert(std::make_pair(I->getType(), I->getType()));
}
std::map<Type *, Type *>::iterator i, e;
for (i = foobar.foo.begin(), e = foobar.foo.end(); i != e; ++i) {
errs() << *i->first << " maps to " << *i->second << "\n";
}
CloneFunctionInto(newFun, f, vmap, false, Returns, "", 0, &foobar);
您会注意到您不需要将ClonedCodeInfo
对象传递给此函数,因此我只需传入 0。