15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITOR_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITOR_H
19 #include "llvm/ADT/FoldingSet.h"
27 class BugReporterContext;
30 class PathDiagnosticPiece;
55 virtual std::unique_ptr<BugReporterVisitor>
clone()
const = 0;
73 virtual std::unique_ptr<PathDiagnosticPiece>
76 virtual void Profile(llvm::FoldingSetNodeID &
ID)
const = 0;
79 static std::unique_ptr<PathDiagnosticPiece>
92 template <
class DERIVED>
94 std::unique_ptr<BugReporterVisitor> clone()
const override {
95 return llvm::make_unique<DERIVED>(*
static_cast<const DERIVED *
>(
this));
107 bool EnableNullFPSuppression;
113 bool EnableNullFPSuppression);
116 bool InEnableNullFPSuppression)
120 EnableNullFPSuppression(InEnableNullFPSuppression) {}
122 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
139 bool IsTrackingTurnedOn;
143 : Constraint(constraint), Assumption(assumption), IsSatisfied(
false),
144 IsZeroCheck(!Assumption && Constraint.getAs<
Loc>()),
145 IsTrackingTurnedOn(
false) {}
147 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
151 static const char *
getTag();
170 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
189 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
196 static const char *
getTag();
236 const Expr *CondVarExpr,
258 return static_cast<void *
>(&Tag);
261 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
291 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
317 bool IsTrackingTurnedOn;
322 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
326 static const char *
getTag();
334 namespace bugreporter {
354 bool EnableNullFPSuppression =
true);
const Expr * getDerefExpr(const Stmt *S)
MemRegion - The root abstract class for all memory regions.
UndefOrNullArgVisitor(const MemRegion *InR)
PathDiagnosticPiece * VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
PathDiagnosticPiece * VisitNode(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
TrackConstraintBRVisitor(DefinedSVal constraint, bool assumption)
PathDiagnosticPiece * VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
void Profile(llvm::FoldingSetNodeID &ID) const override
PathDiagnosticPiece * VisitNode(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
Prints path notes when a message is sent to a nil receiver.
const Stmt * GetDenomExpr(const ExplodedNode *N)
Visitor that tries to report interesting diagnostics from conditions.
void Profile(llvm::FoldingSetNodeID &ID) const override
This class provides a convenience implementation for clone() using the Curiously-Recurring Template P...
bool patternMatch(const Expr *Ex, raw_ostream &Out, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N, Optional< bool > &prunable)
std::unique_ptr< PathDiagnosticPiece > getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR) override
Provide custom definition for the final diagnostic piece on the path - the piece, which is displayed ...
virtual std::unique_ptr< PathDiagnosticPiece > getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR)
Provide custom definition for the final diagnostic piece on the path - the piece, which is displayed ...
void Profile(llvm::FoldingSetNodeID &ID) const override
virtual ~BugReporterVisitor()
BugReporterVisitor()=default
A builtin binary operation expression such as "x + y" or "x <= y".
virtual PathDiagnosticPiece * VisitNode(const ExplodedNode *Succ, const ExplodedNode *Pred, BugReporterContext &BRC, BugReport &BR)=0
Return a diagnostic piece which should be associated with the given node.
static void registerStatementVarDecls(BugReport &BR, const Stmt *S, bool EnableNullFPSuppression)
Creates a visitor for every VarDecl inside a Stmt and registers it with the BugReport.
When a region containing undefined value or '0' value is passed as an argument in a call...
void Profile(llvm::FoldingSetNodeID &ID) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
CFGBlock - Represents a single basic block in a source-level CFG.
static const char * getTag()
Return the tag associated with this visitor.
Expr - This represents one expression.
static const Expr * getNilReceiver(const Stmt *S, const ExplodedNode *N)
If the statement is a message send expression with nil receiver, returns the receiver expression...
void Profile(llvm::FoldingSetNodeID &ID) const override
SuppressInlineDefensiveChecksVisitor(DefinedSVal Val, const ExplodedNode *N)
BugReporterVisitors are used to add custom diagnostics along a path.
PathDiagnosticPiece * VisitTerminator(const Stmt *Term, const ExplodedNode *N, const CFGBlock *srcBlk, const CFGBlock *dstBlk, BugReport &R, BugReporterContext &BRC)
static std::unique_ptr< PathDiagnosticPiece > getDefaultEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR)
Generates the default final diagnostic piece.
void Profile(llvm::FoldingSetNodeID &ID) const override
PathDiagnosticPiece * VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
Suppress reports that might lead to known false positives.
PathDiagnosticPiece * VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
PathDiagnosticPiece * VisitTrueTest(const Expr *Cond, bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N)
PathDiagnosticPiece * VisitConditionVariable(StringRef LhsString, const Expr *CondVarExpr, const bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N)
virtual std::unique_ptr< BugReporterVisitor > clone() const =0
Returns a copy of this BugReporter.
bool isDeclRefExprToReference(const Expr *E)
static const char * getTag()
Return the tag associated with this visitor.
const Stmt * GetRetValExpr(const ExplodedNode *N)
detail::InMemoryDirectory::const_iterator E
Represents an SVal that is guaranteed to not be UnknownVal.
BugReporterVisitor(BugReporterVisitor &&)
PathDiagnosticPiece * VisitNode(const ExplodedNode *Succ, const ExplodedNode *Pred, BugReporterContext &BRC, BugReport &BR) override
Return a diagnostic piece which should be associated with the given node.
bool trackNullOrUndefValue(const ExplodedNode *N, const Stmt *S, BugReport &R, bool IsArg=false, bool EnableNullFPSuppression=true)
Attempts to add visitors to trace a null or undefined value back to its point of origin, whether it is a symbol constrained to null or an explicit assignment.
PathDiagnosticPiece * VisitNodeImpl(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR)
A reference to a declared variable, function, enum, etc.
This class provides an interface through which checkers can create individual bug reports...
FindLastStoreBRVisitor(KnownSVal V, const MemRegion *R, bool InEnableNullFPSuppression)
static const char * getTag()
Return the tag associated with this visitor.