LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
Parameter.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2025 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_DWARF_PARAMETER_H
16#define LIEF_DWARF_PARAMETER_H
17
18#include "LIEF/visibility.h"
19
20#include <memory>
21#include <string>
22#include <cstdint>
23
24namespace LIEF {
25namespace dwarf {
26
27class Type;
28
29namespace details {
30class Parameter;
31}
32
38 public:
45
48 public:
49 enum class Type : uint8_t {
52 };
54 type(ty)
55 {}
56
57 template<class T>
58 const T* as() const {
59 if (T::classof(this)) {
60 return static_cast<const T*>(this);
61 }
62 return nullptr;
63 }
64
66 };
67
69 class LIEF_API RegisterLoc : public Location {
70 public:
71 RegisterLoc(uint64_t reg_id) :
73 id(reg_id)
74 {}
75
76 static bool classof(const Location* loc) {
77 return loc->type == Type::REG;
78 }
79
81 uint64_t id = 0;
82 };
83
84 Parameter() = delete;
87 Parameter& operator=(const Parameter&) = delete;
88 Parameter(const Parameter&) = delete;
89
90
91 KIND kind() const;
92
94 std::string name() const;
95
97 std::unique_ptr<Type> type() const;
98
101 std::unique_ptr<Location> location() const;
102
103 template<class T>
104 const T* as() const {
105 if (T::classof(this)) {
106 return static_cast<const T*>(this);
107 }
108 return nullptr;
109 }
110
111 virtual ~Parameter();
112
113 LIEF_LOCAL static
114 std::unique_ptr<Parameter> create(std::unique_ptr<details::Parameter> impl);
115
116 protected:
117 Parameter(std::unique_ptr<details::Parameter> impl);
118 std::unique_ptr<details::Parameter> impl_;
119};
120
121namespace parameters {
122
136class LIEF_API Formal : public Parameter {
137 public:
139 static bool classof(const Parameter* P) {
140 return P->kind() == Parameter::KIND::FORMAL;
141 }
142
143 ~Formal() override = default;
144};
145
146
158 public:
160 static bool classof(const Parameter* P) {
161 return P->kind() == Parameter::KIND::TEMPLATE_VALUE;
162 }
163
164 ~TemplateValue() override = default;
165};
166
178public:
180 static bool classof(const Parameter* P) {
181 return P->kind() == Parameter::KIND::TEMPLATE_TYPE;
182 }
183
184 ~TemplateType() override = default;
185};
186
187}
188
189}
190}
191#endif
Type
Definition Parameter.hpp:49
@ UNKNOWN
Definition Parameter.hpp:50
@ REG
Definition Parameter.hpp:51
const T * as() const
Definition Parameter.hpp:58
Type type
Definition Parameter.hpp:65
Location(Type ty)
Definition Parameter.hpp:53
static bool classof(const Location *loc)
Definition Parameter.hpp:76
uint64_t id
DWARF id of the register.
Definition Parameter.hpp:81
RegisterLoc(uint64_t reg_id)
Definition Parameter.hpp:71
std::string name() const
Name of the parameter.
Parameter(Parameter &&other)
Parameter & operator=(Parameter &&other)
KIND
Definition Parameter.hpp:39
@ TEMPLATE_VALUE
DW_TAG_template_value_parameter.
Definition Parameter.hpp:42
@ TEMPLATE_TYPE
DW_TAG_template_type_parameter.
Definition Parameter.hpp:41
@ UNKNOWN
Definition Parameter.hpp:40
@ FORMAL
DW_TAG_formal_parameter.
Definition Parameter.hpp:43
static std::unique_ptr< Parameter > create(std::unique_ptr< details::Parameter > impl)
std::unique_ptr< Type > type() const
Type of this parameter.
Parameter(const Parameter &)=delete
std::unique_ptr< Location > location() const
Location of this parameter. For instance it can be a specific register that is not following the call...
const T * as() const
Definition Parameter.hpp:104
Parameter & operator=(const Parameter &)=delete
This class represents a DWARF Type which includes:
Definition DWARF/Type.hpp:64
This class represents a regular function parameter.
Definition Parameter.hpp:136
static bool classof(const Parameter *P)
Definition Parameter.hpp:139
This class represents a template type parameter.
Definition Parameter.hpp:177
static bool classof(const Parameter *P)
Definition Parameter.hpp:180
This class represents a template value parameter.
Definition Parameter.hpp:157
static bool classof(const Parameter *P)
Definition Parameter.hpp:160
Definition DWARF/CompilationUnit.hpp:30
Definition Parameter.hpp:121
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42