Skip to content

Use the new template deduction guides rather than makeArrayRef #71863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1385,14 +1385,6 @@ endif()
add_subdirectory(include)

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

add_subdirectory(lib)

add_subdirectory(SwiftCompilerSources)
Expand Down
14 changes: 7 additions & 7 deletions include/swift/ABI/GenericContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,19 @@ class RuntimeGenericSignature {
PackShapeHeader(packShapeHeader), PackShapeDescriptors(packShapeDescriptors) {}

llvm::ArrayRef<GenericParamDescriptor> getParams() const {
return llvm::makeArrayRef(Params, Header.NumParams);
return llvm::ArrayRef(Params, Header.NumParams);
}

llvm::ArrayRef<TargetGenericRequirementDescriptor<Runtime>> getRequirements() const {
return llvm::makeArrayRef(Requirements, Header.NumRequirements);
return llvm::ArrayRef(Requirements, Header.NumRequirements);
}

const GenericPackShapeHeader &getGenericPackShapeHeader() const {
return PackShapeHeader;
}

llvm::ArrayRef<GenericPackShapeDescriptor> getGenericPackShapeDescriptors() const {
return llvm::makeArrayRef(PackShapeDescriptors, PackShapeHeader.NumPacks);
return llvm::ArrayRef(PackShapeDescriptors, PackShapeHeader.NumPacks);
}

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

/// Retrieve the generic parameters descriptors.
llvm::ArrayRef<GenericParamDescriptor> getGenericParameters() const {
return llvm::makeArrayRef(
return llvm::ArrayRef(
this->template getTrailingObjects<GenericParamDescriptor>(),
getGenericParameterCounts().back());
}

/// Retrieve the generic requirements.
llvm::ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
return llvm::makeArrayRef(
return llvm::ArrayRef(
this->template getTrailingObjects<GenericRequirementDescriptor>(),
Flags.getNumGenericRequirements());
}
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class ASTContext final {
StringRef AllocateCopy(StringRef Str,
AllocationArena arena = AllocationArena::Permanent) const {
ArrayRef<char> Result =
AllocateCopy(llvm::makeArrayRef(Str.data(), Str.size()), arena);
AllocateCopy(llvm::ArrayRef(Str.data(), Str.size()), arena);
return StringRef(Result.data(), Result.size());
}

Expand Down
3 changes: 1 addition & 2 deletions include/swift/AST/CaptureInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ class CaptureInfo {
: DynamicSelf(dynamicSelf), OpaqueValue(opaqueValue), Count(count) { }

ArrayRef<CapturedValue> getCaptures() const {
return llvm::makeArrayRef(this->getTrailingObjects<CapturedValue>(),
Count);
return llvm::ArrayRef(this->getTrailingObjects<CapturedValue>(), Count);
}

DynamicSelfType *getDynamicSelfType() const {
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DocComment {
}

ArrayRef<StringRef> getTags() const {
return llvm::makeArrayRef(Parts.Tags.begin(), Parts.Tags.end());
return llvm::ArrayRef(Parts.Tags.begin(), Parts.Tags.end());
}

std::optional<const swift::markup::Paragraph *> getBrief() const {
Expand Down
6 changes: 3 additions & 3 deletions include/swift/AST/NameLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,16 @@ class LookupResult {
bool empty() const { return innerResults().empty(); }

ArrayRef<LookupResultEntry> innerResults() const {
return llvm::makeArrayRef(Results).take_front(IndexOfFirstOuterResult);
return llvm::ArrayRef(Results).take_front(IndexOfFirstOuterResult);
}

ArrayRef<LookupResultEntry> outerResults() const {
return llvm::makeArrayRef(Results).drop_front(IndexOfFirstOuterResult);
return llvm::ArrayRef(Results).drop_front(IndexOfFirstOuterResult);
}

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

const LookupResultEntry& operator[](unsigned index) const {
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/SILLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class SILLayout final : public llvm::FoldingSetNode,

/// Get the fields inside the layout.
ArrayRef<SILField> getFields() const {
return llvm::makeArrayRef(getTrailingObjects<SILField>(), NumFields);
return llvm::ArrayRef(getTrailingObjects<SILField>(), NumFields);
}

/// Produce a profile of this layout, for use in a folding set.
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class SourceFile final : public FileUnit {
std::optional<ArrayRef<ASTNode>> getCachedTopLevelItems() const {
if (!Items)
return std::nullopt;
return llvm::makeArrayRef(*Items);
return llvm::ArrayRef(*Items);
}

/// Retrieve the parsing options for the file.
Expand Down
3 changes: 1 addition & 2 deletions include/swift/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,7 @@ class alignas(8) PoundAvailableInfo final :
bool isUnavailability);

ArrayRef<AvailabilitySpec *> getQueries() const {
return llvm::makeArrayRef(getTrailingObjects<AvailabilitySpec *>(),
NumQueries);
return llvm::ArrayRef(getTrailingObjects<AvailabilitySpec *>(), NumQueries);
}

SourceLoc getLParenLoc() const { return LParenLoc; }
Expand Down
12 changes: 6 additions & 6 deletions include/swift/AST/TypeRepr.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ class AttributedTypeRepr final
TypeRepr *ty);

ArrayRef<TypeOrCustomAttr> getAttrs() const {
return llvm::makeArrayRef(getTrailingObjects<TypeOrCustomAttr>(),
Bits.AttributedTypeRepr.NumAttributes);
return llvm::ArrayRef(getTrailingObjects<TypeOrCustomAttr>(),
Bits.AttributedTypeRepr.NumAttributes);
}

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

MutableArrayRef<TypeRepr*> getMutableElements() {
return llvm::makeMutableArrayRef(getTrailingObjects<TypeRepr*>(),
Bits.PackTypeRepr.NumElements);
return llvm::MutableArrayRef(getTrailingObjects<TypeRepr *>(),
Bits.PackTypeRepr.NumElements);
}
ArrayRef<TypeRepr*> getElements() const {
return llvm::makeArrayRef(getTrailingObjects<TypeRepr*>(),
Bits.PackTypeRepr.NumElements);
return llvm::ArrayRef(getTrailingObjects<TypeRepr *>(),
Bits.PackTypeRepr.NumElements);
}

static bool classof(const TypeRepr *T) {
Expand Down
7 changes: 4 additions & 3 deletions include/swift/Basic/MultiMapCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ class MultiMapCache {
// If we already have a cached value, just return the cached value.
if (!iter.second) {

return swift::transform(iter.first->second,
return swift::transform(
iter.first->second,
[&](std::tuple<unsigned, unsigned> startLengthRange) {
return llvm::makeArrayRef(data).slice(
return llvm::ArrayRef(data).slice(
std::get<ArrayStartOffset>(startLengthRange),
std::get<ArrayLengthOffset>(startLengthRange));
});
Expand All @@ -88,7 +89,7 @@ class MultiMapCache {
// update the map with the start, length, and return the resulting ArrayRef.
unsigned length = data.size() - initialOffset;
iter.first->second = std::make_tuple(initialOffset, length);
auto result = llvm::makeArrayRef(data).slice(initialOffset, length);
auto result = llvm::ArrayRef(data).slice(initialOffset, length);
return result;
}
};
Expand Down
6 changes: 2 additions & 4 deletions include/swift/Driver/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class Compilation {
}

UnwrappedArrayView<const Action> getActions() const {
return llvm::makeArrayRef(Actions);
return llvm::ArrayRef(Actions);
}

template <typename SpecificAction, typename... Args>
Expand All @@ -278,9 +278,7 @@ class Compilation {
return newAction;
}

UnwrappedArrayView<const Job> getJobs() const {
return llvm::makeArrayRef(Jobs);
}
UnwrappedArrayView<const Job> getJobs() const { return llvm::ArrayRef(Jobs); }

/// To send job list to places that don't truck in fancy array views.
std::vector<const Job *> getJobsSimply() const {
Expand Down
2 changes: 1 addition & 1 deletion include/swift/IDE/CodeCompletion.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ArrayRef<T> copyArray(llvm::BumpPtrAllocator &Allocator,
ArrayRef<T> Arr) {
T *Buffer = Allocator.Allocate<T>(Arr.size());
std::copy(Arr.begin(), Arr.end(), Buffer);
return llvm::makeArrayRef(Buffer, Arr.size());
return llvm::ArrayRef(Buffer, Arr.size());
}

bool isDynamicLookup(Type T);
Expand Down
2 changes: 1 addition & 1 deletion include/swift/IDE/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class DeclNameViewer {
DeclNameViewer() : DeclNameViewer(StringRef()) {}
operator bool() const { return !BaseName.empty(); }
StringRef base() const { return BaseName; }
llvm::ArrayRef<StringRef> args() const { return llvm::makeArrayRef(Labels); }
llvm::ArrayRef<StringRef> args() const { return llvm::ArrayRef(Labels); }
unsigned argSize() const { return Labels.size(); }
unsigned partsCount() const { return 1 + Labels.size(); }
unsigned commonPartsCount(DeclNameViewer &Other) const;
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Markup/Markup.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MarkupContext final {

StringRef allocateCopy(StringRef Str) {
ArrayRef<char> Result =
allocateCopy(llvm::makeArrayRef(Str.data(), Str.size()));
allocateCopy(llvm::ArrayRef(Str.data(), Str.size()));
return StringRef(Result.data(), Result.size());
}

Expand Down
4 changes: 2 additions & 2 deletions include/swift/Runtime/Numeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class IntegerLiteral {
/// the least-significant chunk. The value is sign-extended to fill the
/// final chunk.
llvm::ArrayRef<UnsignedChunk> getData() const {
return llvm::makeArrayRef(Data, (Flags.getBitWidth() + BitsPerChunk - 1) /
BitsPerChunk);
return llvm::ArrayRef(Data, (Flags.getBitWidth() + BitsPerChunk - 1) /
BitsPerChunk);
}

/// The flags for this value.
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SIL/Projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,13 @@ class ProjectionTreeNode {
bool isLeaf() const { return ChildProjections.empty(); }

ArrayRef<unsigned> getChildProjections() const {
return llvm::makeArrayRef(ChildProjections);
return llvm::ArrayRef(ChildProjections);
}

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

const ArrayRef<Operand *> getNonProjUsers() const {
return llvm::makeArrayRef(NonProjUsers);
return llvm::ArrayRef(NonProjUsers);
}

SILType getType() const { return NodeType; }
Expand Down Expand Up @@ -884,7 +884,7 @@ class ProjectionTree {
SILModule &getModule() const { return *Mod; }

llvm::ArrayRef<ProjectionTreeNode *> getProjectionTreeNodes() {
return llvm::makeArrayRef(ProjectionTreeNodes);
return llvm::ArrayRef(ProjectionTreeNodes);
}

/// Iterate over all values in the tree. The function should return false if
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Sema/ConstraintLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ class ConstraintLocator : public llvm::FoldingSetNode {
/// subcomponent.
ArrayRef<PathElement> getPath() const {
// FIXME: Alignment.
return llvm::makeArrayRef(reinterpret_cast<const PathElement *>(this + 1),
numPathElements);
return llvm::ArrayRef(reinterpret_cast<const PathElement *>(this + 1),
numPathElements);
}

unsigned getSummaryFlags() const { return summaryFlags; }
Expand Down
2 changes: 1 addition & 1 deletion include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3472,7 +3472,7 @@ class ConstraintSystem {
/// path element.
ConstraintLocator *
getConstraintLocator(ASTNode anchor, ConstraintLocator::PathElement pathElt) {
return getConstraintLocator(anchor, llvm::makeArrayRef(pathElt),
return getConstraintLocator(anchor, llvm::ArrayRef(pathElt),
pathElt.getNewSummaryFlags());
}

Expand Down
1 change: 0 additions & 1 deletion include/swift/Sema/SolutionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace swift {

using llvm::ArrayRef;
using llvm::makeArrayRef;

namespace constraints {

Expand Down
6 changes: 3 additions & 3 deletions lib/APIDigester/ModuleAnalyzerNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ ArrayRef<NodeAnnotation> SDKNode::
getAnnotations(std::vector<NodeAnnotation> &Scratch) const {
for (auto Ann : Annotations)
Scratch.push_back(Ann);
return llvm::makeArrayRef(Scratch);
return llvm::ArrayRef(Scratch);
}

bool SDKNode::isAnnotatedAs(NodeAnnotation Anno) const {
Expand Down Expand Up @@ -380,7 +380,7 @@ KnownTypeKind SDKNodeType::getTypeKind() const {
}

ArrayRef<TypeAttrKind> SDKNodeType::getTypeAttributes() const {
return llvm::makeArrayRef(TypeAttributes.data(), TypeAttributes.size());
return llvm::ArrayRef(TypeAttributes.data(), TypeAttributes.size());
}

void SDKNodeType::addTypeAttribute(TypeAttrKind AttrKind) {
Expand Down Expand Up @@ -508,7 +508,7 @@ bool SDKNodeDecl::hasDeclAttribute(DeclAttrKind DAKind) const {
}

ArrayRef<DeclAttrKind> SDKNodeDecl::getDeclAttributes() const {
return llvm::makeArrayRef(DeclAttributes.data(), DeclAttributes.size());
return llvm::ArrayRef(DeclAttributes.data(), DeclAttributes.size());
}

bool SDKNodeDecl::hasAttributeChange(const SDKNodeDecl &Another) const {
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2451,7 +2451,7 @@ BridgedGenericTypeParamDecl BridgedGenericTypeParamDecl_createParsed(
if (auto *inheritedType = bridgedInheritedType.unbridged()) {
auto entry = InheritedEntry(inheritedType);
ASTContext &context = cContext.unbridged();
decl->setInherited(context.AllocateCopy(llvm::makeArrayRef(entry)));
decl->setInherited(context.AllocateCopy(llvm::ArrayRef(entry)));
}

return decl;
Expand Down
6 changes: 3 additions & 3 deletions lib/AST/DocComment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ swift::extractCommentParts(swift::markup::MarkupContext &MC,
}

// Copy BodyNodes and ParamFields into the MarkupContext.
Parts.BodyNodes = MC.allocateCopy(llvm::makeArrayRef(BodyNodes));
Parts.ParamFields = MC.allocateCopy(llvm::makeArrayRef(ParamFields));
Parts.BodyNodes = MC.allocateCopy(llvm::ArrayRef(BodyNodes));
Parts.ParamFields = MC.allocateCopy(llvm::ArrayRef(ParamFields));

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

DocComment *swift::getSingleDocComment(swift::markup::MarkupContext &MC,
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2824,7 +2824,7 @@ SourceFile::getIfConfigsWithin(SourceRange outer) const {
}

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

void ModuleDecl::setPackageName(Identifier name) {
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/NameLookupRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ ArrayRef<FileUnit *> OperatorLookupDescriptor::getFiles() const {
return module->getFiles();

// Return an ArrayRef pointing to the FileUnit in the union.
return llvm::makeArrayRef(*fileOrModule.getAddrOfPtr1());
return llvm::ArrayRef(*fileOrModule.getAddrOfPtr1());
}

void swift::simple_display(llvm::raw_ostream &out,
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/RawComment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ RawComment RawCommentRequest::evaluate(Evaluator &eval, const Decl *D) const {
}

if (!SRCs.empty())
return RawComment(ctx.AllocateCopy(llvm::makeArrayRef(SRCs)));
return RawComment(ctx.AllocateCopy(llvm::ArrayRef(SRCs)));
}

// Otherwise check to see if we have a comment available in the swiftdoc.
Expand Down
Loading