MCPcopy Create free account
hub / github.com/argotorg/solidity / buildCreationGraph

Method buildCreationGraph

libsolidity/analysis/FunctionCallGraph.cpp:30–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28using namespace solidity::util;
29
30CallGraph 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
66CallGraph FunctionCallGraphBuilder::buildDeployedGraph(
67 ContractDefinition const& _contract,

Callers

nothing calls this directly

Calls 6

functionReferencedMethod · 0.80
processQueueMethod · 0.80
stateVariablesMethod · 0.45
isConstantMethod · 0.45
acceptMethod · 0.45
constructorMethod · 0.45

Tested by

no test coverage detected