Fix call graph with respect to constants.

This commit is contained in:
chriseth
2021-02-25 16:00:53 +01:00
committed by Kamil Śliwak
parent eacf7c1cf9
commit 16db3a84f1
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -41,7 +41,8 @@ CallGraph FunctionCallGraphBuilder::buildCreationGraph(ContractDefinition const&
// an edge from Entry
builder.m_currentNode = CallGraph::SpecialNode::Entry;
for (auto const* stateVar: base->stateVariables())
stateVar->accept(builder);
if (!stateVar->isConstant())
stateVar->accept(builder);
if (base->constructor())
{
@@ -140,7 +141,15 @@ bool FunctionCallGraphBuilder::visit(EmitStatement const& _emitStatement)
bool FunctionCallGraphBuilder::visit(Identifier const& _identifier)
{
if (auto const* callable = dynamic_cast<CallableDeclaration const*>(_identifier.annotation().referencedDeclaration))
if (auto const* variable = dynamic_cast<VariableDeclaration const*>(_identifier.annotation().referencedDeclaration))
{
if (variable->isConstant())
{
solAssert(variable->isStateVariable() || variable->isFileLevelVariable(), "");
variable->accept(*this);
}
}
else if (auto const* callable = dynamic_cast<CallableDeclaration const*>(_identifier.annotation().referencedDeclaration))
{
solAssert(*_identifier.annotation().requiredLookup == VirtualLookup::Virtual, "");
+1 -1
View File
@@ -66,7 +66,7 @@ void verifyCallGraph(
{
solAssert(
_generatedFunctions.count(expectedFunction) == 1 || expectedFunction->isConstructor(),
"No code generated for function " + expectedFunction->name() + "even though it is not a constructor."
"No code generated for function " + expectedFunction->name() + " even though it is not a constructor."
);
_generatedFunctions.erase(expectedFunction);
}