Coverage Report

Created: 2025-06-24 07:59

/src/solidity/libsolidity/experimental/analysis/Analysis.h
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
#pragma once
19
20
#include <libsolidity/experimental/ast/TypeSystem.h>
21
22
#include <cstdint>
23
#include <memory>
24
#include <vector>
25
26
namespace solidity::frontend
27
{
28
class SourceUnit;
29
class ASTNode;
30
}
31
32
namespace solidity::langutil
33
{
34
class ErrorReporter;
35
}
36
37
namespace solidity::frontend::experimental
38
{
39
40
class TypeSystem;
41
42
class Analysis;
43
44
namespace detail
45
{
46
template<typename Step>
47
struct AnnotationFetcher
48
{
49
  Analysis& analysis;
50
  typename Step::Annotation& get(ASTNode const& _node);
51
  typename Step::GlobalAnnotation& get();
52
};
53
template<typename Step>
54
struct ConstAnnotationFetcher
55
{
56
  Analysis const& analysis;
57
  typename Step::Annotation const& get(ASTNode const& _node) const;
58
  typename Step::GlobalAnnotation const& get() const;
59
};
60
}
61
62
class Analysis
63
{
64
  struct AnnotationContainer;
65
  struct GlobalAnnotationContainer;
66
67
public:
68
  Analysis(langutil::ErrorReporter& _errorReporter, uint64_t _maxAstId);
69
  Analysis(Analysis const&) = delete;
70
  ~Analysis();
71
  Analysis const& operator=(Analysis const&) = delete;
72
  bool check(std::vector<std::shared_ptr<SourceUnit const>> const& _sourceUnits);
73
300
  langutil::ErrorReporter& errorReporter() { return m_errorReporter; }
74
0
  uint64_t maxAstId() const { return m_maxAstId; }
75
200
  TypeSystem& typeSystem() { return m_typeSystem; }
76
0
  TypeSystem const& typeSystem() const { return m_typeSystem; }
77
78
  template<typename Step>
79
  typename Step::Annotation& annotation(ASTNode const& _node)
80
2.19k
  {
81
2.19k
    return detail::AnnotationFetcher<Step>{*this}.get(_node);
82
2.19k
  }
solidity::frontend::experimental::TypeInference::Annotation& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeInference>(solidity::frontend::ASTNode const&)
Line
Count
Source
80
1.39k
  {
81
1.39k
    return detail::AnnotationFetcher<Step>{*this}.get(_node);
82
1.39k
  }
solidity::frontend::experimental::TypeClassRegistration::Annotation& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeClassRegistration>(solidity::frontend::ASTNode const&)
Line
Count
Source
80
98
  {
81
98
    return detail::AnnotationFetcher<Step>{*this}.get(_node);
82
98
  }
solidity::frontend::experimental::TypeRegistration::Annotation& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeRegistration>(solidity::frontend::ASTNode const&)
Line
Count
Source
80
703
  {
81
703
    return detail::AnnotationFetcher<Step>{*this}.get(_node);
82
703
  }
83
84
  template<typename Step>
85
  typename Step::Annotation const& annotation(ASTNode const& _node) const
86
0
  {
87
0
    return detail::ConstAnnotationFetcher<Step>{*this}.get(_node);
88
0
  }
Unexecuted instantiation: solidity::frontend::experimental::TypeInference::Annotation const& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeInference>(solidity::frontend::ASTNode const&) const
Unexecuted instantiation: solidity::frontend::experimental::TypeRegistration::Annotation const& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeRegistration>(solidity::frontend::ASTNode const&) const
Unexecuted instantiation: solidity::frontend::experimental::TypeClassRegistration::Annotation const& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeClassRegistration>(solidity::frontend::ASTNode const&) const
89
90
  template<typename Step>
91
  typename Step::GlobalAnnotation& annotation()
92
2.86k
  {
93
2.86k
    return detail::AnnotationFetcher<Step>{*this}.get();
94
2.86k
  }
solidity::frontend::experimental::FunctionDependencyAnalysis::GlobalAnnotation& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::FunctionDependencyAnalysis>()
Line
Count
Source
92
95
  {
93
95
    return detail::AnnotationFetcher<Step>{*this}.get();
94
95
  }
solidity::frontend::experimental::TypeInference::GlobalAnnotation& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeInference>()
Line
Count
Source
92
2.76k
  {
93
2.76k
    return detail::AnnotationFetcher<Step>{*this}.get();
94
2.76k
  }
solidity::frontend::experimental::TypeRegistration::GlobalAnnotation& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeRegistration>()
Line
Count
Source
92
10
  {
93
10
    return detail::AnnotationFetcher<Step>{*this}.get();
94
10
  }
95
96
  template<typename Step>
97
  typename Step::GlobalAnnotation const& annotation() const
98
0
  {
99
0
    return detail::ConstAnnotationFetcher<Step>{*this}.get();
100
0
  }
Unexecuted instantiation: solidity::frontend::experimental::TypeRegistration::GlobalAnnotation const& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeRegistration>() const
Unexecuted instantiation: solidity::frontend::experimental::TypeInference::GlobalAnnotation const& solidity::frontend::experimental::Analysis::annotation<solidity::frontend::experimental::TypeInference>() const
101
102
  AnnotationContainer& annotationContainer(ASTNode const& _node);
103
  AnnotationContainer const& annotationContainer(ASTNode const& _node) const;
104
2.86k
  GlobalAnnotationContainer& annotationContainer() { return *m_globalAnnotation; }
105
0
  GlobalAnnotationContainer const& annotationContainer() const { return *m_globalAnnotation; }
106
107
private:
108
  langutil::ErrorReporter& m_errorReporter;
109
  TypeSystem m_typeSystem;
110
  uint64_t m_maxAstId = 0;
111
  std::unique_ptr<AnnotationContainer[]> m_annotations;
112
  std::unique_ptr<GlobalAnnotationContainer> m_globalAnnotation;
113
};
114
115
}