mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! Syntactic call graph
This commit is contained in:
parent
ccae691606
commit
2059fdf054
@ -24,8 +24,7 @@ using namespace solidity::util;
|
|||||||
|
|
||||||
FunctionCallGraph::FunctionCallGraph(solidity::frontend::experimental::Analysis& _analysis):
|
FunctionCallGraph::FunctionCallGraph(solidity::frontend::experimental::Analysis& _analysis):
|
||||||
m_analysis(_analysis),
|
m_analysis(_analysis),
|
||||||
m_errorReporter(_analysis.errorReporter()),
|
m_errorReporter(_analysis.errorReporter())
|
||||||
m_currentFunction(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,8 +38,7 @@ bool FunctionCallGraph::analyze(SourceUnit const& _sourceUnit)
|
|||||||
|
|
||||||
bool FunctionCallGraph::visit(FunctionDefinition const& _functionDefinition)
|
bool FunctionCallGraph::visit(FunctionDefinition const& _functionDefinition)
|
||||||
{
|
{
|
||||||
solAssert(!m_inFunctionDefinition && !m_currentFunction);
|
solAssert(!m_currentFunction);
|
||||||
m_inFunctionDefinition = true;
|
|
||||||
m_currentFunction = &_functionDefinition;
|
m_currentFunction = &_functionDefinition;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -51,7 +49,6 @@ void FunctionCallGraph::endVisit(FunctionDefinition const&)
|
|||||||
// another function in its body - insert it into the graph without child nodes.
|
// another function in its body - insert it into the graph without child nodes.
|
||||||
if (!annotation().functionCallGraph.edges.count(m_currentFunction))
|
if (!annotation().functionCallGraph.edges.count(m_currentFunction))
|
||||||
annotation().functionCallGraph.edges.insert({m_currentFunction, {}});
|
annotation().functionCallGraph.edges.insert({m_currentFunction, {}});
|
||||||
m_inFunctionDefinition = false;
|
|
||||||
m_currentFunction = nullptr;
|
m_currentFunction = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,11 +57,8 @@ bool FunctionCallGraph::visit(Identifier const& _identifier)
|
|||||||
auto callee = dynamic_cast<FunctionDefinition const*>(_identifier.annotation().referencedDeclaration);
|
auto callee = dynamic_cast<FunctionDefinition const*>(_identifier.annotation().referencedDeclaration);
|
||||||
// Check that the identifier is within a function body and is a function, and add it to the graph
|
// Check that the identifier is within a function body and is a function, and add it to the graph
|
||||||
// as an ``m_currentFunction`` -> ``callee`` edge.
|
// as an ``m_currentFunction`` -> ``callee`` edge.
|
||||||
if (m_inFunctionDefinition && callee)
|
if (m_currentFunction && callee)
|
||||||
{
|
|
||||||
solAssert(m_currentFunction, "Child node must have a parent");
|
|
||||||
add(m_currentFunction, callee);
|
add(m_currentFunction, callee);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,7 @@ private:
|
|||||||
|
|
||||||
Analysis& m_analysis;
|
Analysis& m_analysis;
|
||||||
langutil::ErrorReporter& m_errorReporter;
|
langutil::ErrorReporter& m_errorReporter;
|
||||||
FunctionDefinition const* m_currentFunction;
|
FunctionDefinition const* m_currentFunction = nullptr;
|
||||||
bool m_inFunctionDefinition = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user