Skip to content

Commit 14b6bf4

Browse files
---
yaml --- r: 335583 b: refs/heads/rxwei-patch-1 c: 2ebd24b h: refs/heads/master i: 335581: c8bfa17 335579: 7bbbf30 335575: 18d484e 335567: 02f96a0 335551: da831c1
1 parent e793df8 commit 14b6bf4

File tree

72 files changed

+2007
-818
lines changed

Some content is hidden

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

72 files changed

+2007
-818
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: d2631c2cec78b0445771725824a924155911fc5d
1018+
refs/heads/rxwei-patch-1: 2ebd24bb9fe270e75277a7948fdf4fdc0c8d6a60
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/cmake/modules/AddSwift.cmake

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ function(_add_swift_library_single target name)
721721
FILE_DEPENDS
722722
FRAMEWORK_DEPENDS
723723
FRAMEWORK_DEPENDS_WEAK
724+
GYB_SOURCES
724725
INCORPORATE_OBJECT_LIBRARIES
725726
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
726727
INTERFACE_LINK_LIBRARIES
@@ -810,10 +811,14 @@ function(_add_swift_library_single target name)
810811
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
811812
endif()
812813

813-
handle_gyb_sources(
814-
gyb_dependency_targets
815-
SWIFTLIB_SINGLE_SOURCES
816-
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
814+
if(SWIFTLIB_SINGLE_GYB_SOURCES)
815+
handle_gyb_sources(
816+
gyb_dependency_targets
817+
SWIFTLIB_SINGLE_GYB_SOURCES
818+
"${SWIFTLIB_SINGLE_ARCHITECTURE}")
819+
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES}
820+
${SWIFTLIB_SINGLE_GYB_SOURCES})
821+
endif()
817822

818823
# Remove the "swift" prefix from the name to determine the module name.
819824
if(SWIFTLIB_IS_STDLIB_CORE)
@@ -1620,6 +1625,7 @@ function(add_swift_target_library name)
16201625
FRAMEWORK_DEPENDS_IOS_TVOS
16211626
FRAMEWORK_DEPENDS_OSX
16221627
FRAMEWORK_DEPENDS_WEAK
1628+
GYB_SOURCES
16231629
INCORPORATE_OBJECT_LIBRARIES
16241630
INCORPORATE_OBJECT_LIBRARIES_SHARED_ONLY
16251631
INTERFACE_LINK_LIBRARIES
@@ -1914,6 +1920,7 @@ function(add_swift_target_library name)
19141920
DEPLOYMENT_VERSION_IOS "${SWIFTLIB_DEPLOYMENT_VERSION_IOS}"
19151921
DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS}"
19161922
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
1923+
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
19171924
)
19181925

19191926
if(NOT SWIFTLIB_OBJECT_LIBRARY)

branches/rxwei-patch-1/cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,31 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
131131
"${SWIFT_SOURCE_DIR}/utils/gyb_sourcekit_support/UIDs.py")
132132

133133
foreach (src ${${sources_var_name}})
134-
string(REGEX REPLACE "[.]gyb$" "" src_sans_gyb "${src}")
135-
if(src STREQUAL src_sans_gyb)
136-
list(APPEND de_gybbed_sources "${src}")
134+
# On Windows (using Visual Studio), the generated project files assume that the
135+
# generated GYB files will be in the source, not binary directory.
136+
# We can work around this by modifying the root directory when generating VS projects.
137+
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
138+
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
137139
else()
140+
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
141+
endif()
138142

139-
# On Windows (using Visual Studio), the generated project files assume that the
140-
# generated GYB files will be in the source, not binary directory.
141-
# We can work around this by modifying the root directory when generating VS projects.
142-
if ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Visual Studio")
143-
set(dir_root ${CMAKE_CURRENT_SOURCE_DIR})
144-
else()
145-
set(dir_root ${CMAKE_CURRENT_BINARY_DIR})
146-
endif()
147-
148-
if (arch)
149-
set(dir "${dir_root}/${ptr_size}")
150-
else()
151-
set(dir "${dir_root}")
152-
endif()
153-
set(output_file_name "${dir}/${src_sans_gyb}")
154-
list(APPEND de_gybbed_sources "${output_file_name}")
155-
handle_gyb_source_single(dependency_target
156-
SOURCE "${src}"
157-
OUTPUT "${output_file_name}"
158-
FLAGS ${extra_gyb_flags}
159-
DEPENDS "${gyb_extra_sources}"
160-
COMMENT "with ptr size = ${ptr_size}")
161-
list(APPEND dependency_targets "${dependency_target}")
143+
if (arch)
144+
set(dir "${dir_root}/${ptr_size}")
145+
else()
146+
set(dir "${dir_root}")
162147
endif()
148+
# get_filename_component(src_sans_gyb ${src} NAME_WLE)
149+
string(REGEX REPLACE "\.gyb$" "" src_sans_gyb ${src})
150+
set(output_file_name "${dir}/${src_sans_gyb}")
151+
list(APPEND de_gybbed_sources "${output_file_name}")
152+
handle_gyb_source_single(dependency_target
153+
SOURCE "${src}"
154+
OUTPUT "${output_file_name}"
155+
FLAGS ${extra_gyb_flags}
156+
DEPENDS "${gyb_extra_sources}"
157+
COMMENT "with ptr size = ${ptr_size}")
158+
list(APPEND dependency_targets "${dependency_target}")
163159
endforeach()
164160
set("${dependency_out_var_name}" "${dependency_targets}" PARENT_SCOPE)
165161
set("${sources_var_name}" "${de_gybbed_sources}" PARENT_SCOPE)

branches/rxwei-patch-1/include/swift/AST/Decl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@ struct OverloadSignature {
213213
/// Whether this is a function.
214214
unsigned IsFunction : 1;
215215

216+
/// Whether this is a enum element.
217+
unsigned IsEnumElement : 1;
218+
219+
/// Whether this is a nominal type.
220+
unsigned IsNominal : 1;
221+
222+
/// Whether this is a type alias.
223+
unsigned IsTypeAlias : 1;
224+
216225
/// Whether this signature is part of a protocol extension.
217226
unsigned InProtocolExtension : 1;
218227

branches/rxwei-patch-1/include/swift/Parse/CodeCompletionCallbacks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class CodeCompletionCallbacks {
123123
virtual void completeDotExpr(Expr *E, SourceLoc DotLoc) {};
124124

125125
/// Complete the beginning of a statement or expression.
126-
virtual void completeStmtOrExpr() {};
126+
virtual void completeStmtOrExpr(CodeCompletionExpr *E) {};
127127

128128
/// Complete the beginning of expr-postfix -- no tokens provided
129129
/// by user.

branches/rxwei-patch-1/include/swift/SILOptimizer/Analysis/AccessedStorageAnalysis.h

Lines changed: 114 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ template <> struct DenseMapInfo<swift::StorageAccessInfo> {
122122
}
123123

124124
namespace swift {
125-
/// The per-function result of AccessedStorageAnalysis.
126-
///
125+
using AccessedStorageSet = llvm::SmallDenseSet<StorageAccessInfo, 8>;
126+
127127
/// Records each unique AccessedStorage in a set of StorageAccessInfo
128128
/// objects. Hashing and equality only sees the AccesedStorage data. The
129129
/// additional StorageAccessInfo bits are recorded as results of this analysis.
@@ -133,28 +133,32 @@ namespace swift {
133133
/// results, either because the call graph is unknown or the access sets are too
134134
/// large. It does not imply that all accesses have Unidentified
135135
/// AccessedStorage, which is never allowed for class or global access.
136-
class FunctionAccessedStorage {
137-
using AccessedStorageSet = llvm::SmallDenseSet<StorageAccessInfo, 8>;
138-
136+
class AccessedStorageResult {
139137
AccessedStorageSet storageAccessSet;
140138
Optional<SILAccessKind> unidentifiedAccess;
141139

142140
public:
143-
FunctionAccessedStorage() {}
141+
AccessedStorageResult() {}
144142

145143
// ---------------------------------------------------------------------------
146144
// Accessing the results.
147145

146+
const AccessedStorageSet &getStorageSet() const { return storageAccessSet; }
147+
148+
bool isEmpty() const {
149+
return storageAccessSet.empty() && !unidentifiedAccess;
150+
}
151+
148152
bool hasUnidentifiedAccess() const { return unidentifiedAccess != None; }
149153

150154
/// Return true if the analysis has determined all accesses of otherStorage
151155
/// have the [no_nested_conflict] flag set.
152156
///
153-
/// Only call this if there is no unidentifiedAccess in the function and the
157+
/// Only call this if there is no unidentifiedAccess in the region and the
154158
/// given storage is uniquely identified.
155159
bool hasNoNestedConflict(const AccessedStorage &otherStorage) const;
156160

157-
/// Does any of the accesses represented by this FunctionAccessedStorage
161+
/// Does any of the accesses represented by this AccessedStorageResult
158162
/// object conflict with the given access kind and storage.
159163
bool mayConflictWith(SILAccessKind otherAccessKind,
160164
const AccessedStorage &otherStorage) const;
@@ -181,6 +185,97 @@ class FunctionAccessedStorage {
181185
unidentifiedAccess = SILAccessKind::Modify;
182186
}
183187

188+
void setUnidentifiedAccess(SILAccessKind kind) { unidentifiedAccess = kind; }
189+
190+
/// Merge effects directly from \p RHS.
191+
bool mergeFrom(const AccessedStorageResult &other);
192+
193+
/// Merge the effects represented in calleeAccess into this
194+
/// FunctionAccessedStorage object. calleeAccess must correspond to at least
195+
/// one callee at the apply site `fullApply`. Merging drops any local effects,
196+
/// and translates parameter effects into effects on the caller-side
197+
/// arguments.
198+
///
199+
/// The full caller-side effects at a call site can be obtained with
200+
/// AccessedStorageAnalysis::getCallSiteEffects().
201+
bool mergeFromApply(const AccessedStorageResult &calleeAccess,
202+
FullApplySite fullApply);
203+
204+
/// Record any access scopes entered by the given single SIL instruction. 'I'
205+
/// must not be a FullApply; use mergeFromApply instead.
206+
void analyzeInstruction(SILInstruction *I);
207+
208+
void print(raw_ostream &os) const;
209+
void dump() const;
210+
211+
protected:
212+
std::pair<AccessedStorageSet::iterator, bool>
213+
insertStorageAccess(StorageAccessInfo storageAccess) {
214+
storageAccess.setStorageIndex(storageAccessSet.size());
215+
return storageAccessSet.insert(storageAccess);
216+
}
217+
218+
bool updateUnidentifiedAccess(SILAccessKind accessKind);
219+
220+
bool mergeAccesses(const AccessedStorageResult &other,
221+
std::function<StorageAccessInfo(const StorageAccessInfo &)>
222+
transformStorage);
223+
224+
template <typename B> void visitBeginAccess(B *beginAccess);
225+
};
226+
} // namespace swift
227+
228+
namespace swift {
229+
/// The per-function result of AccessedStorageAnalysis.
230+
class FunctionAccessedStorage {
231+
AccessedStorageResult accessResult;
232+
233+
public:
234+
FunctionAccessedStorage() {}
235+
236+
// ---------------------------------------------------------------------------
237+
// Accessing the results.
238+
239+
const AccessedStorageResult &getResult() const { return accessResult; }
240+
241+
bool hasUnidentifiedAccess() const {
242+
return accessResult.hasUnidentifiedAccess();
243+
}
244+
245+
/// Return true if the analysis has determined all accesses of otherStorage
246+
/// have the [no_nested_conflict] flag set.
247+
///
248+
/// Only call this if there is no unidentifiedAccess in the function and the
249+
/// given storage is uniquely identified.
250+
bool hasNoNestedConflict(const AccessedStorage &otherStorage) const {
251+
return accessResult.hasNoNestedConflict(otherStorage);
252+
}
253+
254+
/// Does any of the accesses represented by this FunctionAccessedStorage
255+
/// object conflict with the given access kind and storage.
256+
bool mayConflictWith(SILAccessKind otherAccessKind,
257+
const AccessedStorage &otherStorage) const {
258+
return accessResult.mayConflictWith(otherAccessKind, otherStorage);
259+
}
260+
261+
/// Raw access to the result for a given AccessedStorage location.
262+
StorageAccessInfo
263+
getStorageAccessInfo(const AccessedStorage &otherStorage) const {
264+
return accessResult.getStorageAccessInfo(otherStorage);
265+
}
266+
267+
// ---------------------------------------------------------------------------
268+
// Constructing the results.
269+
270+
void clear() { accessResult.clear(); }
271+
272+
/// Return true if these effects are fully conservative.
273+
bool hasWorstEffects() { return accessResult.hasWorstEffects(); }
274+
275+
/// Sets the most conservative effects, if we don't know anything about the
276+
/// function.
277+
void setWorstEffects() { accessResult.setWorstEffects(); }
278+
184279
/// Summarize the given function's effects using this FunctionAccessedStorage
185280
/// object.
186281
//
@@ -201,12 +296,14 @@ class FunctionAccessedStorage {
201296
///
202297
/// TODO: Summarize ArraySemanticsCall accesses.
203298
bool summarizeCall(FullApplySite fullApply) {
204-
assert(storageAccessSet.empty() && "expected uninitialized results.");
299+
assert(accessResult.isEmpty() && "expected uninitialized results.");
205300
return false;
206301
}
207302

208303
/// Merge effects directly from \p RHS.
209-
bool mergeFrom(const FunctionAccessedStorage &RHS);
304+
bool mergeFrom(const FunctionAccessedStorage &RHS) {
305+
return accessResult.mergeFrom(RHS.accessResult);
306+
}
210307

211308
/// Merge the effects represented in calleeAccess into this
212309
/// FunctionAccessedStorage object. calleeAccess must correspond to at least
@@ -217,31 +314,19 @@ class FunctionAccessedStorage {
217314
/// The full caller-side effects at a call site can be obtained with
218315
/// AccessedStorageAnalysis::getCallSiteEffects().
219316
bool mergeFromApply(const FunctionAccessedStorage &calleeAccess,
220-
FullApplySite fullApply);
317+
FullApplySite fullApply) {
318+
return accessResult.mergeFromApply(calleeAccess.accessResult, fullApply);
319+
}
221320

222321
/// Analyze the side-effects of a single SIL instruction \p I.
223322
/// Visited callees are added to \p BottomUpOrder until \p RecursionDepth
224323
/// reaches MaxRecursionDepth.
225-
void analyzeInstruction(SILInstruction *I);
226-
227-
void print(raw_ostream &os) const;
228-
void dump() const;
229-
230-
protected:
231-
std::pair<AccessedStorageSet::iterator, bool>
232-
insertStorageAccess(StorageAccessInfo storageAccess) {
233-
storageAccess.setStorageIndex(storageAccessSet.size());
234-
return storageAccessSet.insert(storageAccess);
324+
void analyzeInstruction(SILInstruction *I) {
325+
accessResult.analyzeInstruction(I);
235326
}
236327

237-
bool updateUnidentifiedAccess(SILAccessKind accessKind);
238-
239-
bool mergeAccesses(
240-
const FunctionAccessedStorage &other,
241-
std::function<StorageAccessInfo(const StorageAccessInfo &)>
242-
transformStorage);
243-
244-
template <typename B> void visitBeginAccess(B *beginAccess);
328+
void print(raw_ostream &os) const { accessResult.print(os); }
329+
void dump() const { accessResult.dump(); }
245330
};
246331

247332
/// Summarizes the dynamic accesses performed within a function and its

branches/rxwei-patch-1/lib/AST/Decl.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,32 @@ bool swift::conflicting(ASTContext &ctx,
20902090
if (!conflicting(sig1, sig2, skipProtocolExtensionCheck))
20912091
return false;
20922092

2093+
// Functions and enum elements do not conflict with each other if their types
2094+
// are different.
2095+
if (((sig1.IsFunction && sig2.IsEnumElement) ||
2096+
(sig1.IsEnumElement && sig2.IsFunction)) &&
2097+
sig1Type != sig2Type) {
2098+
return false;
2099+
}
2100+
2101+
// Nominal types and enum elements always conflict with each other.
2102+
if ((sig1.IsNominal && sig2.IsEnumElement) ||
2103+
(sig1.IsEnumElement && sig2.IsNominal)) {
2104+
return true;
2105+
}
2106+
2107+
// Typealiases and enum elements always conflict with each other.
2108+
if ((sig1.IsTypeAlias && sig2.IsEnumElement) ||
2109+
(sig1.IsEnumElement && sig2.IsTypeAlias)) {
2110+
return true;
2111+
}
2112+
2113+
// Enum elements always conflict with each other. At this point, they
2114+
// have the same base name but different types.
2115+
if (sig1.IsEnumElement && sig2.IsEnumElement) {
2116+
return true;
2117+
}
2118+
20932119
// Functions always conflict with non-functions with the same signature.
20942120
// In practice, this only applies for zero argument functions.
20952121
if (sig1.IsFunction != sig2.IsFunction)
@@ -2248,6 +2274,9 @@ OverloadSignature ValueDecl::getOverloadSignature() const {
22482274
signature.IsInstanceMember = isInstanceMember();
22492275
signature.IsVariable = isa<VarDecl>(this);
22502276
signature.IsFunction = isa<AbstractFunctionDecl>(this);
2277+
signature.IsEnumElement = isa<EnumElementDecl>(this);
2278+
signature.IsNominal = isa<NominalTypeDecl>(this);
2279+
signature.IsTypeAlias = isa<TypeAliasDecl>(this);
22512280

22522281
// Unary operators also include prefix/postfix.
22532282
if (auto func = dyn_cast<FuncDecl>(this)) {
@@ -2293,6 +2322,13 @@ CanType ValueDecl::getOverloadSignatureType() const {
22932322
->getCanonicalType();
22942323
}
22952324

2325+
if (isa<EnumElementDecl>(this)) {
2326+
auto mappedType = mapSignatureFunctionType(
2327+
getASTContext(), getInterfaceType(), /*topLevelFunction=*/false,
2328+
/*isMethod=*/false, /*isInitializer=*/false, /*curryLevels=*/0);
2329+
return mappedType->getCanonicalType();
2330+
}
2331+
22962332
// Note: If you add more cases to this function, you should update the
22972333
// implementation of the swift::conflicting overload that deals with
22982334
// overload types, in order to account for cases where the overload types

0 commit comments

Comments
 (0)