Exemple #1
0
void Where::GetAssertBits(CheckerFrame *frame, PPoint point,
                          Bit *assert_cond, GuardBitVector *res)
{
  GuardBitVector base_res;
  frame->Memory()->TranslateBit(TRK_Point, point, assert_cond, &base_res);
  RemoveValBit(frame->Id(), frame->Memory(), base_res, res);
}
Exemple #2
0
void WherePostcondition::GetCalleeBits(CheckerFrame *callee_frame,
                                       Bit **base_bit, GuardBitVector *res)
{
  BlockMemory *callee_mcfg = callee_frame->Memory();
  PPoint exit_point = callee_mcfg->GetCFG()->GetExitPoint();

  *base_bit = BitConvertExitClobber(m_bit);

  GuardBitVector base_res;
  callee_mcfg->TranslateBit(TRK_Exit, exit_point, m_bit, &base_res);
  RemoveValBit(callee_frame->Id(), callee_frame->Memory(), base_res, res);
}
Exemple #3
0
void WherePostcondition::GetSkipLoopBits(Bit **base_bit, GuardBitVector *res)
{
  BlockMemory *mcfg = m_frame->Memory();

  *base_bit = BitConvertExitClobber(m_bit);

  // TODO: is SkipClobber the best translation to do here?
  // there can't be any clobbers in m_bit, just exit expressions
  // which will be handled correctly by TranslateBit. needs cleanup.

  GuardBitVector base_res;
  mcfg->TranslateBit(TRK_SkipClobber, m_point, m_bit, &base_res);
  RemoveValBit(m_frame->Id(), m_frame->Memory(), base_res, res);
}
Exemple #4
0
void WhereInvariant::GetHeapBits(CheckerFrame *write_frame,
                                 Exp *write_csu, Exp *base_csu,
                                 Bit **base_bit, GuardBitVector *res)
{
  BlockMemory *mcfg = write_frame->Memory();

  Exp *old_lval = NULL;
  if (m_csu) {
    Variable *this_var = Variable::Make(NULL, VK_This, NULL, 0, NULL);
    Exp *old_this = Exp::MakeVar(this_var);
    old_lval = Exp::MakeDrf(old_this);
  }

  Bit *exit_bit = TranslateHeapBit(old_lval, write_csu, true, m_bit);
  Assert(exit_bit);

  if (old_lval)
    old_lval->DecRef();

  // TODO: using this to get the base bit for an invariant is fairly
  // hacked up, but for now we can't do this correctly as the base bit
  // needs to be relative to the CFG exit point, not the point where
  // any writes occur at. for now just get the displayable point for
  // the base CSU, and hope that means the same thing at exit as at
  // the point of the write.

  Bit *new_bit = BitConvertExitClobber(m_bit);

  if (base_csu) {
    *base_bit = BitReplaceExp(new_bit, old_lval, base_csu);
    new_bit->DecRef();
  }
  else {
    *base_bit = new_bit;
  }

  GuardBitVector base_res;
  PPoint exit_point = mcfg->GetCFG()->GetExitPoint();
  mcfg->TranslateBit(TRK_Exit, exit_point, exit_bit, &base_res);

  exit_bit->DecRef();
  RemoveValBit(write_frame->Id(), write_frame->Memory(), base_res, res);
}
void WherePrecondition::GetCallerBits(CheckerFrame *caller_frame, PPoint point,
                                      Bit **base_bit, GuardBitVector *res)
{
  BlockMemory *caller_mcfg = caller_frame->Memory();
  TranslateKind kind = caller_frame->CalleeTranslateKind(point);

  bool unrolling = false;
  if (m_mcfg->GetId()->Kind() == B_Loop && caller_mcfg == m_mcfg)
    unrolling = true;

  ConvertCallsiteMapper mapper(caller_mcfg->GetCFG(), point, unrolling);
  Bit *caller_bit = m_bit->DoMap(&mapper);

  RemoveFrameMapper frame_mapper(caller_frame->Id());
  *base_bit = caller_bit->DoMap(&frame_mapper);

  GuardBitVector base_res;
  caller_mcfg->TranslateBit(kind, point, m_bit, &base_res);
  RemoveValBit(caller_frame->Id(), caller_frame->Memory(), base_res, res);
}