Skip to content

Commit 844ae38

Browse files
authored
Remove some Swift STLExtras that LLVM now provides (swiftlang#26443)
No functionality change.
1 parent 4851942 commit 844ae38

20 files changed

+97
-109
lines changed

include/swift/Basic/STLExtras.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -771,22 +771,6 @@ inline bool is_sorted_and_uniqued(const Container &C) {
771771
return is_sorted_and_uniqued(C.begin(), C.end());
772772
}
773773

774-
template <typename Container, typename OutputIterator>
775-
inline void copy(const Container &C, OutputIterator iter) {
776-
std::copy(C.begin(), C.end(), iter);
777-
}
778-
779-
template <typename Container, typename OutputIterator, typename Predicate>
780-
inline void copy_if(const Container &C, OutputIterator result, Predicate pred) {
781-
std::copy_if(C.begin(), C.end(), result, pred);
782-
}
783-
784-
template <typename Container, typename OutputIterator, typename UnaryOperation>
785-
inline OutputIterator transform(const Container &C, OutputIterator result,
786-
UnaryOperation op) {
787-
return std::transform(C.begin(), C.end(), result, op);
788-
}
789-
790774
template <typename Container, typename T, typename BinaryOperation>
791775
inline T accumulate(const Container &C, T init, BinaryOperation op) {
792776
return std::accumulate(C.begin(), C.end(), init, op);

include/swift/SIL/SILCloner.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ class SILFunctionCloner : public SILClonerWithScopes<SILFunctionCloner> {
509509
// resolve the type mismatch between SILArgument* and SILValue.
510510
SmallVector<SILValue, 8> entryArgs;
511511
entryArgs.reserve(newF->getArguments().size());
512-
transform(newF->getArguments(), std::back_inserter(entryArgs),
513-
[](SILArgument *arg) -> SILValue { return arg; });
512+
llvm::transform(newF->getArguments(), std::back_inserter(entryArgs),
513+
[](SILArgument *arg) -> SILValue { return arg; });
514514

515515
SuperTy::cloneFunctionBody(origF, newEntryBB, entryArgs);
516516
}

lib/SIL/LinearLifetimeChecker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ void State::checkDataflowEndState(DeadEndBlocks &deBlocks) {
399399
// If we are asked to store any leaking blocks, put them in the leaking
400400
// blocks array.
401401
if (leakingBlocks) {
402-
copy(successorBlocksThatMustBeVisited,
403-
std::back_inserter(*leakingBlocks));
402+
llvm::copy(successorBlocksThatMustBeVisited,
403+
std::back_inserter(*leakingBlocks));
404404
}
405405

406406
// If we are supposed to error on leaks, do so now.

lib/SIL/OwnershipUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ bool swift::getUnderlyingBorrowIntroducers(SILValue inputValue,
112112
if (isGuaranteedForwardingValue(v)) {
113113
auto *i = v->getDefiningInstruction();
114114
assert(i);
115-
transform(i->getAllOperands(), std::back_inserter(worklist),
116-
[](const Operand &op) -> SILValue { return op.get(); });
115+
llvm::transform(i->getAllOperands(), std::back_inserter(worklist),
116+
[](const Operand &op) -> SILValue { return op.get(); });
117117
continue;
118118
}
119119

lib/SIL/SILBuilder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -519,17 +519,17 @@ void SILBuilder::emitDestructureValueOperation(
519519
// Otherwise, we want to destructure add the destructure and return.
520520
if (getFunction().hasOwnership()) {
521521
auto *i = emitDestructureValueOperation(loc, v);
522-
copy(i->getResults(), std::back_inserter(results));
522+
llvm::copy(i->getResults(), std::back_inserter(results));
523523
return;
524524
}
525525

526526
// In non qualified ownership SIL, drop back to using projection code.
527527
SmallVector<Projection, 16> projections;
528528
Projection::getFirstLevelProjections(v->getType(), getModule(), projections);
529-
transform(projections, std::back_inserter(results),
530-
[&](const Projection &p) -> SILValue {
531-
return p.createObjectProjection(*this, loc, v).get();
532-
});
529+
llvm::transform(projections, std::back_inserter(results),
530+
[&](const Projection &p) -> SILValue {
531+
return p.createObjectProjection(*this, loc, v).get();
532+
});
533533
}
534534

535535
// TODO: Can we put this on type lowering? It would take a little bit of work
@@ -547,10 +547,10 @@ void SILBuilder::emitDestructureAddressOperation(
547547

548548
SmallVector<Projection, 16> projections;
549549
Projection::getFirstLevelProjections(v->getType(), getModule(), projections);
550-
transform(projections, std::back_inserter(results),
551-
[&](const Projection &p) -> SILValue {
552-
return p.createAddressProjection(*this, loc, v).get();
553-
});
550+
llvm::transform(projections, std::back_inserter(results),
551+
[&](const Projection &p) -> SILValue {
552+
return p.createAddressProjection(*this, loc, v).get();
553+
});
554554
}
555555

556556
void SILBuilder::emitDestructureValueOperation(

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ class SILValueOwnershipChecker {
134134
return false;
135135

136136
SmallVector<BranchPropagatedUser, 32> allRegularUsers;
137-
copy(regularUsers, std::back_inserter(allRegularUsers));
138-
copy(implicitRegularUsers, std::back_inserter(allRegularUsers));
137+
llvm::copy(regularUsers, std::back_inserter(allRegularUsers));
138+
llvm::copy(implicitRegularUsers, std::back_inserter(allRegularUsers));
139139
auto linearLifetimeResult =
140140
valueHasLinearLifetime(value, lifetimeEndingUsers, allRegularUsers,
141141
visitedBlocks, deadEndBlocks, errorBehavior);
@@ -331,8 +331,8 @@ bool SILValueOwnershipChecker::gatherUsers(
331331
for (unsigned i : indices(nonLifetimeEndingUsers)) {
332332
if (auto *bbi = dyn_cast<BeginBorrowInst>(
333333
nonLifetimeEndingUsers[i].getInst())) {
334-
copy(bbi->getEndBorrows(),
335-
std::back_inserter(implicitRegularUsers));
334+
llvm::copy(bbi->getEndBorrows(),
335+
std::back_inserter(implicitRegularUsers));
336336
}
337337
}
338338
}
@@ -361,7 +361,7 @@ bool SILValueOwnershipChecker::gatherUsers(
361361
assert(result.getOwnershipKind() == ValueOwnershipKind::Guaranteed &&
362362
"Our value is guaranteed and this is a forwarding instruction. "
363363
"Should have guaranteed ownership as well.");
364-
copy(result->getUses(), std::back_inserter(users));
364+
llvm::copy(result->getUses(), std::back_inserter(users));
365365
}
366366

367367
continue;

lib/SIL/SILPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
653653
assert(!isa<SingleValueInstruction>(inst) && "SingleValueInstruction was "
654654
"handled by the previous "
655655
"value base check.");
656-
copy(inst->getResults(), std::back_inserter(values));
656+
llvm::copy(inst->getResults(), std::back_inserter(values));
657657
}
658658

659659
// If the set of values is empty, we need to print the ID of

lib/SIL/SILVerifier.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ struct ImmutableAddressUseVerifier {
491491
}
492492

493493
bool isMutatingOrConsuming(SILValue address) {
494-
copy(address->getUses(), std::back_inserter(worklist));
494+
llvm::copy(address->getUses(), std::back_inserter(worklist));
495495
while (!worklist.empty()) {
496496
auto *use = worklist.pop_back_val();
497497
auto *inst = use->getUser();
@@ -584,7 +584,7 @@ struct ImmutableAddressUseVerifier {
584584
case SILInstructionKind::IndexRawPointerInst:
585585
// Add these to our worklist.
586586
for (auto result : inst->getResults()) {
587-
copy(result->getUses(), std::back_inserter(worklist));
587+
llvm::copy(result->getUses(), std::back_inserter(worklist));
588588
}
589589
break;
590590
default:

lib/SILGen/SILGenApply.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ static void convertOwnershipConventionsGivenParamInfos(
240240
llvm::SmallVectorImpl<ManagedValue> &outVar) {
241241
assert(params.size() == values.size() &&
242242
"Different number of params from arguments");
243-
transform(indices(params), std::back_inserter(outVar),
244-
[&](unsigned i) -> ManagedValue {
245-
return convertOwnershipConventionGivenParamInfo(
246-
SGF, params[i], values[i], loc, isForCoroutine);
247-
});
243+
llvm::transform(indices(params), std::back_inserter(outVar),
244+
[&](unsigned i) -> ManagedValue {
245+
return convertOwnershipConventionGivenParamInfo(
246+
SGF, params[i], values[i], loc, isForCoroutine);
247+
});
248248
}
249249

250250
//===----------------------------------------------------------------------===//

lib/SILGen/SILGenBuilder.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ ManagedValue SILGenBuilder::createPartialApply(SILLocation loc, SILValue fn,
5252
ArrayRef<ManagedValue> args,
5353
ParameterConvention calleeConvention) {
5454
llvm::SmallVector<SILValue, 8> values;
55-
transform(args, std::back_inserter(values), [&](ManagedValue mv) -> SILValue {
55+
llvm::transform(args, std::back_inserter(values),
56+
[&](ManagedValue mv) -> SILValue {
5657
return mv.forward(getSILGenFunction());
5758
});
5859
SILValue result =
@@ -209,10 +210,9 @@ ManagedValue SILGenBuilder::createAllocRef(
209210
llvm::SmallVector<SILType, 8> elementTypes(inputElementTypes.begin(),
210211
inputElementTypes.end());
211212
llvm::SmallVector<SILValue, 8> elementCountOperands;
212-
std::transform(std::begin(inputElementCountOperands),
213-
std::end(inputElementCountOperands),
214-
std::back_inserter(elementCountOperands),
215-
[](ManagedValue mv) -> SILValue { return mv.getValue(); });
213+
llvm::transform(inputElementCountOperands,
214+
std::back_inserter(elementCountOperands),
215+
[](ManagedValue mv) -> SILValue { return mv.getValue(); });
216216

217217
AllocRefInst *i = createAllocRef(loc, refType, objc, canAllocOnStack,
218218
elementTypes, elementCountOperands);
@@ -226,10 +226,9 @@ ManagedValue SILGenBuilder::createAllocRefDynamic(
226226
llvm::SmallVector<SILType, 8> elementTypes(inputElementTypes.begin(),
227227
inputElementTypes.end());
228228
llvm::SmallVector<SILValue, 8> elementCountOperands;
229-
std::transform(std::begin(inputElementCountOperands),
230-
std::end(inputElementCountOperands),
231-
std::back_inserter(elementCountOperands),
232-
[](ManagedValue mv) -> SILValue { return mv.getValue(); });
229+
llvm::transform(inputElementCountOperands,
230+
std::back_inserter(elementCountOperands),
231+
[](ManagedValue mv) -> SILValue { return mv.getValue(); });
233232

234233
AllocRefDynamicInst *i =
235234
createAllocRefDynamic(loc, operand.getValue(), refType, objc,
@@ -743,8 +742,8 @@ BranchInst *SILGenBuilder::createBranch(SILLocation loc,
743742
SILBasicBlock *targetBlock,
744743
ArrayRef<ManagedValue> args) {
745744
llvm::SmallVector<SILValue, 8> newArgs;
746-
transform(args, std::back_inserter(newArgs),
747-
[&](ManagedValue mv) -> SILValue { return mv.forward(SGF); });
745+
llvm::transform(args, std::back_inserter(newArgs),
746+
[&](ManagedValue mv) -> SILValue { return mv.forward(SGF); });
748747
return createBranch(loc, targetBlock, newArgs);
749748
}
750749

@@ -771,10 +770,10 @@ ManagedValue SILGenBuilder::createTuple(SILLocation loc, SILType type,
771770
// If we have all trivial values, then just create the tuple and return. No
772771
// cleanups need to be cloned.
773772
if (iter == elements.end()) {
774-
transform(elements, std::back_inserter(forwardedValues),
775-
[&](ManagedValue mv) -> SILValue {
776-
return mv.forward(getSILGenFunction());
777-
});
773+
llvm::transform(elements, std::back_inserter(forwardedValues),
774+
[&](ManagedValue mv) -> SILValue {
775+
return mv.forward(getSILGenFunction());
776+
});
778777
SILValue result = createTuple(loc, type, forwardedValues);
779778
return ManagedValue::forUnmanaged(result);
780779
}
@@ -783,10 +782,10 @@ ManagedValue SILGenBuilder::createTuple(SILLocation loc, SILType type,
783782
// instructions that forward ownership requiring that all input values have
784783
// the same ownership if they are non-trivial.
785784
CleanupCloner cloner(*this, *iter);
786-
transform(elements, std::back_inserter(forwardedValues),
787-
[&](ManagedValue mv) -> SILValue {
788-
return mv.forward(getSILGenFunction());
789-
});
785+
llvm::transform(elements, std::back_inserter(forwardedValues),
786+
[&](ManagedValue mv) -> SILValue {
787+
return mv.forward(getSILGenFunction());
788+
});
790789
return cloner.clone(createTuple(loc, type, forwardedValues));
791790
}
792791

0 commit comments

Comments
 (0)