Dexter
Dexter

Reputation: 35

Check for printf in call instruction

 %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([22 x i8]* @.str, i64 0, i64 0), i32 7) #3

For the above instruction, how can I check whether the call instruction contains printf ?

Upvotes: 0

Views: 419

Answers (1)

Joky
Joky

Reputation: 1628

Just compare the name of the called function:

bool isPrintfCall(CallInst &C) {
   auto *F = C.getCalledFunction();
   auto isPrintf = (F->getName() == "printf");
   return isPrintf;
}

Upvotes: 1

Related Questions