Exemplo n.º 1
0
/// \brief Run checkers for end of path.
void CheckerManager::runCheckersForEndPath(EndOfFunctionNodeBuilder &B,
                                           ExprEngine &Eng) {
  for (unsigned i = 0, e = EndPathCheckers.size(); i != e; ++i) {
    CheckEndPathFunc fn = EndPathCheckers[i];
    EndOfFunctionNodeBuilder specialB = B.withCheckerTag(fn.Checker);
    fn(specialB, Eng);
  }
}
Exemplo n.º 2
0
void MallocChecker::checkEndPath(EndOfFunctionNodeBuilder &B,
                                 ExprEngine &Eng) const {
  const GRState *state = B.getState();
  RegionStateTy M = state->get<RegionState>();

  for (RegionStateTy::iterator I = M.begin(), E = M.end(); I != E; ++I) {
    RefState RS = I->second;
    if (RS.isAllocated()) {
      ExplodedNode *N = B.generateNode(state);
      if (N) {
        if (!BT_Leak)
          BT_Leak.reset(new BuiltinBug("Memory leak",
                    "Allocated memory never released. Potential memory leak."));
        BugReport *R = new BugReport(*BT_Leak, BT_Leak->getDescription(), N);
        Eng.getBugReporter().EmitReport(R);
      }
    }
  }
}
Exemplo n.º 3
0
void StreamChecker::checkEndPath(EndOfFunctionNodeBuilder &B,
                                 ExprEngine &Eng) const {
    const GRState *state = B.getState();
    typedef llvm::ImmutableMap<SymbolRef, StreamState> SymMap;
    SymMap M = state->get<StreamState>();

    for (SymMap::iterator I = M.begin(), E = M.end(); I != E; ++I) {
        StreamState SS = I->second;
        if (SS.isOpened()) {
            ExplodedNode *N = B.generateNode(state);
            if (N) {
                if (!BT_ResourceLeak)
                    BT_ResourceLeak.reset(new BuiltinBug("Resource Leak",
                                                         "Opened File never closed. Potential Resource leak."));
                BugReport *R = new BugReport(*BT_ResourceLeak,
                                             BT_ResourceLeak->getDescription(), N);
                Eng.getBugReporter().EmitReport(R);
            }
        }
    }
}