P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::DiagnosticCountInfo Struct Reference

#include <pass_utils.h>

Public Member Functions

 DiagnosticCountInfo (BaseCompileContext &ctxt=BaseCompileContext::get())
 
void emitInfo (std::string_view componentInfo)
 
DiagnosticCountInfoGuard getInfoGuard (std::string_view componentInfo)
 
DebugHook getPassManagerHook ()
 

Detailed Description

An alternative interface to the diagnostic count info that allows using it outside of pass manager (but can also generate a pass manager hook). All copies of one object and all hooks and guards derived from it share the same diagnostic message counts so they can provide consistent logs.

See also
getDiagnosticCountInPassHook

Constructor & Destructor Documentation

◆ DiagnosticCountInfo()

P4::DiagnosticCountInfo::DiagnosticCountInfo ( BaseCompileContext & ctxt = BaseCompileContext::get())
explicit
Parameters
ctxtOptionally, you can provide a compilation context to take the diagnostic counts from. If not provied BaseCompileContext::get() is used.

Member Function Documentation

◆ emitInfo()

void P4::DiagnosticCountInfo::emitInfo ( std::string_view componentInfo)

Emits the information like printed by the debug hook, except using componentInfo as the info at the beginning of the line: the line will be in form "<componentInfo> emitted <counts>". This is useful e.g. for printing info about diagnostics in parser.

◆ getInfoGuard()

DiagnosticCountInfoGuard P4::DiagnosticCountInfo::getInfoGuard ( std::string_view componentInfo)

Similar to emitInfo, but prints the info at the moment the returned guard is destructed.

◆ getPassManagerHook()

DebugHook P4::DiagnosticCountInfo::getPassManagerHook ( )

Very similar to getDiagnosticCountInPassHook, but the state is tied with this instance so that calling the hook and the emitInfo/ getInfoGuard during one compilation will produce the correct counts.