Coverage Report

Created: 2022-08-24 06:52

/src/solidity/libsolidity/analysis/ControlFlowGraph.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
  This file is part of solidity.
3
4
  solidity is free software: you can redistribute it and/or modify
5
  it under the terms of the GNU General Public License as published by
6
  the Free Software Foundation, either version 3 of the License, or
7
  (at your option) any later version.
8
9
  solidity is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with solidity.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
// SPDX-License-Identifier: GPL-3.0
18
19
#include <libsolidity/analysis/ControlFlowGraph.h>
20
21
#include <libsolidity/analysis/ControlFlowBuilder.h>
22
23
using namespace std;
24
using namespace solidity::langutil;
25
using namespace solidity::frontend;
26
27
bool CFG::constructFlow(ASTNode const& _astRoot)
28
3.60k
{
29
3.60k
  _astRoot.accept(*this);
30
3.60k
  return !Error::containsErrors(m_errorReporter.errors());
31
3.60k
}
32
33
34
bool CFG::visit(FunctionDefinition const& _function)
35
39.6k
{
36
39.6k
  if (_function.isImplemented() && _function.isFree())
37
0
    m_functionControlFlow[{nullptr, &_function}] = ControlFlowBuilder::createFunctionFlow(m_nodeContainer, _function);
38
39.6k
  return false;
39
39.6k
}
40
41
bool CFG::visit(ContractDefinition const& _contract)
42
3.60k
{
43
3.60k
  for (ContractDefinition const* contract: _contract.annotation().linearizedBaseContracts)
44
3.60k
    for (FunctionDefinition const* function: contract->definedFunctions())
45
39.6k
      if (function->isImplemented())
46
39.6k
        m_functionControlFlow[{&_contract, function}] =
47
39.6k
          ControlFlowBuilder::createFunctionFlow(m_nodeContainer, *function, &_contract);
48
49
3.60k
  return true;
50
3.60k
}
51
52
FunctionFlow const& CFG::functionFlow(FunctionDefinition const& _function, ContractDefinition const* _contract) const
53
83.4k
{
54
83.4k
  return *m_functionControlFlow.at({_contract, &_function});
55
83.4k
}
56
57
CFGNode* CFG::NodeContainer::newNode()
58
1.94M
{
59
1.94M
  m_nodes.emplace_back(std::make_unique<CFGNode>());
60
1.94M
  return m_nodes.back().get();
61
1.94M
}