forked from OSchip/llvm-project
[analyzer] Hide and rename FindLastStoreBRVisitor
This component should not be used directly at this point and it is simply an implementation detail, that's why StoreSiteFinder is out of the header file. Differential Revision: https://reviews.llvm.org/D103624
This commit is contained in:
parent
b6bcf95322
commit
87a5c4d374
|
@ -378,50 +378,6 @@ const Expr *getDerefExpr(const Stmt *S);
|
|||
|
||||
} // namespace bugreporter
|
||||
|
||||
/// Finds last store into the given region,
|
||||
/// which is different from a given symbolic value.
|
||||
class FindLastStoreBRVisitor final
|
||||
: public bugreporter::TrackingBugReporterVisitor {
|
||||
const MemRegion *R;
|
||||
SVal V;
|
||||
bool Satisfied = false;
|
||||
|
||||
/// If the visitor is tracking the value directly responsible for the
|
||||
/// bug, we are going to employ false positive suppression.
|
||||
bool EnableNullFPSuppression;
|
||||
|
||||
using TrackingKind = bugreporter::TrackingKind;
|
||||
TrackingKind TKind;
|
||||
const StackFrameContext *OriginSFC;
|
||||
|
||||
public:
|
||||
/// \param V We're searching for the store where \c R received this value.
|
||||
/// \param R The region we're tracking.
|
||||
/// \param TKind May limit the amount of notes added to the bug report.
|
||||
/// \param OriginSFC Only adds notes when the last store happened in a
|
||||
/// different stackframe to this one. Disregarded if the tracking kind
|
||||
/// is thorough.
|
||||
/// This is useful, because for non-tracked regions, notes about
|
||||
/// changes to its value in a nested stackframe could be pruned, and
|
||||
/// this visitor can prevent that without polluting the bugpath too
|
||||
/// much.
|
||||
FindLastStoreBRVisitor(bugreporter::TrackerRef ParentTracker, KnownSVal V,
|
||||
const MemRegion *R, bool InEnableNullFPSuppression,
|
||||
TrackingKind TKind,
|
||||
const StackFrameContext *OriginSFC = nullptr)
|
||||
: TrackingBugReporterVisitor(ParentTracker), R(R), V(V),
|
||||
EnableNullFPSuppression(InEnableNullFPSuppression), TKind(TKind),
|
||||
OriginSFC(OriginSFC) {
|
||||
assert(R);
|
||||
}
|
||||
|
||||
void Profile(llvm::FoldingSetNodeID &ID) const override;
|
||||
|
||||
PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
|
||||
BugReporterContext &BRC,
|
||||
PathSensitiveBugReport &BR) override;
|
||||
};
|
||||
|
||||
class TrackConstraintBRVisitor final : public BugReporterVisitor {
|
||||
DefinedSVal Constraint;
|
||||
bool Assumption;
|
||||
|
|
|
@ -1219,10 +1219,53 @@ public:
|
|||
} // end of anonymous namespace
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Implementation of FindLastStoreBRVisitor.
|
||||
// StoreSiteFinder
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void FindLastStoreBRVisitor::Profile(llvm::FoldingSetNodeID &ID) const {
|
||||
/// Finds last store into the given region,
|
||||
/// which is different from a given symbolic value.
|
||||
class StoreSiteFinder final : public TrackingBugReporterVisitor {
|
||||
const MemRegion *R;
|
||||
SVal V;
|
||||
bool Satisfied = false;
|
||||
|
||||
/// If the visitor is tracking the value directly responsible for the
|
||||
/// bug, we are going to employ false positive suppression.
|
||||
bool EnableNullFPSuppression;
|
||||
|
||||
using TrackingKind = bugreporter::TrackingKind;
|
||||
TrackingKind TKind;
|
||||
const StackFrameContext *OriginSFC;
|
||||
|
||||
public:
|
||||
/// \param V We're searching for the store where \c R received this value.
|
||||
/// \param R The region we're tracking.
|
||||
/// \param TKind May limit the amount of notes added to the bug report.
|
||||
/// \param OriginSFC Only adds notes when the last store happened in a
|
||||
/// different stackframe to this one. Disregarded if the tracking kind
|
||||
/// is thorough.
|
||||
/// This is useful, because for non-tracked regions, notes about
|
||||
/// changes to its value in a nested stackframe could be pruned, and
|
||||
/// this visitor can prevent that without polluting the bugpath too
|
||||
/// much.
|
||||
StoreSiteFinder(bugreporter::TrackerRef ParentTracker, KnownSVal V,
|
||||
const MemRegion *R, bool InEnableNullFPSuppression,
|
||||
TrackingKind TKind,
|
||||
const StackFrameContext *OriginSFC = nullptr)
|
||||
: TrackingBugReporterVisitor(ParentTracker), R(R), V(V),
|
||||
EnableNullFPSuppression(InEnableNullFPSuppression), TKind(TKind),
|
||||
OriginSFC(OriginSFC) {
|
||||
assert(R);
|
||||
}
|
||||
|
||||
void Profile(llvm::FoldingSetNodeID &ID) const override;
|
||||
|
||||
PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
|
||||
BugReporterContext &BRC,
|
||||
PathSensitiveBugReport &BR) override;
|
||||
};
|
||||
|
||||
void StoreSiteFinder::Profile(llvm::FoldingSetNodeID &ID) const {
|
||||
static int tag = 0;
|
||||
ID.AddPointer(&tag);
|
||||
ID.AddPointer(R);
|
||||
|
@ -1393,10 +1436,9 @@ static void showBRDefaultDiagnostics(llvm::raw_svector_ostream &os,
|
|||
}
|
||||
}
|
||||
|
||||
PathDiagnosticPieceRef
|
||||
FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
|
||||
BugReporterContext &BRC,
|
||||
PathSensitiveBugReport &BR) {
|
||||
PathDiagnosticPieceRef StoreSiteFinder::VisitNode(const ExplodedNode *Succ,
|
||||
BugReporterContext &BRC,
|
||||
PathSensitiveBugReport &BR) {
|
||||
if (Satisfied)
|
||||
return nullptr;
|
||||
|
||||
|
@ -2238,7 +2280,7 @@ Tracker::Result Tracker::track(const Expr *E, const ExplodedNode *N,
|
|||
Tracker::Result Tracker::track(SVal V, const MemRegion *R, TrackingOptions Opts,
|
||||
const StackFrameContext *Origin) {
|
||||
if (auto KV = V.getAs<KnownSVal>()) {
|
||||
Report.addVisitor<FindLastStoreBRVisitor>(
|
||||
Report.addVisitor<StoreSiteFinder>(
|
||||
this, *KV, R, Opts.EnableNullFPSuppression, Opts.Kind, Origin);
|
||||
return {true};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue