Coverage Report

Created: 2025-09-04 07:34

/src/solidity/libyul/FunctionReferenceResolver.h
Line
Count
Source
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
#pragma once
20
21
#include <libyul/optimiser/ASTWalker.h>
22
23
namespace solidity::yul
24
{
25
26
/**
27
 * Resolves references to user-defined functions in function calls.
28
 * Assumes the code is correct, i.e. does not check for references to be valid or unique.
29
 *
30
 * Be careful not to iterate over the result - it is not deterministic.
31
 */
32
class FunctionReferenceResolver: private ASTWalker
33
{
34
public:
35
  explicit FunctionReferenceResolver(Block const& _ast);
36
1.32M
  std::map<FunctionCall const*, FunctionDefinition const*> const& references() const { return m_functionReferences; }
37
38
private:
39
  using ASTWalker::operator();
40
  void operator()(FunctionCall const& _functionCall) override;
41
  void operator()(Block const& _block) override;
42
43
  std::map<FunctionCall const*, FunctionDefinition const*> m_functionReferences;
44
  std::vector<std::map<YulName, FunctionDefinition const*>> m_scopes;
45
};
46
47
48
}