Skip to content

Commit 88e9eda

Browse files
authored
---
yaml --- r: 327151 b: refs/heads/tensorflow c: b8f42d6 h: refs/heads/master i: 327149: 33616ea 327147: ce09a57 327143: 243a976 327135: 79fc198
1 parent fc4bfb5 commit 88e9eda

File tree

164 files changed

+5892
-5580
lines changed

Some content is hidden

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

164 files changed

+5892
-5580
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: 931ab4633be4c51e5520107ce8cabec260c24297
819+
refs/heads/tensorflow: b8f42d6165ac71fa619aa55877a8bcf03178cbc0
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/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ function(_compile_swift_files
229229
# The standard library and overlays are always built resiliently.
230230
if(SWIFTFILE_IS_STDLIB)
231231
list(APPEND swift_flags "-enable-library-evolution")
232+
list(APPEND swift_flags "-Xfrontend" "-enable-ownership-stripping-after-serialization")
232233
endif()
233234

234235
if(SWIFT_STDLIB_USE_NONATOMIC_RC)

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ namespace swift {
112112

113113
enum class KnownProtocolKind : uint8_t;
114114

115+
namespace namelookup {
116+
class ImportCache;
117+
}
118+
115119
namespace syntax {
116120
class SyntaxArena;
117121
}
@@ -683,7 +687,9 @@ class ASTContext final {
683687
/// If there is no Clang module loader, returns a null pointer.
684688
/// The loader is owned by the AST context.
685689
ClangModuleLoader *getDWARFModuleLoader() const;
686-
690+
691+
namelookup::ImportCache &getImportCache() const;
692+
687693
/// Asks every module loader to verify the ASTs it has loaded.
688694
///
689695
/// Does nothing in non-asserts (NDEBUG) builds.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ SWIFT_TYPEID(CtorInitializerKind)
2727
SWIFT_TYPEID(ResilienceExpansion)
2828
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>, PropertyWrapperMutability)
2929
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
30+
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
3031
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)
3132
SWIFT_TYPEID(AncestryFlags)
3233
SWIFT_TYPEID_NAMED(GenericSignature *, GenericSignature)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ class Type;
3636
struct TypePair;
3737
enum class AncestryFlags : uint8_t;
3838

39-
#define SWIFT_AST_TYPEID_ZONE 1
40-
4139
// Define the AST type zone (zone 1)
42-
#define SWIFT_TYPEID_ZONE SWIFT_AST_TYPEID_ZONE
40+
#define SWIFT_TYPEID_ZONE AST
4341
#define SWIFT_TYPEID_HEADER "swift/AST/ASTTypeIDZone.def"
4442
#include "swift/Basic/DefineTypeIDZone.h"
4543

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,21 @@ class DefaultAndMaxAccessLevelRequest :
9797
void cacheResult(DefaultAndMax value) const;
9898
};
9999

100-
/// The zone number for access-control requests.
101-
#define SWIFT_ACCESS_REQUESTS_TYPEID_ZONE 11
102-
103-
#define SWIFT_TYPEID_ZONE SWIFT_ACCESS_REQUESTS_TYPEID_ZONE
100+
#define SWIFT_TYPEID_ZONE AccessControl
104101
#define SWIFT_TYPEID_HEADER "swift/AST/AccessTypeIDZone.def"
105102
#include "swift/Basic/DefineTypeIDZone.h"
106103
#undef SWIFT_TYPEID_ZONE
107104
#undef SWIFT_TYPEID_HEADER
108105

109106
// Set up reporting of evaluated requests.
110-
#define SWIFT_TYPEID(RequestType) \
107+
#define SWIFT_REQUEST(Zone, RequestType) \
111108
template<> \
112109
inline void reportEvaluatedRequest(UnifiedStatsReporter &stats, \
113110
const RequestType &request) { \
114111
++stats.getFrontendCounters().RequestType; \
115112
}
116113
#include "swift/AST/AccessTypeIDZone.def"
117-
#undef SWIFT_TYPEID
114+
#undef SWIFT_REQUEST
118115

119116
} // end namespace swift
120117

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// TypeID zone, for use with the TypeID template.
1515
//
1616
//===----------------------------------------------------------------------===//
17-
SWIFT_TYPEID(AccessLevelRequest)
18-
SWIFT_TYPEID(SetterAccessLevelRequest)
19-
SWIFT_TYPEID(DefaultAndMaxAccessLevelRequest)
17+
18+
SWIFT_REQUEST(AccessControl, AccessLevelRequest)
19+
SWIFT_REQUEST(AccessControl, DefaultAndMaxAccessLevelRequest)
20+
SWIFT_REQUEST(AccessControl, SetterAccessLevelRequest)

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5926,7 +5926,6 @@ class FuncDecl : public AbstractFunctionDecl {
59265926

59275927
TypeLoc FnRetType;
59285928

5929-
OperatorDecl *Operator = nullptr;
59305929
OpaqueTypeDecl *OpaqueReturn = nullptr;
59315930

59325931
protected:
@@ -6073,13 +6072,7 @@ class FuncDecl : public AbstractFunctionDecl {
60736072
return cast_or_null<FuncDecl>(AbstractFunctionDecl::getOverriddenDecl());
60746073
}
60756074

6076-
OperatorDecl *getOperatorDecl() const {
6077-
return Operator;
6078-
}
6079-
void setOperatorDecl(OperatorDecl *o) {
6080-
assert(isOperator() && "can't set an OperatorDecl for a non-operator");
6081-
Operator = o;
6082-
}
6075+
OperatorDecl *getOperatorDecl() const;
60836076

60846077
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
60856078
return OpaqueReturn;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ ERROR(decl_new_witness_table_entry,none,"%0 now requires %select{|no}1 new witne
9696

9797
ERROR(new_decl_without_intro,none,"%0 is a new API without @available attribute", (StringRef))
9898

99+
ERROR(objc_name_change,none,"%0 has ObjC name change from %1 to %2", (StringRef, StringRef, StringRef))
100+
99101
#ifndef DIAG_NO_UNDEF
100102
# if defined(DIAG)
101103
# undef DIAG

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class Evaluator {
249249
///
250250
/// These functions will be called to evaluate any requests within that
251251
/// zone.
252-
void registerRequestFunctions(uint8_t zoneID,
252+
void registerRequestFunctions(Zone zone,
253253
ArrayRef<AbstractRequestFunction *> functions);
254254

255255
/// Evaluate the given request and produce its result,
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
//===--- ImportCache.h - Caching the import graph ---------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines interfaces for querying the module import graph in an
14+
// efficient manner.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_AST_IMPORT_CACHE_H
19+
#define SWIFT_AST_IMPORT_CACHE_H
20+
21+
#include "swift/AST/Module.h"
22+
#include "llvm/ADT/DenseMap.h"
23+
#include "llvm/ADT/FoldingSet.h"
24+
25+
namespace swift {
26+
class DeclContext;
27+
28+
namespace namelookup {
29+
30+
/// An object describing a set of modules visible from a DeclContext.
31+
///
32+
/// This consists of two arrays of modules; the top-level imports and the
33+
/// transitive imports.
34+
///
35+
/// The top-level imports contains all public imports of the parent module
36+
/// of 'dc', together with any private imports in the source file containing
37+
/// 'dc', if there is one.
38+
///
39+
/// The transitive imports contains all public imports reachable from the
40+
/// set of top-level imports.
41+
///
42+
/// Both sets only contain unique elements. The top-level imports always
43+
/// include the parent module of 'dc' explicitly.
44+
///
45+
/// The set of transitive imports does not contain any elements found in
46+
/// the top-level imports.
47+
///
48+
/// The Swift standard library module is not included in either set unless
49+
/// it was explicitly imported (or re-exported).
50+
class ImportSet final :
51+
public llvm::FoldingSetNode,
52+
private llvm::TrailingObjects<ImportSet, ModuleDecl::ImportedModule> {
53+
friend TrailingObjects;
54+
friend ImportCache;
55+
56+
unsigned NumTopLevelImports;
57+
unsigned NumTransitiveImports;
58+
59+
ImportSet(ArrayRef<ModuleDecl::ImportedModule> topLevelImports,
60+
ArrayRef<ModuleDecl::ImportedModule> transitiveImports);
61+
62+
ImportSet(const ImportSet &) = delete;
63+
void operator=(const ImportSet &) = delete;
64+
65+
public:
66+
void Profile(llvm::FoldingSetNodeID &ID) {
67+
Profile(ID, getTopLevelImports());
68+
}
69+
static void Profile(
70+
llvm::FoldingSetNodeID &ID,
71+
ArrayRef<ModuleDecl::ImportedModule> topLevelImports);
72+
73+
size_t numTrailingObjects(OverloadToken<ModuleDecl::ImportedModule>) const {
74+
return NumTopLevelImports + NumTransitiveImports;
75+
}
76+
77+
ArrayRef<ModuleDecl::ImportedModule> getTopLevelImports() const {
78+
return {getTrailingObjects<ModuleDecl::ImportedModule>(),
79+
NumTopLevelImports};
80+
}
81+
82+
ArrayRef<ModuleDecl::ImportedModule> getTransitiveImports() const {
83+
return {getTrailingObjects<ModuleDecl::ImportedModule>() +
84+
NumTopLevelImports,
85+
NumTransitiveImports};
86+
}
87+
88+
ArrayRef<ModuleDecl::ImportedModule> getAllImports() const {
89+
return {getTrailingObjects<ModuleDecl::ImportedModule>(),
90+
NumTopLevelImports + NumTransitiveImports};
91+
}
92+
};
93+
94+
class alignas(ModuleDecl::ImportedModule) ImportCache {
95+
ImportCache(const ImportCache &) = delete;
96+
void operator=(const ImportCache &) = delete;
97+
98+
llvm::FoldingSet<ImportSet> ImportSets;
99+
llvm::DenseMap<const DeclContext *, ImportSet *> ImportSetForDC;
100+
llvm::DenseMap<std::tuple<const ModuleDecl *,
101+
const DeclContext *>,
102+
ArrayRef<ModuleDecl::AccessPathTy>> VisibilityCache;
103+
llvm::DenseMap<std::tuple<const ModuleDecl *,
104+
const ModuleDecl *,
105+
const DeclContext *>,
106+
ArrayRef<ModuleDecl::AccessPathTy>> ShadowCache;
107+
108+
ModuleDecl::AccessPathTy EmptyAccessPath;
109+
110+
ArrayRef<ModuleDecl::AccessPathTy> allocateArray(
111+
ASTContext &ctx,
112+
SmallVectorImpl<ModuleDecl::AccessPathTy> &results);
113+
114+
ImportSet &getImportSet(ASTContext &ctx,
115+
ArrayRef<ModuleDecl::ImportedModule> topLevelImports);
116+
117+
public:
118+
ImportCache() {}
119+
120+
/// Returns an object descripting all modules transtiively imported
121+
/// from 'dc'.
122+
ImportSet &getImportSet(const DeclContext *dc);
123+
124+
/// Returns all access paths into 'mod' that are visible from 'dc',
125+
/// including transitively, via re-exports.
126+
ArrayRef<ModuleDecl::AccessPathTy>
127+
getAllVisibleAccessPaths(const ModuleDecl *mod, const DeclContext *dc);
128+
129+
bool isImportedBy(const ModuleDecl *mod,
130+
const DeclContext *dc) {
131+
return !getAllVisibleAccessPaths(mod, dc).empty();
132+
}
133+
134+
/// Determines if 'mod' is visible from 'dc' as a result of a scoped import.
135+
/// Note that if 'mod' was not imported from 'dc' at all, this also returns
136+
/// false.
137+
bool isScopedImport(const ModuleDecl *mod, DeclBaseName name,
138+
const DeclContext *dc) {
139+
auto accessPaths = getAllVisibleAccessPaths(mod, dc);
140+
for (auto accessPath : accessPaths) {
141+
if (accessPath.empty())
142+
continue;
143+
if (ModuleDecl::matchesAccessPath(accessPath, name))
144+
return true;
145+
}
146+
147+
return false;
148+
}
149+
150+
/// Returns all access paths in 'mod' that are visible from 'dc' if we
151+
/// subtract imports of 'other'.
152+
ArrayRef<ModuleDecl::AccessPathTy>
153+
getAllAccessPathsNotShadowedBy(const ModuleDecl *mod,
154+
const ModuleDecl *other,
155+
const DeclContext *dc);
156+
157+
/// Returns 'true' if a declaration named 'name' defined in 'other' shadows
158+
/// defined in 'mod', because no access paths can find 'name' in 'mod' from
159+
/// 'dc' if we ignore imports of 'other'.
160+
bool isShadowedBy(const ModuleDecl *mod,
161+
const ModuleDecl *other,
162+
DeclBaseName name,
163+
const DeclContext *dc) {
164+
auto accessPaths = getAllAccessPathsNotShadowedBy(mod, other, dc);
165+
return llvm::none_of(accessPaths,
166+
[&](ModuleDecl::AccessPathTy accessPath) {
167+
return ModuleDecl::matchesAccessPath(accessPath, name);
168+
});
169+
}
170+
171+
/// Qualified lookup into types uses a slightly different check that does not
172+
/// take access paths into account.
173+
bool isShadowedBy(const ModuleDecl *mod,
174+
const ModuleDecl *other,
175+
const DeclContext *dc) {
176+
auto accessPaths = getAllAccessPathsNotShadowedBy(mod, other, dc);
177+
return accessPaths.empty();
178+
}
179+
180+
/// This is a hack to cope with main file parsing and REPL parsing, where
181+
/// we can add ImportDecls after name binding.
182+
void clear() {
183+
ImportSetForDC.clear();
184+
}
185+
};
186+
187+
} // namespace namelookup
188+
189+
} // namespace swift
190+
191+
#endif

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,11 @@ bool removeOverriddenDecls(SmallVectorImpl<ValueDecl*> &decls);
378378
/// other declarations in that set.
379379
///
380380
/// \param decls The set of declarations being considered.
381-
/// \param curModule The current module.
381+
/// \param dc The DeclContext from which the lookup was performed.
382382
///
383383
/// \returns true if any shadowed declarations were removed.
384384
bool removeShadowedDecls(SmallVectorImpl<ValueDecl*> &decls,
385-
const ModuleDecl *curModule);
385+
const DeclContext *dc);
386386

387387
/// Finds decls visible in the given context and feeds them to the given
388388
/// VisibleDeclConsumer. If the current DeclContext is nested in a function,

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,7 @@ class GetDestructorRequest :
254254
void cacheResult(DestructorDecl *value) const;
255255
};
256256

257-
/// The zone number for name-lookup requests.
258-
#define SWIFT_NAME_LOOKUP_REQUESTS_TYPEID_ZONE 9
259-
260-
#define SWIFT_TYPEID_ZONE SWIFT_NAME_LOOKUP_REQUESTS_TYPEID_ZONE
257+
#define SWIFT_TYPEID_ZONE NameLookup
261258
#define SWIFT_TYPEID_HEADER "swift/AST/NameLookupTypeIDZone.def"
262259
#include "swift/Basic/DefineTypeIDZone.h"
263260
#undef SWIFT_TYPEID_ZONE
@@ -268,14 +265,14 @@ template<typename Request>
268265
void reportEvaluatedRequest(UnifiedStatsReporter &stats,
269266
const Request &request);
270267

271-
#define SWIFT_TYPEID(RequestType) \
268+
#define SWIFT_REQUEST(Zone, RequestType) \
272269
template<> \
273270
inline void reportEvaluatedRequest(UnifiedStatsReporter &stats, \
274271
const RequestType &request) { \
275272
++stats.getFrontendCounters().RequestType; \
276273
}
277274
#include "swift/AST/NameLookupTypeIDZone.def"
278-
#undef SWIFT_TYPEID
275+
#undef SWIFT_REQUEST
279276

280277
} // end namespace swift
281278

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
// TypeID zone, for use with the TypeID template.
1515
//
1616
//===----------------------------------------------------------------------===//
17-
SWIFT_TYPEID(InheritedDeclsReferencedRequest)
18-
SWIFT_TYPEID(UnderlyingTypeDeclsReferencedRequest)
19-
SWIFT_TYPEID(SuperclassDeclRequest)
20-
SWIFT_TYPEID(ExtendedNominalRequest)
21-
SWIFT_TYPEID(SelfBoundsFromWhereClauseRequest)
22-
SWIFT_TYPEID(TypeDeclsFromWhereClauseRequest)
23-
SWIFT_TYPEID(CustomAttrNominalRequest)
24-
SWIFT_TYPEID(GetDestructorRequest)
17+
18+
SWIFT_REQUEST(NameLookup, CustomAttrNominalRequest)
19+
SWIFT_REQUEST(NameLookup, ExtendedNominalRequest)
20+
SWIFT_REQUEST(NameLookup, GetDestructorRequest)
21+
SWIFT_REQUEST(NameLookup, InheritedDeclsReferencedRequest)
22+
SWIFT_REQUEST(NameLookup, SelfBoundsFromWhereClauseRequest)
23+
SWIFT_REQUEST(NameLookup, SuperclassDeclRequest)
24+
SWIFT_REQUEST(NameLookup, TypeDeclsFromWhereClauseRequest)
25+
SWIFT_REQUEST(NameLookup, UnderlyingTypeDeclsReferencedRequest)
26+

0 commit comments

Comments
 (0)