mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10995 from ethereum/function-call-graph-remove-contract-reference
Remove contract reference from function call graph
This commit is contained in:
commit
ddc8692af6
@ -69,8 +69,6 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph(
|
|||||||
CallGraph const& _creationGraph
|
CallGraph const& _creationGraph
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
solAssert(&_creationGraph.contract == &_contract, "");
|
|
||||||
|
|
||||||
FunctionCallGraphBuilder builder(_contract);
|
FunctionCallGraphBuilder builder(_contract);
|
||||||
solAssert(builder.m_currentNode == CallGraph::Node(CallGraph::SpecialNode::Entry), "");
|
solAssert(builder.m_currentNode == CallGraph::Node(CallGraph::SpecialNode::Entry), "");
|
||||||
|
|
||||||
@ -150,7 +148,7 @@ bool FunctionCallGraphBuilder::visit(Identifier const& _identifier)
|
|||||||
|
|
||||||
// For events kind() == Event, so we have an extra check here
|
// For events kind() == Event, so we have an extra check here
|
||||||
if (funType && funType->kind() == FunctionType::Kind::Internal)
|
if (funType && funType->kind() == FunctionType::Kind::Internal)
|
||||||
functionReferenced(callable->resolveVirtual(m_graph.contract), _identifier.annotation().calledDirectly);
|
functionReferenced(callable->resolveVirtual(m_contract), _identifier.annotation().calledDirectly);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -171,8 +169,8 @@ bool FunctionCallGraphBuilder::visit(MemberAccess const& _memberAccess)
|
|||||||
{
|
{
|
||||||
solAssert(contractType->isSuper(), "");
|
solAssert(contractType->isSuper(), "");
|
||||||
functionDef = &functionDef->resolveVirtual(
|
functionDef = &functionDef->resolveVirtual(
|
||||||
m_graph.contract,
|
m_contract,
|
||||||
contractType->contractDefinition().superContract(m_graph.contract)
|
contractType->contractDefinition().superContract(m_contract)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +189,7 @@ bool FunctionCallGraphBuilder::visit(ModifierInvocation const& _modifierInvocati
|
|||||||
VirtualLookup const& requiredLookup = *_modifierInvocation.name().annotation().requiredLookup;
|
VirtualLookup const& requiredLookup = *_modifierInvocation.name().annotation().requiredLookup;
|
||||||
|
|
||||||
if (requiredLookup == VirtualLookup::Virtual)
|
if (requiredLookup == VirtualLookup::Virtual)
|
||||||
functionReferenced(modifier->resolveVirtual(m_graph.contract));
|
functionReferenced(modifier->resolveVirtual(m_contract));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
solAssert(requiredLookup == VirtualLookup::Static, "");
|
solAssert(requiredLookup == VirtualLookup::Static, "");
|
||||||
@ -270,7 +268,8 @@ ostream& solidity::frontend::operator<<(ostream& _out, CallGraph::Node const& _n
|
|||||||
case CallGraph::SpecialNode::Entry:
|
case CallGraph::SpecialNode::Entry:
|
||||||
_out << "Entry";
|
_out << "Entry";
|
||||||
break;
|
break;
|
||||||
default: solAssert(false, "Invalid SpecialNode type");
|
default:
|
||||||
|
solAssert(false, "Invalid SpecialNode type");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
FunctionCallGraphBuilder(ContractDefinition const& _contract):
|
FunctionCallGraphBuilder(ContractDefinition const& _contract):
|
||||||
m_graph{_contract, {}, {}, {}} {}
|
m_contract(_contract),
|
||||||
|
m_graph{{}, {}, {}} {}
|
||||||
|
|
||||||
bool visit(FunctionCall const& _functionCall) override;
|
bool visit(FunctionCall const& _functionCall) override;
|
||||||
bool visit(EmitStatement const& _emitStatement) override;
|
bool visit(EmitStatement const& _emitStatement) override;
|
||||||
@ -81,6 +82,7 @@ private:
|
|||||||
void functionReferenced(CallableDeclaration const& _callable, bool _calledDirectly = true);
|
void functionReferenced(CallableDeclaration const& _callable, bool _calledDirectly = true);
|
||||||
|
|
||||||
CallGraph::Node m_currentNode = CallGraph::SpecialNode::Entry;
|
CallGraph::Node m_currentNode = CallGraph::SpecialNode::Entry;
|
||||||
|
ContractDefinition const& m_contract;
|
||||||
CallGraph m_graph;
|
CallGraph m_graph;
|
||||||
std::deque<CallableDeclaration const*> m_visitQueue;
|
std::deque<CallableDeclaration const*> m_visitQueue;
|
||||||
};
|
};
|
||||||
|
@ -56,9 +56,6 @@ struct CallGraph
|
|||||||
bool operator()(int64_t _lhs, Node const& _rhs) const;
|
bool operator()(int64_t _lhs, Node const& _rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Contract for which this is the graph
|
|
||||||
ContractDefinition const& contract;
|
|
||||||
|
|
||||||
/// Graph edges. Edges are directed and lead from the caller to the callee.
|
/// Graph edges. Edges are directed and lead from the caller to the callee.
|
||||||
/// The map contains a key for every possible caller, even if does not actually perform
|
/// The map contains a key for every possible caller, even if does not actually perform
|
||||||
/// any calls.
|
/// any calls.
|
||||||
|
Loading…
Reference in New Issue
Block a user