[LLVMdev] Strange error using CallInst constructor

Marc Claesen claesenm at gmail.com
Wed Nov 18 08:22:37 PST 2009


Hi,

This is probably more of a standard C++ question instead of an actual 
LLVM question, but here it goes anyway. I'm trying to invoke the 
following constructor:
CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator 
ArgEnd,
const Twine &NameStr, BasicBlock *InsertAtEnd);

My code is:

using namespace llvm;
void replaceByClone(Function *f, CallInst *I){
Function *clone = CloneFunction(f);
BasicBlock::iterator ii(I);
ReplaceInstWithInst(I->getParent()->getInstList(),ii,CallInst(clone,clone->arg_begin(),clone->arg_end()));
}

Compiling generates the following error:
error: no matching function for call to 
‘llvm::CallInst::CallInst(llvm::Function*&, 
llvm::ilist_iterator<llvm::Argument>, llvm::ilist_iterator<llvm::Argument>)’
/media/work/cpp-workspace/DivComp/include/llvm/Instructions.h:985: note: 
candidates are: llvm::CallInst::CallInst(llvm::Value*, const 
llvm::Twine&, llvm::BasicBlock*)
/media/work/cpp-workspace/DivComp/include/llvm/Instructions.h:984: note: 
llvm::CallInst::CallInst(llvm::Value*, const llvm::Twine&, 
llvm::Instruction*)
/media/work/cpp-workspace/DivComp/include/llvm/Instructions.h:982: note: 
llvm::CallInst::CallInst(llvm::Value*, llvm::Value*, const llvm::Twine&, 
llvm::BasicBlock*)
/media/work/cpp-workspace/DivComp/include/llvm/Instructions.h:980: note: 
llvm::CallInst::CallInst(llvm::Value*, llvm::Value*, const llvm::Twine&, 
llvm::Instruction*)
/media/work/cpp-workspace/DivComp/include/llvm/Instructions.h:940: note: 
llvm::CallInst::CallInst(const llvm::CallInst&)

Apparantly, clone is not of type Function* but of type Function*& ... I 
have no idea why this is. I've checked the LLVM source for similar 
invocations and they all seem to do what my code does. Any ideas?

Thanks in advance,
Marc Claesen



More information about the llvm-dev mailing list