2012-02-01 3 views

답변

3

음, 여기에 기능에 대한 모든 호출을 찾아 기본 FunctionPass이다 : 그것은에서 일하고 함수를 호출하는 모든 함수의 이름을 인쇄

class MyPass : public FunctionPass { 
public: 
    static char ID; 

    MyPass() 
     : FunctionPass(ID) 
    {} 

    virtual bool runOnFunction(Function &F) { 
     for (Function::iterator bb = F.begin(), bb_e = F.end(); bb != bb_e; ++bb) { 
      for (BasicBlock::iterator ii = bb->begin(), ii_e = bb->end(); ii != ii_e; ++ii) { 
       if (CallInst *callInst = dyn_cast<CallInst>(&*ii)) { 
        Function *calledFunc = callInst->getCalledFunction(); 
        errs() << "Calling function " << calledFunc->getName() << "\n"; 
       } 
      } 
     } 
    } 
}; 

. getNameStringRef이므로 원하는 모든 값과 비교해보십시오.