| 28 | using namespace solidity::util; |
| 29 | |
| 30 | CallGraph FunctionCallGraphBuilder::buildCreationGraph(ContractDefinition const& _contract) |
| 31 | { |
| 32 | FunctionCallGraphBuilder builder(_contract); |
| 33 | solAssert(builder.m_currentNode == CallGraph::Node(CallGraph::SpecialNode::Entry), ""); |
| 34 | |
| 35 | // Create graph for constructor, state vars, etc |
| 36 | for (ContractDefinition const* base: _contract.annotation().linearizedBaseContracts | ranges::views::reverse) |
| 37 | { |
| 38 | // The constructor and functions called in state variable initial assignments should have |
| 39 | // an edge from Entry |
| 40 | builder.m_currentNode = CallGraph::SpecialNode::Entry; |
| 41 | for (auto const* stateVar: base->stateVariables()) |
| 42 | if (!stateVar->isConstant()) |
| 43 | stateVar->accept(builder); |
| 44 | |
| 45 | if (base->constructor()) |
| 46 | { |
| 47 | builder.functionReferenced(*base->constructor()); |
| 48 | |
| 49 | // Constructors and functions called in state variable initializers have an edge either from |
| 50 | // the previous class in linearized order or from Entry if there's no class before. |
| 51 | builder.m_currentNode = base->constructor(); |
| 52 | } |
| 53 | |
| 54 | // Functions called from the inheritance specifier should have an edge from the constructor |
| 55 | // for consistency with functions called from constructor modifiers. |
| 56 | for (auto const& inheritanceSpecifier: base->baseContracts()) |
| 57 | inheritanceSpecifier->accept(builder); |
| 58 | } |
| 59 | |
| 60 | builder.m_currentNode = CallGraph::SpecialNode::Entry; |
| 61 | builder.processQueue(); |
| 62 | |
| 63 | return std::move(builder.m_graph); |
| 64 | } |
| 65 | |
| 66 | CallGraph FunctionCallGraphBuilder::buildDeployedGraph( |
| 67 | ContractDefinition const& _contract, |
nothing calls this directly
no test coverage detected