JinHuang
2014-Jan-08 07:25 UTC
[LLVMdev] reference to non-static member function must be called
Hi,everyone. I'm writing a pass in which a CallInst to an external function will be inserted. The function is declared like this: void func(int a, unsigned chat *p); and in the Pass(a Function Pass ,and using the InstVistor template ), I wrote like this: void visitStoreInst(StoreInst &SI) { //Get the refference of the types Module *M = SI.getParent()->getParent()->getParent(); IntegerType* Int8Type = IntegerType::getInt8Ty(M->getContext()); IntegerType* Int32Type = IntegerType::getInt32Ty(M->getContext()); IntegerType* Int64Type = IntegerType::getInt64Ty(M->getContext()); PointerType* VoidPtrType = PointerType::getUnqual(Int8Type); Type* VoidType = Type::getVoidTy(M->getContext()); DataLayout *TD = &getAnalysis<DataLayout>(); Value *Pointer = SI.getPointerOperand(); Pointer = castTo(Pointer,VoidPtrType,Pointer->getName(),&SI); uint64_t size = TD->getTypeStoreSize(SI.getOperand(0)->getType()); Value *StoreSize = ConstantInt::get(Int32Type, size); std::vector<Value *> args; args.push_back(StoreSize); args.push_back(Pointer); args.push_back(0); Instruction *inst = CallInst::Create(print,args,"",&SI); } while compiling , it came out such error: error: reference to non-static member function must be called Instruction *inst CallInst::Create(print,args,"",&SI); Can anyone tell me how to fix it? I can not get much useful information in google! Thank you! -JinHuang -- View this message in context: http://llvm.1065342.n5.nabble.com/reference-to-non-static-member-function-must-be-called-tp64865.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Philip Reames
2014-Jan-08 17:38 UTC
[LLVMdev] reference to non-static member function must be called
Which version of LLVM are you building against? In current TOT, there is no CallInst::Create function with the signature you're calling it with. (You're missing the name argument.) Philip On 1/7/14 11:25 PM, JinHuang wrote:> Hi,everyone. > I'm writing a pass in which a CallInst to an external function will be > inserted. The function is declared like this: > > void func(int a, unsigned chat *p); > > and in the Pass(a Function Pass ,and using the InstVistor template ), I > wrote like this: > > void visitStoreInst(StoreInst &SI) > { > //Get the refference of the types > Module *M = SI.getParent()->getParent()->getParent(); > IntegerType* Int8Type = IntegerType::getInt8Ty(M->getContext()); > IntegerType* Int32Type = IntegerType::getInt32Ty(M->getContext()); > IntegerType* Int64Type = IntegerType::getInt64Ty(M->getContext()); > PointerType* VoidPtrType = PointerType::getUnqual(Int8Type); > Type* VoidType = Type::getVoidTy(M->getContext()); > DataLayout *TD = &getAnalysis<DataLayout>(); > > Value *Pointer = SI.getPointerOperand(); > Pointer = castTo(Pointer,VoidPtrType,Pointer->getName(),&SI); > uint64_t size = TD->getTypeStoreSize(SI.getOperand(0)->getType()); > Value *StoreSize = ConstantInt::get(Int32Type, size); > std::vector<Value *> args; > args.push_back(StoreSize); > args.push_back(Pointer); > args.push_back(0); > > Instruction *inst = CallInst::Create(print,args,"",&SI); > > } > while compiling , it came out such error: > > error: reference to non-static member function must be > called > Instruction *inst > CallInst::Create(print,args,"",&SI); > > Can anyone tell me how to fix it? I can not get much useful information in > google! > Thank you! > > -JinHuang > > > > -- > View this message in context: http://llvm.1065342.n5.nabble.com/reference-to-non-static-member-function-must-be-called-tp64865.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reid Kleckner
2014-Jan-08 18:19 UTC
[LLVMdev] reference to non-static member function must be called
On Wed, Jan 8, 2014 at 12:25 AM, JinHuang <54jin.huang at gmail.com> wrote:> > Instruction *inst > CallInst::Create(print,args,"",&SI); >Where is "print" defined here? It looks like it's referencing FunctionPass::print(), which explains your error message (non-static member function without calling it). -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140108/288d6095/attachment.html>
JinHuang
2014-Jan-09 02:11 UTC
[LLVMdev] reference to non-static member function must be called
I'm using LLVM 3.3 Release. From the Class Reference Page. CallInst has a member function : static CallInst * Create (Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=0) This is what I want to use! the default name is "" and I also use that . Thanks! ----- Kind Regards! -JinHuang -- View this message in context: http://llvm.1065342.n5.nabble.com/reference-to-non-static-member-function-must-be-called-tp64865p64894.html Sent from the LLVM - Dev mailing list archive at Nabble.com.