[LLVMdev] Strange error using CallInst constructor

Jeffrey Yasskin jyasskin at google.com
Wed Nov 18 08:39:49 PST 2009


You're trying to invoke a 5-argument constructor with 3 arguments.
Ain't gonna work.

CallInst() is private, so even if you found the right overload, it
wouldn't compile. To build LLVM IR objects, you generally call their
static Foo::Create() function, which does have an overload taking your
parameters.

It doesn't really matter that clone is of type Function*&. It's true,
and will let you pass it to a parameter of that type, but it'll also
match a parameter of type Function*.

On Wed, Nov 18, 2009 at 8:22 AM, Marc Claesen <claesenm at gmail.com> wrote:
> 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
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list