34
34
#include < optional>
35
35
#include < string>
36
36
#include < string_view>
37
+ #include < variant>
37
38
#include < vector>
38
39
39
40
#include " oi/ContainerInfo.h"
@@ -195,6 +196,10 @@ class Incomplete : public Type {
195
196
Incomplete (Type& underlyingType) : underlyingType_(underlyingType) {
196
197
}
197
198
199
+ Incomplete (std::string underlyingTypeName)
200
+ : underlyingType_(std::move(underlyingTypeName)) {
201
+ }
202
+
198
203
static inline constexpr bool has_node_id = false ;
199
204
200
205
DECLARE_ACCEPT
@@ -204,7 +209,13 @@ class Incomplete : public Type {
204
209
}
205
210
206
211
std::string_view inputName () const override {
207
- return underlyingType_.inputName ();
212
+ if (std::holds_alternative<std::string>(underlyingType_)) {
213
+ return std::get<std::string>(underlyingType_);
214
+ }
215
+
216
+ return std::get<std::reference_wrapper<Type>>(underlyingType_)
217
+ .get ()
218
+ .inputName ();
208
219
}
209
220
210
221
size_t size () const override {
@@ -219,12 +230,16 @@ class Incomplete : public Type {
219
230
return -1 ;
220
231
}
221
232
222
- Type& underlyingType () const {
223
- return underlyingType_;
233
+ std::optional<std::reference_wrapper<Type>> underlyingType () const {
234
+ if (std::holds_alternative<std::string>(underlyingType_)) {
235
+ return std::nullopt ;
236
+ }
237
+
238
+ return std::get<std::reference_wrapper<Type>>(underlyingType_);
224
239
}
225
240
226
241
private:
227
- Type& underlyingType_;
242
+ std::variant<std::string, std::reference_wrapper< Type>> underlyingType_;
228
243
static const std::string kName ;
229
244
};
230
245
@@ -551,8 +566,6 @@ class Primitive : public Type {
551
566
552
567
StubbedPointer,
553
568
Void,
554
- Incomplete, // Behaves the same as Void, but alerts us that the type was
555
- // stubbed out due to incomplete DWARF
556
569
};
557
570
558
571
explicit Primitive (Kind kind) : kind_(kind), name_(getName(kind)) {
0 commit comments