clang 20.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]

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.
 
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.
 
virtual PathDiagnosticPieceRef handle (StoreInfo SI, BugReporterContext &BRC, TrackingOptions Opts)
 Handle the store operation and produce the note.
 
void addHighPriorityHandler (ExpressionHandlerPtr SH)
 Add custom expression handler with the highest priority.
 
void addLowPriorityHandler (ExpressionHandlerPtr SH)
 Add custom expression handler with the lowest priority.
 
void addHighPriorityHandler (StoreHandlerPtr SH)
 Add custom store handler with the highest priority.
 
void addLowPriorityHandler (StoreHandlerPtr SH)
 Add custom store handler with the lowest priority.
 
template<class HandlerType , class... Args>
void addHighPriorityHandler (Args &&... ConstructorArgs)
 Add custom expression/store handler with the highest priority.
 
template<class HandlerType , class... Args>
void addLowPriorityHandler (Args &&... ConstructorArgs)
 Add custom expression/store handler with the lowest priority.
 

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 173 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 2541 of file BugReporterVisitors.cpp.

◆ ~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 283 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 251 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 267 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 292 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 259 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 275 of file BugReporterVisitors.h.

◆ create()

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

◆ getReport()

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

Definition at line 193 of file BugReporterVisitors.h.

References clang::sema::Report.

◆ 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 2588 of file BugReporterVisitors.cpp.

◆ track() [1/2]

Tracker::Result 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.

Definition at line 2554 of file BugReporterVisitors.cpp.

References clang::ento::bugreporter::Tracker::Result::combineWith(), E, findNodeForExpression(), peelOffOuterExpr(), and clang::ento::bugreporter::Tracker::Result::WasInterrupted.

◆ track() [2/2]

Tracker::Result 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.

Definition at line 2579 of file BugReporterVisitors.cpp.

References clang::sema::Report, and V.


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