检查printf in call instruction

时间:2015-01-03 14:59:45

标签: llvm llvm-clang

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

对于上述指令,如何检查调用指令是否包含printf?

1 个答案:

答案 0 :(得分:1)

只需比较被调用函数的名称:

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