PathDiagnosticPiece *ConditionBRVisitor::VisitNodeImpl(const ExplodedNode *N,
                                                       const ExplodedNode *Prev,
                                                       BugReporterContext &BRC,
                                                       BugReport &BR) {
  
  const ProgramPoint &progPoint = N->getLocation();

  ProgramStateRef CurrentState = N->getState();
  ProgramStateRef PrevState = Prev->getState();
  
  // Compare the GDMs of the state, because that is where constraints
  // are managed.  Note that ensure that we only look at nodes that
  // were generated by the analyzer engine proper, not checkers.
  if (CurrentState->getGDM().getRoot() ==
      PrevState->getGDM().getRoot())
    return 0;
  
  // If an assumption was made on a branch, it should be caught
  // here by looking at the state transition.
  if (const BlockEdge *BE = dyn_cast<BlockEdge>(&progPoint)) {
    const CFGBlock *srcBlk = BE->getSrc();    
    if (const Stmt *term = srcBlk->getTerminator())
      return VisitTerminator(term, N, srcBlk, BE->getDst(), BR, BRC);
    return 0;
  }
  
  if (const PostStmt *PS = dyn_cast<PostStmt>(&progPoint)) {
    // FIXME: Assuming that BugReporter is a GRBugReporter is a layering
    // violation.
    const std::pair<const ProgramPointTag *, const ProgramPointTag *> &tags =      
      cast<GRBugReporter>(BRC.getBugReporter()).
        getEngine().getEagerlyAssumeTags();

    const ProgramPointTag *tag = PS->getTag();
    if (tag == tags.first)
      return VisitTrueTest(cast<Expr>(PS->getStmt()), true,
                           BRC, BR, N);
    if (tag == tags.second)
      return VisitTrueTest(cast<Expr>(PS->getStmt()), false,
                           BRC, BR, N);
                           
    return 0;
  }
    
  return 0;
}
示例#2
0
ProgramStateRef ProgramStateManager::removeGDM(ProgramStateRef state, void *Key) {
    ProgramState::GenericDataMap OldM = state->getGDM();
    ProgramState::GenericDataMap NewM = GDMFactory.remove(OldM, Key);

    if (NewM == OldM)
        return state;

    ProgramState NewState = *state;
    NewState.GDM = NewM;
    return getPersistentState(NewState);
}
示例#3
0
ProgramStateRef ProgramStateManager::addGDM(ProgramStateRef St, void *Key, void *Data) {
    ProgramState::GenericDataMap M1 = St->getGDM();
    ProgramState::GenericDataMap M2 = GDMFactory.add(M1, Key, Data);

    if (M1 == M2)
        return St;

    ProgramState NewSt = *St;
    NewSt.GDM = M2;
    return getPersistentState(NewSt);
}