mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #30341 from gottesmm/pr-91997a0048cde708ab0a33c5e524a8c8f9422956
Recommit #30289 with ASAN fix.
This commit is contained in:
@@ -91,11 +91,17 @@ public:
|
||||
frozen = true;
|
||||
}
|
||||
|
||||
/// Reset the frozen multimap in an unfrozen state with its storage cleared.
|
||||
void reset() {
|
||||
storage.clear();
|
||||
frozen = false;
|
||||
}
|
||||
|
||||
unsigned size() const { return storage.size(); }
|
||||
bool empty() const { return storage.empty(); }
|
||||
|
||||
struct iterator : std::iterator<std::forward_iterator_tag,
|
||||
std::pair<Key, ArrayRef<Value>>> {
|
||||
std::pair<Key, PairToSecondEltRange>> {
|
||||
using base_iterator = typename decltype(storage)::iterator;
|
||||
|
||||
FrozenMultiMap ↦
|
||||
@@ -159,9 +165,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
using RangeType = llvm::iterator_range<iterator>;
|
||||
|
||||
/// Return a range of (key, ArrayRef<Value>) pairs. The keys are guaranteed to
|
||||
/// be in key sorted order and the ArrayRef<Value> are in insertion order.
|
||||
llvm::iterator_range<iterator> getRange() const {
|
||||
RangeType getRange() const {
|
||||
assert(isFrozen() &&
|
||||
"Can not create range until data structure is frozen?!");
|
||||
auto *self = const_cast<FrozenMultiMap *>(this);
|
||||
|
||||
@@ -598,6 +598,28 @@ struct OwnedValueIntroducer {
|
||||
return OwnedValueIntroducer(value, *kind);
|
||||
}
|
||||
|
||||
/// Returns true if this owned introducer is able to be converted into a
|
||||
/// guaranteed form if none of its uses are consuming uses (looking through
|
||||
/// forwarding uses).
|
||||
bool isConvertableToGuaranteed() const {
|
||||
switch (kind) {
|
||||
case OwnedValueIntroducerKind::Copy:
|
||||
case OwnedValueIntroducerKind::LoadCopy:
|
||||
return true;
|
||||
case OwnedValueIntroducerKind::Apply:
|
||||
case OwnedValueIntroducerKind::BeginApply:
|
||||
case OwnedValueIntroducerKind::TryApply:
|
||||
case OwnedValueIntroducerKind::LoadTake:
|
||||
case OwnedValueIntroducerKind::Phi:
|
||||
case OwnedValueIntroducerKind::FunctionArgument:
|
||||
case OwnedValueIntroducerKind::PartialApplyInit:
|
||||
case OwnedValueIntroducerKind::AllocBoxInit:
|
||||
case OwnedValueIntroducerKind::AllocRefInit:
|
||||
return false;
|
||||
}
|
||||
llvm_unreachable("Covered switch isn't covered?!");
|
||||
}
|
||||
|
||||
bool operator==(const OwnedValueIntroducer &other) const {
|
||||
return value == other.value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user