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

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

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).

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!

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!

Sorry ,I forgot to give the definition. I define the print in the doInitialization(Module &M); and it seems in the InstVisitor(), this can not be identified .
What I really want to do is to get every load/store instructions’s operand address in runtime and print it out when the program is running. I wrote a function to do the print work and make it into a dynamic library, so in the functionPass , I define the print functiono like this :

bool doInitialization(Module &M)
{
//Get the refference of the types
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());

//Get the function we needed in runtime
Function *print = cast(M.getOrInsertFunction(“my_print”,
VoidType,
Int32Type,
VoidPtrType
));
};

I thought if I define the function here ,then in the InstVisitor, I can use it directly,without define it in every specific InstVisitor function()(eg:visitStoreInst() visitLoadInst(),etc).But I was wrong.

I redefine the function in the visitStoreInst(), and it works.

Is there any easy way to use the function I wrote myself in the instVisitor?

Thanks.