@@ -363,11 +363,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
363
363
HasCachedType : 1
364
364
);
365
365
366
- enum { NumFlagBits = 8 };
367
- SWIFT_INLINE_BITFIELD (ParenType, SugarType, NumFlagBits,
368
- // / Whether there is an original type.
369
- Flags : NumFlagBits
370
- );
366
+ SWIFT_INLINE_BITFIELD_EMPTY (ParenType, SugarType);
371
367
372
368
SWIFT_INLINE_BITFIELD_FULL (AnyFunctionType, TypeBase, NumAFTExtInfoBits+1 +1 +1 +16 ,
373
369
// / Extra information which affects how the function is called, like
@@ -429,11 +425,7 @@ class alignas(1 << TypeAlignInBits) TypeBase
429
425
ArgCount : 32
430
426
);
431
427
432
- SWIFT_INLINE_BITFIELD_FULL (TupleType, TypeBase, 1 +32 ,
433
- // / Whether an element of the tuple is inout, __shared or __owned.
434
- // / Values cannot have such tuple types in the language.
435
- HasElementWithOwnership : 1 ,
436
-
428
+ SWIFT_INLINE_BITFIELD_FULL (TupleType, TypeBase, 32 ,
437
429
: NumPadBits,
438
430
439
431
// / The number of elements of the tuple.
@@ -724,8 +716,8 @@ class alignas(1 << TypeAlignInBits) TypeBase
724
716
return getRecursiveProperties ().isLValue ();
725
717
}
726
718
727
- // / Is this a first-class value type, meaning it is not an InOutType or a
728
- // / tuple type containing an InOutType?
719
+ // / Is this a first-class value type, meaning it is not an LValueType or an
720
+ // / InOutType.
729
721
bool isMaterializable ();
730
722
731
723
// / Is this a non-escaping type, that is, a non-escaping function type or a
@@ -1995,11 +1987,6 @@ class TypeAliasType final
1995
1987
}
1996
1988
};
1997
1989
1998
- // TODO: As part of AST modernization, replace with a proper
1999
- // 'ParameterTypeElt' or similar, and have FunctionTypes only have a list
2000
- // of 'ParameterTypeElt's. Then, this information can be removed from
2001
- // TupleTypeElt.
2002
- //
2003
1990
// / Provide parameter type relevant flags, i.e. variadic, autoclosure, and
2004
1991
// / escaping.
2005
1992
class ParameterTypeFlags {
@@ -2218,21 +2205,12 @@ class YieldTypeFlags {
2218
2205
2219
2206
// / ParenType - A paren type is a type that's been written in parentheses.
2220
2207
class ParenType : public SugarType {
2221
- friend class ASTContext ;
2222
-
2223
- ParenType (Type UnderlyingType, RecursiveTypeProperties properties,
2224
- ParameterTypeFlags flags);
2208
+ ParenType (Type UnderlyingType, RecursiveTypeProperties properties);
2225
2209
2226
2210
public:
2227
- Type getUnderlyingType () const { return getSinglyDesugaredType (); }
2228
-
2229
- static ParenType *get (const ASTContext &C, Type underlying,
2230
- ParameterTypeFlags flags = {});
2211
+ static ParenType *get (const ASTContext &C, Type underlying);
2231
2212
2232
- // / Get the parameter flags
2233
- ParameterTypeFlags getParameterFlags () const {
2234
- return ParameterTypeFlags::fromRaw (Bits.ParenType .Flags );
2235
- }
2213
+ Type getUnderlyingType () const { return getSinglyDesugaredType (); }
2236
2214
2237
2215
// Implement isa/cast/dyncast/etc.
2238
2216
static bool classof (const TypeBase *T) {
@@ -2248,37 +2226,17 @@ class TupleTypeElt {
2248
2226
// / This is the type of the field.
2249
2227
Type ElementType;
2250
2228
2251
- // / Flags that are specific to and relevant for parameter types
2252
- ParameterTypeFlags Flags;
2253
-
2254
2229
friend class TupleType ;
2255
2230
2256
2231
public:
2257
2232
TupleTypeElt () = default ;
2258
- TupleTypeElt (Type ty, Identifier name = Identifier(),
2259
- ParameterTypeFlags fl = {});
2260
-
2233
+ TupleTypeElt (Type ty, Identifier name = Identifier());
2234
+
2261
2235
bool hasName () const { return !Name.empty (); }
2262
2236
Identifier getName () const { return Name; }
2263
-
2264
- Type getRawType () const { return ElementType; }
2265
- Type getType () const ;
2266
-
2267
- ParameterTypeFlags getParameterFlags () const { return Flags; }
2268
2237
2269
- // / Determine whether this field is variadic.
2270
- bool isVararg () const { return Flags.isVariadic (); }
2238
+ Type getType () const { return ElementType; }
2271
2239
2272
- // / Determine whether this field is an autoclosure parameter closure.
2273
- bool isAutoClosure () const { return Flags.isAutoClosure (); }
2274
-
2275
- // / Determine whether this field is marked 'inout'.
2276
- bool isInOut () const { return Flags.isInOut (); }
2277
-
2278
- // / Remove the type of this varargs element designator, without the array
2279
- // / type wrapping it.
2280
- Type getVarargBaseTy () const ;
2281
-
2282
2240
// / Retrieve a copy of this tuple type element with the type replaced.
2283
2241
TupleTypeElt getWithType (Type T) const ;
2284
2242
@@ -2340,11 +2298,6 @@ class TupleType final : public TypeBase, public llvm::FoldingSetNode,
2340
2298
// / getNamedElementId - If this tuple has an element with the specified name,
2341
2299
// / return the element index, otherwise return -1.
2342
2300
int getNamedElementId (Identifier I) const ;
2343
-
2344
- // / Returns true if this tuple has inout, __shared or __owned elements.
2345
- bool hasElementWithOwnership () const {
2346
- return static_cast <bool >(Bits.TupleType .HasElementWithOwnership );
2347
- }
2348
2301
2349
2302
// Implement isa/cast/dyncast/etc.
2350
2303
static bool classof (const TypeBase *T) {
@@ -2359,13 +2312,11 @@ class TupleType final : public TypeBase, public llvm::FoldingSetNode,
2359
2312
2360
2313
private:
2361
2314
TupleType (ArrayRef<TupleTypeElt> elements, const ASTContext *CanCtx,
2362
- RecursiveTypeProperties properties,
2363
- bool hasElementWithOwnership)
2364
- : TypeBase(TypeKind::Tuple, CanCtx, properties) {
2365
- Bits.TupleType .HasElementWithOwnership = hasElementWithOwnership;
2366
- Bits.TupleType .Count = elements.size ();
2367
- std::uninitialized_copy (elements.begin (), elements.end (),
2368
- getTrailingObjects<TupleTypeElt>());
2315
+ RecursiveTypeProperties properties)
2316
+ : TypeBase(TypeKind::Tuple, CanCtx, properties) {
2317
+ Bits.TupleType .Count = elements.size ();
2318
+ std::uninitialized_copy (elements.begin (), elements.end (),
2319
+ getTrailingObjects<TupleTypeElt>());
2369
2320
}
2370
2321
};
2371
2322
BEGIN_CAN_TYPE_WRAPPER (TupleType, Type)
@@ -6554,17 +6505,9 @@ inline bool TypeBase::isTypeSequenceParameter() {
6554
6505
t->castTo <GenericTypeParamType>()->isTypeSequence ();
6555
6506
}
6556
6507
6508
+ // TODO: This will become redundant once InOutType is removed.
6557
6509
inline bool TypeBase::isMaterializable () {
6558
- if (hasLValueType ())
6559
- return false ;
6560
-
6561
- if (is<InOutType>())
6562
- return false ;
6563
-
6564
- if (auto *TTy = getAs<TupleType>())
6565
- return !TTy->hasElementWithOwnership ();
6566
-
6567
- return true ;
6510
+ return !(hasLValueType () || is<InOutType>());
6568
6511
}
6569
6512
6570
6513
inline GenericTypeParamType *TypeBase::getRootGenericParam () {
@@ -6776,26 +6719,12 @@ inline bool CanType::isActuallyCanonicalOrNull() const {
6776
6719
getPointer ()->isCanonical ();
6777
6720
}
6778
6721
6779
- inline Type TupleTypeElt::getVarargBaseTy () const {
6780
- TypeBase *T = getType ().getPointer ();
6781
- if (auto *AT = dyn_cast<VariadicSequenceType>(T))
6782
- return AT->getBaseType ();
6783
- if (auto *BGT = dyn_cast<BoundGenericType>(T)) {
6784
- // It's the stdlib Array<T>.
6785
- return BGT->getGenericArgs ()[0 ];
6786
- }
6787
- assert (T->hasError ());
6788
- return T;
6789
- }
6790
-
6791
6722
inline TupleTypeElt TupleTypeElt::getWithName (Identifier name) const {
6792
- assert (getParameterFlags ().isInOut () == getType ()->is <InOutType>());
6793
- return TupleTypeElt (getRawType (), name, getParameterFlags ());
6723
+ return TupleTypeElt (getType (), name);
6794
6724
}
6795
6725
6796
6726
inline TupleTypeElt TupleTypeElt::getWithType (Type T) const {
6797
- auto flags = getParameterFlags ().withInOut (T->is <InOutType>());
6798
- return TupleTypeElt (T->getInOutObjectType (), getName (), flags);
6727
+ return TupleTypeElt (T, getName ());
6799
6728
}
6800
6729
6801
6730
// / Create one from what's present in the parameter decl and type
0 commit comments