annotateWarningWithSourceLineInformation(state, obligation, bugInstance);
for (Iterator<State> i = factAtExit.stateIterator(); i.hasNext();) { State state = i.next(); checkStateForLeakedObligations(state, leakedObligationMap); Obligation obligation = entry.getKey(); State state = entry.getValue(); reportWarning(obligation, state, factAtExit);
private void checkStateForLeakedObligations(State state, Map<Obligation, State> leakedObligationMap) throws IllegalStateException { if (DEBUG) { Path path = state.getPath(); if (path.getLength() > 0 && path.getBlockIdAt(path.getLength() - 1) != cfg.getExit().getLabel()) { throw new IllegalStateException("path " + path + " at cfg exit has no label for exit block"); } } for (int id = 0; id < database.getFactory().getMaxObligationTypes(); ++id) { Obligation obligation = database.getFactory().getObligationById(id); // If the raw count produced by the analysis // for this obligation type is 0, // assume everything is ok on this state's path. int rawLeakCount = state.getObligationSet().getCount(id); if (rawLeakCount == 0) { continue; } // Apply the false-positive suppression heuristics int leakCount = getAdjustedLeakCount(state, id); if (leakCount > 0) { leakedObligationMap.put(obligation, state); } // TODO: if the leak count is less than 0, then a nonexistent // resource was closed } }
for (Iterator<State> i = factAtExit.stateIterator(); i.hasNext();) { State state = i.next(); checkStateForLeakedObligations(state, leakedObligationMap); Obligation obligation = entry.getKey(); State state = entry.getValue(); reportWarning(obligation, state, factAtExit);
annotateWarningWithSourceLineInformation(state, obligation, bugInstance);
private void checkStateForLeakedObligations(State state, Map<Obligation, State> leakedObligationMap) throws IllegalStateException { if (DEBUG) { Path path = state.getPath(); if (path.getLength() > 0 && path.getBlockIdAt(path.getLength() - 1) != cfg.getExit().getLabel()) { throw new IllegalStateException("path " + path + " at cfg exit has no label for exit block"); } } for (int id = 0; id < database.getFactory().getMaxObligationTypes(); ++id) { Obligation obligation = database.getFactory().getObligationById(id); // If the raw count produced by the analysis // for this obligation type is 0, // assume everything is ok on this state's path. int rawLeakCount = state.getObligationSet().getCount(id); if (rawLeakCount == 0) { continue; } // Apply the false-positive suppression heuristics int leakCount = getAdjustedLeakCount(state, id); if (leakCount > 0) { leakedObligationMap.put(obligation, state); } // TODO: if the leak count is less than 0, then a nonexistent // resource was closed } }
private void annotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance) { // The reportPath() method currently does all reporting // of source line information. if (REPORT_PATH) { reportPath(bugInstance, obligation, state); } }
@Override protected void visitMethodCFG(MethodDescriptor methodDescriptor, CFG cfg) throws CheckedAnalysisException { MethodChecker methodChecker = new MethodChecker(methodDescriptor, cfg); methodChecker.analyzeMethod(); }
private void annotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance) { // The reportPath() method currently does all reporting // of source line information. if (REPORT_PATH) { reportPath(bugInstance, obligation, state); } }
@Override protected void visitMethodCFG(MethodDescriptor methodDescriptor, CFG cfg) throws CheckedAnalysisException { MethodChecker methodChecker = new MethodChecker(methodDescriptor, cfg); methodChecker.analyzeMethod(); }