LLVM 19.0.0git
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
llvm::sandboxir::Tracker Class Reference

The tracker collects all the change objects and implements the main API for saving / reverting / accepting. More...

#include "llvm/SandboxIR/Tracker.h"

Public Types

enum class  TrackerState { Disabled , Record }
 

Public Member Functions

 Tracker (Context &Ctx)
 
 ~Tracker ()
 
ContextgetContext () const
 
void track (std::unique_ptr< IRChangeBase > &&Change)
 Record Change and take ownership.
 
bool isTracking () const
 \Returns true if the tracker is recording changes.
 
TrackerState getState () const
 \Returns the current state of the tracker.
 
void save ()
 Turns on IR tracking.
 
void accept ()
 Stops tracking and accept changes.
 
void revert ()
 Stops tracking and reverts to saved state.
 
void dump (raw_ostream &OS) const
 
LLVM_DUMP_METHOD void dump () const
 

Public Attributes

bool InMiddleOfCreatingChange = false
 Helps catch bugs where we are creating new change objects while in the middle of creating other change objects.
 

Friends

unsigned IRChangeBase::getIdx () const
 
raw_ostreamoperator<< (raw_ostream &OS, const Tracker &Tracker)
 

Detailed Description

The tracker collects all the change objects and implements the main API for saving / reverting / accepting.

Definition at line 181 of file Tracker.h.

Member Enumeration Documentation

◆ TrackerState

Enumerator
Disabled 
Record 

‍Tracking is disabled

Definition at line 183 of file Tracker.h.

Constructor & Destructor Documentation

◆ Tracker()

llvm::sandboxir::Tracker::Tracker ( Context Ctx)
inlineexplicit

Definition at line 205 of file Tracker.h.

◆ ~Tracker()

Tracker::~Tracker ( )

Definition at line 40 of file Tracker.cpp.

References assert().

Member Function Documentation

◆ accept()

void Tracker::accept ( )

Stops tracking and accept changes.

Definition at line 170 of file Tracker.cpp.

References assert(), Disabled, and Record.

Referenced by llvm::sandboxir::Context::accept().

◆ dump() [1/2]

void Tracker::dump ( ) const

Definition at line 185 of file Tracker.cpp.

References llvm::dbgs(), and dump().

Referenced by dump().

◆ dump() [2/2]

void Tracker::dump ( raw_ostream OS) const

Definition at line 179 of file Tracker.cpp.

References OS.

◆ getContext()

Context & llvm::sandboxir::Tracker::getContext ( ) const
inline

Definition at line 207 of file Tracker.h.

Referenced by llvm::sandboxir::EraseFromParent::revert().

◆ getState()

TrackerState llvm::sandboxir::Tracker::getState ( ) const
inline

\Returns the current state of the tracker.

Definition at line 214 of file Tracker.h.

◆ isTracking()

bool llvm::sandboxir::Tracker::isTracking ( ) const
inline

◆ revert()

void Tracker::revert ( )

Stops tracking and reverts to saved state.

Definition at line 162 of file Tracker.cpp.

References assert(), Disabled, Record, and llvm::reverse().

Referenced by llvm::sandboxir::Context::revert().

◆ save()

void Tracker::save ( )

Turns on IR tracking.

Definition at line 160 of file Tracker.cpp.

References Record.

Referenced by llvm::sandboxir::Context::save().

◆ track()

void Tracker::track ( std::unique_ptr< IRChangeBase > &&  Change)

Friends And Related Function Documentation

◆ IRChangeBase::getIdx

unsigned IRChangeBase::getIdx ( ) const
friend

◆ operator<<

raw_ostream & operator<< ( raw_ostream OS,
const Tracker Tracker 
)
friend

Definition at line 225 of file Tracker.h.

Member Data Documentation

◆ InMiddleOfCreatingChange

bool llvm::sandboxir::Tracker::InMiddleOfCreatingChange = false

Helps catch bugs where we are creating new change objects while in the middle of creating other change objects.

Definition at line 202 of file Tracker.h.

Referenced by llvm::sandboxir::IRChangeBase::IRChangeBase(), and track().


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