15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H 16 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H 21 #include "llvm/ADT/FoldingSet.h" 22 #include "llvm/ADT/STLExtras.h" 23 #include "llvm/ADT/StringRef.h" 37 class BugReporterContext;
40 class PathDiagnosticPiece;
60 virtual std::shared_ptr<PathDiagnosticPiece>
61 VisitNode(
const ExplodedNode *Succ,
62 BugReporterContext &BRC, BugReport &BR) = 0;
66 virtual void finalizeVisitor(BugReporterContext &BRC,
67 const ExplodedNode *EndPathNode,
75 virtual std::shared_ptr<PathDiagnosticPiece>
76 getEndPath(BugReporterContext &BRC,
const ExplodedNode *N, BugReport &BR);
78 virtual void Profile(llvm::FoldingSetNodeID &
ID)
const = 0;
81 static std::shared_ptr<PathDiagnosticPiece>
82 getDefaultEndPath(BugReporterContext &BRC,
const ExplodedNode *N,
91 bool Satisfied =
false;
95 bool EnableNullFPSuppression;
100 static void registerStatementVarDecls(BugReport &BR,
const Stmt *S,
101 bool EnableNullFPSuppression);
103 FindLastStoreBRVisitor(KnownSVal V,
const MemRegion *R,
104 bool InEnableNullFPSuppression)
105 : R(R), V(V), EnableNullFPSuppression(InEnableNullFPSuppression) {}
107 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
109 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
110 BugReporterContext &BRC,
111 BugReport &BR)
override;
115 DefinedSVal Constraint;
117 bool IsSatisfied =
false;
122 bool IsTrackingTurnedOn =
false;
125 TrackConstraintBRVisitor(DefinedSVal constraint,
bool assumption)
126 : Constraint(constraint), Assumption(assumption),
127 IsZeroCheck(!Assumption && Constraint.getAs<Loc>()) {}
129 void Profile(llvm::FoldingSetNodeID &
ID)
const override;
133 static const char *getTag();
135 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
136 BugReporterContext &BRC,
137 BugReport &BR)
override;
141 bool isUnderconstrained(
const ExplodedNode *N)
const;
148 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
153 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
154 BugReporterContext &BRC,
155 BugReport &BR)
override;
159 static const Expr *getNilReceiver(
const Stmt *S,
const ExplodedNode *N);
165 static const char *
const GenericTrueMessage;
166 static const char *
const GenericFalseMessage;
169 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
176 static const char *getTag();
178 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
179 BugReporterContext &BRC,
180 BugReport &BR)
override;
182 std::shared_ptr<PathDiagnosticPiece> VisitNodeImpl(
const ExplodedNode *N,
183 BugReporterContext &BRC,
186 std::shared_ptr<PathDiagnosticPiece>
187 VisitTerminator(
const Stmt *Term,
const ExplodedNode *N,
188 const CFGBlock *srcBlk,
const CFGBlock *dstBlk, BugReport &R,
189 BugReporterContext &BRC);
191 std::shared_ptr<PathDiagnosticPiece>
192 VisitTrueTest(
const Expr *Cond,
bool tookTrue, BugReporterContext &BRC,
193 BugReport &R,
const ExplodedNode *N);
195 std::shared_ptr<PathDiagnosticPiece>
196 VisitTrueTest(
const Expr *Cond,
const DeclRefExpr *DR,
const bool tookTrue,
197 BugReporterContext &BRC, BugReport &R,
const ExplodedNode *N);
199 std::shared_ptr<PathDiagnosticPiece>
200 VisitTrueTest(
const Expr *Cond,
const BinaryOperator *BExpr,
201 const bool tookTrue, BugReporterContext &BRC, BugReport &R,
202 const ExplodedNode *N);
204 std::shared_ptr<PathDiagnosticPiece>
205 VisitConditionVariable(StringRef LhsString,
const Expr *CondVarExpr,
206 const bool tookTrue, BugReporterContext &BRC,
207 BugReport &R,
const ExplodedNode *N);
209 bool patternMatch(
const Expr *Ex,
210 const Expr *ParentEx,
212 BugReporterContext &BRC,
214 const ExplodedNode *N,
215 Optional<bool> &prunable);
217 static bool isPieceMessageGeneric(
const PathDiagnosticPiece *Piece);
223 class LikelyFalsePositiveSuppressionBRVisitor final
226 static void *getTag() {
228 return static_cast<void *
>(&Tag);
231 void Profile(llvm::FoldingSetNodeID &
ID)
const override {
232 ID.AddPointer(getTag());
235 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *,
236 BugReporterContext &,
237 BugReport &)
override {
241 void finalizeVisitor(BugReporterContext &BRC,
const ExplodedNode *N,
242 BugReport &BR)
override;
255 UndefOrNullArgVisitor(
const MemRegion *InR) : R(InR) {}
257 void Profile(llvm::FoldingSetNodeID &ID)
const override {
263 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
264 BugReporterContext &BRC,
265 BugReport &BR)
override;
274 bool IsSatisfied =
false;
281 bool IsTrackingTurnedOn =
false;
284 SuppressInlineDefensiveChecksVisitor(DefinedSVal Val,
const ExplodedNode *N);
286 void Profile(llvm::FoldingSetNodeID &ID)
const override;
290 static const char *getTag();
292 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *Succ,
293 BugReporterContext &BRC,
294 BugReport &BR)
override;
298 bool Satisfied =
false;
301 CXXSelfAssignmentBRVisitor() =
default;
303 void Profile(llvm::FoldingSetNodeID &ID)
const override {}
305 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *Succ,
306 BugReporterContext &BRC,
307 BugReport &BR)
override;
317 TaintBugVisitor(
const SVal V) : V(V) {}
318 void Profile(llvm::FoldingSetNodeID &ID)
const override { ID.Add(V); }
320 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
321 BugReporterContext &BRC,
322 BugReport &BR)
override;
334 FalsePositiveRefutationBRVisitor();
336 void Profile(llvm::FoldingSetNodeID &ID)
const override;
338 std::shared_ptr<PathDiagnosticPiece> VisitNode(
const ExplodedNode *N,
339 BugReporterContext &BRC,
340 BugReport &BR)
override;
342 void finalizeVisitor(BugReporterContext &BRC,
const ExplodedNode *EndPathNode,
343 BugReport &BR)
override;
346 namespace bugreporter {
360 bool trackExpressionValue(
const ExplodedNode *N,
const Expr *E, BugReport &R,
361 bool EnableNullFPSuppression =
true);
363 const Expr *getDerefExpr(
const Stmt *S);
371 #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H
llvm::ImmutableMap< SymbolRef, RangeSet > ConstraintRangeTy
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Dataflow Directional Tag Classes.