示例#1
0
文件: modset.cpp 项目: wh5a/xgill
void BlockModset::ComputeModsetCall(BlockMemory *mcfg, PEdge *edge,
                                    BlockId *callee, Exp *rfld_chain)
{
  PPoint point = edge->GetSource();
  BlockModset *modset = GetBlockModset(callee);

  for (size_t mind = 0; mind < modset->GetModsetCount(); mind++) {
    const PointValue &cv = modset->GetModsetLval(mind);
    Exp *new_lval = CallEdgeAddRfldExp(cv.lval, callee, rfld_chain);

    GuardExpVector caller_res;
    mcfg->TranslateExp(TRK_Callee, point, new_lval, &caller_res);

    new_lval->DecRef();

    for (size_t cind = 0; cind < caller_res.Size(); cind++) {
      const GuardExp &gt = caller_res[cind];
      ProcessUpdatedLval(mcfg, gt.exp, cv.kind, false, edge->IsCall());
    }
  }

  modset->DecRef();
}
  void ComputeClobberCall(BlockMemory *mcfg, PEdge *edge,
                          Vector<GuardAssign> *assigns,
                          Vector<GuardAssign> *clobbered,
                          bool direct, BlockId *callee, Exp *rfld_chain)
  {
    PPoint point = edge->GetSource();
    BlockModset *modset = GetBlockModset(callee);

    // fill the assigns in the caller, but only for direct calls.
    if (direct) {
      for (size_t ind = 0; ind < modset->GetAssignCount(); ind++) {
        const GuardAssign &gts = modset->GetAssign(ind);
        mcfg->TranslateAssign(TRK_Callee, point, NULL,
                              gts.left, gts.right, gts.guard, assigns);
      }
    }

    for (size_t mind = 0; mind < modset->GetModsetCount(); mind++) {
      const PointValue &cv = modset->GetModsetLval(mind);
      Exp *new_lval = CallEdgeAddRfldExp(cv.lval, callee, rfld_chain);

      GuardExpVector caller_res;
      mcfg->TranslateExp(TRK_Callee, point, new_lval, &caller_res);

      for (size_t ind = 0; ind < caller_res.Size(); ind++) {
        const GuardExp &gt = caller_res[ind];

        // filter out lvalues containing rfld.
        if (gt.exp->RfldCount() > 0)
          continue;

        GuardAssign gti(gt.exp, cv.lval, gt.guard, cv.kind);
        clobbered->PushBack(gti);
      }
    }
  }