clang  14.0.0git
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
clang::ento::bugreporter::Tracker Class Reference

A generalized component for tracking expressions, values, and stores. More...

#include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"

Inheritance diagram for clang::ento::bugreporter::Tracker:
Inheritance graph
[legend]
Collaboration diagram for clang::ento::bugreporter::Tracker:
Collaboration graph
[legend]

Classes

struct  Result
 Describes a tracking result with the most basic information of what was actually done (or not done). More...
 

Public Member Functions

virtual ~Tracker ()=default
 
PathSensitiveBugReportgetReport ()
 
virtual Result track (const Expr *E, const ExplodedNode *N, TrackingOptions Opts={})
 Track expression value back to its point of origin. More...
 
virtual Result track (SVal V, const MemRegion *R, TrackingOptions Opts={}, const StackFrameContext *Origin=nullptr)
 Track how the value got stored into the given region and where it came from. More...
 
virtual PathDiagnosticPieceRef handle (StoreInfo SI, BugReporterContext &BRC, TrackingOptions Opts)
 Handle the store operation and produce the note. More...
 
void addHighPriorityHandler (ExpressionHandlerPtr SH)
 Add custom expression handler with the highest priority. More...
 
void addLowPriorityHandler (ExpressionHandlerPtr SH)
 Add custom expression handler with the lowest priority. More...
 
void addHighPriorityHandler (StoreHandlerPtr SH)
 Add custom store handler with the highest priority. More...
 
void addLowPriorityHandler (StoreHandlerPtr SH)
 Add custom store handler with the lowest priority. More...
 
template<class HandlerType , class... Args>
void addHighPriorityHandler (Args &&... ConstructorArgs)
 Add custom expression/store handler with the highest priority. More...
 
template<class HandlerType , class... Args>
void addLowPriorityHandler (Args &&... ConstructorArgs)
 Add custom expression/store handler with the lowest priority. More...
 

Static Public Member Functions

static TrackerRef create (PathSensitiveBugReport &Report)
 

Protected Member Functions

 Tracker (PathSensitiveBugReport &Report)
 

Detailed Description

A generalized component for tracking expressions, values, and stores.

Tracker aimes at providing a sensible set of default behaviors that can be used by any checker, while providing mechanisms to hook into any part of the tracking process and insert checker-specific logic.

Definition at line 166 of file BugReporterVisitors.h.

Constructor & Destructor Documentation

◆ Tracker()

Tracker::Tracker ( PathSensitiveBugReport Report)
protected
Parameters
ReportThe bug report to which visitors should be attached.

Definition at line 2411 of file BugReporterVisitors.cpp.

Referenced by create().

◆ ~Tracker()

virtual clang::ento::bugreporter::Tracker::~Tracker ( )
virtualdefault

Member Function Documentation

◆ addHighPriorityHandler() [1/3]

template<class HandlerType , class... Args>
void clang::ento::bugreporter::Tracker::addHighPriorityHandler ( Args &&...  ConstructorArgs)
inline

Add custom expression/store handler with the highest priority.

See other overloads for explanation.

Definition at line 276 of file BugReporterVisitors.h.

References addHighPriorityHandler().

◆ addHighPriorityHandler() [2/3]

void clang::ento::bugreporter::Tracker::addHighPriorityHandler ( ExpressionHandlerPtr  SH)
inline

Add custom expression handler with the highest priority.

It means that it will be asked for handling first, and can prevent other handlers from running if decides to interrupt.

Definition at line 244 of file BugReporterVisitors.h.

Referenced by addHighPriorityHandler().

◆ addHighPriorityHandler() [3/3]

void clang::ento::bugreporter::Tracker::addHighPriorityHandler ( StoreHandlerPtr  SH)
inline

Add custom store handler with the highest priority.

It means that it will be asked for handling first, and will prevent other handlers from running if it produces non-null note.

Definition at line 260 of file BugReporterVisitors.h.

◆ addLowPriorityHandler() [1/3]

template<class HandlerType , class... Args>
void clang::ento::bugreporter::Tracker::addLowPriorityHandler ( Args &&...  ConstructorArgs)
inline

Add custom expression/store handler with the lowest priority.

See other overloads for explanation.

Definition at line 285 of file BugReporterVisitors.h.

References addLowPriorityHandler().

◆ addLowPriorityHandler() [2/3]

void clang::ento::bugreporter::Tracker::addLowPriorityHandler ( ExpressionHandlerPtr  SH)
inline

Add custom expression handler with the lowest priority.

It means that it will be asked for handling last, and other handlers can prevent it from running if any of them decides to interrupt.

Definition at line 252 of file BugReporterVisitors.h.

Referenced by addLowPriorityHandler().

◆ addLowPriorityHandler() [3/3]

void clang::ento::bugreporter::Tracker::addLowPriorityHandler ( StoreHandlerPtr  SH)
inline

Add custom store handler with the lowest priority.

It means that it will be asked for handling last, only if all other handlers failed to produce the note.

Definition at line 268 of file BugReporterVisitors.h.

◆ create()

static TrackerRef clang::ento::bugreporter::Tracker::create ( PathSensitiveBugReport Report)
inlinestatic

Definition at line 182 of file BugReporterVisitors.h.

References Tracker().

◆ getReport()

PathSensitiveBugReport& clang::ento::bugreporter::Tracker::getReport ( )
inline

Definition at line 186 of file BugReporterVisitors.h.

◆ handle()

PathDiagnosticPieceRef Tracker::handle ( StoreInfo  SI,
BugReporterContext BRC,
TrackingOptions  Opts 
)
virtual

Handle the store operation and produce the note.

Parameters
SIThe information fully describing the store.
OptsTracking options specifying how we got to it.

NOTE: this method is designed for sub-trackers and visitors.

Definition at line 2458 of file BugReporterVisitors.cpp.

◆ track() [1/2]

virtual Result clang::ento::bugreporter::Tracker::track ( const Expr E,
const ExplodedNode N,
TrackingOptions  Opts = {} 
)
virtual

Track expression value back to its point of origin.

Parameters
EThe expression value which we are tracking
NA node "downstream" from the evaluation of the statement.
OptsTracking options specifying how we want to track the value.

◆ track() [2/2]

virtual Result clang::ento::bugreporter::Tracker::track ( SVal  V,
const MemRegion R,
TrackingOptions  Opts = {},
const StackFrameContext Origin = nullptr 
)
virtual

Track how the value got stored into the given region and where it came from.

Parameters
VWe're searching for the store where R received this value.
RThe region we're tracking.
OptsTracking options specifying how we want to track the value.
OriginOnly 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.

The documentation for this class was generated from the following files: