Skip to content

Commit f292ec9

Browse files
committed
Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their constructor equivalent.
1 parent b4a5ad2 commit f292ec9

File tree

122 files changed

+305
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+305
-360
lines changed

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,14 +1385,6 @@ endif()
13851385
add_subdirectory(include)
13861386

13871387
if(SWIFT_INCLUDE_TOOLS)
1388-
# TODO Remove this once release/5.9 is done and we can finish migrating Swift
1389-
# off of `llvm::None`/`llvm::Optional`, and `llvm::makeArrayRef`.
1390-
# This is to silence the avalanche of deprecation warnings from LLVM headers
1391-
# until we can actually do something about them. This is nasty, but it's
1392-
# better than losing context due to the sheer number in-actionable deprecation
1393-
# warnings or the massive number of merge-conflicts we would get otherwise.
1394-
add_definitions(-DSWIFT_TARGET)
1395-
13961388
add_subdirectory(lib)
13971389

13981390
add_subdirectory(SwiftCompilerSources)

include/swift/ABI/GenericContext.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,19 @@ class RuntimeGenericSignature {
318318
PackShapeHeader(packShapeHeader), PackShapeDescriptors(packShapeDescriptors) {}
319319

320320
llvm::ArrayRef<GenericParamDescriptor> getParams() const {
321-
return llvm::makeArrayRef(Params, Header.NumParams);
321+
return llvm::ArrayRef(Params, Header.NumParams);
322322
}
323323

324324
llvm::ArrayRef<TargetGenericRequirementDescriptor<Runtime>> getRequirements() const {
325-
return llvm::makeArrayRef(Requirements, Header.NumRequirements);
325+
return llvm::ArrayRef(Requirements, Header.NumRequirements);
326326
}
327327

328328
const GenericPackShapeHeader &getGenericPackShapeHeader() const {
329329
return PackShapeHeader;
330330
}
331331

332332
llvm::ArrayRef<GenericPackShapeDescriptor> getGenericPackShapeDescriptors() const {
333-
return llvm::makeArrayRef(PackShapeDescriptors, PackShapeHeader.NumPacks);
333+
return llvm::ArrayRef(PackShapeDescriptors, PackShapeHeader.NumPacks);
334334
}
335335

336336
size_t getArgumentLayoutSizeInWords() const {
@@ -379,20 +379,20 @@ class TargetGenericEnvironment
379379
public:
380380
/// Retrieve the cumulative generic parameter counts at each level of genericity.
381381
llvm::ArrayRef<uint16_t> getGenericParameterCounts() const {
382-
return llvm::makeArrayRef(this->template getTrailingObjects<uint16_t>(),
383-
Flags.getNumGenericParameterLevels());
382+
return llvm::ArrayRef(this->template getTrailingObjects<uint16_t>(),
383+
Flags.getNumGenericParameterLevels());
384384
}
385385

386386
/// Retrieve the generic parameters descriptors.
387387
llvm::ArrayRef<GenericParamDescriptor> getGenericParameters() const {
388-
return llvm::makeArrayRef(
388+
return llvm::ArrayRef(
389389
this->template getTrailingObjects<GenericParamDescriptor>(),
390390
getGenericParameterCounts().back());
391391
}
392392

393393
/// Retrieve the generic requirements.
394394
llvm::ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
395-
return llvm::makeArrayRef(
395+
return llvm::ArrayRef(
396396
this->template getTrailingObjects<GenericRequirementDescriptor>(),
397397
Flags.getNumGenericRequirements());
398398
}

include/swift/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class ASTContext final {
523523
StringRef AllocateCopy(StringRef Str,
524524
AllocationArena arena = AllocationArena::Permanent) const {
525525
ArrayRef<char> Result =
526-
AllocateCopy(llvm::makeArrayRef(Str.data(), Str.size()), arena);
526+
AllocateCopy(llvm::ArrayRef(Str.data(), Str.size()), arena);
527527
return StringRef(Result.data(), Result.size());
528528
}
529529

include/swift/AST/CaptureInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ class CaptureInfo {
145145
: DynamicSelf(dynamicSelf), OpaqueValue(opaqueValue), Count(count) { }
146146

147147
ArrayRef<CapturedValue> getCaptures() const {
148-
return llvm::makeArrayRef(this->getTrailingObjects<CapturedValue>(),
149-
Count);
148+
return llvm::ArrayRef(this->getTrailingObjects<CapturedValue>(), Count);
150149
}
151150

152151
DynamicSelfType *getDynamicSelfType() const {

include/swift/AST/Comment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DocComment {
4646
}
4747

4848
ArrayRef<StringRef> getTags() const {
49-
return llvm::makeArrayRef(Parts.Tags.begin(), Parts.Tags.end());
49+
return llvm::ArrayRef(Parts.Tags.begin(), Parts.Tags.end());
5050
}
5151

5252
std::optional<const swift::markup::Paragraph *> getBrief() const {

include/swift/AST/NameLookup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ class LookupResult {
163163
bool empty() const { return innerResults().empty(); }
164164

165165
ArrayRef<LookupResultEntry> innerResults() const {
166-
return llvm::makeArrayRef(Results).take_front(IndexOfFirstOuterResult);
166+
return llvm::ArrayRef(Results).take_front(IndexOfFirstOuterResult);
167167
}
168168

169169
ArrayRef<LookupResultEntry> outerResults() const {
170-
return llvm::makeArrayRef(Results).drop_front(IndexOfFirstOuterResult);
170+
return llvm::ArrayRef(Results).drop_front(IndexOfFirstOuterResult);
171171
}
172172

173173
/// \returns An array of both the inner and outer results.
174174
ArrayRef<LookupResultEntry> allResults() const {
175-
return llvm::makeArrayRef(Results);
175+
return llvm::ArrayRef(Results);
176176
}
177177

178178
const LookupResultEntry& operator[](unsigned index) const {

include/swift/AST/SILLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class SILLayout final : public llvm::FoldingSetNode,
142142

143143
/// Get the fields inside the layout.
144144
ArrayRef<SILField> getFields() const {
145-
return llvm::makeArrayRef(getTrailingObjects<SILField>(), NumFields);
145+
return llvm::ArrayRef(getTrailingObjects<SILField>(), NumFields);
146146
}
147147

148148
/// Produce a profile of this layout, for use in a folding set.

include/swift/AST/SourceFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class SourceFile final : public FileUnit {
302302
std::optional<ArrayRef<ASTNode>> getCachedTopLevelItems() const {
303303
if (!Items)
304304
return std::nullopt;
305-
return llvm::makeArrayRef(*Items);
305+
return llvm::ArrayRef(*Items);
306306
}
307307

308308
/// Retrieve the parsing options for the file.

include/swift/AST/Stmt.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,7 @@ class alignas(8) PoundAvailableInfo final :
514514
bool isUnavailability);
515515

516516
ArrayRef<AvailabilitySpec *> getQueries() const {
517-
return llvm::makeArrayRef(getTrailingObjects<AvailabilitySpec *>(),
518-
NumQueries);
517+
return llvm::ArrayRef(getTrailingObjects<AvailabilitySpec *>(), NumQueries);
519518
}
520519

521520
SourceLoc getLParenLoc() const { return LParenLoc; }

include/swift/AST/TypeRepr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ class AttributedTypeRepr final
281281
TypeRepr *ty);
282282

283283
ArrayRef<TypeOrCustomAttr> getAttrs() const {
284-
return llvm::makeArrayRef(getTrailingObjects<TypeOrCustomAttr>(),
285-
Bits.AttributedTypeRepr.NumAttributes);
284+
return llvm::ArrayRef(getTrailingObjects<TypeOrCustomAttr>(),
285+
Bits.AttributedTypeRepr.NumAttributes);
286286
}
287287

288288
TypeAttribute *get(TypeAttrKind kind) const;
@@ -871,12 +871,12 @@ class PackTypeRepr final
871871
SourceRange getBracesRange() const { return BraceLocs; }
872872

873873
MutableArrayRef<TypeRepr*> getMutableElements() {
874-
return llvm::makeMutableArrayRef(getTrailingObjects<TypeRepr*>(),
875-
Bits.PackTypeRepr.NumElements);
874+
return llvm::MutableArrayRef(getTrailingObjects<TypeRepr *>(),
875+
Bits.PackTypeRepr.NumElements);
876876
}
877877
ArrayRef<TypeRepr*> getElements() const {
878-
return llvm::makeArrayRef(getTrailingObjects<TypeRepr*>(),
879-
Bits.PackTypeRepr.NumElements);
878+
return llvm::ArrayRef(getTrailingObjects<TypeRepr *>(),
879+
Bits.PackTypeRepr.NumElements);
880880
}
881881

882882
static bool classof(const TypeRepr *T) {

include/swift/Basic/MultiMapCache.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ class MultiMapCache {
6464
// If we already have a cached value, just return the cached value.
6565
if (!iter.second) {
6666

67-
return swift::transform(iter.first->second,
67+
return swift::transform(
68+
iter.first->second,
6869
[&](std::tuple<unsigned, unsigned> startLengthRange) {
69-
return llvm::makeArrayRef(data).slice(
70+
return llvm::ArrayRef(data).slice(
7071
std::get<ArrayStartOffset>(startLengthRange),
7172
std::get<ArrayLengthOffset>(startLengthRange));
7273
});
@@ -88,7 +89,7 @@ class MultiMapCache {
8889
// update the map with the start, length, and return the resulting ArrayRef.
8990
unsigned length = data.size() - initialOffset;
9091
iter.first->second = std::make_tuple(initialOffset, length);
91-
auto result = llvm::makeArrayRef(data).slice(initialOffset, length);
92+
auto result = llvm::ArrayRef(data).slice(initialOffset, length);
9293
return result;
9394
}
9495
};

include/swift/Driver/Compilation.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class Compilation {
268268
}
269269

270270
UnwrappedArrayView<const Action> getActions() const {
271-
return llvm::makeArrayRef(Actions);
271+
return llvm::ArrayRef(Actions);
272272
}
273273

274274
template <typename SpecificAction, typename... Args>
@@ -278,9 +278,7 @@ class Compilation {
278278
return newAction;
279279
}
280280

281-
UnwrappedArrayView<const Job> getJobs() const {
282-
return llvm::makeArrayRef(Jobs);
283-
}
281+
UnwrappedArrayView<const Job> getJobs() const { return llvm::ArrayRef(Jobs); }
284282

285283
/// To send job list to places that don't truck in fancy array views.
286284
std::vector<const Job *> getJobsSimply() const {

include/swift/IDE/CodeCompletion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ArrayRef<T> copyArray(llvm::BumpPtrAllocator &Allocator,
5656
ArrayRef<T> Arr) {
5757
T *Buffer = Allocator.Allocate<T>(Arr.size());
5858
std::copy(Arr.begin(), Arr.end(), Buffer);
59-
return llvm::makeArrayRef(Buffer, Arr.size());
59+
return llvm::ArrayRef(Buffer, Arr.size());
6060
}
6161

6262
bool isDynamicLookup(Type T);

include/swift/IDE/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class DeclNameViewer {
428428
DeclNameViewer() : DeclNameViewer(StringRef()) {}
429429
operator bool() const { return !BaseName.empty(); }
430430
StringRef base() const { return BaseName; }
431-
llvm::ArrayRef<StringRef> args() const { return llvm::makeArrayRef(Labels); }
431+
llvm::ArrayRef<StringRef> args() const { return llvm::ArrayRef(Labels); }
432432
unsigned argSize() const { return Labels.size(); }
433433
unsigned partsCount() const { return 1 + Labels.size(); }
434434
unsigned commonPartsCount(DeclNameViewer &Other) const;

include/swift/Markup/Markup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class MarkupContext final {
5353

5454
StringRef allocateCopy(StringRef Str) {
5555
ArrayRef<char> Result =
56-
allocateCopy(llvm::makeArrayRef(Str.data(), Str.size()));
56+
allocateCopy(llvm::ArrayRef(Str.data(), Str.size()));
5757
return StringRef(Result.data(), Result.size());
5858
}
5959

include/swift/Runtime/Numeric.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class IntegerLiteral {
4545
/// the least-significant chunk. The value is sign-extended to fill the
4646
/// final chunk.
4747
llvm::ArrayRef<UnsignedChunk> getData() const {
48-
return llvm::makeArrayRef(Data, (Flags.getBitWidth() + BitsPerChunk - 1) /
49-
BitsPerChunk);
48+
return llvm::ArrayRef(Data, (Flags.getBitWidth() + BitsPerChunk - 1) /
49+
BitsPerChunk);
5050
}
5151

5252
/// The flags for this value.

include/swift/SIL/Projection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,13 @@ class ProjectionTreeNode {
770770
bool isLeaf() const { return ChildProjections.empty(); }
771771

772772
ArrayRef<unsigned> getChildProjections() const {
773-
return llvm::makeArrayRef(ChildProjections);
773+
return llvm::ArrayRef(ChildProjections);
774774
}
775775

776776
std::optional<Projection> &getProjection() { return Proj; }
777777

778778
const ArrayRef<Operand *> getNonProjUsers() const {
779-
return llvm::makeArrayRef(NonProjUsers);
779+
return llvm::ArrayRef(NonProjUsers);
780780
}
781781

782782
SILType getType() const { return NodeType; }
@@ -884,7 +884,7 @@ class ProjectionTree {
884884
SILModule &getModule() const { return *Mod; }
885885

886886
llvm::ArrayRef<ProjectionTreeNode *> getProjectionTreeNodes() {
887-
return llvm::makeArrayRef(ProjectionTreeNodes);
887+
return llvm::ArrayRef(ProjectionTreeNodes);
888888
}
889889

890890
/// Iterate over all values in the tree. The function should return false if

include/swift/Sema/ConstraintLocator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
216216
/// subcomponent.
217217
ArrayRef<PathElement> getPath() const {
218218
// FIXME: Alignment.
219-
return llvm::makeArrayRef(reinterpret_cast<const PathElement *>(this + 1),
220-
numPathElements);
219+
return llvm::ArrayRef(reinterpret_cast<const PathElement *>(this + 1),
220+
numPathElements);
221221
}
222222

223223
unsigned getSummaryFlags() const { return summaryFlags; }

include/swift/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,7 @@ class ConstraintSystem {
34723472
/// path element.
34733473
ConstraintLocator *
34743474
getConstraintLocator(ASTNode anchor, ConstraintLocator::PathElement pathElt) {
3475-
return getConstraintLocator(anchor, llvm::makeArrayRef(pathElt),
3475+
return getConstraintLocator(anchor, llvm::ArrayRef(pathElt),
34763476
pathElt.getNewSummaryFlags());
34773477
}
34783478

include/swift/Sema/SolutionResult.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
namespace swift {
2424

2525
using llvm::ArrayRef;
26-
using llvm::makeArrayRef;
2726

2827
namespace constraints {
2928

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ ArrayRef<NodeAnnotation> SDKNode::
328328
getAnnotations(std::vector<NodeAnnotation> &Scratch) const {
329329
for (auto Ann : Annotations)
330330
Scratch.push_back(Ann);
331-
return llvm::makeArrayRef(Scratch);
331+
return llvm::ArrayRef(Scratch);
332332
}
333333

334334
bool SDKNode::isAnnotatedAs(NodeAnnotation Anno) const {
@@ -380,7 +380,7 @@ KnownTypeKind SDKNodeType::getTypeKind() const {
380380
}
381381

382382
ArrayRef<TypeAttrKind> SDKNodeType::getTypeAttributes() const {
383-
return llvm::makeArrayRef(TypeAttributes.data(), TypeAttributes.size());
383+
return llvm::ArrayRef(TypeAttributes.data(), TypeAttributes.size());
384384
}
385385

386386
void SDKNodeType::addTypeAttribute(TypeAttrKind AttrKind) {
@@ -508,7 +508,7 @@ bool SDKNodeDecl::hasDeclAttribute(DeclAttrKind DAKind) const {
508508
}
509509

510510
ArrayRef<DeclAttrKind> SDKNodeDecl::getDeclAttributes() const {
511-
return llvm::makeArrayRef(DeclAttributes.data(), DeclAttributes.size());
511+
return llvm::ArrayRef(DeclAttributes.data(), DeclAttributes.size());
512512
}
513513

514514
bool SDKNodeDecl::hasAttributeChange(const SDKNodeDecl &Another) const {

lib/AST/ASTBridging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,7 @@ BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createParsed(
24512451
if (auto *inheritedType = bridgedInheritedType.unbridged()) {
24522452
auto entry = InheritedEntry(inheritedType);
24532453
ASTContext &context = cContext.unbridged();
2454-
decl->setInherited(context.AllocateCopy(llvm::makeArrayRef(entry)));
2454+
decl->setInherited(context.AllocateCopy(llvm::ArrayRef(entry)));
24552455
}
24562456

24572457
return decl;

lib/AST/DocComment.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ swift::extractCommentParts(swift::markup::MarkupContext &MC,
343343
}
344344

345345
// Copy BodyNodes and ParamFields into the MarkupContext.
346-
Parts.BodyNodes = MC.allocateCopy(llvm::makeArrayRef(BodyNodes));
347-
Parts.ParamFields = MC.allocateCopy(llvm::makeArrayRef(ParamFields));
346+
Parts.BodyNodes = MC.allocateCopy(llvm::ArrayRef(BodyNodes));
347+
Parts.ParamFields = MC.allocateCopy(llvm::ArrayRef(ParamFields));
348348

349349
for (auto Param : Parts.ParamFields) {
350350
auto ParamParts = extractCommentParts(MC, Param);
@@ -378,7 +378,7 @@ void DocComment::addInheritanceNote(swift::markup::MarkupContext &MC,
378378
SmallVector<const markup::MarkupASTNode *, 8> BodyNodes{
379379
Parts.BodyNodes.begin(), Parts.BodyNodes.end()};
380380
BodyNodes.push_back(note);
381-
Parts.BodyNodes = MC.allocateCopy(llvm::makeArrayRef(BodyNodes));
381+
Parts.BodyNodes = MC.allocateCopy(llvm::ArrayRef(BodyNodes));
382382
}
383383

384384
DocComment *swift::getSingleDocComment(swift::markup::MarkupContext &MC,

lib/AST/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,7 +2824,7 @@ SourceFile::getIfConfigsWithin(SourceRange outer) const {
28242824
}
28252825

28262826
// First let's find the first #if that is after the outer start loc.
2827-
auto ranges = llvm::makeArrayRef(IfConfigRanges.Ranges);
2827+
auto ranges = llvm::ArrayRef(IfConfigRanges.Ranges);
28282828
auto lower = llvm::lower_bound(
28292829
ranges, outer.Start, [&](IfConfigRangeInfo range, SourceLoc loc) {
28302830
return SM.isBeforeInBuffer(range.getStartLoc(), loc);
@@ -2838,7 +2838,7 @@ SourceFile::getIfConfigsWithin(SourceRange outer) const {
28382838
ranges, outer.End, [&](SourceLoc loc, IfConfigRangeInfo range) {
28392839
return SM.isBeforeInBuffer(loc, range.getStartLoc());
28402840
});
2841-
return llvm::makeArrayRef(lower, upper - lower);
2841+
return llvm::ArrayRef(lower, upper - lower);
28422842
}
28432843

28442844
void ModuleDecl::setPackageName(Identifier name) {

lib/AST/NameLookupRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ ArrayRef<FileUnit *> OperatorLookupDescriptor::getFiles() const {
322322
return module->getFiles();
323323

324324
// Return an ArrayRef pointing to the FileUnit in the union.
325-
return llvm::makeArrayRef(*fileOrModule.getAddrOfPtr1());
325+
return llvm::ArrayRef(*fileOrModule.getAddrOfPtr1());
326326
}
327327

328328
void swift::simple_display(llvm::raw_ostream &out,

lib/AST/RawComment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ RawComment RawCommentRequest::evaluate(Evaluator &eval, const Decl *D) const {
158158
}
159159

160160
if (!SRCs.empty())
161-
return RawComment(ctx.AllocateCopy(llvm::makeArrayRef(SRCs)));
161+
return RawComment(ctx.AllocateCopy(llvm::ArrayRef(SRCs)));
162162
}
163163

164164
// Otherwise check to see if we have a comment available in the swiftdoc.

0 commit comments

Comments
 (0)