29class UndefBranchChecker :
public Checker<check::BranchCondition> {
30 const BugType BT{
this,
"Branch condition evaluates to a garbage value"};
32 struct FindUndefExpr {
34 const LocationContext *LCtx;
37 : St(std::move(S)), LCtx(L) {}
39 const Expr *FindExpr(
const Expr *Ex) {
40 if (!MatchesCriteria(Ex))
43 for (
const Stmt *SubStmt : Ex->
children())
44 if (
const Expr *ExI = dyn_cast_or_null<Expr>(SubStmt))
45 if (
const Expr *E2 = FindExpr(ExI))
51 bool MatchesCriteria(
const Expr *Ex) {
52 return St->getSVal(Ex, LCtx).isUndef();
57 void checkBranchCondition(
const Stmt *
Condition, CheckerContext &Ctx)
const;
62void UndefBranchChecker::checkBranchCondition(
const Stmt *
Condition,
95 if (std::optional<PostStmt> PS = P.
getAs<PostStmt>())
96 if (PS->getStmt() == Ex)
100 Ex = FindIt.FindExpr(Ex);
103 auto R = std::make_unique<PathSensitiveBugReport>(BT, BT.
getDescription(), N);
110void ento::registerUndefBranchChecker(CheckerManager &mgr) {
114bool ento::shouldRegisterUndefBranchChecker(
const CheckerManager &mgr) {
Defines the Objective-C statement AST node classes.
C Language Family Type Representation.
std::optional< T > getAs() const
Convert to the specified ProgramPoint type, returning std::nullopt if this ProgramPoint is not of the...
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
StringRef getDescription() const
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
ExplodedNode * generateErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
const LocationContext * getLocationContext() const
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
CHECKER * registerChecker(AT &&...Args)
Register a single-part checker (derived from Checker): construct its singleton instance,...
Simple checker classes that implement one frontend (i.e.
const ProgramStateRef & getState() const
pred_iterator pred_begin()
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
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.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const Fact * ProgramPoint
A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)