29class UndefBranchChecker :
public Checker<check::BranchCondition> {
30 const BugType BT{
this,
"Branch condition evaluates to a garbage value"};
32 struct FindUndefExpr {
37 : St(
std::move(S)), LCtx(L) {}
39 const Expr *FindExpr(
const Expr *Ex) {
40 if (!MatchesCriteria(Ex))
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();
62void UndefBranchChecker::checkBranchCondition(
const Stmt *
Condition,
65 if (isa<ObjCForCollectionStmt>(
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);
114bool ento::shouldRegisterUndefBranchChecker(
const CheckerManager &mgr) {
Defines the Objective-C statement AST node classes.
C Language Family Type Representation.
This represents one expression.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
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...
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)
Used to register checkers.
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.
The JSON file list parser is used to communicate input to InstallAPI.