@@ -36,22 +36,23 @@ class TypeInfo;
36
36
// / This data structure holds everything needed to emit debug info
37
37
// / for a type.
38
38
class DebugTypeInfo {
39
+ protected:
39
40
// / The type we need to emit may be different from the type
40
41
// / mentioned in the Decl, for example, stripped of qualifiers.
41
42
TypeBase *Type = nullptr ;
42
43
// / Needed to determine the size of basic types and to determine
43
44
// / the storage type for undefined variables.
44
45
llvm::Type *StorageType = nullptr ;
45
- Size size = Size( 0 ) ;
46
- Alignment align = Alignment() ;
46
+ Optional< Size> size;
47
+ Alignment align;
47
48
bool DefaultAlignment = true ;
48
49
bool IsMetadataType = false ;
49
50
50
51
public:
51
52
DebugTypeInfo () = default ;
52
- DebugTypeInfo (swift::Type Ty, llvm::Type *StorageTy, Size SizeInBytes,
53
- Alignment AlignInBytes, bool HasDefaultAlignment ,
54
- bool IsMetadataType);
53
+ DebugTypeInfo (swift::Type Ty, llvm::Type *StorageTy,
54
+ Optional<Size> SizeInBytes, Alignment AlignInBytes ,
55
+ bool HasDefaultAlignment, bool IsMetadataType);
55
56
56
57
// / Create type for a local variable.
57
58
static DebugTypeInfo getLocalVariable (VarDecl *Decl,
@@ -92,24 +93,44 @@ class DebugTypeInfo {
92
93
}
93
94
94
95
llvm::Type *getStorageType () const {
95
- assert ((StorageType || size. isZero ()) &&
96
- " only defined types may have a size" );
96
+ if (size && size-> isZero ())
97
+ assert (StorageType && " only defined types may have a size" );
97
98
return StorageType;
98
99
}
99
- Size getSize () const { return size; }
100
+ Optional< Size> getSize () const { return size; }
100
101
void setSize (Size NewSize) { size = NewSize; }
101
102
Alignment getAlignment () const { return align; }
102
103
bool isNull () const { return Type == nullptr ; }
103
104
bool isForwardDecl () const { return StorageType == nullptr ; }
104
105
bool isMetadataType () const { return IsMetadataType; }
105
106
bool hasDefaultAlignment () const { return DefaultAlignment; }
106
-
107
+
107
108
bool operator ==(DebugTypeInfo T) const ;
108
109
bool operator !=(DebugTypeInfo T) const ;
109
110
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
110
111
LLVM_DUMP_METHOD void dump () const ;
111
112
#endif
112
113
};
114
+
115
+ // / A DebugTypeInfo with a defined size (that may be 0).
116
+ class CompletedDebugTypeInfo : public DebugTypeInfo {
117
+ CompletedDebugTypeInfo (DebugTypeInfo DbgTy) : DebugTypeInfo(DbgTy) {}
118
+ public:
119
+ static Optional<CompletedDebugTypeInfo> get (DebugTypeInfo DbgTy) {
120
+ if (!DbgTy.getSize ())
121
+ return {};
122
+ return CompletedDebugTypeInfo (DbgTy);
123
+ }
124
+
125
+ static Optional<CompletedDebugTypeInfo>
126
+ getFromTypeInfo (swift::Type Ty, const TypeInfo &Info) {
127
+ return CompletedDebugTypeInfo::get (
128
+ DebugTypeInfo::getFromTypeInfo (Ty, Info));
129
+ }
130
+
131
+ Size::int_type getSizeValue () const { return size.getValue ().getValue (); }
132
+ };
133
+
113
134
}
114
135
}
115
136
0 commit comments