15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H 16 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_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;
111 static void registerStatementVarDecls(
BugReport &BR,
const Stmt *S,
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();
207 std::shared_ptr<PathDiagnosticPiece> VisitNodeImpl(
const ExplodedNode *N,
212 std::shared_ptr<PathDiagnosticPiece>
217 std::shared_ptr<PathDiagnosticPiece>
221 std::shared_ptr<PathDiagnosticPiece>
222 VisitTrueTest(
const Expr *Cond,
const DeclRefExpr *DR,
const bool tookTrue,
225 std::shared_ptr<PathDiagnosticPiece>
230 std::shared_ptr<PathDiagnosticPiece>
231 VisitConditionVariable(StringRef LhsString,
const Expr *CondVarExpr,
235 bool patternMatch(
const Expr *Ex,
236 const Expr *ParentEx,
254 return static_cast<void *
>(&Tag);
257 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
258 ID.AddPointer(getTag());
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)
Given that expression S represents a pointer that would be dereferenced, try to find a sub-expression...
MemRegion - The root abstract class for all memory regions.
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
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.
This class provides a convenience implementation for clone() using the Curiously-Recurring Template P...
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".
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.
Expr - This represents one expression.
BugReporterVisitors are used to add custom diagnostics along a path.
static std::unique_ptr< PathDiagnosticPiece > getDefaultEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR)
Generates the default final diagnostic piece.
CXXSelfAssignmentBRVisitor()
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)
Dataflow Directional Tag Classes.
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)
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)