Skip to content

Commit ca74d06

Browse files
committed
---
yaml --- r: 318431 b: refs/heads/master-rebranch c: 0130fd2 h: refs/heads/master i: 318429: 301dcc4 318427: c89cab1 318423: 25e1a8f 318415: 19dd5c6 318399: eea194e
1 parent ba08f3f commit ca74d06

File tree

58 files changed

+496
-258
lines changed

Some content is hidden

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

58 files changed

+496
-258
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: f856401ba9bdccf702d570c471d017fc2f19dc8a
1460+
refs/heads/master-rebranch: 0130fd2307d378c8ab05548ee4b14a74982c330f

branches/master-rebranch/cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ endfunction()
3030
# Compute the library subdirectory to use for the given sdk and
3131
# architecture, placing the result in 'result_var_name'.
3232
function(compute_library_subdir result_var_name sdk arch)
33-
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
33+
if(sdk IN_LIST SWIFT_APPLE_PLATFORMS)
34+
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}" PARENT_SCOPE)
35+
else()
36+
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
37+
endif()
3438
endfunction()
3539

3640
function(_compute_lto_flag option out_var)
@@ -1156,6 +1160,8 @@ function(_add_swift_library_single target name)
11561160
# Don't set PROPERTY COMPILE_FLAGS or LINK_FLAGS directly.
11571161
set(c_compile_flags ${SWIFTLIB_SINGLE_C_COMPILE_FLAGS})
11581162
set(link_flags ${SWIFTLIB_SINGLE_LINK_FLAGS})
1163+
1164+
set(library_search_subdir "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
11591165
set(library_search_directories
11601166
"${SWIFTLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
11611167
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
@@ -1300,6 +1306,7 @@ function(_add_swift_library_single target name)
13001306
if(target_static)
13011307
set_property(TARGET "${target_static}" APPEND_STRING PROPERTY
13021308
COMPILE_FLAGS " ${c_compile_flags}")
1309+
# FIXME: The fallback paths here are going to be dynamic libraries.
13031310
set(library_search_directories
13041311
"${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
13051312
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"

branches/master-rebranch/cmake/modules/SwiftSource.cmake

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ function(handle_swift_sources
6161
endif()
6262

6363
if(swift_sources)
64-
compute_library_subdir(SWIFTSOURCES_LIBRARY_SUBDIR
65-
"${SWIFTSOURCES_SDK}" "${SWIFTSOURCES_ARCHITECTURE}")
66-
set(objsubdir "/${SWIFTSOURCES_LIBRARY_SUBDIR}")
64+
set(objsubdir "/${SWIFTSOURCES_SDK}/${SWIFTSOURCES_ARCHITECTURE}")
6765

6866
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}${objsubdir}")
6967

@@ -255,6 +253,8 @@ function(_compile_swift_files
255253
"-nostdimport" "-parse-stdlib" "-module-name" "Swift")
256254
list(APPEND swift_flags "-Xfrontend" "-group-info-path"
257255
"-Xfrontend" "${GROUP_INFO_JSON_FILE}")
256+
else()
257+
list(APPEND swift_flags "-module-name" "${SWIFTFILE_MODULE_NAME}")
258258
endif()
259259

260260
# Force swift 5 mode for Standard Library.
@@ -313,19 +313,32 @@ function(_compile_swift_files
313313
list(APPEND swift_flags "-parse-as-library")
314314

315315
set(module_base "${module_dir}/${SWIFTFILE_MODULE_NAME}")
316+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
317+
set(specific_module_dir "${module_base}.swiftmodule")
318+
set(module_base "${module_base}.swiftmodule/${SWIFTFILE_ARCHITECTURE}")
319+
endif()
316320
set(module_file "${module_base}.swiftmodule")
321+
set(module_doc_file "${module_base}.swiftdoc")
322+
323+
# FIXME: These don't really belong inside the swiftmodule, but there's not
324+
# an obvious alternate place to put them.
317325
set(sib_file "${module_base}.Onone.sib")
318326
set(sibopt_file "${module_base}.O.sib")
319327
set(sibgen_file "${module_base}.sibgen")
320-
set(module_doc_file "${module_base}.swiftdoc")
321328

322329
if(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES)
323330
set(interface_file "${module_base}.swiftinterface")
324-
list(APPEND swift_flags "-emit-parseable-module-interface")
331+
list(APPEND swift_flags
332+
"-emit-parseable-module-interface-path" "${interface_file}")
325333
endif()
326334

327-
list(APPEND command_create_dirs
328-
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
335+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
336+
list(APPEND command_create_dirs
337+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${specific_module_dir}")
338+
else()
339+
list(APPEND command_create_dirs
340+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${module_dir}")
341+
endif()
329342

330343
# If we have extra regexp flags, check if we match any of the regexps. If so
331344
# add the relevant flags to our swift_flags.
@@ -349,10 +362,15 @@ function(_compile_swift_files
349362
set(optional_arg "OPTIONAL")
350363
endif()
351364

352-
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
353-
FILES ${module_outputs}
354-
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
355-
"${optional_arg}")
365+
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
366+
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
367+
DIRECTORY "${specific_module_dir}"
368+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}")
369+
else()
370+
swift_install_in_component("${SWIFTFILE_INSTALL_IN_COMPONENT}"
371+
FILES ${module_outputs}
372+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}")
373+
endif()
356374

357375
set(line_directive_tool "${SWIFT_SOURCE_DIR}/utils/line-directive")
358376
set(swift_compiler_tool "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc")

branches/master-rebranch/lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static void updateRuntimeLibraryPath(SearchPathOptions &SearchPathOpts,
4949
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
5050
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
5151

52-
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
52+
if (!Triple.isOSDarwin())
53+
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
5354
SearchPathOpts.RuntimeLibraryImportPath = LibPath.str();
5455
}
5556

branches/master-rebranch/lib/SILGen/SILGenPattern.cpp

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,38 +2844,47 @@ void SILGenFunction::emitSwitchFallthrough(FallthroughStmt *S) {
28442844

28452845
if (!caseStmt->hasBoundDecls()) {
28462846
Cleanups.emitBranchAndCleanups(sharedDest, S);
2847-
} else {
2848-
// Generate branch args to pass along current vars to fallthrough case.
2849-
SILModule &M = F.getModule();
2850-
ArrayRef<CaseLabelItem> labelItems = caseStmt->getCaseLabelItems();
2851-
SmallVector<SILValue, 4> args;
2852-
SmallVector<VarDecl *, 4> expectedVarOrder;
2853-
labelItems[0].getPattern()->collectVariables(expectedVarOrder);
2854-
2855-
for (auto *expected : expectedVarOrder) {
2856-
if (!expected->hasName())
2847+
return;
2848+
}
2849+
2850+
// Generate branch args to pass along current vars to fallthrough case.
2851+
SILModule &M = F.getModule();
2852+
ArrayRef<CaseLabelItem> labelItems = caseStmt->getCaseLabelItems();
2853+
SmallVector<SILValue, 4> args;
2854+
SmallVector<VarDecl *, 4> expectedVarOrder;
2855+
labelItems[0].getPattern()->collectVariables(expectedVarOrder);
2856+
2857+
for (auto *expected : expectedVarOrder) {
2858+
if (!expected->hasName())
2859+
continue;
2860+
for (auto var : VarLocs) {
2861+
auto varDecl = dyn_cast<VarDecl>(var.getFirst());
2862+
if (!varDecl || !varDecl->hasName() ||
2863+
varDecl->getName() != expected->getName()) {
28572864
continue;
2858-
for (auto var : VarLocs) {
2859-
auto varDecl = dyn_cast<VarDecl>(var.getFirst());
2860-
if (varDecl && varDecl->hasName() && varDecl->getName() == expected->getName()) {
2861-
SILValue value = var.getSecond().value;
2862-
2863-
if (value->getType().isAddressOnly(M)) {
2864-
context->Emission.emitAddressOnlyInitialization(expected, value);
2865-
} else if (var.getSecond().box) {
2866-
auto &lowering = getTypeLowering(value->getType());
2867-
auto argValue = lowering.emitLoad(B, CurrentSILLoc, value, LoadOwnershipQualifier::Copy);
2868-
args.push_back(argValue);
2869-
} else {
2870-
auto argValue = B.emitCopyValueOperation(CurrentSILLoc, value);
2871-
args.push_back(argValue);
2872-
}
2873-
break;
2874-
}
28752865
}
2866+
2867+
SILValue value = var.getSecond().value;
2868+
2869+
if (value->getType().isAddressOnly(M)) {
2870+
context->Emission.emitAddressOnlyInitialization(expected, value);
2871+
break;
2872+
}
2873+
2874+
if (var.getSecond().box) {
2875+
auto &lowering = getTypeLowering(value->getType());
2876+
auto argValue = lowering.emitLoad(B, CurrentSILLoc, value,
2877+
LoadOwnershipQualifier::Copy);
2878+
args.push_back(argValue);
2879+
break;
2880+
}
2881+
2882+
auto argValue = B.emitCopyValueOperation(CurrentSILLoc, value);
2883+
args.push_back(argValue);
2884+
break;
28762885
}
2877-
Cleanups.emitBranchAndCleanups(sharedDest, S, args);
28782886
}
2887+
Cleanups.emitBranchAndCleanups(sharedDest, S, args);
28792888
}
28802889

28812890

branches/master-rebranch/lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,21 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
301301

302302
// Search the runtime import path.
303303
isFramework = false;
304-
return !findModuleFilesInDirectory(
305-
moduleID, Ctx.SearchPathOpts.RuntimeLibraryImportPath,
306-
moduleFilename.str(), moduleDocFilename.str(), moduleBuffer,
307-
moduleDocBuffer);
304+
currPath = Ctx.SearchPathOpts.RuntimeLibraryImportPath;
305+
if (Ctx.LangOpts.Target.isOSDarwin()) {
306+
// Apple platforms always use architecture-specific files within a
307+
// .swiftmodule directory for the stdlib.
308+
llvm::sys::path::append(currPath, moduleFilename.str());
309+
return !findModuleFilesInDirectory(moduleID, currPath,
310+
archFileNames.first,
311+
archFileNames.second,
312+
moduleBuffer, moduleDocBuffer);
313+
}
314+
// Non-Apple platforms always use single-architecture swiftmodules.
315+
return !findModuleFilesInDirectory(moduleID, currPath,
316+
moduleFilename.str(),
317+
moduleDocFilename.str(),
318+
moduleBuffer, moduleDocBuffer);
308319
}
309320

310321
static std::pair<StringRef, clang::VersionTuple>

branches/master-rebranch/stdlib/public/Darwin/Foundation/URLComponents.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,8 @@ public struct URLComponents : ReferenceConvertible, Hashable, Equatable, _Mutabl
192192

193193
@available(macOS 10.11, iOS 9.0, *)
194194
private func _toStringRange(_ r : NSRange) -> Range<String.Index>? {
195-
guard r.location != NSNotFound else { return nil }
196-
197-
let utf16Start = String.UTF16View.Index(encodedOffset: r.location)
198-
let utf16End = String.UTF16View.Index(encodedOffset: r.location + r.length)
199-
200195
guard let s = self.string else { return nil }
201-
guard let start = String.Index(utf16Start, within: s) else { return nil }
202-
guard let end = String.Index(utf16End, within: s) else { return nil }
203-
204-
return start..<end
196+
return Range(r, in: s)
205197
}
206198

207199
/// Returns the character range of the scheme in the string returned by `var string`.

branches/master-rebranch/stdlib/public/Darwin/NaturalLanguage/NLTagger.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ extension NLTagger {
1818
@nonobjc
1919
public func tokenRange(at index: String.Index, unit: NLTokenUnit) -> Range<String.Index> {
2020
let str = self.string ?? ""
21-
let characterIndex = index.encodedOffset
21+
let characterIndex = index.utf16Offset(in: str)
2222
let nsrange = self.__tokenRange(at: characterIndex, unit: unit)
2323
return Range(nsrange, in: str)!
2424
}
2525

2626
@nonobjc
2727
public func tag(at index: String.Index, unit: NLTokenUnit, scheme: NLTagScheme) -> (NLTag?, Range<String.Index>) {
2828
let str = self.string ?? ""
29-
let characterIndex = index.encodedOffset
29+
let characterIndex = index.utf16Offset(in: str)
3030
let rangePointer = NSRangePointer.allocate(capacity: 1)
3131
rangePointer.initialize(to: NSMakeRange(0, 0))
3232
let tag = self.__tag(at: characterIndex, unit: unit, scheme: scheme, tokenRange: rangePointer)

branches/master-rebranch/stdlib/public/Darwin/NaturalLanguage/NLTokenizer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension NLTokenizer {
1818
@nonobjc
1919
public func tokenRange(at index: String.Index) -> Range<String.Index> {
2020
let str = self.string ?? ""
21-
let characterIndex = index.encodedOffset
21+
let characterIndex = index.utf16Offset(in: str)
2222
let nsrange = self.__tokenRange(at:characterIndex)
2323
return Range(nsrange, in: str)!
2424
}

branches/master-rebranch/stdlib/public/core/String.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,8 @@ internal func _fastWithNormalizedCodeUnitsImpl(
935935
var icuInputBuffer = icuInputBuffer
936936
var icuOutputBuffer = icuOutputBuffer
937937

938-
var index = String.Index(encodedOffset: 0)
939-
let cachedEndIndex = String.Index(encodedOffset: sourceBuffer.count)
938+
var index = String.Index(_encodedOffset: 0)
939+
let cachedEndIndex = String.Index(_encodedOffset: sourceBuffer.count)
940940

941941
var hasBufferOwnership = false
942942

branches/master-rebranch/stdlib/public/core/StringBreadcrumbs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ extension _StringBreadcrumbs {
7979
internal func getBreadcrumb(
8080
forIndex idx: String.Index
8181
) -> (lowerBound: String.Index, offset: Int) {
82-
var lowerBound = idx.encodedOffset / 3 / stride
83-
var upperBound = Swift.min(1 + (idx.encodedOffset / stride), crumbs.count)
82+
var lowerBound = idx._encodedOffset / 3 / stride
83+
var upperBound = Swift.min(1 + (idx._encodedOffset / stride), crumbs.count)
8484
_internalInvariant(crumbs[lowerBound] <= idx)
8585
_internalInvariant(upperBound == crumbs.count || crumbs[upperBound] >= idx)
8686

branches/master-rebranch/stdlib/public/core/StringCharacterView.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ extension String: BidirectionalCollection {
6666

6767
// TODO: known-ASCII fast path, single-scalar-grapheme fast path, etc.
6868
let stride = _characterStride(startingAt: i)
69-
let nextOffset = i.encodedOffset &+ stride
69+
let nextOffset = i._encodedOffset &+ stride
7070
let nextStride = _characterStride(
71-
startingAt: Index(encodedOffset: nextOffset))
71+
startingAt: Index(_encodedOffset: nextOffset))
7272

7373
return Index(
7474
encodedOffset: nextOffset, characterStride: nextStride)
@@ -84,7 +84,7 @@ extension String: BidirectionalCollection {
8484

8585
// TODO: known-ASCII fast path, single-scalar-grapheme fast path, etc.
8686
let stride = _characterStride(endingAt: i)
87-
let priorOffset = i.encodedOffset &- stride
87+
let priorOffset = i._encodedOffset &- stride
8888
return Index(encodedOffset: priorOffset, characterStride: stride)
8989
}
9090
/// Returns an index that is the specified distance from the given index.
@@ -198,7 +198,7 @@ extension String: BidirectionalCollection {
198198
let i = _guts.scalarAlign(i)
199199
let distance = _characterStride(startingAt: i)
200200
return _guts.errorCorrectedCharacter(
201-
startingAt: i.encodedOffset, endingAt: i.encodedOffset &+ distance)
201+
startingAt: i._encodedOffset, endingAt: i._encodedOffset &+ distance)
202202
}
203203
}
204204

@@ -209,14 +209,14 @@ extension String: BidirectionalCollection {
209209

210210
if i == endIndex { return 0 }
211211

212-
return _guts._opaqueCharacterStride(startingAt: i.encodedOffset)
212+
return _guts._opaqueCharacterStride(startingAt: i._encodedOffset)
213213
}
214214

215215
@inlinable @inline(__always)
216216
internal func _characterStride(endingAt i: Index) -> Int {
217217
if i == startIndex { return 0 }
218218

219-
return _guts._opaqueCharacterStride(endingAt: i.encodedOffset)
219+
return _guts._opaqueCharacterStride(endingAt: i._encodedOffset)
220220
}
221221
}
222222

branches/master-rebranch/stdlib/public/core/StringComparison.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ extension _StringGutsSlice {
328328
if _fastPath(self.isFastUTF8 && other.isFastUTF8) {
329329
return self.withFastUTF8 { leftUTF8 in
330330
other.withFastUTF8 { rightUTF8 in
331-
let leftStartIndex = String.Index(encodedOffset: 0)
332-
let rightStartIndex = String.Index(encodedOffset: 0)
333-
let leftEndIndex = String.Index(encodedOffset: leftUTF8.count)
334-
let rightEndIndex = String.Index(encodedOffset: rightUTF8.count)
331+
let leftStartIndex = String.Index(_encodedOffset: 0)
332+
let rightStartIndex = String.Index(_encodedOffset: 0)
333+
let leftEndIndex = String.Index(_encodedOffset: leftUTF8.count)
334+
let rightEndIndex = String.Index(_encodedOffset: rightUTF8.count)
335335
return _normalizedCompareImpl(
336336
left_outputBuffer: _castOutputBuffer(&left_output),
337337
left_icuInputBuffer: _castOutputBuffer(&left_icuInput),

branches/master-rebranch/stdlib/public/core/StringGraphemeBreaking.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ extension _StringGuts {
156156
internal func isOnGraphemeClusterBoundary(_ i: String.Index) -> Bool {
157157
guard i.transcodedOffset == 0 else { return false }
158158

159-
let offset = i.encodedOffset
159+
let offset = i._encodedOffset
160160
if offset == 0 || offset == self.count { return true }
161161

162162
guard isOnUnicodeScalarBoundary(i) else { return false }
@@ -197,7 +197,7 @@ extension _StringGuts {
197197
let count = _object.largeCount
198198
let cocoa = _object.cocoaObject
199199

200-
let startIdx = String.Index(encodedOffset: i)
200+
let startIdx = String.Index(_encodedOffset: i)
201201
let (sc1, len) = foreignErrorCorrectedScalar(startingAt: startIdx)
202202
if i &+ len == count {
203203
// Last scalar is last grapheme
@@ -263,7 +263,7 @@ extension _StringGuts {
263263
let count = _object.largeCount
264264
let cocoa = _object.cocoaObject
265265

266-
let endIdx = String.Index(encodedOffset: i)
266+
let endIdx = String.Index(_encodedOffset: i)
267267
let (sc2, len) = foreignErrorCorrectedScalar(endingAt: endIdx)
268268
if i &- len == 0 {
269269
// First scalar is first grapheme

branches/master-rebranch/stdlib/public/core/StringGuts.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ extension _StringGuts {
274274

275275
@inlinable
276276
internal var startIndex: String.Index {
277-
@inline(__always) get { return Index(encodedOffset: 0) }
277+
@inline(__always) get { return Index(_encodedOffset: 0) }
278278
}
279279
@inlinable
280280
internal var endIndex: String.Index {
281-
@inline(__always) get { return Index(encodedOffset: self.count) }
281+
@inline(__always) get { return Index(_encodedOffset: self.count) }
282282
}
283283
}
284284

0 commit comments

Comments
 (0)