Skip to content

Commit 3236d2d

Browse files
committed
Merge branch 'master_6' into tensorflow-merge
2 parents c8c7c1f + 7063ecd commit 3236d2d

File tree

90 files changed

+760
-928
lines changed

Some content is hidden

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

90 files changed

+760
-928
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
129129
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
130130
# can be reused when a new version of Swift comes out (assuming the user hasn't
131131
# manually set it as part of their own CMake configuration).
132-
set(SWIFT_VERSION "5.1")
132+
set(SWIFT_VERSION "5.1.1")
133133

134134
set(SWIFT_VENDOR "" CACHE STRING
135135
"The vendor name of the Swift compiler")

include/swift/ABI/Metadata.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,6 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
998998
using StoredPointer = typename Runtime::StoredPointer;
999999
using StoredSize = typename Runtime::StoredSize;
10001000

1001-
friend class ReflectionContext;
1002-
10031001
TargetClassMetadata() = default;
10041002
constexpr TargetClassMetadata(const TargetAnyClassMetadata<Runtime> &base,
10051003
ClassFlags flags,

include/swift/AST/ASTDemangler.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ class ASTBuilder {
5858
using BuiltTypeDecl = swift::GenericTypeDecl *; // nominal or type alias
5959
using BuiltProtocolDecl = swift::ProtocolDecl *;
6060
explicit ASTBuilder(ASTContext &ctx) : Ctx(ctx) {}
61-
62-
/// The resolver to use for type checking, if necessary.
63-
LazyResolver *Resolver = nullptr;
6461

6562
ASTContext &getASTContext() { return Ctx; }
6663
DeclContext *getNotionalDC();

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SWIFT_TYPEID_NAMED(InfixOperatorDecl *, InfixOperatorDecl)
3333
SWIFT_TYPEID_NAMED(IterableDeclContext *, IterableDeclContext)
3434
SWIFT_TYPEID_NAMED(ModuleDecl *, ModuleDecl)
3535
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
36+
SWIFT_TYPEID_NAMED(OpaqueTypeDecl *, OpaqueTypeDecl)
3637
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
3738
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>,
3839
PropertyWrapperMutability)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class IterableDeclContext;
3434
class ModuleDecl;
3535
class NominalTypeDecl;
3636
class OperatorDecl;
37+
class OpaqueTypeDecl;
3738
class PrecedenceGroupDecl;
3839
struct PropertyWrapperBackingPropertyInfo;
3940
struct PropertyWrapperTypeInfo;

include/swift/AST/AnyRequest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class AnyRequest {
5454
friend llvm::DenseMapInfo<swift::AnyRequest>;
5555

5656
static hash_code hashForHolder(uint64_t typeID, hash_code requestHash) {
57-
return hash_combine(hash_value(typeID), requestHash);
57+
return hash_combine(typeID, requestHash);
5858
}
5959

6060
/// Abstract base class used to hold the specific request kind.

include/swift/AST/Decl.h

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,7 @@ class alignas(1 << DeclAlignInBits) Decl {
340340
IsUserAccessible : 1
341341
);
342342

343-
SWIFT_INLINE_BITFIELD(AbstractStorageDecl, ValueDecl, 1+1+1,
344-
/// Whether a keypath component can directly reference this storage,
345-
/// or if it must use the overridden declaration instead.
346-
HasComputedValidKeyPathComponent : 1,
347-
ValidKeyPathComponent : 1,
348-
343+
SWIFT_INLINE_BITFIELD(AbstractStorageDecl, ValueDecl, 1,
349344
/// Whether this property is a type property (currently unfortunately
350345
/// called 'static').
351346
IsStatic : 1
@@ -2769,12 +2764,6 @@ class ValueDecl : public Decl {
27692764
/// Get the representative for this value's opaque result type, if it has one.
27702765
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr() const;
27712766

2772-
/// Set the opaque return type decl for this decl.
2773-
///
2774-
/// `this` must be of a decl type that supports opaque return types, and
2775-
/// must not have previously had an opaque result type set.
2776-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *D);
2777-
27782767
/// Retrieve the attribute associating this declaration with a
27792768
/// function builder, if there is one.
27802769
CustomAttr *getAttachedFunctionBuilder() const;
@@ -4559,10 +4548,6 @@ class AbstractStorageDecl : public ValueDecl {
45594548
Bits.AbstractStorageDecl.IsStatic = IsStatic;
45604549
}
45614550

4562-
void computeIsValidKeyPathComponent();
4563-
4564-
OpaqueTypeDecl *OpaqueReturn = nullptr;
4565-
45664551
public:
45674552

45684553
/// Should this declaration be treated as if annotated with transparent
@@ -4803,18 +4788,9 @@ class AbstractStorageDecl : public ValueDecl {
48034788
/// property from the given module?
48044789
bool isResilient(ModuleDecl *M, ResilienceExpansion expansion) const;
48054790

4806-
void setIsValidKeyPathComponent(bool value) {
4807-
Bits.AbstractStorageDecl.HasComputedValidKeyPathComponent = true;
4808-
Bits.AbstractStorageDecl.ValidKeyPathComponent = value;
4809-
}
4810-
48114791
/// True if the storage can be referenced by a keypath directly.
48124792
/// Otherwise, its override must be referenced.
4813-
bool isValidKeyPathComponent() const {
4814-
if (!Bits.AbstractStorageDecl.HasComputedValidKeyPathComponent)
4815-
const_cast<AbstractStorageDecl *>(this)->computeIsValidKeyPathComponent();
4816-
return Bits.AbstractStorageDecl.ValidKeyPathComponent;
4817-
}
4793+
bool isValidKeyPathComponent() const;
48184794

48194795
/// True if the storage exports a property descriptor for key paths in
48204796
/// other modules.
@@ -4829,14 +4805,6 @@ class AbstractStorageDecl : public ValueDecl {
48294805

48304806
bool hasAnyDynamicReplacementAccessors() const;
48314807

4832-
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
4833-
return OpaqueReturn;
4834-
}
4835-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
4836-
assert(!OpaqueReturn && "already has opaque type decl");
4837-
OpaqueReturn = decl;
4838-
}
4839-
48404808
// Implement isa/cast/dyncast/etc.
48414809
static bool classof(const Decl *D) {
48424810
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&
@@ -6022,8 +5990,6 @@ class FuncDecl : public AbstractFunctionDecl {
60225990

60235991
TypeLoc FnRetType;
60245992

6025-
OpaqueTypeDecl *OpaqueReturn = nullptr;
6026-
60275993
protected:
60285994
FuncDecl(DeclKind Kind,
60295995
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -6172,15 +6138,7 @@ class FuncDecl : public AbstractFunctionDecl {
61726138
}
61736139

61746140
OperatorDecl *getOperatorDecl() const;
6175-
6176-
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
6177-
return OpaqueReturn;
6178-
}
6179-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
6180-
assert(!OpaqueReturn && "already has opaque type decl");
6181-
OpaqueReturn = decl;
6182-
}
6183-
6141+
61846142
/// Returns true if the function is forced to be statically dispatched.
61856143
bool hasForcedStaticDispatch() const {
61866144
return Bits.FuncDecl.ForcedStaticDispatch;

include/swift/AST/FileUnit.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ class FileUnit : public DeclContext {
6060

6161
/// Look up an opaque return type by the mangled name of the declaration
6262
/// that defines it.
63-
virtual OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName,
64-
LazyResolver *resolver) {
63+
virtual OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) {
6564
return nullptr;
6665
}
6766

include/swift/AST/Module.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ class ModuleDecl : public DeclContext, public TypeDecl {
354354

355355
/// Look up an opaque return type by the mangled name of the declaration
356356
/// that defines it.
357-
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName,
358-
LazyResolver *resolver);
357+
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName);
359358

360359
/// Find ValueDecls in the module and pass them to the given consumer object.
361360
///

include/swift/AST/SearchPathOptions.h

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef SWIFT_AST_SEARCHPATHOPTIONS_H
1414
#define SWIFT_AST_SEARCHPATHOPTIONS_H
1515

16+
#include "swift/Basic/ArrayRefView.h"
1617
#include "llvm/ADT/Hashing.h"
1718

1819
#include <string>
@@ -81,30 +82,38 @@ class SearchPathOptions {
8182
/// would for a non-system header.
8283
bool DisableModulesValidateSystemDependencies = false;
8384

85+
private:
86+
static StringRef
87+
pathStringFromFrameworkSearchPath(const FrameworkSearchPath &next) {
88+
return next.Path;
89+
};
90+
91+
public:
8492
/// Return a hash code of any components from these options that should
8593
/// contribute to a Swift Bridging PCH hash.
8694
llvm::hash_code getPCHHashComponents() const {
87-
using llvm::hash_value;
8895
using llvm::hash_combine;
89-
auto Code = hash_value(SDKPath);
90-
for (auto Import : ImportSearchPaths) {
91-
Code = hash_combine(Code, Import);
92-
}
93-
for (auto VFSFile : VFSOverlayFiles) {
94-
Code = hash_combine(Code, VFSFile);
95-
}
96-
for (const auto &FrameworkPath : FrameworkSearchPaths) {
97-
Code = hash_combine(Code, FrameworkPath.Path);
98-
}
99-
for (auto LibraryPath : LibrarySearchPaths) {
100-
Code = hash_combine(Code, LibraryPath);
101-
}
102-
Code = hash_combine(Code, RuntimeResourcePath);
103-
for (auto RuntimeLibraryImportPath : RuntimeLibraryImportPaths) {
104-
Code = hash_combine(Code, RuntimeLibraryImportPath);
105-
}
106-
Code = hash_combine(Code, DisableModulesValidateSystemDependencies);
107-
return Code;
96+
using llvm::hash_combine_range;
97+
98+
using FrameworkPathView = ArrayRefView<FrameworkSearchPath, StringRef,
99+
pathStringFromFrameworkSearchPath>;
100+
FrameworkPathView frameworkPathsOnly{FrameworkSearchPaths};
101+
102+
return hash_combine(SDKPath,
103+
hash_combine_range(ImportSearchPaths.begin(),
104+
ImportSearchPaths.end()),
105+
hash_combine_range(VFSOverlayFiles.begin(),
106+
VFSOverlayFiles.end()),
107+
// FIXME: Should we include the system-ness of framework
108+
// search paths too?
109+
hash_combine_range(frameworkPathsOnly.begin(),
110+
frameworkPathsOnly.end()),
111+
hash_combine_range(LibrarySearchPaths.begin(),
112+
LibrarySearchPaths.end()),
113+
RuntimeResourcePath,
114+
hash_combine_range(RuntimeLibraryImportPaths.begin(),
115+
RuntimeLibraryImportPaths.end()),
116+
DisableModulesValidateSystemDependencies);
108117
}
109118
};
110119

include/swift/AST/SourceFile.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ class SourceFile final : public FileUnit {
117117
/// The scope map that describes this source file.
118118
std::unique_ptr<ASTScope> Scope;
119119

120+
/// The set of validated opaque return type decls in the source file.
121+
llvm::SmallVector<OpaqueTypeDecl *, 4> OpaqueReturnTypes;
122+
llvm::StringMap<OpaqueTypeDecl *> ValidatedOpaqueReturnTypes;
123+
/// The set of parsed decls with opaque return types that have not yet
124+
/// been validated.
125+
llvm::SetVector<ValueDecl *> UnvalidatedDeclsWithOpaqueReturnTypes;
126+
120127
friend ASTContext;
121128
friend Impl;
122129
public:
@@ -130,13 +137,6 @@ class SourceFile final : public FileUnit {
130137
/// The list of local type declarations in the source file.
131138
llvm::SetVector<TypeDecl *> LocalTypeDecls;
132139

133-
/// The set of validated opaque return type decls in the source file.
134-
llvm::SmallVector<OpaqueTypeDecl *, 4> OpaqueReturnTypes;
135-
llvm::StringMap<OpaqueTypeDecl *> ValidatedOpaqueReturnTypes;
136-
/// The set of parsed decls with opaque return types that have not yet
137-
/// been validated.
138-
llvm::DenseSet<ValueDecl *> UnvalidatedDeclsWithOpaqueReturnTypes;
139-
140140
/// A set of special declaration attributes which require the
141141
/// Foundation module to be imported to work. If the foundation
142142
/// module is still not imported by the time type checking is
@@ -433,14 +433,13 @@ class SourceFile final : public FileUnit {
433433
void setSyntaxRoot(syntax::SourceFileSyntax &&Root);
434434
bool hasSyntaxRoot() const;
435435

436-
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName,
437-
LazyResolver *resolver) override;
436+
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName) override;
438437

439438
void addUnvalidatedDeclWithOpaqueResultType(ValueDecl *vd) {
440439
UnvalidatedDeclsWithOpaqueReturnTypes.insert(vd);
441440
}
442441

443-
void markDeclWithOpaqueResultTypeAsValidated(ValueDecl *vd);
442+
ArrayRef<OpaqueTypeDecl *> getOpaqueReturnTypeDecls();
444443

445444
private:
446445

include/swift/AST/TypeCheckRequests.h

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,7 @@ struct WhereClauseOwner {
387387
SourceLoc getLoc() const;
388388

389389
friend hash_code hash_value(const WhereClauseOwner &owner) {
390-
return hash_combine(hash_value(owner.dc),
391-
hash_value(owner.source.getOpaqueValue()));
390+
return llvm::hash_combine(owner.dc, owner.source.getOpaqueValue());
392391
}
393392

394393
friend bool operator==(const WhereClauseOwner &lhs,
@@ -1196,7 +1195,7 @@ class GenericSignatureRequest :
11961195
void cacheResult(GenericSignature value) const;
11971196
};
11981197

1199-
/// Compute the interface type of the underlying definition type of a typealias declaration.
1198+
/// Compute the underlying interface type of a typealias.
12001199
class UnderlyingTypeRequest :
12011200
public SimpleRequest<UnderlyingTypeRequest,
12021201
Type(TypeAliasDecl *),
@@ -1216,8 +1215,10 @@ class UnderlyingTypeRequest :
12161215
bool isCached() const { return true; }
12171216
Optional<Type> getCachedResult() const;
12181217
void cacheResult(Type value) const;
1218+
void diagnoseCycle(DiagnosticEngine &diags) const;
12191219
};
12201220

1221+
/// Looks up the precedence group of an operator declaration.
12211222
class OperatorPrecedenceGroupRequest
12221223
: public SimpleRequest<OperatorPrecedenceGroupRequest,
12231224
PrecedenceGroupDecl *(InfixOperatorDecl *),
@@ -1262,6 +1263,42 @@ class EnumRawValuesRequest :
12621263
void cacheResult(bool value) const;
12631264
};
12641265

1266+
class IsABICompatibleOverrideRequest
1267+
: public SimpleRequest<IsABICompatibleOverrideRequest, bool(ValueDecl *),
1268+
CacheKind::Cached> {
1269+
public:
1270+
using SimpleRequest::SimpleRequest;
1271+
1272+
private:
1273+
friend SimpleRequest;
1274+
1275+
// Evaluation.
1276+
llvm::Expected<bool> evaluate(Evaluator &evaluator, ValueDecl *decl) const;
1277+
1278+
public:
1279+
// Caching.
1280+
bool isCached() const { return true; }
1281+
};
1282+
1283+
/// Builds an opaque result type for a declaration.
1284+
class OpaqueResultTypeRequest
1285+
: public SimpleRequest<OpaqueResultTypeRequest,
1286+
OpaqueTypeDecl *(ValueDecl *),
1287+
CacheKind::Cached> {
1288+
public:
1289+
using SimpleRequest::SimpleRequest;
1290+
1291+
private:
1292+
friend SimpleRequest;
1293+
1294+
llvm::Expected<OpaqueTypeDecl *>
1295+
evaluate(Evaluator &evaluator, ValueDecl *VD) const;
1296+
1297+
public:
1298+
// Caching.
1299+
bool isCached() const { return true; }
1300+
};
1301+
12651302
// Allow AnyValue to compare two Type values, even though Type doesn't
12661303
// support ==.
12671304
template<>

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ SWIFT_REQUEST(TypeChecker, MangleLocalTypeDeclRequest,
8888
SWIFT_REQUEST(TypeChecker, OpaqueReadOwnershipRequest,
8989
OpaqueReadOwnership(AbstractStorageDecl *), SeparatelyCached,
9090
NoLocationInfo)
91+
SWIFT_REQUEST(TypeChecker, OpaqueResultTypeRequest,
92+
OpaqueTypeDecl *(ValueDecl *),
93+
Cached, NoLocationInfo)
9194
SWIFT_REQUEST(TypeChecker, OperatorPrecedenceGroupRequest,
9295
PrecedenceGroupDecl *(PrecedenceGroupDecl *),
9396
Cached, NoLocationInfo)
@@ -142,3 +145,5 @@ SWIFT_REQUEST(TypeChecker, UnderlyingTypeRequest, Type(TypeAliasDecl *),
142145
SeparatelyCached, NoLocationInfo)
143146
SWIFT_REQUEST(TypeChecker, USRGenerationRequest, std::string(const ValueDecl *),
144147
Cached, NoLocationInfo)
148+
SWIFT_REQUEST(TypeChecker, IsABICompatibleOverrideRequest,
149+
bool(ValueDecl *), Cached, NoLocationInfo)

include/swift/AST/TypeLoc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ struct TypeLoc {
6868
TypeLoc clone(ASTContext &ctx) const;
6969

7070
friend llvm::hash_code hash_value(const TypeLoc &owner) {
71-
return hash_combine(llvm::hash_value(owner.Ty.getPointer()),
72-
llvm::hash_value(owner.TyR));
71+
return llvm::hash_combine(owner.Ty.getPointer(), owner.TyR);
7372
}
7473

7574
friend bool operator==(const TypeLoc &lhs,

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,10 @@ namespace swift {
452452
/// Return a hash code of any components from these options that should
453453
/// contribute to a Swift Bridging PCH hash.
454454
llvm::hash_code getPCHHashComponents() const {
455-
auto code = llvm::hash_value(Target.str());
456455
SmallString<16> Scratch;
457456
llvm::raw_svector_ostream OS(Scratch);
458457
OS << EffectiveLanguageVersion;
459-
code = llvm::hash_combine(code, OS.str());
460-
return code;
458+
return llvm::hash_combine(Target.str(), OS.str());
461459
}
462460

463461
private:

0 commit comments

Comments
 (0)