Coverage Report

Created: 2026-09-14 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/solidity/libsolidity/analysis/ImmutableValidator.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 <libsolidity/ast/ASTVisitor.h>
22
#include <liblangutil/ErrorReporter.h>
23
24
namespace solidity::frontend
25
{
26
27
/**
28
 * Validates access and initialization of immutable variables:
29
 * must be directly initialized in a c'tor or inline
30
*/
31
class ImmutableValidator: private ASTConstVisitor
32
{
33
public:
34
  ImmutableValidator(langutil::ErrorReporter& _errorReporter, ContractDefinition const& _contractDefinition):
35
18.4k
    m_mostDerivedContract(_contractDefinition),
36
18.4k
    m_errorReporter(_errorReporter)
37
18.4k
  { }
38
39
  void analyze();
40
41
private:
42
  bool visit(FunctionDefinition const& _functionDefinition);
43
  void endVisit(MemberAccess const& _memberAccess);
44
  void endVisit(Identifier const& _identifier);
45
46
  void analyseVariableReference(Declaration const* _variableReference, Expression const& _expression);
47
48
  ContractDefinition const& m_mostDerivedContract;
49
50
  langutil::ErrorReporter& m_errorReporter;
51
};
52
53
}