15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITOR_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITOR_H
19 #include "llvm/ADT/FoldingSet.h"
26 class BugReporterContext;
29 class PathDiagnosticPiece;
54 virtual std::unique_ptr<BugReporterVisitor>
clone()
const = 0;
72 virtual std::unique_ptr<PathDiagnosticPiece>
75 virtual void Profile(llvm::FoldingSetNodeID &
ID)
const = 0;
78 static std::unique_ptr<PathDiagnosticPiece>
91 template <
class DERIVED>
93 std::unique_ptr<BugReporterVisitor> clone()
const override {
94 return llvm::make_unique<DERIVED>(*
static_cast<const DERIVED *
>(
this));
106 bool EnableNullFPSuppression;
112 bool EnableNullFPSuppression);
115 bool InEnableNullFPSuppression)
119 EnableNullFPSuppression(InEnableNullFPSuppression) {}
121 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
138 bool IsTrackingTurnedOn;
142 : Constraint(constraint), Assumption(assumption), IsSatisfied(
false),
143 IsZeroCheck(!Assumption && Constraint.getAs<
Loc>()),
144 IsTrackingTurnedOn(
false) {}
146 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
150 static const char *
getTag();
169 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
188 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
195 static const char *
getTag();
235 const Expr *CondVarExpr,
257 return static_cast<void *
>(&Tag);
260 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
290 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
316 bool IsTrackingTurnedOn;
321 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
325 static const char *
getTag();
333 namespace bugreporter {
353 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.
ID
Defines the set of possible language-specific address spaces.
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.