@@ -54,58 +54,6 @@ void ControlFlowRevertPruner::run()
5454 modifyFunctionFlows ();
5555}
5656
57- FunctionDefinition const * ControlFlowRevertPruner::resolveCall (FunctionCall const & _functionCall, ContractDefinition const * _contract)
58- {
59- auto result = m_resolveCache.find ({&_functionCall, _contract});
60- if (result != m_resolveCache.end ())
61- return result->second ;
62-
63- auto const & functionType = dynamic_cast <FunctionType const &>(
64- *_functionCall.expression ().annotation ().type
65- );
66-
67- if (!functionType.hasDeclaration ())
68- return nullptr ;
69-
70- auto const & unresolvedFunctionDefinition =
71- dynamic_cast <FunctionDefinition const &>(functionType.declaration ());
72-
73- FunctionDefinition const * returnFunctionDef = &unresolvedFunctionDefinition;
74-
75- if (auto const * memberAccess = dynamic_cast <MemberAccess const *>(&_functionCall.expression ()))
76- {
77- if (*memberAccess->annotation ().requiredLookup == VirtualLookup::Super)
78- {
79- if (auto const typeType = dynamic_cast <TypeType const *>(memberAccess->expression ().annotation ().type ))
80- if (auto const contractType = dynamic_cast <ContractType const *>(typeType->actualType ()))
81- {
82- solAssert (contractType->isSuper (), " " );
83- ContractDefinition const * superContract = contractType->contractDefinition ().superContract (*_contract);
84-
85- returnFunctionDef = &unresolvedFunctionDefinition.resolveVirtual (
86- *_contract,
87- superContract
88- );
89- }
90- }
91- else
92- {
93- solAssert (*memberAccess->annotation ().requiredLookup == VirtualLookup::Static, " " );
94- returnFunctionDef = &unresolvedFunctionDefinition;
95- }
96- }
97- else if (auto const * identifier = dynamic_cast <Identifier const *>(&_functionCall.expression ()))
98- {
99- solAssert (*identifier->annotation ().requiredLookup == VirtualLookup::Virtual, " " );
100- returnFunctionDef = &unresolvedFunctionDefinition.resolveVirtual (*_contract);
101- }
102-
103- if (returnFunctionDef && !returnFunctionDef->isImplemented ())
104- returnFunctionDef = nullptr ;
105-
106- return m_resolveCache[{&_functionCall, _contract}] = returnFunctionDef;
107- }
108-
10957void ControlFlowRevertPruner::findRevertStates ()
11058{
11159 std::set<CFG::FunctionContractTuple> pendingFunctions = keys (m_functions);
@@ -130,9 +78,9 @@ void ControlFlowRevertPruner::findRevertStates()
13078
13179 for (auto const * functionCall: _node->functionCalls )
13280 {
133- auto const * resolvedFunction = resolveCall (*functionCall, item.contract );
81+ auto const * resolvedFunction = ASTNode::resolveFunctionCall (*functionCall, item.contract );
13482
135- if (resolvedFunction == nullptr )
83+ if (resolvedFunction == nullptr || !resolvedFunction-> isImplemented () )
13684 continue ;
13785
13886 switch (m_functions.at ({findScopeContract (*resolvedFunction, item.contract ), resolvedFunction}))
@@ -180,9 +128,9 @@ void ControlFlowRevertPruner::modifyFunctionFlows()
180128 [&](CFGNode* _node, auto && _addChild) {
181129 for (auto const * functionCall: _node->functionCalls )
182130 {
183- auto const * resolvedFunction = resolveCall (*functionCall, item.first .contract );
131+ auto const * resolvedFunction = ASTNode::resolveFunctionCall (*functionCall, item.first .contract );
184132
185- if (resolvedFunction == nullptr )
133+ if (resolvedFunction == nullptr || !resolvedFunction-> isImplemented () )
186134 continue ;
187135
188136 switch (m_functions.at ({findScopeContract (*resolvedFunction, item.first .contract ), resolvedFunction}))
@@ -223,7 +171,11 @@ void ControlFlowRevertPruner::collectCalls(FunctionDefinition const& _function,
223171 solidity::util::BreadthFirstSearch<CFGNode*>{{functionFlow.entry }}.run (
224172 [&](CFGNode* _node, auto && _addChild) {
225173 for (auto const * functionCall: _node->functionCalls )
226- m_calledBy[resolveCall (*functionCall, _mostDerivedContract)].insert (pair);
174+ {
175+ auto const * funcDef = ASTNode::resolveFunctionCall (*functionCall, _mostDerivedContract);
176+ if (funcDef && funcDef->isImplemented ())
177+ m_calledBy[funcDef].insert (pair);
178+ }
227179
228180 for (CFGNode* exit: _node->exits )
229181 _addChild (exit);
0 commit comments