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;
51 virtual std::unique_ptr<BugReporterVisitor>
clone()
const = 0;
69 virtual std::unique_ptr<PathDiagnosticPiece>
72 virtual void Profile(llvm::FoldingSetNodeID &
ID)
const = 0;
75 static std::unique_ptr<PathDiagnosticPiece>
88 template <
class DERIVED>
90 std::unique_ptr<BugReporterVisitor> clone()
const override {
91 return llvm::make_unique<DERIVED>(*
static_cast<const DERIVED *
>(
this));
104 bool EnableNullFPSuppression;
110 bool EnableNullFPSuppression);
113 bool InEnableNullFPSuppression)
117 EnableNullFPSuppression(InEnableNullFPSuppression) {}
119 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
137 bool IsTrackingTurnedOn;
141 : Constraint(constraint), Assumption(assumption), IsSatisfied(
false),
142 IsZeroCheck(!Assumption && Constraint.getAs<
Loc>()),
143 IsTrackingTurnedOn(
false) {}
145 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
149 static const char *
getTag();
168 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
186 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
193 static const char *
getTag();
233 const Expr *CondVarExpr,
255 return static_cast<void *
>(&Tag);
258 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
288 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
315 bool IsTrackingTurnedOn;
320 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
324 static const char *
getTag();
332 namespace bugreporter {
352 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
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()
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)
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
static const char * getTag()
ID
Defines the set of possible language-specific address spaces.
static const Expr * getNilReceiver(const Stmt *S, const ExplodedNode *N)
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.
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()
const Stmt * GetRetValExpr(const ExplodedNode *N)
Represents an SVal that is guaranteed to not be UnknownVal.
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)
PathDiagnosticPiece * VisitNodeImpl(const ExplodedNode *N, const ExplodedNode *Prev, BugReporterContext &BRC, BugReport &BR)
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
FindLastStoreBRVisitor(KnownSVal V, const MemRegion *R, bool InEnableNullFPSuppression)
static const char * getTag()