P4C
The P4 Compiler
Loading...
Searching...
No Matches
BfErrorReporter Class Reference
Inheritance diagram for BfErrorReporter:
[legend]

Public Types

enum class  CheckResult { NO_TESTS , SUCCESS , FAILURE }
 

Public Member Functions

void add_check (ErrorMessage::MessageType type, const std::string &msg)
 Adds a check with no specified source code line.
 
void add_check (ErrorMessage::MessageType type, int line, const std::string &msg)
 Adds a check which requires that an error/warning message includes the specified regex as well as the specified line number.
 
void increment_the_error_count ()
 
CheckResult verify_checks () const
 Verify error/warning checks in the program. During compilation, if an error/warning message matches the check message regex and its source line, the check is considered to be successful.
 

Protected Member Functions

void emit_message (const ErrorMessage &msg) override
 
void emit_message (const ParserErrorMessage &msg) override
 

Member Function Documentation

◆ add_check() [1/2]

void BfErrorReporter::add_check ( ErrorMessage::MessageType type,
const std::string & msg )

Adds a check with no specified source code line.

Parameters
typeerror or warning
msgexpected regex

◆ add_check() [2/2]

void BfErrorReporter::add_check ( ErrorMessage::MessageType type,
int line,
const std::string & msg )

Adds a check which requires that an error/warning message includes the specified regex as well as the specified line number.

Parameters
typeerror or warning
linesource location that the error/warning has to include, value of 0 means that no source location is required
msgexpected regex

◆ verify_checks()

BfErrorReporter::CheckResult BfErrorReporter::verify_checks ( ) const

Verify error/warning checks in the program. During compilation, if an error/warning message matches the check message regex and its source line, the check is considered to be successful.

This method should be called at the end of compilation. It will report any unmatched checks as errors as well as any additional errors that weren't matched to a check. If there are no checks in the program, the method does nothing and returns NO_TESTS.

Returns
CheckResult