retdec
|
A base class for all validators. More...
#include <validator.h>
Public Member Functions | |
virtual std::string | getId () const =0 |
bool | validate (ShPtr< Module > module, bool printMessageOnError=false) |
Validates the given module. More... | |
Protected Member Functions | |
Validator () | |
Constructs a new validator. More... | |
void | traverseAllGlobalVariables () |
Traverses all global variables in the current module and calls accept() on every one of them. More... | |
void | traverseAllFunctions () |
Traverses all functions in the current module and calls accept() on every one of them. More... | |
void | validationError (const std::string &warningMessage) |
Function to be called when there is a validation error. More... | |
![]() | |
OrderedAllVisitor (bool visitSuccessors=true, bool visitNestedStmts=true) | |
Constructs a new visitor. More... | |
virtual void | visitStmt (ShPtr< Statement > stmt, bool visitSuccessors=true, bool visitNestedStmts=true) |
Visits the given statement, and possibly its successors or nested statements. More... | |
void | restart (bool visitSuccessors=true, bool visitNestedStmts=true) |
"Restarts" the visitor so it is in the state like it was when it was created. More... | |
bool | makeAccessedAndCheckIfAccessed (ShPtr< Type > type) |
Makes the given type accessed. More... | |
virtual void | visit (ShPtr< GlobalVarDef > varDef) override |
virtual void | visit (ShPtr< Function > func) override |
virtual void | visit (ShPtr< AssignStmt > stmt) override |
virtual void | visit (ShPtr< BreakStmt > stmt) override |
virtual void | visit (ShPtr< CallStmt > stmt) override |
virtual void | visit (ShPtr< ContinueStmt > stmt) override |
virtual void | visit (ShPtr< EmptyStmt > stmt) override |
virtual void | visit (ShPtr< ForLoopStmt > stmt) override |
virtual void | visit (ShPtr< UForLoopStmt > stmt) override |
virtual void | visit (ShPtr< GotoStmt > stmt) override |
virtual void | visit (ShPtr< IfStmt > stmt) override |
virtual void | visit (ShPtr< ReturnStmt > stmt) override |
virtual void | visit (ShPtr< SwitchStmt > stmt) override |
virtual void | visit (ShPtr< UnreachableStmt > stmt) override |
virtual void | visit (ShPtr< VarDefStmt > stmt) override |
virtual void | visit (ShPtr< WhileLoopStmt > stmt) override |
virtual void | visit (ShPtr< AddOpExpr > expr) override |
virtual void | visit (ShPtr< AddressOpExpr > expr) override |
virtual void | visit (ShPtr< AndOpExpr > expr) override |
virtual void | visit (ShPtr< ArrayIndexOpExpr > expr) override |
virtual void | visit (ShPtr< AssignOpExpr > expr) override |
virtual void | visit (ShPtr< BitAndOpExpr > expr) override |
virtual void | visit (ShPtr< BitOrOpExpr > expr) override |
virtual void | visit (ShPtr< BitShlOpExpr > expr) override |
virtual void | visit (ShPtr< BitShrOpExpr > expr) override |
virtual void | visit (ShPtr< BitXorOpExpr > expr) override |
virtual void | visit (ShPtr< CallExpr > expr) override |
virtual void | visit (ShPtr< CommaOpExpr > expr) override |
virtual void | visit (ShPtr< DerefOpExpr > expr) override |
virtual void | visit (ShPtr< DivOpExpr > expr) override |
virtual void | visit (ShPtr< EqOpExpr > expr) override |
virtual void | visit (ShPtr< GtEqOpExpr > expr) override |
virtual void | visit (ShPtr< GtOpExpr > expr) override |
virtual void | visit (ShPtr< LtEqOpExpr > expr) override |
virtual void | visit (ShPtr< LtOpExpr > expr) override |
virtual void | visit (ShPtr< ModOpExpr > expr) override |
virtual void | visit (ShPtr< MulOpExpr > expr) override |
virtual void | visit (ShPtr< NegOpExpr > expr) override |
virtual void | visit (ShPtr< NeqOpExpr > expr) override |
virtual void | visit (ShPtr< NotOpExpr > expr) override |
virtual void | visit (ShPtr< OrOpExpr > expr) override |
virtual void | visit (ShPtr< StructIndexOpExpr > expr) override |
virtual void | visit (ShPtr< SubOpExpr > expr) override |
virtual void | visit (ShPtr< TernaryOpExpr > expr) override |
virtual void | visit (ShPtr< Variable > var) override |
virtual void | visit (ShPtr< BitCastExpr > expr) override |
virtual void | visit (ShPtr< ExtCastExpr > expr) override |
virtual void | visit (ShPtr< FPToIntCastExpr > expr) override |
virtual void | visit (ShPtr< IntToFPCastExpr > expr) override |
virtual void | visit (ShPtr< IntToPtrCastExpr > expr) override |
virtual void | visit (ShPtr< PtrToIntCastExpr > expr) override |
virtual void | visit (ShPtr< TruncCastExpr > expr) override |
virtual void | visit (ShPtr< ConstArray > constant) override |
virtual void | visit (ShPtr< ConstBool > constant) override |
virtual void | visit (ShPtr< ConstFloat > constant) override |
virtual void | visit (ShPtr< ConstInt > constant) override |
virtual void | visit (ShPtr< ConstNullPointer > constant) override |
virtual void | visit (ShPtr< ConstString > constant) override |
virtual void | visit (ShPtr< ConstStruct > constant) override |
virtual void | visit (ShPtr< ConstSymbol > constant) override |
virtual void | visit (ShPtr< ArrayType > type) override |
virtual void | visit (ShPtr< FloatType > type) override |
virtual void | visit (ShPtr< IntType > type) override |
virtual void | visit (ShPtr< PointerType > type) override |
virtual void | visit (ShPtr< StringType > type) override |
virtual void | visit (ShPtr< StructType > type) override |
virtual void | visit (ShPtr< FunctionType > type) override |
virtual void | visit (ShPtr< VoidType > type) override |
virtual void | visit (ShPtr< UnknownType > type) override |
![]() | |
Visitor ()=default | |
virtual | ~Visitor ()=default |
Protected Attributes | |
ShPtr< Module > | module |
The validated module. More... | |
ShPtr< Function > | func |
The currently traversed function. More... | |
![]() | |
ShPtr< Statement > | lastStmt |
Statement that has been accessed as the last one. More... | |
StmtUSet | accessedStmts |
A set of all accessed statements. More... | |
TypeUSet | accessedTypes |
A set of all accessed types. More... | |
bool | visitSuccessors |
Should statements' successor be accessed? More... | |
bool | visitNestedStmts |
Should nested statements be accessed? More... | |
Private Member Functions | |
virtual void | runValidation () |
Runs the validation over the module. More... | |
Private Attributes | |
bool | printMessageOnError |
Should we print a warning message when encountering an error? More... | |
bool | moduleIsCorrect |
true if there has not been an error, false otherwise. More... | |
A base class for all validators.
Every concrete validator has to:
ShPtr<Validator> create()
functiongetId()
, which returns the ID of the validatorrunValidation()
A concrete validator can utilize protected members of this base class.
Instances of this class have reference object semantics.
|
protected |
Constructs a new validator.
|
pure virtual |
|
privatevirtual |
Runs the validation over the module.
By default, this function calls traverseAllGlobalVariables() and traverseAllFunctions(). If you want to do anything else, redefine this member function.
|
protected |
Traverses all functions in the current module and calls accept()
on every one of them.
Furthermore, before traversing a function, it sets the data member func
to the traversed function.
|
protected |
Traverses all global variables in the current module and calls accept()
on every one of them.
bool retdec::llvmir2hll::Validator::validate | ( | ShPtr< Module > | module, |
bool | printMessageOnError = false |
||
) |
Validates the given module.
[in] | module | Module to be validated. |
[in] | printMessageOnError | If true and the module is not valid, it prints a warning message to standard error. |
true
if the module is correct, false
otherwise.The details depend on the concrete validator. See its class description. If there are multiple errors and printMessageOnError is true
, it prints a warning message for each of these errors.
|
inlineprotected |
Function to be called when there is a validation error.
|
private |
true
if there has not been an error, false
otherwise.
|
private |
Should we print a warning message when encountering an error?