mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ControlFlowAnalyser: Also consider called functions in a flow
This commit is contained in:
@@ -19,30 +19,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <libsolidity/analysis/ControlFlowGraph.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <set>
|
||||
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class ControlFlowAnalyzer: private ASTConstVisitor
|
||||
class ControlFlowAnalyzer
|
||||
{
|
||||
public:
|
||||
explicit ControlFlowAnalyzer(CFG const& _cfg, langutil::ErrorReporter& _errorReporter):
|
||||
m_cfg(_cfg), m_errorReporter(_errorReporter) {}
|
||||
|
||||
bool analyze(ASTNode const& _astRoot);
|
||||
|
||||
bool visit(FunctionDefinition const& _function) override;
|
||||
bool run();
|
||||
|
||||
private:
|
||||
void analyze(FunctionDefinition const& _function, ContractDefinition const* _contract, FunctionFlow const& _flow);
|
||||
/// Checks for uninitialized variable accesses in the control flow between @param _entry and @param _exit.
|
||||
void checkUninitializedAccess(CFGNode const* _entry, CFGNode const* _exit, bool _emptyBody) const;
|
||||
/// @param _entry entry node
|
||||
/// @param _exit exit node
|
||||
/// @param _emptyBody whether the body of the function is empty (true) or not (false)
|
||||
/// @param _contractName name of the most derived contract, should be empty
|
||||
/// if the function is also defined in it
|
||||
void checkUninitializedAccess(CFGNode const* _entry, CFGNode const* _exit, bool _emptyBody, std::optional<std::string> _contractName = {});
|
||||
/// Checks for unreachable code, i.e. code ending in @param _exit, @param _revert or @param _transactionReturn
|
||||
/// that can not be reached from @param _entry.
|
||||
void checkUnreachable(CFGNode const* _entry, CFGNode const* _exit, CFGNode const* _revert, CFGNode const* _transactionReturn) const;
|
||||
void checkUnreachable(CFGNode const* _entry, CFGNode const* _exit, CFGNode const* _revert, CFGNode const* _transactionReturn);
|
||||
|
||||
CFG const& m_cfg;
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
|
||||
std::set<langutil::SourceLocation> m_unreachableLocationsAlreadyWarnedFor;
|
||||
std::set<VariableDeclaration const*> m_unassignedReturnVarsAlreadyWarnedFor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user