Skip to content

Commit ff8d5bc

Browse files
committed
[NFC] MutableArrayRef<TypeLoc> -> ArrayRef<TypeLoc>
The first step on the road to splitting the semantic type information here from the syntactic information in the other half of the TypeLoc.
1 parent 3cc1dbb commit ff8d5bc

File tree

4 files changed

+24
-48
lines changed

4 files changed

+24
-48
lines changed

include/swift/AST/Decl.h

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
11931193
/// extended nominal.
11941194
llvm::PointerIntPair<NominalTypeDecl *, 1, bool> ExtendedNominal;
11951195

1196-
MutableArrayRef<TypeLoc> Inherited;
1196+
ArrayRef<TypeLoc> Inherited;
11971197

11981198
/// The next extension in the linked list of extensions.
11991199
///
@@ -1212,7 +1212,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
12121212
friend class IterableDeclContext;
12131213

12141214
ExtensionDecl(SourceLoc extensionLoc, TypeRepr *extendedType,
1215-
MutableArrayRef<TypeLoc> inherited,
1215+
ArrayRef<TypeLoc> inherited,
12161216
DeclContext *parent,
12171217
TrailingWhereClause *trailingWhereClause);
12181218

@@ -1237,7 +1237,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
12371237
/// Create a new extension declaration.
12381238
static ExtensionDecl *create(ASTContext &ctx, SourceLoc extensionLoc,
12391239
TypeRepr *extendedType,
1240-
MutableArrayRef<TypeLoc> inherited,
1240+
ArrayRef<TypeLoc> inherited,
12411241
DeclContext *parent,
12421242
TrailingWhereClause *trailingWhereClause,
12431243
ClangNode clangNode = ClangNode());
@@ -1289,10 +1289,9 @@ class ExtensionDecl final : public GenericContext, public Decl,
12891289

12901290
/// Retrieve the set of protocols that this type inherits (i.e,
12911291
/// explicitly conforms to).
1292-
MutableArrayRef<TypeLoc> getInherited() { return Inherited; }
12931292
ArrayRef<TypeLoc> getInherited() const { return Inherited; }
12941293

1295-
void setInherited(MutableArrayRef<TypeLoc> i) { Inherited = i; }
1294+
void setInherited(ArrayRef<TypeLoc> i) { Inherited = i; }
12961295

12971296
bool hasDefaultAccessLevel() const {
12981297
return Bits.ExtensionDecl.DefaultAndMaxAccessLevel != 0;
@@ -2405,12 +2404,12 @@ class ValueDecl : public Decl {
24052404

24062405
/// This is a common base class for declarations which declare a type.
24072406
class TypeDecl : public ValueDecl {
2408-
MutableArrayRef<TypeLoc> Inherited;
2407+
ArrayRef<TypeLoc> Inherited;
24092408

24102409
protected:
24112410
TypeDecl(DeclKind K, llvm::PointerUnion<DeclContext *, ASTContext *> context,
24122411
Identifier name, SourceLoc NameLoc,
2413-
MutableArrayRef<TypeLoc> inherited) :
2412+
ArrayRef<TypeLoc> inherited) :
24142413
ValueDecl(K, context, name, NameLoc), Inherited(inherited) {}
24152414

24162415
public:
@@ -2428,10 +2427,9 @@ class TypeDecl : public ValueDecl {
24282427

24292428
/// Retrieve the set of protocols that this type inherits (i.e,
24302429
/// explicitly conforms to).
2431-
MutableArrayRef<TypeLoc> getInherited() { return Inherited; }
24322430
ArrayRef<TypeLoc> getInherited() const { return Inherited; }
24332431

2434-
void setInherited(MutableArrayRef<TypeLoc> i) { Inherited = i; }
2432+
void setInherited(ArrayRef<TypeLoc> i) { Inherited = i; }
24352433

24362434
static bool classof(const Decl *D) {
24372435
return D->getKind() >= DeclKind::First_TypeDecl &&
@@ -2456,7 +2454,7 @@ class GenericTypeDecl : public GenericContext, public TypeDecl {
24562454
public:
24572455
GenericTypeDecl(DeclKind K, DeclContext *DC,
24582456
Identifier name, SourceLoc nameLoc,
2459-
MutableArrayRef<TypeLoc> inherited,
2457+
ArrayRef<TypeLoc> inherited,
24602458
GenericParamList *GenericParams);
24612459

24622460
// Resolve ambiguity due to multiple base classes.
@@ -2982,7 +2980,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
29822980

29832981
NominalTypeDecl(DeclKind K, DeclContext *DC, Identifier name,
29842982
SourceLoc NameLoc,
2985-
MutableArrayRef<TypeLoc> inherited,
2983+
ArrayRef<TypeLoc> inherited,
29862984
GenericParamList *GenericParams) :
29872985
GenericTypeDecl(K, DC, name, NameLoc, inherited, GenericParams),
29882986
IterableDeclContext(IterableDeclContextKind::NominalTypeDecl)
@@ -3224,34 +3222,14 @@ class EnumDecl final : public NominalTypeDecl {
32243222
// Is the complete set of raw values type checked?
32253223
HasFixedRawValuesAndTypes = 1 << 2,
32263224
};
3227-
3228-
struct {
3229-
/// The raw type and a bit to indicate whether the
3230-
/// raw was computed yet or not.
3231-
llvm::PointerIntPair<Type, 3, OptionSet<SemanticInfoFlags>> RawTypeAndFlags;
3232-
3233-
bool hasRawType() const {
3234-
return RawTypeAndFlags.getInt().contains(HasComputedRawType);
3235-
}
3236-
void cacheRawType(Type ty) {
3237-
auto flags = RawTypeAndFlags.getInt() | HasComputedRawType;
3238-
RawTypeAndFlags.setPointerAndInt(ty, flags);
3239-
}
3240-
3241-
bool hasFixedRawValues() const {
3242-
return RawTypeAndFlags.getInt().contains(HasFixedRawValues);
3243-
}
3244-
bool hasCheckedRawValues() const {
3245-
return RawTypeAndFlags.getInt().contains(HasFixedRawValuesAndTypes);
3246-
}
3247-
} LazySemanticInfo;
3225+
OptionSet<SemanticInfoFlags> SemanticFlags;
32483226

32493227
friend class EnumRawValuesRequest;
32503228
friend class EnumRawTypeRequest;
32513229

32523230
public:
32533231
EnumDecl(SourceLoc EnumLoc, Identifier Name, SourceLoc NameLoc,
3254-
MutableArrayRef<TypeLoc> Inherited,
3232+
ArrayRef<TypeLoc> Inherited,
32553233
GenericParamList *GenericParams, DeclContext *DC);
32563234

32573235
SourceLoc getStartLoc() const { return EnumLoc; }
@@ -3387,7 +3365,7 @@ class StructDecl final : public NominalTypeDecl {
33873365

33883366
public:
33893367
StructDecl(SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc,
3390-
MutableArrayRef<TypeLoc> Inherited,
3368+
ArrayRef<TypeLoc> Inherited,
33913369
GenericParamList *GenericParams, DeclContext *DC);
33923370

33933371
SourceLoc getStartLoc() const { return StructLoc; }
@@ -3526,7 +3504,7 @@ class ClassDecl final : public NominalTypeDecl {
35263504

35273505
public:
35283506
ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,
3529-
MutableArrayRef<TypeLoc> Inherited,
3507+
ArrayRef<TypeLoc> Inherited,
35303508
GenericParamList *GenericParams, DeclContext *DC);
35313509

35323510
SourceLoc getStartLoc() const { return ClassLoc; }
@@ -3907,7 +3885,7 @@ class ProtocolDecl final : public NominalTypeDecl {
39073885

39083886
public:
39093887
ProtocolDecl(DeclContext *DC, SourceLoc ProtocolLoc, SourceLoc NameLoc,
3910-
Identifier Name, MutableArrayRef<TypeLoc> Inherited,
3888+
Identifier Name, ArrayRef<TypeLoc> Inherited,
39113889
TrailingWhereClause *TrailingWhere);
39123890

39133891
using Decl::getASTContext;

lib/AST/Decl.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ NominalTypeDecl::takeConformanceLoaderSlow() {
11061106

11071107
ExtensionDecl::ExtensionDecl(SourceLoc extensionLoc,
11081108
TypeRepr *extendedType,
1109-
MutableArrayRef<TypeLoc> inherited,
1109+
ArrayRef<TypeLoc> inherited,
11101110
DeclContext *parent,
11111111
TrailingWhereClause *trailingWhereClause)
11121112
: GenericContext(DeclContextKind::ExtensionDecl, parent, nullptr),
@@ -1123,7 +1123,7 @@ ExtensionDecl::ExtensionDecl(SourceLoc extensionLoc,
11231123

11241124
ExtensionDecl *ExtensionDecl::create(ASTContext &ctx, SourceLoc extensionLoc,
11251125
TypeRepr *extendedType,
1126-
MutableArrayRef<TypeLoc> inherited,
1126+
ArrayRef<TypeLoc> inherited,
11271127
DeclContext *parent,
11281128
TrailingWhereClause *trailingWhereClause,
11291129
ClangNode clangNode) {
@@ -3704,7 +3704,7 @@ PropertyWrapperTypeInfo NominalTypeDecl::getPropertyWrapperTypeInfo() const {
37043704

37053705
GenericTypeDecl::GenericTypeDecl(DeclKind K, DeclContext *DC,
37063706
Identifier name, SourceLoc nameLoc,
3707-
MutableArrayRef<TypeLoc> inherited,
3707+
ArrayRef<TypeLoc> inherited,
37083708
GenericParamList *GenericParams) :
37093709
GenericContext(DeclContextKind::GenericTypeDecl, DC, GenericParams),
37103710
TypeDecl(K, DC, name, nameLoc, inherited) {}
@@ -3914,7 +3914,7 @@ AssociatedTypeDecl *AssociatedTypeDecl::getAssociatedTypeAnchor() const {
39143914

39153915
EnumDecl::EnumDecl(SourceLoc EnumLoc,
39163916
Identifier Name, SourceLoc NameLoc,
3917-
MutableArrayRef<TypeLoc> Inherited,
3917+
ArrayRef<TypeLoc> Inherited,
39183918
GenericParamList *GenericParams, DeclContext *Parent)
39193919
: NominalTypeDecl(DeclKind::Enum, Parent, Name, NameLoc, Inherited,
39203920
GenericParams),
@@ -3934,7 +3934,7 @@ Type EnumDecl::getRawType() const {
39343934
}
39353935

39363936
StructDecl::StructDecl(SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc,
3937-
MutableArrayRef<TypeLoc> Inherited,
3937+
ArrayRef<TypeLoc> Inherited,
39383938
GenericParamList *GenericParams, DeclContext *Parent)
39393939
: NominalTypeDecl(DeclKind::Struct, Parent, Name, NameLoc, Inherited,
39403940
GenericParams),
@@ -4045,7 +4045,7 @@ void NominalTypeDecl::synthesizeSemanticMembersIfNeeded(DeclName member) {
40454045
}
40464046

40474047
ClassDecl::ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,
4048-
MutableArrayRef<TypeLoc> Inherited,
4048+
ArrayRef<TypeLoc> Inherited,
40494049
GenericParamList *GenericParams, DeclContext *Parent)
40504050
: NominalTypeDecl(DeclKind::Class, Parent, Name, NameLoc, Inherited,
40514051
GenericParams),
@@ -4509,9 +4509,7 @@ bool EnumDecl::isEffectivelyExhaustive(ModuleDecl *M,
45094509
}
45104510

45114511
void EnumDecl::setHasFixedRawValues() {
4512-
auto flags = LazySemanticInfo.RawTypeAndFlags.getInt() |
4513-
EnumDecl::HasFixedRawValues;
4514-
LazySemanticInfo.RawTypeAndFlags.setInt(flags);
4512+
SemanticFlags |= OptionSet<EnumDecl::SemanticInfoFlags>{EnumDecl::HasFixedRawValues};
45154513
}
45164514

45174515
bool EnumDecl::hasCircularRawValue() const {
@@ -4523,7 +4521,7 @@ bool EnumDecl::hasCircularRawValue() const {
45234521

45244522
ProtocolDecl::ProtocolDecl(DeclContext *DC, SourceLoc ProtocolLoc,
45254523
SourceLoc NameLoc, Identifier Name,
4526-
MutableArrayRef<TypeLoc> Inherited,
4524+
ArrayRef<TypeLoc> Inherited,
45274525
TrailingWhereClause *TrailingWhere)
45284526
: NominalTypeDecl(DeclKind::Protocol, DC, Name, NameLoc, Inherited,
45294527
nullptr),

lib/IRGen/GenClass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ ClassDecl *IRGenModule::getObjCRuntimeBaseClass(Identifier name,
23402340

23412341
// Make a really fake-looking class.
23422342
auto SwiftRootClass = new (Context) ClassDecl(SourceLoc(), name, SourceLoc(),
2343-
MutableArrayRef<TypeLoc>(),
2343+
ArrayRef<TypeLoc>(),
23442344
/*generics*/ nullptr,
23452345
Context.TheBuiltinModule);
23462346
SwiftRootClass->setIsObjC(Context.LangOpts.EnableObjCInterop);

lib/Sema/DerivedConformanceCodable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static EnumDecl *synthesizeCodingKeysEnum(DerivedConformance &derived) {
234234
auto *codingKeyProto = C.getProtocol(KnownProtocolKind::CodingKey);
235235
auto codingKeyType = codingKeyProto->getDeclaredInterfaceType();
236236
TypeLoc protoTypeLoc[1] = {TypeLoc::withoutLoc(codingKeyType)};
237-
MutableArrayRef<TypeLoc> inherited = C.AllocateCopy(protoTypeLoc);
237+
ArrayRef<TypeLoc> inherited = C.AllocateCopy(protoTypeLoc);
238238

239239
auto *enumDecl = new (C) EnumDecl(SourceLoc(), C.Id_CodingKeys, SourceLoc(),
240240
inherited, nullptr, target);

0 commit comments

Comments
 (0)