Skip to content

Commit 9a141a8

Browse files
authored
Merge pull request #31746 from compnerd/ArrayRef
runtime: explicitly namespace ArrayRef in shared headers
2 parents 14ff43e + 96313ce commit 9a141a8

File tree

10 files changed

+103
-100
lines changed

10 files changed

+103
-100
lines changed

include/swift/ABI/Metadata.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,7 @@ struct TargetExistentialTypeMetadata
20002000
}
20012001

20022002
/// Retrieve the set of protocols required by the existential.
2003-
ArrayRef<ProtocolDescriptorRef> getProtocols() const {
2003+
llvm::ArrayRef<ProtocolDescriptorRef> getProtocols() const {
20042004
return { this->template getTrailingObjects<ProtocolDescriptorRef>(),
20052005
NumProtocols };
20062006
}
@@ -2013,7 +2013,7 @@ struct TargetExistentialTypeMetadata
20132013
}
20142014

20152015
/// Retrieve the set of protocols required by the existential.
2016-
MutableArrayRef<ProtocolDescriptorRef> getMutableProtocols() {
2016+
llvm::MutableArrayRef<ProtocolDescriptorRef> getMutableProtocols() {
20172017
return { this->template getTrailingObjects<ProtocolDescriptorRef>(),
20182018
NumProtocols };
20192019
}
@@ -2535,13 +2535,13 @@ struct TargetProtocolConformanceDescriptor final
25352535
getWitnessTable(const TargetMetadata<Runtime> *type) const;
25362536

25372537
/// Retrieve the resilient witnesses.
2538-
ArrayRef<ResilientWitness> getResilientWitnesses() const{
2538+
llvm::ArrayRef<ResilientWitness> getResilientWitnesses() const {
25392539
if (!Flags.hasResilientWitnesses())
25402540
return { };
25412541

2542-
return ArrayRef<ResilientWitness>(
2543-
this->template getTrailingObjects<ResilientWitness>(),
2544-
numTrailingObjects(OverloadToken<ResilientWitness>()));
2542+
return llvm::ArrayRef<ResilientWitness>(
2543+
this->template getTrailingObjects<ResilientWitness>(),
2544+
numTrailingObjects(OverloadToken<ResilientWitness>()));
25452545
}
25462546

25472547
ConstTargetPointer<Runtime, GenericWitnessTable>
@@ -2828,23 +2828,23 @@ class TargetGenericEnvironment
28282828

28292829
public:
28302830
/// Retrieve the cumulative generic parameter counts at each level of genericity.
2831-
ArrayRef<uint16_t> getGenericParameterCounts() const {
2832-
return ArrayRef<uint16_t>(this->template getTrailingObjects<uint16_t>(),
2831+
llvm::ArrayRef<uint16_t> getGenericParameterCounts() const {
2832+
return llvm::makeArrayRef(this->template getTrailingObjects<uint16_t>(),
28332833
Flags.getNumGenericParameterLevels());
28342834
}
28352835

28362836
/// Retrieve the generic parameters descriptors.
2837-
ArrayRef<GenericParamDescriptor> getGenericParameters() const {
2838-
return ArrayRef<GenericParamDescriptor>(
2839-
this->template getTrailingObjects<GenericParamDescriptor>(),
2840-
getGenericParameterCounts().back());
2837+
llvm::ArrayRef<GenericParamDescriptor> getGenericParameters() const {
2838+
return llvm::makeArrayRef(
2839+
this->template getTrailingObjects<GenericParamDescriptor>(),
2840+
getGenericParameterCounts().back());
28412841
}
28422842

28432843
/// Retrieve the generic requirements.
2844-
ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
2845-
return ArrayRef<GenericRequirementDescriptor>(
2846-
this->template getTrailingObjects<GenericRequirementDescriptor>(),
2847-
Flags.getNumGenericRequirements());
2844+
llvm::ArrayRef<GenericRequirementDescriptor> getGenericRequirements() const {
2845+
return llvm::makeArrayRef(
2846+
this->template getTrailingObjects<GenericRequirementDescriptor>(),
2847+
Flags.getNumGenericRequirements());
28482848
}
28492849
};
28502850

@@ -4604,7 +4604,8 @@ class DynamicReplacementScope
46044604
DynamicReplacementDescriptor>;
46054605
friend TrailingObjects;
46064606

4607-
ArrayRef<DynamicReplacementDescriptor> getReplacementDescriptors() const {
4607+
llvm::ArrayRef<DynamicReplacementDescriptor>
4608+
getReplacementDescriptors() const {
46084609
return {this->template getTrailingObjects<DynamicReplacementDescriptor>(),
46094610
numReplacements};
46104611
}

include/swift/Basic/LLVM.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ namespace llvm {
3838
template <typename T, unsigned N> class SmallVector;
3939
template <unsigned N> class SmallString;
4040
template <typename T, unsigned N> class SmallSetVector;
41+
#if !defined(swiftCore_EXPORTS)
4142
template<typename T> class ArrayRef;
4243
template<typename T> class MutableArrayRef;
44+
#endif
4345
template<typename T> class TinyPtrVector;
4446
template<typename T> class Optional;
4547
template <typename ...PTs> class PointerUnion;
@@ -63,9 +65,11 @@ namespace swift {
6365
using llvm::cast_or_null;
6466

6567
// Containers.
68+
#if !defined(swiftCore_EXPORTS)
6669
using llvm::ArrayRef;
67-
using llvm::iterator_range;
6870
using llvm::MutableArrayRef;
71+
#endif
72+
using llvm::iterator_range;
6973
using llvm::None;
7074
using llvm::Optional;
7175
using llvm::PointerUnion;

include/swift/Demangling/TypeDecoder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/Basic/LLVM.h"
2424
#include "swift/Runtime/Unreachable.h"
2525
#include "swift/Strings.h"
26+
#include "llvm/ADT/ArrayRef.h"
2627
#include <vector>
2728

2829
namespace swift {
@@ -876,7 +877,7 @@ class TypeDecoder {
876877
}
877878
}
878879
genericArgsLevels.push_back(genericArgsBuf.size());
879-
std::vector<ArrayRef<BuiltType>> genericArgs;
880+
std::vector<llvm::ArrayRef<BuiltType>> genericArgs;
880881
for (unsigned i = 0; i < genericArgsLevels.size() - 1; ++i) {
881882
auto start = genericArgsLevels[i], end = genericArgsLevels[i+1];
882883
genericArgs.emplace_back(genericArgsBuf.data() + start,

include/swift/Reflection/TypeRef.h

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ class OpaqueArchetypeTypeRef final : public TypeRef {
346346
// Each ArrayRef in ArgumentLists references into the buffer owned by this
347347
// vector, which must not be modified after construction.
348348
std::vector<const TypeRef *> AllArgumentsBuf;
349-
std::vector<ArrayRef<const TypeRef *>> ArgumentLists;
350-
351-
static TypeRefID Profile(StringRef idString,
352-
StringRef description, unsigned ordinal,
353-
ArrayRef<ArrayRef<const TypeRef *>> argumentLists) {
349+
std::vector<llvm::ArrayRef<const TypeRef *>> ArgumentLists;
350+
351+
static TypeRefID
352+
Profile(StringRef idString, StringRef description, unsigned ordinal,
353+
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> argumentLists) {
354354
TypeRefID ID;
355355
ID.addString(idString.str());
356356
ID.addInteger(ordinal);
@@ -362,14 +362,13 @@ class OpaqueArchetypeTypeRef final : public TypeRef {
362362

363363
return ID;
364364
}
365-
365+
366366
public:
367-
OpaqueArchetypeTypeRef(StringRef id,
368-
StringRef description, unsigned ordinal,
369-
ArrayRef<ArrayRef<const TypeRef *>> argumentLists)
370-
: TypeRef(TypeRefKind::OpaqueArchetype),
371-
ID(id), Description(description), Ordinal(ordinal)
372-
{
367+
OpaqueArchetypeTypeRef(
368+
StringRef id, StringRef description, unsigned ordinal,
369+
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> argumentLists)
370+
: TypeRef(TypeRefKind::OpaqueArchetype), ID(id), Description(description),
371+
Ordinal(ordinal) {
373372
std::vector<unsigned> argumentListLengths;
374373

375374
for (auto argList : argumentLists) {
@@ -379,25 +378,24 @@ class OpaqueArchetypeTypeRef final : public TypeRef {
379378
}
380379
auto *data = AllArgumentsBuf.data();
381380
for (auto length : argumentListLengths) {
382-
ArgumentLists.push_back(ArrayRef<const TypeRef *>(data, length));
381+
ArgumentLists.push_back(llvm::ArrayRef<const TypeRef *>(data, length));
383382
data += length;
384383
}
385384
assert(data == AllArgumentsBuf.data() + AllArgumentsBuf.size());
386385
}
387-
386+
388387
template <typename Allocator>
389-
static const OpaqueArchetypeTypeRef *create(Allocator &A,
390-
StringRef id, StringRef description,
391-
unsigned ordinal,
392-
ArrayRef<ArrayRef<const TypeRef *>> arguments) {
388+
static const OpaqueArchetypeTypeRef *
389+
create(Allocator &A, StringRef id, StringRef description, unsigned ordinal,
390+
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> arguments) {
393391
FIND_OR_CREATE_TYPEREF(A, OpaqueArchetypeTypeRef,
394392
id, description, ordinal, arguments);
395393
}
396394

397-
ArrayRef<ArrayRef<const TypeRef *>> getArgumentLists() const {
395+
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> getArgumentLists() const {
398396
return ArgumentLists;
399397
}
400-
398+
401399
unsigned getOrdinal() const {
402400
return Ordinal;
403401
}

include/swift/Reflection/TypeRefBuilder.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,14 @@ class TypeRefBuilder {
361361

362362
const BoundGenericTypeRef *
363363
createBoundGenericType(const Optional<std::string> &mangledName,
364-
ArrayRef<const TypeRef *> args,
364+
llvm::ArrayRef<const TypeRef *> args,
365365
const TypeRef *parent) {
366366
return BoundGenericTypeRef::create(*this, *mangledName, args, parent);
367367
}
368-
368+
369369
const TypeRef *
370370
resolveOpaqueType(NodePointer opaqueDescriptor,
371-
ArrayRef<ArrayRef<const TypeRef *>> genericArgs,
371+
llvm::ArrayRef<llvm::ArrayRef<const TypeRef *>> genericArgs,
372372
unsigned ordinal) {
373373
// TODO: Produce a type ref for the opaque type if the underlying type isn't
374374
// available.
@@ -403,26 +403,25 @@ class TypeRefBuilder {
403403
genericArgs);
404404
}
405405

406-
const TupleTypeRef *
407-
createTupleType(ArrayRef<const TypeRef *> elements,
408-
std::string &&labels, bool isVariadic) {
406+
const TupleTypeRef *createTupleType(llvm::ArrayRef<const TypeRef *> elements,
407+
std::string &&labels, bool isVariadic) {
409408
// FIXME: Add uniqueness checks in TupleTypeRef::Profile and
410409
// unittests/Reflection/TypeRef.cpp if using labels for identity.
411410
return TupleTypeRef::create(*this, elements, isVariadic);
412411
}
413412

414413
const FunctionTypeRef *createFunctionType(
415-
ArrayRef<remote::FunctionParam<const TypeRef *>> params,
414+
llvm::ArrayRef<remote::FunctionParam<const TypeRef *>> params,
416415
const TypeRef *result, FunctionTypeFlags flags) {
417416
return FunctionTypeRef::create(*this, params, result, flags);
418417
}
419418

420419
const FunctionTypeRef *createImplFunctionType(
421-
Demangle::ImplParameterConvention calleeConvention,
422-
ArrayRef<Demangle::ImplFunctionParam<const TypeRef *>> params,
423-
ArrayRef<Demangle::ImplFunctionResult<const TypeRef *>> results,
424-
Optional<Demangle::ImplFunctionResult<const TypeRef *>> errorResult,
425-
ImplFunctionTypeFlags flags) {
420+
Demangle::ImplParameterConvention calleeConvention,
421+
llvm::ArrayRef<Demangle::ImplFunctionParam<const TypeRef *>> params,
422+
llvm::ArrayRef<Demangle::ImplFunctionResult<const TypeRef *>> results,
423+
Optional<Demangle::ImplFunctionResult<const TypeRef *>> errorResult,
424+
ImplFunctionTypeFlags flags) {
426425
// Minimal support for lowered function types. These come up in
427426
// reflection as capture types. For the reflection library's
428427
// purposes, the only part that matters is the convention.
@@ -451,9 +450,8 @@ class TypeRefBuilder {
451450
}
452451

453452
const ProtocolCompositionTypeRef *
454-
createProtocolCompositionType(ArrayRef<BuiltProtocolDecl> protocols,
455-
BuiltType superclass,
456-
bool isClassBound) {
453+
createProtocolCompositionType(llvm::ArrayRef<BuiltProtocolDecl> protocols,
454+
BuiltType superclass, bool isClassBound) {
457455
std::vector<const TypeRef *> protocolRefs;
458456
for (const auto &protocol : protocols) {
459457
if (!protocol)
@@ -530,7 +528,7 @@ class TypeRefBuilder {
530528

531529
const ObjCClassTypeRef *
532530
createBoundGenericObjCClassType(const std::string &name,
533-
ArrayRef<const TypeRef *> args) {
531+
llvm::ArrayRef<const TypeRef *> args) {
534532
// Remote reflection just ignores generic arguments for Objective-C
535533
// lightweight generic types, since they don't affect layout.
536534
return createObjCClassType(name);

include/swift/Runtime/Numeric.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class IntegerLiteral {
4444
/// Return the chunks of data making up this value, arranged starting from
4545
/// the least-significant chunk. The value is sign-extended to fill the
4646
/// final chunk.
47-
ArrayRef<UnsignedChunk> getData() const {
48-
return ArrayRef<UnsignedChunk>(Data,
49-
(Flags.getBitWidth() + BitsPerChunk - 1) / BitsPerChunk);
47+
llvm::ArrayRef<UnsignedChunk> getData() const {
48+
return llvm::makeArrayRef(Data, (Flags.getBitWidth() + BitsPerChunk - 1) /
49+
BitsPerChunk);
5050
}
5151

5252
/// The flags for this value.

stdlib/public/Reflection/TypeRef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,9 @@ class TypeRefSubstitution
10721072
newArgsBuffer.push_back(visit(arg));
10731073
}
10741074
}
1075-
1076-
std::vector<ArrayRef<const TypeRef *>> newArgLists;
1077-
1075+
1076+
std::vector<llvm::ArrayRef<const TypeRef *>> newArgLists;
1077+
10781078
return OpaqueArchetypeTypeRef::create(Builder, O->getID(), O->getDescription(),
10791079
O->getOrdinal(),
10801080
newArgLists);

stdlib/public/runtime/Metadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5311,7 +5311,7 @@ checkTransitiveCompleteness(const Metadata *initialType) {
53115311
/// Diagnose a metadata dependency cycle.
53125312
SWIFT_NORETURN static void
53135313
diagnoseMetadataDependencyCycle(const Metadata *start,
5314-
ArrayRef<MetadataDependency> links) {
5314+
llvm::ArrayRef<MetadataDependency> links) {
53155315
assert(start == links.back().Value);
53165316

53175317
std::string diagnostic =

0 commit comments

Comments
 (0)