28class DivZeroChecker :
public Checker< check::PreStmt<BinaryOperator> > {
29 const BugType BT{
this,
"Division by zero"};
44 if (
const auto *BE = dyn_cast<BinaryOperator>(S))
52 auto R = std::make_unique<PathSensitiveBugReport>(BT, Msg, N);
54 C.emitReport(std::move(R));
58void DivZeroChecker::reportTaintBug(
62 auto R = std::make_unique<PathSensitiveBugReport>(TaintBT, Msg, N);
64 for (
auto Sym : TaintedSyms)
65 R->markInteresting(Sym);
66 C.emitReport(std::move(R));
93 std::tie(stateNotZero, stateZero) = CM.
assumeDual(
C.getState(), *DV);
97 reportBug(
"Division by zero", stateZero,
C);
101 if ((stateNotZero && stateZero)) {
103 if (!taintedSyms.empty()) {
104 reportTaintBug(
"Division by a tainted value, possibly zero", stateZero,
C,
112 C.addTransition(stateNotZero);
119bool ento::shouldRegisterDivZeroChecker(
const CheckerManager &mgr) {
static const Expr * getDenomExpr(const ExplodedNode *N)
A builtin binary operation expression such as "x + y" or "x <= y".
This represents one expression.
Stmt - This represents one statement.
bool isScalarType() const
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
ProgramStatePair assumeDual(ProgramStateRef State, DefinedSVal Cond)
Returns a pair of states (StTrue, StFalse) where the given condition is assumed to be true or false,...
std::optional< T > getLocationAs() const &
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
std::optional< T > getAs() const
Convert to the specified SVal type, returning std::nullopt if this SVal is not of the desired type.
bool trackExpressionValue(const ExplodedNode *N, const Expr *E, PathSensitiveBugReport &R, TrackingOptions Opts={})
Attempts to add visitors to track expression value back to its point of origin.
const char *const TaintedData
std::vector< SymbolRef > getTaintedSymbols(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Returns the tainted Symbols for a given Statement and state.
The JSON file list parser is used to communicate input to InstallAPI.