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;
62 virtual std::shared_ptr<PathDiagnosticPiece>
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 {
189 static const char *
const GenericTrueMessage;
190 static const char *
const GenericFalseMessage;
193 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
200 static const char *
getTag();
212 std::shared_ptr<PathDiagnosticPiece>
217 std::shared_ptr<PathDiagnosticPiece>
221 std::shared_ptr<PathDiagnosticPiece>
225 std::shared_ptr<PathDiagnosticPiece>
230 std::shared_ptr<PathDiagnosticPiece>
236 const Expr *ParentEx,
254 return static_cast<void *
>(&Tag);
257 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
287 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
313 bool IsTrackingTurnedOn;
318 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
322 static const char *
getTag();
338 void Profile(llvm::FoldingSetNodeID &
ID)
const override {}
346 namespace bugreporter {
366 bool EnableNullFPSuppression =
true);
const Expr * getDerefExpr(const Stmt *S)
MemRegion - The root abstract class for all memory regions.
std::shared_ptr< 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.
UndefOrNullArgVisitor(const MemRegion *InR)
Stmt - This represents one statement.
void Profile(llvm::FoldingSetNodeID &ID) const override
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
TrackConstraintBRVisitor(DefinedSVal constraint, bool assumption)
void Profile(llvm::FoldingSetNodeID &ID) const override
std::shared_ptr< PathDiagnosticPiece > VisitNodeImpl(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR)
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
std::shared_ptr< PathDiagnosticPiece > VisitTrueTest(const Expr *Cond, bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N)
This class provides a convenience implementation for clone() using the Curiously-Recurring Template P...
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
std::shared_ptr< PathDiagnosticPiece > VisitConditionVariable(StringRef LhsString, const Expr *CondVarExpr, const bool tookTrue, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N)
A builtin binary operation expression such as "x + y" or "x <= y".
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...
std::shared_ptr< 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
void Profile(llvm::FoldingSetNodeID &ID) const override
std::shared_ptr< 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.
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 bool isPieceMessageGeneric(const PathDiagnosticPiece *Piece)
std::shared_ptr< 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.
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...
bool patternMatch(const Expr *Ex, const Expr *ParentEx, raw_ostream &Out, BugReporterContext &BRC, BugReport &R, const ExplodedNode *N, Optional< bool > &prunable)
void Profile(llvm::FoldingSetNodeID &ID) const override
SuppressInlineDefensiveChecksVisitor(DefinedSVal Val, const ExplodedNode *N)
std::shared_ptr< 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.
std::shared_ptr< 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.
BugReporterVisitors are used to add custom diagnostics along a path.
std::shared_ptr< 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.
static std::unique_ptr< PathDiagnosticPiece > getDefaultEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR)
Generates the default final diagnostic piece.
CXXSelfAssignmentBRVisitor()
std::shared_ptr< PathDiagnosticPiece > VisitTerminator(const Stmt *Term, const ExplodedNode *N, const CFGBlock *srcBlk, const CFGBlock *dstBlk, BugReport &R, BugReporterContext &BRC)
void Profile(llvm::FoldingSetNodeID &ID) const override
Suppress reports that might lead to known false positives.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
virtual std::unique_ptr< BugReporterVisitor > clone() const =0
Returns a copy of this BugReporter.
virtual std::shared_ptr< 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.
bool isDeclRefExprToReference(const Expr *E)
static const char * getTag()
Return the tag associated with this visitor.
std::shared_ptr< 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.
const Stmt * GetRetValExpr(const ExplodedNode *N)
detail::InMemoryDirectory::const_iterator E
Represents an SVal that is guaranteed to not be UnknownVal.
BugReporterVisitor(BugReporterVisitor &&)
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.
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.