#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/Checker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
#include <utility>
usingnamespaceclang;
usingnamespaceento;
namespace {
SymbolVector;
struct StreamState { … };
class SimpleStreamChecker : public Checker<check::PostCall,
check::PreCall,
check::DeadSymbols,
check::PointerEscape> { … };
}
REGISTER_MAP_WITH_PROGRAMSTATE(…)
void SimpleStreamChecker::checkPostCall(const CallEvent &Call,
CheckerContext &C) const { … }
void SimpleStreamChecker::checkPreCall(const CallEvent &Call,
CheckerContext &C) const { … }
static bool isLeaked(SymbolRef Sym, const StreamState &SS,
bool IsSymDead, ProgramStateRef State) { … }
void SimpleStreamChecker::checkDeadSymbols(SymbolReaper &SymReaper,
CheckerContext &C) const { … }
void SimpleStreamChecker::reportDoubleClose(SymbolRef FileDescSym,
const CallEvent &Call,
CheckerContext &C) const { … }
void SimpleStreamChecker::reportLeaks(ArrayRef<SymbolRef> LeakedStreams,
CheckerContext &C,
ExplodedNode *ErrNode) const { … }
bool SimpleStreamChecker::guaranteedNotToCloseFile(const CallEvent &Call) const{ … }
ProgramStateRef
SimpleStreamChecker::checkPointerEscape(ProgramStateRef State,
const InvalidatedSymbols &Escaped,
const CallEvent *Call,
PointerEscapeKind Kind) const { … }
void ento::registerSimpleStreamChecker(CheckerManager &mgr) { … }
bool ento::shouldRegisterSimpleStreamChecker(const CheckerManager &mgr) { … }