@@ -143,7 +143,7 @@ SymbolicValue::Kind SymbolicValue::getKind() const {
143
143
// / Clone this SymbolicValue into the specified ASTContext and return the new
144
144
// / version. This only works for valid constants.
145
145
SymbolicValue
146
- SymbolicValue::cloneInto (ASTContext &astContext ) const {
146
+ SymbolicValue::cloneInto (SymbolicValueAllocator &allocator ) const {
147
147
auto thisRK = representationKind;
148
148
switch (thisRK) {
149
149
case RK_UninitMemory:
@@ -156,26 +156,26 @@ SymbolicValue::cloneInto(ASTContext &astContext) const {
156
156
return *this ;
157
157
case RK_IntegerInline:
158
158
case RK_Integer:
159
- return SymbolicValue::getInteger (getIntegerValue (), astContext );
159
+ return SymbolicValue::getInteger (getIntegerValue (), allocator );
160
160
case RK_String:
161
- return SymbolicValue::getString (getStringValue (), astContext );
161
+ return SymbolicValue::getString (getStringValue (), allocator );
162
162
case RK_Aggregate: {
163
163
auto elts = getAggregateValue ();
164
164
SmallVector<SymbolicValue, 4 > results;
165
165
results.reserve (elts.size ());
166
166
for (auto elt : elts)
167
- results.push_back (elt.cloneInto (astContext ));
168
- return getAggregate (results, astContext );
167
+ results.push_back (elt.cloneInto (allocator ));
168
+ return getAggregate (results, allocator );
169
169
}
170
170
case RK_EnumWithPayload:
171
- return getEnumWithPayload (getEnumValue (), getEnumPayloadValue (), astContext );
171
+ return getEnumWithPayload (getEnumValue (), getEnumPayloadValue (), allocator );
172
172
case RK_DirectAddress:
173
173
case RK_DerivedAddress: {
174
174
SmallVector<unsigned , 4 > accessPath;
175
175
auto *memObject = getAddressValue (accessPath);
176
176
auto *newMemObject = SymbolicValueMemoryObject::create (
177
- memObject->getType (), memObject->getValue (), astContext );
178
- return getAddress (newMemObject, accessPath, astContext );
177
+ memObject->getType (), memObject->getValue (), allocator );
178
+ return getAddress (newMemObject, accessPath, allocator );
179
179
}
180
180
}
181
181
}
@@ -186,9 +186,9 @@ SymbolicValue::cloneInto(ASTContext &astContext) const {
186
186
187
187
SymbolicValueMemoryObject *
188
188
SymbolicValueMemoryObject::create (Type type, SymbolicValue value,
189
- ASTContext &astContext ) {
190
- auto *result = astContext. Allocate (sizeof (SymbolicValueMemoryObject),
191
- alignof (SymbolicValueMemoryObject));
189
+ SymbolicValueAllocator &allocator ) {
190
+ auto *result = allocator. allocate (sizeof (SymbolicValueMemoryObject),
191
+ alignof (SymbolicValueMemoryObject));
192
192
new (result) SymbolicValueMemoryObject (type, value);
193
193
return (SymbolicValueMemoryObject *)result;
194
194
}
@@ -206,14 +206,14 @@ SymbolicValue SymbolicValue::getInteger(int64_t value, unsigned bitWidth) {
206
206
}
207
207
208
208
SymbolicValue SymbolicValue::getInteger (const APInt &value,
209
- ASTContext &astContext ) {
209
+ SymbolicValueAllocator &allocator ) {
210
210
// In the common case, we can form an inline representation.
211
211
unsigned numWords = value.getNumWords ();
212
212
if (numWords == 1 )
213
213
return getInteger (value.getRawData ()[0 ], value.getBitWidth ());
214
214
215
- // Copy the integers from the APInt into the bump pointer .
216
- auto *words = astContext. Allocate <uint64_t >(numWords). data ( );
215
+ // Copy the integers from the APInt into the allocator .
216
+ auto *words = allocator. allocate <uint64_t >(numWords);
217
217
std::uninitialized_copy (value.getRawData (), value.getRawData () + numWords,
218
218
words);
219
219
@@ -251,11 +251,11 @@ unsigned SymbolicValue::getIntegerValueBitWidth() const {
251
251
252
252
// Returns a SymbolicValue representing a UTF-8 encoded string.
253
253
SymbolicValue SymbolicValue::getString (StringRef string,
254
- ASTContext &astContext ) {
254
+ SymbolicValueAllocator &allocator ) {
255
255
// TODO: Could have an inline representation for strings if thre was demand,
256
256
// just store a char[8] as the storage.
257
257
258
- auto *resultPtr = astContext. Allocate <char >(string.size ()). data ( );
258
+ auto *resultPtr = allocator. allocate <char >(string.size ());
259
259
std::uninitialized_copy (string.begin (), string.end (), resultPtr);
260
260
261
261
SymbolicValue result;
@@ -280,10 +280,9 @@ StringRef SymbolicValue::getStringValue() const {
280
280
// / This returns a constant Symbolic value with the specified elements in it.
281
281
// / This assumes that the elements lifetime has been managed for this.
282
282
SymbolicValue SymbolicValue::getAggregate (ArrayRef<SymbolicValue> elements,
283
- ASTContext &astContext ) {
283
+ SymbolicValueAllocator &allocator ) {
284
284
// Copy the elements into the bump pointer.
285
- auto *resultElts =
286
- astContext.Allocate <SymbolicValue>(elements.size ()).data ();
285
+ auto *resultElts = allocator.allocate <SymbolicValue>(elements.size ());
287
286
std::uninitialized_copy (elements.begin (), elements.end (), resultElts);
288
287
289
288
SymbolicValue result;
@@ -320,10 +319,10 @@ struct alignas(SourceLoc) UnknownSymbolicValue final
320
319
321
320
static UnknownSymbolicValue *create (SILNode *node, UnknownReason reason,
322
321
ArrayRef<SourceLoc> elements,
323
- ASTContext &astContext ) {
322
+ SymbolicValueAllocator &allocator ) {
324
323
auto byteSize =
325
324
UnknownSymbolicValue::totalSizeToAlloc<SourceLoc>(elements.size ());
326
- auto *rawMem = astContext. Allocate (byteSize, alignof (UnknownSymbolicValue));
325
+ auto *rawMem = allocator. allocate (byteSize, alignof (UnknownSymbolicValue));
327
326
328
327
// Placement-new the value inside the memory we just allocated.
329
328
auto value = ::new (rawMem) UnknownSymbolicValue (
@@ -353,12 +352,12 @@ struct alignas(SourceLoc) UnknownSymbolicValue final
353
352
354
353
SymbolicValue SymbolicValue::getUnknown (SILNode *node, UnknownReason reason,
355
354
llvm::ArrayRef<SourceLoc> callStack,
356
- ASTContext &astContext ) {
355
+ SymbolicValueAllocator &allocator ) {
357
356
assert (node && " node must be present" );
358
357
SymbolicValue result;
359
358
result.representationKind = RK_Unknown;
360
359
result.value .unknown =
361
- UnknownSymbolicValue::create (node, reason, callStack, astContext );
360
+ UnknownSymbolicValue::create (node, reason, callStack, allocator );
362
361
return result;
363
362
}
364
363
@@ -402,10 +401,10 @@ struct EnumWithPayloadSymbolicValue final {
402
401
// / payload.
403
402
SymbolicValue
404
403
SymbolicValue::getEnumWithPayload (EnumElementDecl *decl, SymbolicValue payload,
405
- ASTContext &astContext ) {
404
+ SymbolicValueAllocator &allocator ) {
406
405
assert (decl && payload.isConstant ());
407
- auto rawMem = astContext. Allocate (sizeof (EnumWithPayloadSymbolicValue),
408
- alignof (EnumWithPayloadSymbolicValue));
406
+ auto rawMem = allocator. allocate (sizeof (EnumWithPayloadSymbolicValue),
407
+ alignof (EnumWithPayloadSymbolicValue));
409
408
auto enumVal = ::new (rawMem) EnumWithPayloadSymbolicValue (decl, payload);
410
409
411
410
SymbolicValue result;
@@ -446,10 +445,10 @@ struct DerivedAddressValue final
446
445
447
446
static DerivedAddressValue *create (SymbolicValueMemoryObject *memoryObject,
448
447
ArrayRef<unsigned > elements,
449
- ASTContext &astContext ) {
448
+ SymbolicValueAllocator &allocator ) {
450
449
auto byteSize =
451
450
DerivedAddressValue::totalSizeToAlloc<unsigned >(elements.size ());
452
- auto *rawMem = astContext. Allocate (byteSize, alignof (DerivedAddressValue));
451
+ auto *rawMem = allocator. allocate (byteSize, alignof (DerivedAddressValue));
453
452
454
453
// Placement initialize the object.
455
454
auto dav =
@@ -483,11 +482,11 @@ struct DerivedAddressValue final
483
482
// / indexed by a path.
484
483
SymbolicValue SymbolicValue::getAddress (SymbolicValueMemoryObject *memoryObject,
485
484
ArrayRef<unsigned > indices,
486
- ASTContext &astContext ) {
485
+ SymbolicValueAllocator &allocator ) {
487
486
if (indices.empty ())
488
487
return getAddress (memoryObject);
489
488
490
- auto dav = DerivedAddressValue::create (memoryObject, indices, astContext );
489
+ auto dav = DerivedAddressValue::create (memoryObject, indices, allocator );
491
490
SymbolicValue result;
492
491
result.representationKind = RK_DerivedAddress;
493
492
result.value .derivedAddress = dav;
@@ -694,7 +693,7 @@ SymbolicValueMemoryObject::getIndexedElement(ArrayRef<unsigned> accessPath) {
694
693
static SymbolicValue setIndexedElement (SymbolicValue aggregate,
695
694
ArrayRef<unsigned > accessPath,
696
695
SymbolicValue newElement, Type type,
697
- ASTContext &astCtx ) {
696
+ SymbolicValueAllocator &allocator ) {
698
697
// We're done if we've run out of access path.
699
698
if (accessPath.empty ())
700
699
return newElement;
@@ -715,7 +714,7 @@ static SymbolicValue setIndexedElement(SymbolicValue aggregate,
715
714
716
715
SmallVector<SymbolicValue, 4 > newElts (numMembers,
717
716
SymbolicValue::getUninitMemory ());
718
- aggregate = SymbolicValue::getAggregate (newElts, astCtx );
717
+ aggregate = SymbolicValue::getAggregate (newElts, allocator );
719
718
}
720
719
721
720
assert (aggregate.getKind () == SymbolicValue::Aggregate &&
@@ -738,12 +737,11 @@ static SymbolicValue setIndexedElement(SymbolicValue aggregate,
738
737
739
738
// Update the indexed element of the aggregate.
740
739
SmallVector<SymbolicValue, 4 > newElts (oldElts.begin (), oldElts.end ());
741
- newElts[elementNo] = setIndexedElement (newElts[elementNo],
742
- accessPath.drop_front (), newElement,
743
- eltType, astCtx);
744
-
745
- aggregate = SymbolicValue::getAggregate (newElts, astCtx);
740
+ newElts[elementNo] =
741
+ setIndexedElement (newElts[elementNo], accessPath.drop_front (), newElement,
742
+ eltType, allocator);
746
743
744
+ aggregate = SymbolicValue::getAggregate (newElts, allocator);
747
745
return aggregate;
748
746
}
749
747
@@ -755,6 +753,6 @@ static SymbolicValue setIndexedElement(SymbolicValue aggregate,
755
753
// / Precondition: The access path must be valid for this memory object's type.
756
754
void SymbolicValueMemoryObject::setIndexedElement (
757
755
ArrayRef<unsigned > accessPath, SymbolicValue newElement,
758
- ASTContext &astCtx ) {
759
- value = ::setIndexedElement (value, accessPath, newElement, type, astCtx );
756
+ SymbolicValueAllocator &allocator ) {
757
+ value = ::setIndexedElement (value, accessPath, newElement, type, allocator );
760
758
}
0 commit comments