Skip to content

Commit a592d1d

Browse files
authored
---
yaml --- r: 326618 b: refs/heads/tensorflow c: 5add168 h: refs/heads/master
1 parent 1e52bec commit a592d1d

File tree

68 files changed

+724
-558
lines changed

Some content is hidden

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

68 files changed

+724
-558
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: c36993e30cd23782f42c8f2ce8a463ab3c18d591
819+
refs/heads/tensorflow: 5add16804272b4df917da15c46eb6f28d826d656
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/include/swift/ABI/Metadata.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,6 +2340,12 @@ struct TargetProtocolConformanceDescriptor final
23402340
return TypeRef.getTypeDescriptor(getTypeKind());
23412341
}
23422342

2343+
const TargetContextDescriptor<Runtime> **_getTypeDescriptorLocation() const {
2344+
if (getTypeKind() != TypeReferenceKind::IndirectTypeDescriptor)
2345+
return nullptr;
2346+
return TypeRef.IndirectTypeDescriptor.get();
2347+
}
2348+
23432349
/// Retrieve the context of a retroactive conformance.
23442350
const TargetContextDescriptor<Runtime> *getRetroactiveContext() const {
23452351
if (!Flags.isRetroactive()) return nullptr;

branches/tensorflow/include/swift/AST/Attr.def

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ DECL_ATTR(_restatedObjCConformance, RestatedObjCConformance,
348348
LongAttribute | RejectByParser |
349349
NotSerialized, 70)
350350
// NOTE: 71 is unused
351-
SIMPLE_DECL_ATTR(_implicitly_unwrapped_optional, ImplicitlyUnwrappedOptional,
352-
OnFunc | OnAccessor | OnVar | OnParam | OnSubscript | OnConstructor |
353-
RejectByParser,
354-
72)
351+
// NOTE: 72 is unused
355352
DECL_ATTR(_optimize, Optimize,
356353
OnAbstractFunction | OnSubscript | OnVar |
357354
UserInaccessible,

branches/tensorflow/include/swift/AST/ClangModuleLoader.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,33 @@ class ClangModuleLoader : public ModuleLoader {
7171
virtual bool
7272
isInOverlayModuleForImportedModule(const DeclContext *overlayDC,
7373
const DeclContext *importedDC) = 0;
74+
75+
/// Look for declarations associated with the given name.
76+
///
77+
/// \param name The name we're searching for.
78+
virtual void lookupValue(DeclName name, VisibleDeclConsumer &consumer) = 0;
79+
80+
/// Look up a type declaration by its Clang name.
81+
///
82+
/// Note that this method does no filtering. If it finds the type in a loaded
83+
/// module, it returns it. This is intended for use in reflection / debugging
84+
/// contexts where access is not a problem.
85+
virtual void
86+
lookupTypeDecl(StringRef clangName, ClangTypeKind kind,
87+
llvm::function_ref<void(TypeDecl *)> receiver) = 0;
88+
89+
/// Look up type a declaration synthesized by the Clang importer itself, using
90+
/// a "related entity kind" to determine which type it should be. For example,
91+
/// this can be used to find the synthesized error struct for an
92+
/// NS_ERROR_ENUM.
93+
///
94+
/// Note that this method does no filtering. If it finds the type in a loaded
95+
/// module, it returns it. This is intended for use in reflection / debugging
96+
/// contexts where access is not a problem.
97+
virtual void
98+
lookupRelatedEntity(StringRef clangName, ClangTypeKind kind,
99+
StringRef relatedEntityKind,
100+
llvm::function_ref<void(TypeDecl *)> receiver) = 0;
74101
};
75102

76103
} // namespace swift

branches/tensorflow/include/swift/AST/Decl.h

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -456,16 +456,16 @@ class alignas(1 << DeclAlignInBits) Decl {
456456
IsTransparentComputed : 1
457457
);
458458

459-
SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 3+2+1,
459+
SWIFT_INLINE_BITFIELD(ConstructorDecl, AbstractFunctionDecl, 3+1+1,
460460
/// The body initialization kind (+1), or zero if not yet computed.
461461
///
462462
/// This value is cached but is not serialized, because it is a property
463463
/// of the definition of the constructor that is useful only to semantic
464464
/// analysis and SIL generation.
465465
ComputedBodyInitKind : 3,
466466

467-
/// The failability of this initializer, which is an OptionalTypeKind.
468-
Failability : 2,
467+
/// Whether this constructor can fail, by building an Optional type.
468+
Failable : 1,
469469

470470
/// Whether this initializer is a stub placed into a subclass to
471471
/// catch invalid delegations to a designated initializer not
@@ -2412,12 +2412,20 @@ class ValueDecl : public Decl {
24122412
/// Whether this declaration is 'final'. A final class can't be subclassed,
24132413
/// a final class member can't be overriden.
24142414
unsigned isFinal : 1;
2415+
2416+
/// Whether the "isIUO" bit" has been computed yet.
2417+
unsigned isIUOComputed : 1;
2418+
2419+
/// Whether this declaration produces an implicitly unwrapped
2420+
/// optional result.
2421+
unsigned isIUO : 1;
24152422
} LazySemanticInfo = { };
24162423

24172424
friend class OverriddenDeclsRequest;
24182425
friend class IsObjCRequest;
24192426
friend class IsFinalRequest;
24202427
friend class IsDynamicRequest;
2428+
friend class IsImplicitlyUnwrappedOptionalRequest;
24212429

24222430
protected:
24232431
ValueDecl(DeclKind K,
@@ -2686,6 +2694,21 @@ class ValueDecl : public Decl {
26862694
/// Returns true if this decl can be found by id-style dynamic lookup.
26872695
bool canBeAccessedByDynamicLookup() const;
26882696

2697+
/// Returns true if this declaration has an implicitly unwrapped optional
2698+
/// result. The precise meaning depends on the declaration kind:
2699+
/// - for properties, the value is IUO
2700+
/// - for subscripts, the element type is IUO
2701+
/// - for functions, the result type is IUO
2702+
/// - for constructors, the failability kind is IUO
2703+
bool isImplicitlyUnwrappedOptional() const;
2704+
2705+
/// Should only be set on imported and deserialized declarations; parsed
2706+
/// declarations compute this lazily via a request.
2707+
void setImplicitlyUnwrappedOptional(bool isIUO) {
2708+
LazySemanticInfo.isIUOComputed = 1;
2709+
LazySemanticInfo.isIUO = isIUO;
2710+
}
2711+
26892712
/// Returns the protocol requirements that this decl conforms to.
26902713
ArrayRef<ValueDecl *>
26912714
getSatisfiedProtocolRequirements(bool Sorted = false) const;
@@ -3198,19 +3221,6 @@ class AssociatedTypeDecl : public AbstractTypeParamDecl {
31983221

31993222
class MemberLookupTable;
32003223
class ConformanceLookupTable;
3201-
3202-
/// Kinds of optional types.
3203-
enum OptionalTypeKind : unsigned {
3204-
/// The type is not an optional type.
3205-
OTK_None = 0,
3206-
3207-
/// The type is Optional<T>.
3208-
OTK_Optional,
3209-
3210-
/// The type is ImplicitlyUnwrappedOptional<T>.
3211-
OTK_ImplicitlyUnwrappedOptional
3212-
};
3213-
enum { NumOptionalTypeKinds = 2 };
32143224

32153225
// Kinds of pointer types.
32163226
enum PointerTypeKind : unsigned {
@@ -6495,7 +6505,7 @@ class ConstructorDecl : public AbstractFunctionDecl {
64956505

64966506
public:
64976507
ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
6498-
OptionalTypeKind Failability, SourceLoc FailabilityLoc,
6508+
bool Failable, SourceLoc FailabilityLoc,
64996509
bool Throws, SourceLoc ThrowsLoc,
65006510
ParameterList *BodyParams,
65016511
GenericParamList *GenericParams,
@@ -6595,9 +6605,9 @@ class ConstructorDecl : public AbstractFunctionDecl {
65956605
llvm_unreachable("bad CtorInitializerKind");
65966606
}
65976607

6598-
/// Determine the failability of the initializer.
6599-
OptionalTypeKind getFailability() const {
6600-
return static_cast<OptionalTypeKind>(Bits.ConstructorDecl.Failability);
6608+
/// Determine if this is a failable initializer.
6609+
bool isFailable() const {
6610+
return Bits.ConstructorDecl.Failable;
66016611
}
66026612

66036613
/// Retrieve the location of the '!' or '?' in a failable initializer.

branches/tensorflow/include/swift/AST/PrintOptions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ struct PrintOptions {
292292
/// List of attribute kinds that should not be printed.
293293
std::vector<AnyAttrKind> ExcludeAttrList = {DAK_Transparent, DAK_Effects,
294294
DAK_FixedLayout,
295-
DAK_ShowInInterface,
296-
DAK_ImplicitlyUnwrappedOptional};
295+
DAK_ShowInInterface};
297296

298297
/// List of attribute kinds that should be printed exclusively.
299298
/// Empty means allow all.

branches/tensorflow/include/swift/AST/Type.h

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ class Type {
374374
class CanType : public Type {
375375
bool isActuallyCanonicalOrNull() const;
376376

377-
static bool isReferenceTypeImpl(CanType type, bool functionsCount);
377+
static bool isReferenceTypeImpl(CanType type, GenericSignature *sig,
378+
bool functionsCount);
378379
static bool isExistentialTypeImpl(CanType type);
379380
static bool isAnyExistentialTypeImpl(CanType type);
380381
static bool isObjCExistentialTypeImpl(CanType type);
@@ -408,8 +409,26 @@ class CanType : public Type {
408409
// Provide a few optimized accessors that are really type-class queries.
409410

410411
/// Do values of this type have reference semantics?
412+
///
413+
/// This includes isAnyClassReferenceType(), as well as function types.
411414
bool hasReferenceSemantics() const {
412-
return isReferenceTypeImpl(*this, /*functions count*/ true);
415+
return isReferenceTypeImpl(*this,
416+
/*signature*/ nullptr,
417+
/*functions count*/ true);
418+
}
419+
420+
/// Are variables of this type permitted to have
421+
/// ownership attributes?
422+
///
423+
/// This includes:
424+
/// - class types, generic or not
425+
/// - archetypes with class or class protocol bounds
426+
/// - existentials with class or class protocol bounds
427+
/// But not:
428+
/// - function types
429+
bool allowsOwnership(GenericSignature *sig) const {
430+
return isReferenceTypeImpl(*this, sig,
431+
/*functions count*/ false);
413432
}
414433

415434
/// Are values of this type essentially just class references,
@@ -419,10 +438,13 @@ class CanType : public Type {
419438
/// - a class type
420439
/// - a bound generic class type
421440
/// - a class-bounded archetype type
441+
/// - a class-bounded type parameter
422442
/// - a class-bounded existential type
423443
/// - a dynamic Self type
424444
bool isAnyClassReferenceType() const {
425-
return isReferenceTypeImpl(*this, /*functions count*/ false);
445+
return isReferenceTypeImpl(*this,
446+
/*signature*/ nullptr,
447+
/*functions count*/ false);
426448
}
427449

428450
/// Is this type existential?

branches/tensorflow/include/swift/AST/TypeCheckRequests.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,27 @@ class EmittedMembersRequest :
10311031
void cacheResult(DeclRange value) const;
10321032
};
10331033

1034+
class IsImplicitlyUnwrappedOptionalRequest :
1035+
public SimpleRequest<IsImplicitlyUnwrappedOptionalRequest,
1036+
bool(ValueDecl *),
1037+
CacheKind::SeparatelyCached> {
1038+
public:
1039+
using SimpleRequest::SimpleRequest;
1040+
1041+
private:
1042+
friend SimpleRequest;
1043+
1044+
// Evaluation.
1045+
llvm::Expected<bool>
1046+
evaluate(Evaluator &evaluator, ValueDecl *value) const;
1047+
1048+
public:
1049+
// Separate caching.
1050+
bool isCached() const { return true; }
1051+
Optional<bool> getCachedResult() const;
1052+
void cacheResult(bool value) const;
1053+
};
1054+
10341055
// Allow AnyValue to compare two Type values, even though Type doesn't
10351056
// support ==.
10361057
template<>

branches/tensorflow/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ SWIFT_TYPEID(RequiresOpaqueModifyCoroutineRequest)
5555
SWIFT_TYPEID(IsAccessorTransparentRequest)
5656
SWIFT_TYPEID(SynthesizeAccessorRequest)
5757
SWIFT_TYPEID(EmittedMembersRequest)
58+
SWIFT_TYPEID(IsImplicitlyUnwrappedOptionalRequest)

branches/tensorflow/include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
541541

542542
/// allowsOwnership() - Are variables of this type permitted to have
543543
/// ownership attributes?
544-
bool allowsOwnership();
544+
bool allowsOwnership(GenericSignature *sig=nullptr);
545545

546546
/// Determine whether this type involves a type variable.
547547
bool hasTypeVariable() const {

branches/tensorflow/include/swift/ClangImporter/ClangImporter.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ class TypeDecl;
6060
class VisibleDeclConsumer;
6161
enum class SelectorSplitKind;
6262

63+
/// Kinds of optional types.
64+
enum OptionalTypeKind : unsigned {
65+
/// The type is not an optional type.
66+
OTK_None = 0,
67+
68+
/// The type is Optional<T>.
69+
OTK_Optional,
70+
71+
/// The type is ImplicitlyUnwrappedOptional<T>.
72+
OTK_ImplicitlyUnwrappedOptional
73+
};
74+
enum { NumOptionalTypeKinds = 2 };
75+
6376
/// This interface is implemented by LLDB to serve as a fallback when Clang
6477
/// modules can't be imported from source in the debugger.
6578
///
@@ -71,11 +84,13 @@ enum class SelectorSplitKind;
7184
/// Clang AST to ClangImporter to import the type into Swift.
7285
class DWARFImporterDelegate {
7386
public:
74-
virtual ~DWARFImporterDelegate() {}
87+
virtual ~DWARFImporterDelegate() = default;
7588
/// Perform a qualified lookup of a Clang type with this name.
7689
/// \param kind Only return results with this type kind.
7790
virtual void lookupValue(StringRef name, llvm::Optional<ClangTypeKind> kind,
7891
SmallVectorImpl<clang::Decl *> &results) {}
92+
/// vtable anchor.
93+
virtual void anchor();
7994
};
8095

8196
/// Class that imports Clang modules into Swift, mapping directly
@@ -91,7 +106,7 @@ class ClangImporter final : public ClangModuleLoader {
91106

92107
ClangImporter(ASTContext &ctx, const ClangImporterOptions &clangImporterOpts,
93108
DependencyTracker *tracker,
94-
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate);
109+
DWARFImporterDelegate *dwarfImporterDelegate);
95110

96111
ModuleDecl *loadModuleClang(SourceLoc importLoc,
97112
ArrayRef<std::pair<Identifier, SourceLoc>> path);
@@ -117,7 +132,7 @@ class ClangImporter final : public ClangModuleLoader {
117132
static std::unique_ptr<ClangImporter>
118133
create(ASTContext &ctx, const ClangImporterOptions &importerOpts,
119134
std::string swiftPCHHash = "", DependencyTracker *tracker = nullptr,
120-
std::unique_ptr<DWARFImporterDelegate> dwarfImporterDelegate = {});
135+
DWARFImporterDelegate *dwarfImporterDelegate = nullptr);
121136

122137
ClangImporter(const ClangImporter &) = delete;
123138
ClangImporter(ClangImporter &&) = delete;
@@ -172,15 +187,15 @@ class ClangImporter final : public ClangModuleLoader {
172187
/// Look for declarations associated with the given name.
173188
///
174189
/// \param name The name we're searching for.
175-
void lookupValue(DeclName name, VisibleDeclConsumer &consumer);
190+
void lookupValue(DeclName name, VisibleDeclConsumer &consumer) override;
176191

177192
/// Look up a type declaration by its Clang name.
178193
///
179194
/// Note that this method does no filtering. If it finds the type in a loaded
180195
/// module, it returns it. This is intended for use in reflection / debugging
181196
/// contexts where access is not a problem.
182197
void lookupTypeDecl(StringRef clangName, ClangTypeKind kind,
183-
llvm::function_ref<void(TypeDecl *)> receiver);
198+
llvm::function_ref<void(TypeDecl *)> receiver) override;
184199

185200
/// Look up type a declaration synthesized by the Clang importer itself, using
186201
/// a "related entity kind" to determine which type it should be. For example,
@@ -193,7 +208,7 @@ class ClangImporter final : public ClangModuleLoader {
193208
void
194209
lookupRelatedEntity(StringRef clangName, ClangTypeKind kind,
195210
StringRef relatedEntityKind,
196-
llvm::function_ref<void(TypeDecl *)> receiver);
211+
llvm::function_ref<void(TypeDecl *)> receiver) override;
197212

198213
/// Look for textually included declarations from the bridging header.
199214
///

branches/tensorflow/include/swift/Parse/Parser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,6 @@ class Parser {
10191019
ParserStatus parseGetSet(ParseDeclOptions Flags,
10201020
GenericParamList *GenericParams,
10211021
ParameterList *Indices,
1022-
TypeLoc ElementTy,
10231022
ParsedAccessors &accessors,
10241023
AbstractStorageDecl *storage,
10251024
SourceLoc StaticLoc);

0 commit comments

Comments
 (0)