So this is what I am trying to do:
if(isa<CallInst>(&(*BI)) )
{
ArrayRef <Value *> arguments('c');
StringRef fname = cast<CallInst>(&(*BI))->getCalledFunction()->getName();
errs()<<fname + " was called\n";
//CallInst *CI = dyn_cast<CallInst>(BI);
if(fname=="pthread_mutex_lock"){
Instruction *newInst = CallInst::Create(hook, arguments, "");
BB->getInstList().insert(BI, newInst);
}
where "hook" is the function. The error I get is:
no matching constructor for initialization of 'ArrayRef' ArrayRef arguments('c');
And when I change ArrayRef <Value *> arguments('c')
to ArrayRef <char> arguments('c')
the error becomes:
no matching function for call to 'Create' Instruction *newInst = CallInst::Create(hook, argume... ^~~~~~~~~~~~~~~~ /.../llvm/IR/Instructions.h:1187:20: note: candidate function not viable: no known conversion from 'ArrayRef' to 'ArrayRef' for 2nd argument static CallInst *Create(Value *Func, ^ /.../llvm/llvm-3.4/include/llvm/IR/Instructions.h:1200:20: note: candidate function not viable: no known conversion from 'ArrayRef' to 'const llvm::Twine' for 2nd argument static CallInst *Create(Value *F, const Twine &NameStr = "", ^ /.../llvm/llvm-3.4/include/llvm/IR/Instructions.h:1204:20: note: candidate function not viable: no known conversion from 'ArrayRef' to 'const llvm::Twine' for 2nd argument static CallInst *Create(Value *F, const Twine &NameStr, ^ /.../llvm/llvm-3.4/include/llvm/IR/Instructions.h:1194:20: note: candidate function not viable: requires 4 arguments, but 3 were provided static CallInst *Create(Value *Func, ^
I lack the understanding to passing arguments to external functions I call in my LLVM pass as I am new to this stuff. Help will be appreciated!