@@ -117,6 +117,29 @@ unsigned StructLayout::getElementContainingOffset(uint64_t FixedOffset) const {
117
117
return SI - MemberOffsets.begin ();
118
118
}
119
119
120
+ namespace {
121
+
122
+ class StructLayoutMap {
123
+ using LayoutInfoTy = DenseMap<StructType*, StructLayout*>;
124
+ LayoutInfoTy LayoutInfo;
125
+
126
+ public:
127
+ ~StructLayoutMap () {
128
+ // Remove any layouts.
129
+ for (const auto &I : LayoutInfo) {
130
+ StructLayout *Value = I.second ;
131
+ Value->~StructLayout ();
132
+ free (Value);
133
+ }
134
+ }
135
+
136
+ StructLayout *&operator [](StructType *STy) {
137
+ return LayoutInfo[STy];
138
+ }
139
+ };
140
+
141
+ } // end anonymous namespace
142
+
120
143
// ===----------------------------------------------------------------------===//
121
144
// LayoutAlignElem, LayoutAlign support
122
145
// ===----------------------------------------------------------------------===//
@@ -214,7 +237,8 @@ DataLayout::DataLayout(StringRef LayoutString) {
214
237
}
215
238
216
239
DataLayout &DataLayout::operator =(const DataLayout &Other) {
217
- // Copy everything except for LayoutMap, which will be recomputed on demand.
240
+ delete static_cast <StructLayoutMap *>(LayoutMap);
241
+ LayoutMap = nullptr ;
218
242
StringRepresentation = Other.StringRepresentation ;
219
243
BigEndian = Other.BigEndian ;
220
244
AllocaAddrSpace = Other.AllocaAddrSpace ;
@@ -687,29 +711,6 @@ Align DataLayout::getIntegerAlignment(uint32_t BitWidth,
687
711
return abi_or_pref ? I->ABIAlign : I->PrefAlign ;
688
712
}
689
713
690
- namespace {
691
-
692
- class StructLayoutMap {
693
- using LayoutInfoTy = DenseMap<StructType*, StructLayout*>;
694
- LayoutInfoTy LayoutInfo;
695
-
696
- public:
697
- ~StructLayoutMap () {
698
- // Remove any layouts.
699
- for (const auto &I : LayoutInfo) {
700
- StructLayout *Value = I.second ;
701
- Value->~StructLayout ();
702
- free (Value);
703
- }
704
- }
705
-
706
- StructLayout *&operator [](StructType *STy) {
707
- return LayoutInfo[STy];
708
- }
709
- };
710
-
711
- } // end anonymous namespace
712
-
713
714
DataLayout::~DataLayout () { delete static_cast <StructLayoutMap *>(LayoutMap); }
714
715
715
716
const StructLayout *DataLayout::getStructLayout (StructType *Ty) const {
0 commit comments