clang 20.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
clang::dataflow::Logger Class Reference

A logger is notified as the analysis progresses. More...

#include "clang/Analysis/FlowSensitive/Logger.h"

Public Member Functions

virtual ~Logger ()=default
 
virtual void beginAnalysis (const AdornedCFG &, TypeErasedDataflowAnalysis &)
 Called by the framework as we start analyzing a new function or statement.
 
virtual void endAnalysis ()
 
virtual void enterBlock (const CFGBlock &, bool PostVisit)
 Called when we start (re-)processing a block in the CFG.
 
virtual void enterElement (const CFGElement &)
 Called when we start processing an element in the current CFG block.
 
virtual void recordState (TypeErasedDataflowAnalysisState &)
 Records the analysis state computed for the current program point.
 
virtual void blockConverged ()
 Records that the analysis state for the current block is now final.
 
void log (llvm::function_ref< void(llvm::raw_ostream &)> Emit)
 Called by the framework or user code to report some event.
 

Static Public Member Functions

static Loggernull ()
 Returns a dummy logger that does nothing.
 
static std::unique_ptr< Loggertextual (llvm::raw_ostream &)
 A logger that simply writes messages to the specified ostream in real time.
 
static std::unique_ptr< Loggerhtml (std::function< std::unique_ptr< llvm::raw_ostream >()>)
 A logger that builds an HTML UI to inspect the analysis results.
 

Protected Member Functions

 Logger (bool ShouldLogText=true)
 ShouldLogText should be false for trivial loggers that ignore logText().
 

Detailed Description

A logger is notified as the analysis progresses.

It can produce a report of the analysis's findings and how it came to them.

The framework reports key structural events (e.g. traversal of blocks). The specific analysis can add extra details to be presented in context.

Definition at line 27 of file Logger.h.

Constructor & Destructor Documentation

◆ ~Logger()

virtual clang::dataflow::Logger::~Logger ( )
virtualdefault

◆ Logger()

clang::dataflow::Logger::Logger ( bool  ShouldLogText = true)
inlineprotected

ShouldLogText should be false for trivial loggers that ignore logText().

This allows log() to skip evaluating its Emit function.

Definition at line 82 of file Logger.h.

Member Function Documentation

◆ beginAnalysis()

virtual void clang::dataflow::Logger::beginAnalysis ( const AdornedCFG ,
TypeErasedDataflowAnalysis  
)
inlinevirtual

Called by the framework as we start analyzing a new function or statement.

Forms a pair with endAnalysis().

Definition at line 43 of file Logger.h.

◆ blockConverged()

virtual void clang::dataflow::Logger::blockConverged ( )
inlinevirtual

Records that the analysis state for the current block is now final.

Definition at line 64 of file Logger.h.

◆ endAnalysis()

virtual void clang::dataflow::Logger::endAnalysis ( )
inlinevirtual

Definition at line 45 of file Logger.h.

◆ enterBlock()

virtual void clang::dataflow::Logger::enterBlock ( const CFGBlock ,
bool  PostVisit 
)
inlinevirtual

Called when we start (re-)processing a block in the CFG.

The target program point is the entry to the specified block. Calls to log() describe transferBranch(), join() etc. PostVisit specifies whether we're processing the block for the post-visit callback.

Definition at line 55 of file Logger.h.

◆ enterElement()

virtual void clang::dataflow::Logger::enterElement ( const CFGElement )
inlinevirtual

Called when we start processing an element in the current CFG block.

The target program point is after the specified element. Calls to log() describe the transfer() function.

Definition at line 59 of file Logger.h.

◆ html()

std::unique_ptr< Logger > clang::dataflow::Logger::html ( std::function< std::unique_ptr< llvm::raw_ostream >()>  Streams)
static

A logger that builds an HTML UI to inspect the analysis results.

Each function's analysis is written to a stream obtained from the factory.

Definition at line 579 of file HTMLLogger.cpp.

◆ log()

void clang::dataflow::Logger::log ( llvm::function_ref< void(llvm::raw_ostream &)>  Emit)
inline

Called by the framework or user code to report some event.

The event is associated with the current context (program point). The Emit function produces the log message. It may or may not be called, depending on if the logger is interested; it should have no side effects.

Definition at line 70 of file Logger.h.

◆ null()

Logger & clang::dataflow::Logger::null ( )
static

Returns a dummy logger that does nothing.

Definition at line 16 of file Logger.cpp.

◆ recordState()

virtual void clang::dataflow::Logger::recordState ( TypeErasedDataflowAnalysisState )
inlinevirtual

Records the analysis state computed for the current program point.

Definition at line 62 of file Logger.h.

◆ textual()

std::unique_ptr< Logger > clang::dataflow::Logger::textual ( llvm::raw_ostream &  OS)
static

A logger that simply writes messages to the specified ostream in real time.

Definition at line 107 of file Logger.cpp.


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