Merge pull request #11976 from compnerd/llp64
runtime: make LLP64 clean
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a4bb3a..9eca43e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -751,7 +751,17 @@
# Should we cross-compile the standard library for Windows?
is_sdk_requested(WINDOWS swift_build_windows)
if(swift_build_windows AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
- configure_sdk_windows(WINDOWS "Windows" "msvc" i686)
+ if("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "aarch64")
+ configure_sdk_windows(WINDOWS "Windows" "msvc" aarch64)
+ elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "armv7")
+ configure_sdk_windows(WINDOWS "Windows" "msvc" armv7)
+ elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "i686")
+ configure_sdk_windows(WINDOWS "Windows" "msvc" i686)
+ elseif("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "x86_64")
+ configure_sdk_windows(WINDOWS "Windows" "msvc" x86_64)
+ else()
+ message(FATAL_ERROR "unable to calculate triple for Windows host on ${SWIFT_HOST_VARIANT_ARCH}")
+ endif()
endif()
if("${SWIFT_SDKS}" STREQUAL "")
diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt
index b091330..da0678a 100644
--- a/benchmark/CMakeLists.txt
+++ b/benchmark/CMakeLists.txt
@@ -104,6 +104,7 @@
single-source/StrToInt
single-source/StringBuilder
single-source/StringEdits
+ single-source/StringEnum
single-source/StringInterpolation
single-source/StringMatch
single-source/StringTests
diff --git a/benchmark/single-source/StringEnum.swift b/benchmark/single-source/StringEnum.swift
new file mode 100644
index 0000000..74573b4
--- /dev/null
+++ b/benchmark/single-source/StringEnum.swift
@@ -0,0 +1,221 @@
+//===--- StringEnum.swift -------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+import TestsUtils
+
+enum TestEnum : String {
+ case c1 = "Swift"
+ case c2 = "is"
+ case c3 = "a"
+ case c4 = "general-purpose"
+ case c5 = "programming language"
+ case c7 = "built"
+ case c8 = "using"
+ case c10 = "modern"
+ case c11 = "approach"
+ case c12 = "to"
+ case c13 = "safety,"
+ case c14 = "performance,"
+ case c15 = "and"
+ case c16 = "software"
+ case c17 = "design"
+ case c18 = "patterns."
+ case c19 = ""
+ case c20 = "The"
+ case c21 = "goal"
+ case c22 = "of"
+ case c23 = "the"
+ case c25 = "project"
+ case c28 = "create"
+ case c30 = "best"
+ case c31 = "available"
+ case c33 = "for"
+ case c34 = "uses"
+ case c35 = "ranging"
+ case c36 = "from"
+ case c37 = "systems"
+ case c40 = "mobile"
+ case c42 = "desktop"
+ case c43 = "apps,"
+ case c44 = "scaling"
+ case c45 = "up"
+ case c47 = "cloud"
+ case c48 = "services."
+ case c49 = "Most"
+ case c50 = "importantly,"
+ case c53 = "designed"
+ case c55 = "make"
+ case c56 = "writing"
+ case c58 = "maintaining"
+ case c59 = "correct"
+ case c60 = "programs"
+ case c61 = "easier"
+ case c64 = "developer."
+ case c65 = "To"
+ case c66 = "achieve"
+ case c67 = "this"
+ case c68 = "goal,"
+ case c69 = "we"
+ case c70 = "believe"
+ case c71 = "that"
+ case c73 = "most"
+ case c74 = "obvious"
+ case c75 = "way"
+ case c77 = "write"
+ case c79 = "code"
+ case c80 = "must"
+ case c81 = "also"
+ case c82 = "be:"
+ case c84 = "Safe."
+ case c92 = "should"
+ case c94 = "behave"
+ case c95 = "in"
+ case c97 = "safe"
+ case c98 = "manner."
+ case c99 = "Undefined"
+ case c100 = "behavior"
+ case c103 = "enemy"
+ case c107 = "developer"
+ case c108 = "mistakes"
+ case c110 = "be"
+ case c111 = "caught"
+ case c112 = "before"
+ case c116 = "production."
+ case c117 = "Opting"
+ case c119 = "safety"
+ case c120 = "sometimes"
+ case c121 = "means"
+ case c123 = "will"
+ case c124 = "feel"
+ case c125 = "strict,"
+ case c126 = "but"
+ case c130 = "clarity"
+ case c131 = "saves"
+ case c132 = "time"
+ case c135 = "long"
+ case c136 = "run."
+ case c138 = "Fast."
+ case c141 = "intended"
+ case c142 = "as"
+ case c144 = "replacement"
+ case c146 = "C-based"
+ case c147 = "languages"
+ case c148 = "(C, C++, Objective-C)."
+ case c152 = "As"
+ case c153 = "such,"
+ case c157 = "comparable"
+ case c159 = "those"
+ case c162 = "performance"
+ case c165 = "tasks."
+ case c166 = "Performance"
+ case c170 = "predictable"
+ case c172 = "consistent,"
+ case c173 = "not"
+ case c174 = "just"
+ case c175 = "fast"
+ case c177 = "short"
+ case c178 = "bursts"
+ case c180 = "require"
+ case c181 = "clean-up"
+ case c182 = "later."
+ case c183 = "There"
+ case c184 = "are"
+ case c185 = "lots"
+ case c188 = "with"
+ case c189 = "novel"
+ case c190 = "features"
+ case c191 = "—"
+ case c192 = "being"
+ case c195 = "rare."
+ case c197 = "Expressive."
+ case c199 = "benefits"
+ case c201 = "decades"
+ case c203 = "advancement"
+ case c205 = "computer"
+ case c206 = "science"
+ case c208 = "offer"
+ case c209 = "syntax"
+ case c213 = "joy"
+ case c215 = "use,"
+ case c219 = "developers"
+ case c220 = "expect."
+ case c221 = "But"
+ case c224 = "never"
+ case c225 = "done."
+ case c226 = "We"
+ case c228 = "monitor"
+ case c230 = "advancements"
+ case c232 = "embrace"
+ case c233 = "what"
+ case c234 = "works,"
+ case c235 = "continually"
+ case c236 = "evolving"
+ case c240 = "even"
+ case c241 = "better."
+ case c243 = "Tools"
+ case c246 = "critical"
+ case c247 = "part"
+ case c251 = "ecosystem."
+ case c253 = "strive"
+ case c255 = "integrate"
+ case c256 = "well"
+ case c257 = "within"
+ case c259 = "developer’s"
+ case c260 = "toolset,"
+ case c262 = "build"
+ case c263 = "quickly,"
+ case c265 = "present"
+ case c266 = "excellent"
+ case c267 = "diagnostics,"
+ case c270 = "enable"
+ case c271 = "interactive"
+ case c272 = "development"
+ case c273 = "experiences."
+ case c275 = "can"
+ case c278 = "so"
+ case c279 = "much"
+ case c280 = "more"
+ case c281 = "powerful,"
+ case c282 = "like"
+ case c283 = "Swift-based"
+ case c284 = "playgrounds"
+ case c285 = "do"
+ case c287 = "Xcode,"
+ case c288 = "or"
+ case c290 = "web-based"
+ case c291 = "REPL"
+ case c293 = "when"
+ case c294 = "working"
+ case c296 = "Linux"
+ case c297 = "server-side"
+ case c298 = "code."
+}
+
+@inline(never)
+func convert(_ s: String) {
+ blackHole(TestEnum(rawValue: s))
+}
+
+@inline(never)
+public func run_StringEnumRawValueInitialization(_ N: Int) {
+ let first = "Swift"
+ let short = "To"
+ let long = "(C, C++, Objective-C)."
+ let last = "code."
+ for _ in 1...2000*N {
+ convert(first)
+ convert(short)
+ convert(long)
+ convert(last)
+ }
+}
+
diff --git a/benchmark/utils/main.swift b/benchmark/utils/main.swift
index 3a73db9..73389bb 100644
--- a/benchmark/utils/main.swift
+++ b/benchmark/utils/main.swift
@@ -109,6 +109,7 @@
import StrToInt
import StringBuilder
import StringEdits
+import StringEnum
import StringInterpolation
import StringMatch
import StringTests
@@ -417,6 +418,7 @@
addTo(&precommitTests, "StringBuilder", run_StringBuilder)
addTo(&precommitTests, "StringBuilderLong", run_StringBuilderLong)
addTo(&precommitTests, "StringEdits", run_StringEdits)
+addTo(&precommitTests, "StringEnumRawValueInitialization", run_StringEnumRawValueInitialization)
addTo(&precommitTests, "StringEqualPointerComparison", run_StringEqualPointerComparison)
addTo(&precommitTests, "StringFromLongWholeSubstring", run_StringFromLongWholeSubstring)
addTo(&precommitTests, "StringFromLongWholeSubstringGeneric", run_StringFromLongWholeSubstringGeneric)
diff --git a/docs/ABI/Mangling.rst b/docs/ABI/Mangling.rst
index 8f21b7c..c8b41ec 100644
--- a/docs/ABI/Mangling.rst
+++ b/docs/ABI/Mangling.rst
@@ -117,6 +117,10 @@
global ::= global 'Tm' // merged function
global ::= entity // some identifiable thing
global ::= type type generic-signature? 'T' REABSTRACT-THUNK-TYPE // reabstraction thunk helper function
+ global ::= entity generic-signature? type type* 'TK' // key path getter
+ global ::= entity generic-signature? type type* 'Tk' // key path setter
+ global ::= type generic-signature 'TH' // key path equality
+ global ::= type generic-signature 'Th' // key path hasher
REABSTRACT-THUNK-TYPE ::= 'R' // reabstraction thunk helper function
REABSTRACT-THUNK-TYPE ::= 'r' // reabstraction thunk
diff --git a/docs/Windows.md b/docs/Windows.md
index 42324a8..8b65abf 100644
--- a/docs/Windows.md
+++ b/docs/Windows.md
@@ -4,10 +4,10 @@
### 1. Setup Visual Studio Environment Variables
Building for Windows requires that the Visual Studio environment variables are
-setup similar to the values on Windows. The following assumes that
+setup similar to the values on Windows. The following assumes that
`WINKIT_ROOT` points to the path where the Windows 10 SDK is available and that
`VC_ROOT` points to the path where the Visual Studio VC headers and libraries
-are available. Currently, the runtime has been tested to build against the
+are available. Currently, the runtime has been tested to build against the
Windows 10 SDK at revision 10.10.586.
```
@@ -20,17 +20,17 @@
### 2. Setup `visualc` and `ucrt` modules
The `visualc.modulemap` located at
`swift/stdlib/public/Platform/visualc.modulemap` needs to be copied into
-`${VC_ROOT}/include`. The `ucrt.modulemap` located at
+`${VC_ROOT}/include`. The `ucrt.modulemap` located at
`swift/stdlib/public/Platform/ucrt.modulemap` needs to be copied into
`${WINKIT_ROOT}/Include/10.0.10586.0/ucrt`.
### 3. Configure the runtime to be built with the just built clang
Ensure that we use the tools from the just built LLVM and clang tools to build
-the Windows SDK. You will need to pass a few extra options to cmake via the
-`build-script` invocation to achieve this. You will need to expand out the
-path where llvm-ar and llvm-ranlib are built. These are needed to correctly
-build the static libraries. Note that cross-compiling will require the use of
-lld. Ensure that lld-link.exe (lld-link) is available to clang via your path.
+the Windows SDK. You will need to pass a few extra options to cmake via the
+`build-script` invocation to achieve this. You will need to expand out the
+path where llvm-ar and llvm-ranlib are built. These are needed to correctly
+build the static libraries. Note that cross-compiling will require the use of
+lld. Ensure that lld-link.exe (lld-link) is available to clang via your path.
Additionally, the ICU headers and libraries need to be provided for the build.
```
@@ -40,7 +40,7 @@
## MSVC
- Windows doesn't currently have a build script. You'll need to run commands manually to build Swift on Windows.
- Release/RelWithDebInfo modes have not been tested and may not be supported.
-- Windows support for Swift is very much a WIP, and may not work on your system.
+- Windows support for Swift is very much a work in progress and may not work on your system.
- Using the latest Visual Studio version is recommended. Swift may fail to build with older C++ compilers.
### 1. Install dependencies
@@ -49,7 +49,7 @@
2. Latest version (3.7.0-rc3 tested) of [CMake](https://cmake.org/download/)
3. Latest version (1.7.1 tested) of [Ninja](https://github.com/ninja-build/ninja/releases/latest)
4. Latest version (2015 Update 3 tested) of [Visual Studio](https://www.visualstudio.com/downloads/)
-- Make sure to include `Programming Languages|Visual C++`, and `Windows and Web Development|Universal Windows App Development|Windows SDK` in your installation.
+- Make sure to include `Programming Languages|Visual C++` and `Windows and Web Development|Universal Windows App Development|Windows SDK` in your installation.
- Windows SDK 10.0.10240 was tested. Some later versions (e.g. 10.0.14393) are known not to work, as they are not supported by `compiler-rt`.
### 2. Clone the repositories
@@ -58,7 +58,7 @@
3. `apple/swift-clang` into a folder named `clang`
5. `apple/swift-llvm` into a folder named `llvm`
5. `apple/swift` into a folder named `swift`
-- Currently, other repositories in the Swift project have not been tested, and may not be supported.
+- Currently, other repositories in the Swift project have not been tested and may not be supported.
### 3. Build ICU
1. Download and extract the [ICU source code](http://site.icu-project.org/download) to a folder named `icu` in the same directory as the other Swift project repositories.
@@ -72,13 +72,13 @@
```
VsDevCmd -arch=amd64
```
-- Then adapt the following command, and run it.
+- Then adapt the following command and run it.
```
set swift_source_dir=path-to-directory-containing-all-cloned-repositories
```
### 5. Build CMark
-- This must be done from within a developer command prompt, and could take up to 10 minutes.
+- This must be done from within a developer command prompt. CMark is a fairly small project and should only take a few minutes to build.
```
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"
pushd "%swift_source_dir%/build/Ninja-DebugAssert/cmark-windows-amd64"
@@ -88,9 +88,10 @@
```
### 6. Build LLVM/Clang/Compiler-RT
-- This must be done from within a developer command prompt, and could take up to 5 hours.
+- This must be done from within a developer command prompt. LLVM and Clang are large projects so building might take a few hours. Make sure that the build type (e.g. Debug/Release) for LLVM/Clang matches the build type for Swift.
+- Optionally, you can omit building compiler-rt by removing all lines referring to `compiler-rt` below, which should give faster build times.
```
-mklink /J "%swift_source_dir%/llvm/tools/clang" "%swift_source_dir%my-swift/clang"
+mklink /J "%swift_source_dir%/llvm/tools/clang" "%swift_source_dir%/clang"
mklink /J "%swift_source_dir%/llvm/tools/compiler-rt" "%swift_source_dir%/compiler-rt"
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
pushd "%swift_source_dir%/build/Ninja-DebugAssert/llvm-windows-amd64"
@@ -108,8 +109,9 @@
```
### 7. Build Swift
-- This must be done from within a developer command prompt, and could take up to 2 hours.
+- This must be done from within a developer command prompt and could take up to two hours depending on your system.
- You may need to adjust the SWIFT_WINDOWS_LIB_DIRECTORY parameter depending on your target platform or Windows SDK version.
+- While the commands here use MSVC to build, using clang-cl is recommended (see the **Clang-cl** section below).
```
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
pushd "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
@@ -136,7 +138,7 @@
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja"
```
-- To create a VisualStudio project, you'll need to change the generator and, if you have a 64 bit processor, specify the generator platform. Note that you may get multiple build errors compiling the `swift` project due to an MSBuild limitation that file paths cannot exceed 260 characters. These can be ignored, as they occur after the build, writing the last build status to a file.
+- To create a VisualStudio project, you'll need to change the generator and, if you have a 64 bit processor, specify the generator platform. Note that you may get multiple build errors compiling the `swift` project due to an MSBuild limitation that file paths cannot exceed 260 characters. These can be ignored, as they occur after the build when writing the last build status to a file.
```
cmake -G "Visual Studio 15" "%swift_source_dir%/swift"^
-DCMAKE_GENERATOR_PLATFORM="x64"^
@@ -145,12 +147,13 @@
## Clang-cl
-Follow the instructions for MSVC, but add the following lines to each CMake configuration command. We need to use LLVM's `lld-link.exe` linker, as MSVC's `link.exe` crashes due to corrupt PDB files using `clang-cl`. `Clang-cl` 3.9.0 has been tested. You can remove the `SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE` definition, as overlays are supported with `clang-cl`, as it supports modules.
+Follow the instructions for MSVC, but add the following lines to each CMake configuration command. `Clang-cl` 4.0.1 has been tested. You can remove the `SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE` definition, as overlays are supported with `clang-cl`, as it supports modules. The `Z7` flag is required to produce PDB files that MSVC's `link.exe` can read, and also enables proper stack traces.
```
-DCMAKE_C_COMPILER="<path-to-llvm-bin>/clang-cl.exe"^
-DCMAKE_CXX_COMPILER="<path-to-llvm-bin>/bin/clang-cl.exe"^
- -DCMAKE_LINKER="<path-to-llvm-bin>/lld-link.exe"^
+ -DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 /Z7"^
+ -DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 -Z7" ^
```
## Windows Subsystem for Linux (WSL)
diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h
index 2a64e80..052946a 100644
--- a/include/swift/AST/ASTContext.h
+++ b/include/swift/AST/ASTContext.h
@@ -170,7 +170,6 @@
};
class SILLayout; // From SIL
-
/// \brief Describes either a nominal type declaration or an extension
/// declaration.
typedef llvm::PointerUnion<NominalTypeDecl *, ExtensionDecl *>
@@ -438,6 +437,9 @@
FuncDecl *get##Name(LazyResolver *resolver) const;
#include "swift/AST/KnownDecls.def"
+ /// Get the '+' function on two RangeReplaceableCollection.
+ FuncDecl *getPlusFunctionOnRangeReplaceableCollection() const;
+
/// Check whether the standard library provides all the correct
/// intrinsic support for Optional<T>.
///
diff --git a/include/swift/AST/ASTMangler.h b/include/swift/AST/ASTMangler.h
index 4fd228a..feebb2e 100644
--- a/include/swift/AST/ASTMangler.h
+++ b/include/swift/AST/ASTMangler.h
@@ -114,12 +114,18 @@
Type FromType, Type ToType,
ModuleDecl *Module);
- std::string mangleKeyPathGetterThunkHelper(const VarDecl *property,
+ std::string mangleKeyPathGetterThunkHelper(const AbstractStorageDecl *property,
GenericSignature *signature,
- CanType baseType);
- std::string mangleKeyPathSetterThunkHelper(const VarDecl *property,
+ CanType baseType,
+ ArrayRef<CanType> subs);
+ std::string mangleKeyPathSetterThunkHelper(const AbstractStorageDecl *property,
GenericSignature *signature,
- CanType baseType);
+ CanType baseType,
+ ArrayRef<CanType> subs);
+ std::string mangleKeyPathEqualsHelper(ArrayRef<CanType> indices,
+ GenericSignature *signature);
+ std::string mangleKeyPathHashHelper(ArrayRef<CanType> indices,
+ GenericSignature *signature);
std::string mangleTypeForDebugger(Type decl, const DeclContext *DC,
GenericEnvironment *GE);
diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h
index b484580..2857478 100644
--- a/include/swift/AST/Decl.h
+++ b/include/swift/AST/Decl.h
@@ -367,7 +367,7 @@
unsigned BodyKind : 3;
/// Number of curried parameter lists.
- unsigned NumParameterLists : 6;
+ unsigned NumParameterLists : 5;
/// Whether we are overridden later.
unsigned Overridden : 1;
@@ -380,6 +380,9 @@
/// Whether NeedsNewVTableEntry is valid.
unsigned HasComputedNeedsNewVTableEntry : 1;
+
+ /// The ResilienceExpansion to use for default arguments.
+ unsigned DefaultArgumentResilienceExpansion : 1;
};
enum { NumAbstractFunctionDeclBits = NumValueDeclBits + 13 };
static_assert(NumAbstractFunctionDeclBits <= 32, "fits in an unsigned");
@@ -4859,6 +4862,8 @@
AbstractFunctionDeclBits.Throws = Throws;
AbstractFunctionDeclBits.NeedsNewVTableEntry = false;
AbstractFunctionDeclBits.HasComputedNeedsNewVTableEntry = false;
+ AbstractFunctionDeclBits.DefaultArgumentResilienceExpansion =
+ unsigned(ResilienceExpansion::Maximal);
// Verify no bitfield truncation.
assert(AbstractFunctionDeclBits.NumParameterLists == NumParameterLists);
@@ -5076,6 +5081,21 @@
/// Resolved during type checking
void setIsOverridden() { AbstractFunctionDeclBits.Overridden = true; }
+ /// The ResilienceExpansion for default arguments.
+ ///
+ /// In Swift 4 mode, default argument expressions are serialized, and must
+ /// obey the restrictions imposed upon inlineable function bodies.
+ ResilienceExpansion getDefaultArgumentResilienceExpansion() const {
+ return ResilienceExpansion(
+ AbstractFunctionDeclBits.DefaultArgumentResilienceExpansion);
+ }
+
+ /// Set the ResilienceExpansion for default arguments.
+ void setDefaultArgumentResilienceExpansion(ResilienceExpansion expansion) {
+ AbstractFunctionDeclBits.DefaultArgumentResilienceExpansion =
+ unsigned(expansion);
+ }
+
/// Set information about the foreign error convention used by this
/// declaration.
void setForeignErrorConvention(const ForeignErrorConvention &convention);
diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def
index 63c3da0..b6260cf 100644
--- a/include/swift/AST/DiagnosticsParse.def
+++ b/include/swift/AST/DiagnosticsParse.def
@@ -589,6 +589,15 @@
"keypath must have at least one component", ())
ERROR(sil_keypath_no_root,none,
"keypath must have a root component declared",())
+ERROR(sil_keypath_index_not_hashable,none,
+ "key path index type %0 does not conform to Hashable", (Type))
+ERROR(sil_keypath_index_operand_type_conflict,none,
+ "conflicting types for key path operand %0: %1 vs. %2",
+ (unsigned, Type, Type))
+ERROR(sil_keypath_no_use_of_operand_in_pattern,none,
+ "operand %0 is not referenced by any component in the pattern",
+ (unsigned))
+
// SIL Basic Blocks
ERROR(expected_sil_block_name,none,
"expected basic block name or '}'", ())
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index 130ab65..321f1f5 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -470,6 +470,8 @@
"string interpolation can only appear inside a string literal", ())
ERROR(unsupported_keypath_tuple_element_reference,none,
"key path cannot reference tuple elements", ())
+ERROR(expr_keypath_subscript_index_not_hashable, none,
+ "subscript index of type %0 in a key path must be Hashable", (Type))
// Selector expressions.
ERROR(expr_selector_no_objc_runtime,none,
@@ -1195,7 +1197,7 @@
// Variables (var and let).
ERROR(unimplemented_static_var,none,
"%select{ERROR|static|class}1 stored properties not supported"
- "%select{ in this context| in generic types| in classes}0"
+ "%select{ in this context| in generic types| in classes| in protocol extensions}0"
"%select{|; did you mean 'static'?}2",
(unsigned, StaticSpellingKind, unsigned))
ERROR(observingprop_requires_initializer,none,
@@ -1934,6 +1936,8 @@
// Inheritance
ERROR(duplicate_inheritance,none,
"duplicate inheritance from %0", (Type))
+WARNING(duplicate_anyobject_class_inheritance,none,
+ "redundant inheritance from 'AnyObject' and Swift 3 'class' keyword", ())
ERROR(multiple_inheritance,none,
"multiple inheritance from classes %0 and %1", (Type, Type))
ERROR(non_class_inheritance,none,
diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h
index e78e864..c4e6cf0 100644
--- a/include/swift/AST/Expr.h
+++ b/include/swift/AST/Expr.h
@@ -4674,6 +4674,7 @@
llvm::PointerIntPair<Expr *, 3, Kind> SubscriptIndexExprAndKind;
ArrayRef<Identifier> SubscriptLabels;
+ ArrayRef<ProtocolConformanceRef> SubscriptHashableConformances;
Type ComponentType;
SourceLoc Loc;
@@ -4681,20 +4682,22 @@
DeclNameOrRef decl,
Expr *indexExpr,
ArrayRef<Identifier> subscriptLabels,
+ ArrayRef<ProtocolConformanceRef> indexHashables,
Kind kind,
Type type,
SourceLoc loc);
public:
Component()
- : Component(nullptr, {}, nullptr, {}, Kind::Invalid, Type(), SourceLoc())
+ : Component(nullptr, {}, nullptr, {}, {}, Kind::Invalid,
+ Type(), SourceLoc())
{}
/// Create an unresolved component for a property.
static Component forUnresolvedProperty(DeclName UnresolvedName,
SourceLoc Loc) {
return Component(nullptr,
- UnresolvedName, nullptr, {},
+ UnresolvedName, nullptr, {}, {},
Kind::UnresolvedProperty,
Type(),
Loc);
@@ -4720,13 +4723,14 @@
SourceLoc loc) {
return Component(&context,
- {}, index, subscriptLabels, Kind::UnresolvedSubscript,
+ {}, index, subscriptLabels, {},
+ Kind::UnresolvedSubscript,
Type(), loc);
}
/// Create an unresolved optional force `!` component.
static Component forUnresolvedOptionalForce(SourceLoc BangLoc) {
- return Component(nullptr, {}, nullptr, {},
+ return Component(nullptr, {}, nullptr, {}, {},
Kind::OptionalForce,
Type(),
BangLoc);
@@ -4734,7 +4738,7 @@
/// Create an unresolved optional chain `?` component.
static Component forUnresolvedOptionalChain(SourceLoc QuestionLoc) {
- return Component(nullptr, {}, nullptr, {},
+ return Component(nullptr, {}, nullptr, {}, {},
Kind::OptionalChain,
Type(),
QuestionLoc);
@@ -4744,7 +4748,7 @@
static Component forProperty(ConcreteDeclRef property,
Type propertyType,
SourceLoc loc) {
- return Component(nullptr, property, nullptr, {},
+ return Component(nullptr, property, nullptr, {}, {},
Kind::Property,
propertyType,
loc);
@@ -4752,14 +4756,15 @@
/// Create a component for a subscript.
static Component forSubscript(ASTContext &ctx,
- ConcreteDeclRef subscript,
- SourceLoc lSquareLoc,
- ArrayRef<Expr *> indexArgs,
- ArrayRef<Identifier> indexArgLabels,
- ArrayRef<SourceLoc> indexArgLabelLocs,
- SourceLoc rSquareLoc,
- Expr *trailingClosure,
- Type elementType);
+ ConcreteDeclRef subscript,
+ SourceLoc lSquareLoc,
+ ArrayRef<Expr *> indexArgs,
+ ArrayRef<Identifier> indexArgLabels,
+ ArrayRef<SourceLoc> indexArgLabelLocs,
+ SourceLoc rSquareLoc,
+ Expr *trailingClosure,
+ Type elementType,
+ ArrayRef<ProtocolConformanceRef> indexHashables);
/// Create a component for a subscript.
///
@@ -4767,11 +4772,12 @@
/// list of index arguments.
static Component forSubscriptWithPrebuiltIndexExpr(
ConcreteDeclRef subscript, Expr *index, ArrayRef<Identifier> labels,
- Type elementType, SourceLoc loc);
+ Type elementType, SourceLoc loc,
+ ArrayRef<ProtocolConformanceRef> indexHashables);
/// Create an optional-forcing `!` component.
static Component forOptionalForce(Type forcedType, SourceLoc bangLoc) {
- return Component(nullptr, {}, nullptr, {},
+ return Component(nullptr, {}, nullptr, {}, {},
Kind::OptionalForce, forcedType,
bangLoc);
}
@@ -4779,7 +4785,7 @@
/// Create an optional-chaining `?` component.
static Component forOptionalChain(Type unwrappedType,
SourceLoc questionLoc) {
- return Component(nullptr, {}, nullptr, {},
+ return Component(nullptr, {}, nullptr, {}, {},
Kind::OptionalChain, unwrappedType,
questionLoc);
}
@@ -4788,7 +4794,7 @@
/// syntax but may appear when the non-optional result of an optional chain
/// is implicitly wrapped.
static Component forOptionalWrap(Type wrappedType) {
- return Component(nullptr, {}, nullptr, {},
+ return Component(nullptr, {}, nullptr, {}, {},
Kind::OptionalWrap, wrappedType,
SourceLoc());
}
@@ -4855,6 +4861,26 @@
llvm_unreachable("no subscript labels for this kind");
}
}
+
+ ArrayRef<ProtocolConformanceRef>
+ getSubscriptIndexHashableConformances() const {
+ switch (getKind()) {
+ case Kind::Subscript:
+ return SubscriptHashableConformances;
+
+ case Kind::UnresolvedSubscript:
+ case Kind::Invalid:
+ case Kind::OptionalChain:
+ case Kind::OptionalWrap:
+ case Kind::OptionalForce:
+ case Kind::UnresolvedProperty:
+ case Kind::Property:
+ llvm_unreachable("no hashable conformances for this kind");
+ }
+ }
+
+ void setSubscriptIndexHashableConformances(
+ ArrayRef<ProtocolConformanceRef> hashables);
DeclName getUnresolvedDeclName() const {
switch (getKind()) {
diff --git a/include/swift/AST/Initializer.h b/include/swift/AST/Initializer.h
index 754f5a6..bb02e88 100644
--- a/include/swift/AST/Initializer.h
+++ b/include/swift/AST/Initializer.h
@@ -154,26 +154,16 @@
public:
explicit DefaultArgumentInitializer(DeclContext *parent, unsigned index)
: Initializer(InitializerKind::DefaultArgument, parent) {
- SpareBits = (unsigned(ResilienceExpansion::Maximal) | index << 1);
+ SpareBits = index;
}
- unsigned getIndex() const { return SpareBits >> 1; }
-
- ResilienceExpansion getResilienceExpansion() const {
- return ResilienceExpansion(SpareBits & 1);
- }
+ unsigned getIndex() const { return SpareBits; }
/// Change the parent of this context. This is necessary because
/// the function signature is parsed before the function
/// declaration/expression itself is built.
void changeFunction(AbstractFunctionDecl *parent);
- /// Change the resilience expansion of this context, necessary
- /// for the same reason as above.
- void changeResilienceExpansion(ResilienceExpansion expansion) {
- SpareBits = (SpareBits & ~1) | unsigned(expansion);
- }
-
static bool classof(const DeclContext *DC) {
if (auto init = dyn_cast<Initializer>(DC))
return classof(init);
diff --git a/include/swift/AST/KnownStdlibTypes.def b/include/swift/AST/KnownStdlibTypes.def
index 8120bbb..904d543 100644
--- a/include/swift/AST/KnownStdlibTypes.def
+++ b/include/swift/AST/KnownStdlibTypes.def
@@ -77,5 +77,6 @@
KNOWN_STDLIB_TYPE_DECL(Decoder, ProtocolDecl, 1)
KNOWN_STDLIB_TYPE_DECL(KeyedEncodingContainer, NominalTypeDecl, 1)
KNOWN_STDLIB_TYPE_DECL(KeyedDecodingContainer, NominalTypeDecl, 1)
+KNOWN_STDLIB_TYPE_DECL(RangeReplaceableCollection, ProtocolDecl, 1)
#undef KNOWN_STDLIB_TYPE_DECL
diff --git a/include/swift/AST/Module.h b/include/swift/AST/Module.h
index 7b7c482..72c6545 100644
--- a/include/swift/AST/Module.h
+++ b/include/swift/AST/Module.h
@@ -488,7 +488,7 @@
}
/// Returns the associated clang module if one exists.
- const clang::Module *findUnderlyingClangModule();
+ const clang::Module *findUnderlyingClangModule() const;
SourceRange getSourceRange() const { return SourceRange(); }
@@ -719,7 +719,9 @@
}
/// Returns the associated clang module if one exists.
- virtual const clang::Module *getUnderlyingClangModule() { return nullptr; }
+ virtual const clang::Module *getUnderlyingClangModule() const {
+ return nullptr;
+ }
/// Traverse the decls within this file.
///
diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h
index 97000a4..2923787 100644
--- a/include/swift/Basic/LangOptions.h
+++ b/include/swift/Basic/LangOptions.h
@@ -236,9 +236,6 @@
/// Diagnose uses of NSCoding with classes that have unstable mangled names.
bool EnableNSKeyedArchiverDiagnostics = true;
- /// Enable keypath components that aren't fully implemented.
- bool EnableExperimentalKeyPathComponents = false;
-
/// When a conversion from String to Substring fails, emit a fix-it to append
/// the void subscript '[]'.
/// FIXME: Remove this flag when void subscripts are implemented.
diff --git a/include/swift/Basic/STLExtras.h b/include/swift/Basic/STLExtras.h
index ce20fb6..199537f 100644
--- a/include/swift/Basic/STLExtras.h
+++ b/include/swift/Basic/STLExtras.h
@@ -786,6 +786,24 @@
return std::transform(C.begin(), C.end(), result, op);
}
+/// Provides default implementations of !=, <=, >, and >= based on == and <.
+template <typename T>
+class RelationalOperationsBase {
+public:
+ friend bool operator>(const T &left, const T &right) {
+ return right < left;
+ }
+ friend bool operator>=(const T &left, const T &right) {
+ return !(left < right);
+ }
+ friend bool operator<=(const T &left, const T &right) {
+ return !(right < left);
+ }
+ friend bool operator!=(const T &left, const T &right) {
+ return !(left == right);
+ }
+};
+
} // end namespace swift
#endif // SWIFT_BASIC_INTERLEAVE_H
diff --git a/include/swift/ClangImporter/ClangImporter.h b/include/swift/ClangImporter/ClangImporter.h
index 718b9af..180a098 100644
--- a/include/swift/ClangImporter/ClangImporter.h
+++ b/include/swift/ClangImporter/ClangImporter.h
@@ -317,6 +317,15 @@
ImportDecl *createImportDecl(ASTContext &Ctx, DeclContext *DC, ClangNode ClangN,
ArrayRef<clang::Module *> Exported);
-}
+
+/// Determine whether \c overlayDC is within an overlay module for the
+/// imported context enclosing \c importedDC.
+///
+/// This routine is used for various hacks that are only permitted within
+/// overlays of imported modules, e.g., Objective-C bridging conformances.
+bool isInOverlayModuleForImportedModule(const DeclContext *overlayDC,
+ const DeclContext *importedDC);
+
+} // end namespace swift
#endif
diff --git a/include/swift/ClangImporter/ClangModule.h b/include/swift/ClangImporter/ClangModule.h
index 5a8e10b..003ec24 100644
--- a/include/swift/ClangImporter/ClangModule.h
+++ b/include/swift/ClangImporter/ClangModule.h
@@ -56,6 +56,11 @@
/// Returns the Swift module that overlays this Clang module.
ModuleDecl *getAdapterModule() const;
+ /// Retrieve the "exported" name of the module, which is usually the module
+ /// name, but might be the name of the public module through which this
+ /// (private) module is re-exported.
+ std::string getExportedModuleName() const;
+
virtual bool isSystemModule() const override;
virtual void lookupValue(ModuleDecl::AccessPathTy accessPath,
@@ -102,7 +107,7 @@
virtual StringRef getFilename() const override;
- virtual const clang::Module *getUnderlyingClangModule() override {
+ virtual const clang::Module *getUnderlyingClangModule() const override {
return getClangModule();
}
diff --git a/include/swift/Demangling/DemangleNodes.def b/include/swift/Demangling/DemangleNodes.def
index d0b26c9..92f7c0f 100644
--- a/include/swift/Demangling/DemangleNodes.def
+++ b/include/swift/Demangling/DemangleNodes.def
@@ -97,6 +97,8 @@
CONTEXT_NODE(Initializer)
NODE(KeyPathGetterThunkHelper)
NODE(KeyPathSetterThunkHelper)
+NODE(KeyPathEqualsThunkHelper)
+NODE(KeyPathHashThunkHelper)
NODE(LazyProtocolWitnessTableAccessor)
NODE(LazyProtocolWitnessTableCacheVariable)
NODE(LocalDeclName)
diff --git a/include/swift/IDE/RefactoringKinds.def b/include/swift/IDE/RefactoringKinds.def
index f08a5b2..9e88ddf 100644
--- a/include/swift/IDE/RefactoringKinds.def
+++ b/include/swift/IDE/RefactoringKinds.def
@@ -38,6 +38,8 @@
CURSOR_REFACTORING(SimplifyNumberLiteral, "Simplify Long Number Literal", simplify.long.number.literal)
+CURSOR_REFACTORING(CollapseNestedIfExpr, "Collapse Nested If Expression", collapse.nested.if.expr)
+
RANGE_REFACTORING(ExtractExpr, "Extract Expression", extract.expr)
RANGE_REFACTORING(ExtractFunction, "Extract Method", extract.function)
diff --git a/include/swift/Option/FrontendOptions.td b/include/swift/Option/FrontendOptions.td
index 867e1e9..8a306eb 100644
--- a/include/swift/Option/FrontendOptions.td
+++ b/include/swift/Option/FrontendOptions.td
@@ -283,10 +283,6 @@
Flag<["-"], "enable-experimental-property-behaviors">,
HelpText<"Enable experimental property behaviors">;
-def enable_experimental_keypath_components :
- Flag<["-"], "enable-experimental-keypath-components">,
- HelpText<"Enable unimplemented keypath component kinds">;
-
def enable_deserialization_recovery :
Flag<["-"], "enable-deserialization-recovery">,
HelpText<"Attempt to recover from missing xrefs (etc) in swiftmodules">;
diff --git a/include/swift/Parse/Lexer.h b/include/swift/Parse/Lexer.h
index 3f908c0..bf43821 100644
--- a/include/swift/Parse/Lexer.h
+++ b/include/swift/Parse/Lexer.h
@@ -546,6 +546,11 @@
});
}
+/// Given an ordered token array \param AllTokens , get the slice of the array
+/// where front() locates at \param StartLoc and back() locates at \param EndLoc .
+ArrayRef<Token> slice_token_array(ArrayRef<Token> AllTokens, SourceLoc StartLoc,
+ SourceLoc EndLoc);
+
} // end namespace swift
#endif
diff --git a/include/swift/Runtime/HeapObject.h b/include/swift/Runtime/HeapObject.h
index c78c309..c21291d 100644
--- a/include/swift/Runtime/HeapObject.h
+++ b/include/swift/Runtime/HeapObject.h
@@ -889,13 +889,15 @@
///
/// \param ref - never null
/// \param value - not necessarily a native Swift object; can be null
+/// \return ref
SWIFT_RUNTIME_EXPORT
-void swift_unknownWeakInit(WeakReference *ref, void *value);
+WeakReference *swift_unknownWeakInit(WeakReference *ref, void *value);
#else
-static inline void swift_unknownWeakInit(WeakReference *ref, void *value) {
- swift_weakInit(ref, static_cast<HeapObject *>(value));
+static inline WeakReference *swift_unknownWeakInit(WeakReference *ref,
+ void *value) {
+ return swift_weakInit(ref, static_cast<HeapObject *>(value));
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -906,13 +908,15 @@
///
/// \param ref - never null
/// \param value - not necessarily a native Swift object; can be null
+/// \return ref
SWIFT_RUNTIME_EXPORT
-void swift_unknownWeakAssign(WeakReference *ref, void *value);
+WeakReference *swift_unknownWeakAssign(WeakReference *ref, void *value);
#else
-static inline void swift_unknownWeakAssign(WeakReference *ref, void *value) {
- swift_weakAssign(ref, static_cast<HeapObject *>(value));
+static inline WeakReference *swift_unknownWeakAssign(WeakReference *ref,
+ void *value) {
+ return swift_weakAssign(ref, static_cast<HeapObject *>(value));
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -973,15 +977,16 @@
/// Copy-initialize a weak reference variable from one that might not
/// refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownWeakCopyInit(WeakReference *dest,
- WeakReference *src);
+WeakReference *swift_unknownWeakCopyInit(WeakReference *dest,
+ WeakReference *src);
#else
-static inline void swift_unknownWeakCopyInit(WeakReference *dest,
- WeakReference *src) {
- swift_weakCopyInit(dest, src);
+static inline WeakReference *swift_unknownWeakCopyInit(WeakReference *dest,
+ WeakReference *src) {
+ return swift_weakCopyInit(dest, src);
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -990,15 +995,16 @@
/// Take-initialize a weak reference variable from one that might not
/// refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownWeakTakeInit(WeakReference *dest,
- WeakReference *src);
+WeakReference *swift_unknownWeakTakeInit(WeakReference *dest,
+ WeakReference *src);
#else
-static inline void swift_unknownWeakTakeInit(WeakReference *dest,
- WeakReference *src) {
- swift_weakTakeInit(dest, src);
+static inline WeakReference *swift_unknownWeakTakeInit(WeakReference *dest,
+ WeakReference *src) {
+ return swift_weakTakeInit(dest, src);
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1007,15 +1013,16 @@
/// Copy-assign a weak reference variable from another when either
/// or both variables might not refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownWeakCopyAssign(WeakReference *dest,
- WeakReference *src);
+WeakReference *swift_unknownWeakCopyAssign(WeakReference *dest,
+ WeakReference *src);
#else
-static inline void swift_unknownWeakCopyAssign(WeakReference *dest,
- WeakReference *src) {
- swift_weakCopyAssign(dest, src);
+static inline WeakReference *swift_unknownWeakCopyAssign(WeakReference *dest,
+ WeakReference *src) {
+ return swift_weakCopyAssign(dest, src);
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1024,15 +1031,16 @@
/// Take-assign a weak reference variable from another when either
/// or both variables might not refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownWeakTakeAssign(WeakReference *dest,
- WeakReference *src);
+WeakReference *swift_unknownWeakTakeAssign(WeakReference *dest,
+ WeakReference *src);
#else
-static inline void swift_unknownWeakTakeAssign(WeakReference *dest,
- WeakReference *src) {
- swift_weakTakeAssign(dest, src);
+static inline WeakReference *swift_unknownWeakTakeAssign(WeakReference *dest,
+ WeakReference *src) {
+ return swift_weakTakeAssign(dest, src);
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1045,14 +1053,16 @@
/// Initialize an unowned reference to an object with unknown reference
/// counting.
+/// \return ref
SWIFT_RUNTIME_EXPORT
-void swift_unknownUnownedInit(UnownedReference *ref, void *value);
+UnownedReference *swift_unknownUnownedInit(UnownedReference *ref, void *value);
#else
-static inline void swift_unknownUnownedInit(UnownedReference *ref,
- void *value) {
+static inline UnownedReference *swift_unknownUnownedInit(UnownedReference *ref,
+ void *value) {
swift_unownedInit(ref, static_cast<HeapObject*>(value));
+ return ref;
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1061,14 +1071,17 @@
/// Assign to an unowned reference holding an object with unknown reference
/// counting.
+/// \return ref
SWIFT_RUNTIME_EXPORT
-void swift_unknownUnownedAssign(UnownedReference *ref, void *value);
+UnownedReference *swift_unknownUnownedAssign(UnownedReference *ref,
+ void *value);
#else
-static inline void swift_unknownUnownedAssign(UnownedReference *ref,
- void *value) {
+static inline UnownedReference *
+swift_unknownUnownedAssign(UnownedReference *ref, void *value) {
swift_unownedAssign(ref, static_cast<HeapObject*>(value));
+ return ref;
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1121,15 +1134,17 @@
/// Copy-initialize an unowned reference variable from one that might not
/// refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownUnownedCopyInit(UnownedReference *dest,
- UnownedReference *src);
+UnownedReference *swift_unknownUnownedCopyInit(UnownedReference *dest,
+ UnownedReference *src);
#else
-static inline void swift_unknownUnownedCopyInit(UnownedReference *dest,
- UnownedReference *src) {
+static inline UnownedReference *
+swift_unknownUnownedCopyInit(UnownedReference *dest, UnownedReference *src) {
swift_unownedCopyInit(dest, src);
+ return dest;
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1139,14 +1154,15 @@
/// Take-initialize an unowned reference variable from one that might not
/// refer to a native Swift object.
SWIFT_RUNTIME_EXPORT
-void swift_unknownUnownedTakeInit(UnownedReference *dest,
- UnownedReference *src);
+UnownedReference *swift_unknownUnownedTakeInit(UnownedReference *dest,
+ UnownedReference *src);
#else
-static inline void swift_unknownUnownedTakeInit(UnownedReference *dest,
- UnownedReference *src) {
+static inline UnownedReference *
+swift_unknownUnownedTakeInit(UnownedReference *dest, UnownedReference *src) {
swift_unownedTakeInit(dest, src);
+ return dest;
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1155,15 +1171,17 @@
/// Copy-assign an unowned reference variable from another when either
/// or both variables might not refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownUnownedCopyAssign(UnownedReference *dest,
- UnownedReference *src);
+UnownedReference *swift_unknownUnownedCopyAssign(UnownedReference *dest,
+ UnownedReference *src);
#else
-static inline void swift_unknownUnownedCopyAssign(UnownedReference *dest,
- UnownedReference *src) {
+static inline UnownedReference *
+swift_unknownUnownedCopyAssign(UnownedReference *dest, UnownedReference *src) {
swift_unownedCopyAssign(dest, src);
+ return dest;
}
#endif /* SWIFT_OBJC_INTEROP */
@@ -1172,15 +1190,17 @@
/// Take-assign an unowned reference variable from another when either
/// or both variables might not refer to a native Swift object.
+/// \return dest
SWIFT_RUNTIME_EXPORT
-void swift_unknownUnownedTakeAssign(UnownedReference *dest,
- UnownedReference *src);
+UnownedReference *swift_unknownUnownedTakeAssign(UnownedReference *dest,
+ UnownedReference *src);
#else
-static inline void swift_unknownUnownedTakeAssign(UnownedReference *dest,
- UnownedReference *src) {
+static inline UnownedReference *
+swift_unknownUnownedTakeAssign(UnownedReference *dest, UnownedReference *src) {
swift_unownedTakeAssign(dest, src);
+ return dest;
}
#endif /* SWIFT_OBJC_INTEROP */
diff --git a/include/swift/Runtime/RuntimeFunctions.def b/include/swift/Runtime/RuntimeFunctions.def
index afa1eb9..0f5ff24 100644
--- a/include/swift/Runtime/RuntimeFunctions.def
+++ b/include/swift/Runtime/RuntimeFunctions.def
@@ -520,15 +520,15 @@
// void swift_unknownWeakInit(WeakReference *object, void *value);
FUNCTION(UnknownWeakInit, swift_unknownWeakInit, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(WeakReferencePtrTy),
ARGS(WeakReferencePtrTy, UnknownRefCountedPtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownWeakAssign(WeakReference *object, void *value);
+// WeakReference *swift_unknownWeakAssign(WeakReference *object, void *value);
FUNCTION(UnknownWeakAssign, swift_unknownWeakAssign, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(WeakReferencePtrTy),
ARGS(WeakReferencePtrTy, UnknownRefCountedPtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
// void *swift_unknownWeakLoad(WeakReference *object);
FUNCTION(UnknownWeakLoadStrong, swift_unknownWeakLoadStrong,DefaultCC,
@@ -542,29 +542,29 @@
ARGS(WeakReferencePtrTy),
ATTRS(NoUnwind))
-// void swift_unknownWeakCopyInit(WeakReference *dest, WeakReference *src);
+// WeakReference *swift_unknownWeakCopyInit(WeakReference *dest, WeakReference *src);
FUNCTION(UnknownWeakCopyInit, swift_unknownWeakCopyInit, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(WeakReferencePtrTy),
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownWeakTakeInit(WeakReference *dest, WeakReference *src);
+// void *swift_unknownWeakTakeInit(WeakReference *dest, WeakReference *src);
FUNCTION(UnknownWeakTakeInit, swift_unknownWeakTakeInit, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(WeakReferencePtrTy),
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownWeakCopyAssign(WeakReference *dest, WeakReference *src);
+// WeakReference *swift_unknownWeakCopyAssign(WeakReference *dest, WeakReference *src);
FUNCTION(UnknownWeakCopyAssign, swift_unknownWeakCopyAssign, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(WeakReferencePtrTy),
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownWeakTakeAssign(WeakReference *dest, WeakReference *src);
+// WeakReference *swift_unknownWeakTakeAssign(WeakReference *dest, WeakReference *src);
FUNCTION(UnknownWeakTakeAssign, swift_unknownWeakTakeAssign, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(WeakReferencePtrTy),
ARGS(WeakReferencePtrTy, WeakReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
// void swift_unknownUnownedDestroy(UnownedReference *object);
FUNCTION(UnknownUnownedDestroy, swift_unknownUnownedDestroy, DefaultCC,
@@ -572,17 +572,17 @@
ARGS(UnownedReferencePtrTy),
ATTRS(NoUnwind))
-// void swift_unknownUnownedInit(UnownedReference *object, void *value);
+// UnownedReference *swift_unknownUnownedInit(UnownedReference *object, void *value);
FUNCTION(UnknownUnownedInit, swift_unknownUnownedInit, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(UnownedReferencePtrTy),
ARGS(UnownedReferencePtrTy, UnknownRefCountedPtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownUnownedAssign(UnownedReference *object, void *value);
+// UnownedReference *swift_unknownUnownedAssign(UnownedReference *object, void *value);
FUNCTION(UnknownUnownedAssign, swift_unknownUnownedAssign, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(UnownedReferencePtrTy),
ARGS(UnownedReferencePtrTy, UnknownRefCountedPtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
// void *swift_unknownUnownedLoad(UnownedReference *object);
FUNCTION(UnknownUnownedLoadStrong, swift_unknownUnownedLoadStrong, DefaultCC,
@@ -596,29 +596,29 @@
ARGS(UnownedReferencePtrTy),
ATTRS(NoUnwind))
-// void swift_unknownUnownedCopyInit(UnownedReference *dest, UnownedReference *src);
+// UnownedReference *swift_unknownUnownedCopyInit(UnownedReference *dest, UnownedReference *src);
FUNCTION(UnknownUnownedCopyInit, swift_unknownUnownedCopyInit, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(UnownedReferencePtrTy),
ARGS(UnownedReferencePtrTy, UnownedReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownUnownedTakeInit(UnownedReference *dest, UnownedReference *src);
+// UnownedReference *swift_unknownUnownedTakeInit(UnownedReference *dest, UnownedReference *src);
FUNCTION(UnknownUnownedTakeInit, swift_unknownUnownedTakeInit, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(UnownedReferencePtrTy),
ARGS(UnownedReferencePtrTy, UnownedReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownUnownedCopyAssign(UnownedReference *dest, UnownedReference *src);
+// UnownedReference *swift_unknownUnownedCopyAssign(UnownedReference *dest, UnownedReference *src);
FUNCTION(UnknownUnownedCopyAssign, swift_unknownUnownedCopyAssign, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(UnownedReferencePtrTy),
ARGS(UnownedReferencePtrTy, UnownedReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
-// void swift_unknownUnownedTakeAssign(UnownedReference *dest, UnownedReference *src);
+// UnownedReference *swift_unknownUnownedTakeAssign(UnownedReference *dest, UnownedReference *src);
FUNCTION(UnknownUnownedTakeAssign, swift_unknownUnownedTakeAssign, DefaultCC,
- RETURNS(VoidTy),
+ RETURNS(UnownedReferencePtrTy),
ARGS(UnownedReferencePtrTy, UnownedReferencePtrTy),
- ATTRS(NoUnwind))
+ ATTRS(NoUnwind, FirstParamReturned))
// bool swift_isUniquelyReferencedNonObjC(const void *);
FUNCTION(IsUniquelyReferencedNonObjC, swift_isUniquelyReferencedNonObjC,
@@ -1287,6 +1287,10 @@
RETURNS(RefCountedPtrTy),
ARGS(Int8PtrTy, Int8PtrTy),
ATTRS(NoUnwind))
+FUNCTION(CopyKeyPathTrivialIndices, swift_copyKeyPathTrivialIndices, DefaultCC,
+ RETURNS(VoidTy),
+ ARGS(Int8PtrTy, Int8PtrTy, SizeTy),
+ ATTRS(NoUnwind))
#if SWIFT_OBJC_INTEROP || !defined(SWIFT_RUNTIME_GENERATE_GLOBAL_SYMBOLS)
diff --git a/include/swift/SIL/SILBuilder.h b/include/swift/SIL/SILBuilder.h
index e2bba6f..58c86d9 100644
--- a/include/swift/SIL/SILBuilder.h
+++ b/include/swift/SIL/SILBuilder.h
@@ -535,9 +535,11 @@
KeyPathInst *createKeyPath(SILLocation Loc,
KeyPathPattern *Pattern,
SubstitutionList Subs,
+ ArrayRef<SILValue> Args,
SILType Ty) {
return insert(KeyPathInst::create(getSILDebugLocation(Loc),
- Pattern, Subs, Ty, getFunction()));
+ Pattern, Subs, Args,
+ Ty, getFunction()));
}
/// Convenience function for calling emitLoad on the type lowering for
diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h
index 90773f3..6e05444 100644
--- a/include/swift/SIL/SILCloner.h
+++ b/include/swift/SIL/SILCloner.h
@@ -2344,10 +2344,15 @@
template <typename ImplClass>
void SILCloner<ImplClass>::visitKeyPathInst(KeyPathInst *Inst) {
getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope()));
+ SmallVector<SILValue, 4> opValues;
+ for (auto &op : Inst->getAllOperands())
+ opValues.push_back(getOpValue(op.get()));
+
doPostProcess(Inst, getBuilder().createKeyPath(
getOpLocation(Inst->getLoc()),
Inst->getPattern(),
getOpSubstitutions(Inst->getSubstitutions()),
+ opValues,
getOpType(Inst->getType())));
}
diff --git a/include/swift/SIL/SILGlobalVariable.h b/include/swift/SIL/SILGlobalVariable.h
index 747bd3e..7fe6ba5 100644
--- a/include/swift/SIL/SILGlobalVariable.h
+++ b/include/swift/SIL/SILGlobalVariable.h
@@ -154,7 +154,8 @@
/// Returns true if \p I is a valid instruction to be contained in the
/// static initializer.
- static bool isValidStaticInitializerInst(const SILInstruction *I);
+ static bool isValidStaticInitializerInst(const SILInstruction *I,
+ SILModule &M);
void dropAllReferences() {
StaticInitializerBlock.dropAllReferences();
diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h
index c32b4a6..288bf2b 100644
--- a/include/swift/SIL/SILInstruction.h
+++ b/include/swift/SIL/SILInstruction.h
@@ -1534,11 +1534,13 @@
OptionalWrap,
};
- // The pair of a captured index value and its Hashable conformance for a
+ // Description of a captured index value and its Hashable conformance for a
// subscript keypath.
- struct IndexPair {
+ struct Index {
unsigned Operand;
- ProtocolConformance *Hashable;
+ CanType FormalType;
+ SILType LoweredType;
+ ProtocolConformanceRef Hashable;
};
private:
@@ -1555,7 +1557,9 @@
ComputedPropertyId::KindType>
SetterAndIdKind;
ComputedPropertyId::ValueType IdValue;
- ArrayRef<IndexPair> Indices;
+ ArrayRef<Index> Indices;
+ SILFunction *IndicesEqual;
+ SILFunction *IndicesHash;
CanType ComponentType;
unsigned kindForPacking(Kind k) {
@@ -1579,13 +1583,21 @@
KeyPathPatternComponent(ComputedPropertyId id, Kind kind,
SILFunction *getter,
SILFunction *setter,
- ArrayRef<IndexPair> indices,
+ ArrayRef<Index> indices,
+ SILFunction *indicesEqual,
+ SILFunction *indicesHash,
CanType ComponentType)
: ValueAndKind(getter, kindForPacking(kind)),
SetterAndIdKind(setter, id.Kind),
IdValue(id.Value),
Indices(indices),
- ComponentType(ComponentType) {}
+ IndicesEqual(indicesEqual),
+ IndicesHash(indicesHash),
+ ComponentType(ComponentType) {
+ assert(indices.empty() == !indicesEqual
+ && indices.empty() == !indicesHash
+ && "must have equals/hash functions iff there are indices");
+ }
public:
KeyPathPatternComponent() : ValueAndKind(nullptr, 0) {}
@@ -1661,7 +1673,7 @@
llvm_unreachable("unhandled kind");
}
- ArrayRef<IndexPair> getComputedPropertyIndices() const {
+ ArrayRef<Index> getComputedPropertyIndices() const {
switch (getKind()) {
case Kind::StoredProperty:
case Kind::OptionalChain:
@@ -1674,6 +1686,13 @@
}
}
+ SILFunction *getComputedPropertyIndexEquals() const {
+ return IndicesEqual;
+ }
+ SILFunction *getComputedPropertyIndexHash() const {
+ return IndicesHash;
+ }
+
bool isComputedSettablePropertyMutating() const;
static KeyPathPatternComponent forStoredProperty(VarDecl *property,
@@ -1684,20 +1703,26 @@
static KeyPathPatternComponent
forComputedGettableProperty(ComputedPropertyId identifier,
SILFunction *getter,
- ArrayRef<IndexPair> indices,
+ ArrayRef<Index> indices,
+ SILFunction *indicesEquals,
+ SILFunction *indicesHash,
CanType ty) {
return KeyPathPatternComponent(identifier, Kind::GettableProperty,
- getter, nullptr, indices, ty);
+ getter, nullptr, indices,
+ indicesEquals, indicesHash, ty);
}
static KeyPathPatternComponent
forComputedSettableProperty(ComputedPropertyId identifier,
SILFunction *getter,
SILFunction *setter,
- ArrayRef<IndexPair> indices,
+ ArrayRef<Index> indices,
+ SILFunction *indicesEquals,
+ SILFunction *indicesHash,
CanType ty) {
return KeyPathPatternComponent(identifier, Kind::SettableProperty,
- getter, setter, indices, ty);
+ getter, setter, indices,
+ indicesEquals, indicesHash, ty);
}
static KeyPathPatternComponent
@@ -1797,32 +1822,40 @@
/// Instantiates a key path object.
class KeyPathInst final
: public SILInstruction,
- private llvm::TrailingObjects<KeyPathInst, Substitution>
+ private llvm::TrailingObjects<KeyPathInst, Substitution, Operand>
{
friend SILBuilder;
friend TrailingObjects;
KeyPathPattern *Pattern;
- unsigned NumSubstitutions;
+ unsigned NumSubstitutions, NumOperands;
static KeyPathInst *create(SILDebugLocation Loc,
KeyPathPattern *Pattern,
SubstitutionList Subs,
+ ArrayRef<SILValue> Args,
SILType Ty,
SILFunction &F);
KeyPathInst(SILDebugLocation Loc,
KeyPathPattern *Pattern,
SubstitutionList Subs,
+ ArrayRef<SILValue> Args,
SILType Ty);
+ size_t numTrailingObjects(OverloadToken<Substitution>) const {
+ return NumSubstitutions;
+ }
+ size_t numTrailingObjects(OverloadToken<Operand>) const {
+ return NumOperands;
+ }
+
public:
KeyPathPattern *getPattern() const;
bool hasPattern() const { return (bool)Pattern; }
ArrayRef<Operand> getAllOperands() const {
- // TODO: Subscript keypaths will have operands.
- return {};
+ return const_cast<KeyPathInst*>(this)->getAllOperands();
}
MutableArrayRef<Operand> getAllOperands();
diff --git a/include/swift/SIL/SILType.h b/include/swift/SIL/SILType.h
index e3b548f..12daf09 100644
--- a/include/swift/SIL/SILType.h
+++ b/include/swift/SIL/SILType.h
@@ -258,8 +258,10 @@
/// True if the type, or the referenced type of an address type, is trivial.
bool isTrivial(SILModule &M) const;
- /// True if the type, or the referenced type of an address type, is a
- /// scalar reference-counted type.
+ /// True if the type, or the referenced type of an address type, is known to
+ /// be a scalar reference-counted type. If this is false, then some part of
+ /// the type may be opaque. It may become reference counted later after
+ /// specialization.
bool isReferenceCounted(SILModule &M) const;
/// Returns true if the referenced type is a function type that never
diff --git a/include/swift/SIL/SILValue.h b/include/swift/SIL/SILValue.h
index bc7d869..4de46f2 100644
--- a/include/swift/SIL/SILValue.h
+++ b/include/swift/SIL/SILValue.h
@@ -326,15 +326,13 @@
/// FIXME: this could be space-compressed.
SILInstruction *Owner;
+public:
Operand(SILInstruction *owner) : Owner(owner) {}
Operand(SILInstruction *owner, SILValue theValue)
: TheValue(theValue), Owner(owner) {
insertIntoCurrent();
}
- template<unsigned N> friend class FixedOperandList;
- template<unsigned N> friend class TailAllocatedOperandList;
-public:
/// Operands are not copyable.
Operand(const Operand &use) = delete;
Operand &operator=(const Operand &use) = delete;
diff --git a/include/swift/Serialization/ModuleFormat.h b/include/swift/Serialization/ModuleFormat.h
index 4afeb8e..08f2d2e 100644
--- a/include/swift/Serialization/ModuleFormat.h
+++ b/include/swift/Serialization/ModuleFormat.h
@@ -54,7 +54,7 @@
/// in source control, you should also update the comment to briefly
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
-const uint16_t VERSION_MINOR = 364; // Last change: Builtin.assignCopyArray...
+const uint16_t VERSION_MINOR = 366; // Last change: default argument resilience expansion
using DeclID = PointerEmbeddedInt<unsigned, 31>;
using DeclIDField = BCFixed<31>;
@@ -388,6 +388,13 @@
/// TODO: Float, string, char, etc.
};
+// These IDs must \em not be renumbered or reordered without incrementing
+// VERSION_MAJOR.
+enum class ResilienceExpansion : uint8_t {
+ Minimal = 0,
+ Maximal,
+};
+
using EnumElementRawValueKindField = BCFixed<4>;
/// The various types of blocks that can occur within a serialized Swift
@@ -893,6 +900,7 @@
DeclIDField, // overridden decl
AccessLevelField, // access level
BCFixed<1>, // requires a new vtable slot
+ BCFixed<1>, // default argument resilience expansion
BCFixed<1>, // 'required' but overridden is not (used for recovery)
BCVBR<5>, // number of parameter name components
BCArray<IdentifierIDField> // name components,
@@ -957,6 +965,7 @@
AddressorKindField, // addressor kind
AccessLevelField, // access level
BCFixed<1>, // requires a new vtable slot
+ BCFixed<1>, // default argument resilience expansion
BCArray<IdentifierIDField> // name components,
// followed by TypeID dependencies
// The record is trailed by:
diff --git a/include/swift/Serialization/SerializedModuleLoader.h b/include/swift/Serialization/SerializedModuleLoader.h
index adce04b..0978e16 100644
--- a/include/swift/Serialization/SerializedModuleLoader.h
+++ b/include/swift/Serialization/SerializedModuleLoader.h
@@ -193,7 +193,7 @@
bool hasEntryPoint() const override;
- virtual const clang::Module *getUnderlyingClangModule() override;
+ virtual const clang::Module *getUnderlyingClangModule() const override;
static bool classof(const FileUnit *file) {
return file->getKind() == FileUnitKind::SerializedAST;
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index b1a9b87..8d003f1 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -129,6 +129,9 @@
DECL_CLASS *NAME##Decl = nullptr;
#include "swift/AST/KnownStdlibTypes.def"
+ /// The declaration of '+' function for two RangeReplaceableCollection.
+ FuncDecl *PlusFunctionOnRangeReplaceableCollection = nullptr;
+
/// The declaration of Swift.Optional<T>.Some.
EnumElementDecl *OptionalSomeDecl = nullptr;
@@ -545,6 +548,30 @@
return nullptr;
}
+FuncDecl *ASTContext::getPlusFunctionOnRangeReplaceableCollection() const {
+ if (Impl.PlusFunctionOnRangeReplaceableCollection) {
+ return Impl.PlusFunctionOnRangeReplaceableCollection;
+ }
+ // Find all of the declarations with this name in the Swift module.
+ SmallVector<ValueDecl *, 1> Results;
+ lookupInSwiftModule("+", Results);
+ for (auto Result : Results) {
+ if (auto *FD = dyn_cast<FuncDecl>(Result)) {
+ if(!FD->getOperatorDecl())
+ continue;
+ for (auto Req: FD->getGenericRequirements()) {
+ if (Req.getKind() == RequirementKind::Conformance &&
+ Req.getSecondType()->getNominalOrBoundGenericNominal() ==
+ getRangeReplaceableCollectionDecl()) {
+ Impl.PlusFunctionOnRangeReplaceableCollection = FD;
+ }
+ }
+ }
+ }
+ return Impl.PlusFunctionOnRangeReplaceableCollection;
+}
+
+
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
DECL_CLASS *ASTContext::get##NAME##Decl() const { \
if (!Impl.NAME##Decl) \
diff --git a/lib/AST/ASTMangler.cpp b/lib/AST/ASTMangler.cpp
index 8e0db26..0191a17 100644
--- a/lib/AST/ASTMangler.cpp
+++ b/lib/AST/ASTMangler.cpp
@@ -276,30 +276,70 @@
return finalize();
}
-std::string ASTMangler::mangleKeyPathGetterThunkHelper(const VarDecl *property,
- GenericSignature *signature,
- CanType baseType) {
+std::string ASTMangler::mangleKeyPathGetterThunkHelper(
+ const AbstractStorageDecl *property,
+ GenericSignature *signature,
+ CanType baseType,
+ ArrayRef<CanType> subs) {
beginMangling();
appendEntity(property);
if (signature)
appendGenericSignature(signature);
appendType(baseType);
+ if (isa<SubscriptDecl>(property)) {
+ // Subscripts can be generic, and different key paths could capture the same
+ // subscript at different generic arguments.
+ for (auto &sub : subs) {
+ appendType(sub);
+ }
+ }
appendOperator("TK");
return finalize();
}
-std::string ASTMangler::mangleKeyPathSetterThunkHelper(const VarDecl *property,
- GenericSignature *signature,
- CanType baseType) {
+std::string ASTMangler::mangleKeyPathSetterThunkHelper(
+ const AbstractStorageDecl *property,
+ GenericSignature *signature,
+ CanType baseType,
+ ArrayRef<CanType> subs) {
beginMangling();
appendEntity(property);
if (signature)
appendGenericSignature(signature);
appendType(baseType);
+ if (isa<SubscriptDecl>(property)) {
+ // Subscripts can be generic, and different key paths could capture the same
+ // subscript at different generic arguments.
+ for (auto &sub : subs) {
+ appendType(sub);
+ }
+ }
appendOperator("Tk");
return finalize();
}
+std::string ASTMangler::mangleKeyPathEqualsHelper(ArrayRef<CanType> indices,
+ GenericSignature *signature) {
+ beginMangling();
+ for (auto &index : indices)
+ appendType(index);
+ if (signature)
+ appendGenericSignature(signature);
+ appendOperator("TH");
+ return finalize();
+}
+
+std::string ASTMangler::mangleKeyPathHashHelper(ArrayRef<CanType> indices,
+ GenericSignature *signature) {
+ beginMangling();
+ for (auto &index : indices)
+ appendType(index);
+ if (signature)
+ appendGenericSignature(signature);
+ appendOperator("Th");
+ return finalize();
+}
+
std::string ASTMangler::mangleGlobalInit(const VarDecl *decl, int counter,
bool isInitFunc) {
auto topLevelContext = decl->getDeclContext()->getModuleScopeContext();
diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp
index 63c53ce..4cc135e 100644
--- a/lib/AST/ASTPrinter.cpp
+++ b/lib/AST/ASTPrinter.cpp
@@ -2503,10 +2503,13 @@
printContextIfNeeded(decl);
recordDeclLoc(decl,
[&]{ // Name
- if (!decl->hasName())
+ if (!decl->hasName()) {
Printer << "<anonymous>";
- else
+ } else {
Printer.printName(decl->getName());
+ if (decl->isOperator())
+ Printer << " ";
+ }
}, [&] { // Parameters
if (decl->isGeneric())
if (auto *genericSig = decl->getGenericSignature())
diff --git a/lib/AST/ASTWalker.cpp b/lib/AST/ASTWalker.cpp
index e4055aa..78a2088 100644
--- a/lib/AST/ASTWalker.cpp
+++ b/lib/AST/ASTWalker.cpp
@@ -954,7 +954,8 @@
newIndex,
component.getSubscriptLabels(),
component.getComponentType(),
- component.getLoc())
+ component.getLoc(),
+ component.getSubscriptIndexHashableConformances())
: KeyPathExpr::Component
::forUnresolvedSubscriptWithPrebuiltIndexExpr(
E->getType()->getASTContext(),
diff --git a/lib/AST/DeclContext.cpp b/lib/AST/DeclContext.cpp
index f8d4e75..45690b5 100644
--- a/lib/AST/DeclContext.cpp
+++ b/lib/AST/DeclContext.cpp
@@ -519,8 +519,10 @@
for (const auto *dc = this; dc->isLocalContext(); dc = dc->getParent()) {
// Default argument initializer contexts have their resilience expansion
// set when they're type checked.
- if (auto *DAI = dyn_cast<DefaultArgumentInitializer>(dc))
- return DAI->getResilienceExpansion();
+ if (auto *DAI = dyn_cast<DefaultArgumentInitializer>(dc)) {
+ return cast<AbstractFunctionDecl>(dc->getParent())
+ ->getDefaultArgumentResilienceExpansion();
+ }
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(dc)) {
// If the function is a nested function, we will serialize its body if
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 819fd19..03ba1bb 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -2131,14 +2131,15 @@
KeyPathExpr::Component
KeyPathExpr::Component::forSubscript(ASTContext &ctx,
- ConcreteDeclRef subscript,
- SourceLoc lSquareLoc,
- ArrayRef<Expr *> indexArgs,
- ArrayRef<Identifier> indexArgLabels,
- ArrayRef<SourceLoc> indexArgLabelLocs,
- SourceLoc rSquareLoc,
- Expr *trailingClosure,
- Type elementType) {
+ ConcreteDeclRef subscript,
+ SourceLoc lSquareLoc,
+ ArrayRef<Expr *> indexArgs,
+ ArrayRef<Identifier> indexArgLabels,
+ ArrayRef<SourceLoc> indexArgLabelLocs,
+ SourceLoc rSquareLoc,
+ Expr *trailingClosure,
+ Type elementType,
+ ArrayRef<ProtocolConformanceRef> indexHashables) {
SmallVector<Identifier, 4> indexArgLabelsScratch;
SmallVector<SourceLoc, 4> indexArgLabelLocsScratch;
Expr *index = packSingleArgument(ctx, lSquareLoc, indexArgs, indexArgLabels,
@@ -2149,7 +2150,8 @@
return forSubscriptWithPrebuiltIndexExpr(subscript, index,
indexArgLabels,
elementType,
- lSquareLoc);
+ lSquareLoc,
+ indexHashables);
}
KeyPathExpr::Component
@@ -2176,6 +2178,7 @@
DeclNameOrRef decl,
Expr *indexExpr,
ArrayRef<Identifier> subscriptLabels,
+ ArrayRef<ProtocolConformanceRef> indexHashables,
Kind kind,
Type type,
SourceLoc loc)
@@ -2183,13 +2186,35 @@
SubscriptLabels(subscriptLabels.empty()
? subscriptLabels
: ctxForCopyingLabels->AllocateCopy(subscriptLabels)),
+ SubscriptHashableConformances(indexHashables),
ComponentType(type), Loc(loc)
{}
KeyPathExpr::Component
KeyPathExpr::Component::forSubscriptWithPrebuiltIndexExpr(
ConcreteDeclRef subscript, Expr *index, ArrayRef<Identifier> labels,
- Type elementType, SourceLoc loc) {
+ Type elementType, SourceLoc loc,
+ ArrayRef<ProtocolConformanceRef> indexHashables) {
return Component(&elementType->getASTContext(),
- subscript, index, {}, Kind::Subscript, elementType, loc);
+ subscript, index, labels, indexHashables,
+ Kind::Subscript, elementType, loc);
+}
+
+void KeyPathExpr::Component::setSubscriptIndexHashableConformances(
+ ArrayRef<ProtocolConformanceRef> hashables) {
+ switch (getKind()) {
+ case Kind::Subscript:
+ SubscriptHashableConformances = getComponentType()->getASTContext()
+ .AllocateCopy(hashables);
+ return;
+
+ case Kind::UnresolvedSubscript:
+ case Kind::Invalid:
+ case Kind::OptionalChain:
+ case Kind::OptionalWrap:
+ case Kind::OptionalForce:
+ case Kind::UnresolvedProperty:
+ case Kind::Property:
+ llvm_unreachable("no hashable conformances for this kind");
+ }
}
diff --git a/lib/AST/GenericSignatureBuilder.cpp b/lib/AST/GenericSignatureBuilder.cpp
index d0ed957..ed9d420 100644
--- a/lib/AST/GenericSignatureBuilder.cpp
+++ b/lib/AST/GenericSignatureBuilder.cpp
@@ -579,6 +579,32 @@
return selfPA;
}
+/// Determine whether the given protocol requirement is self-derived when it
+/// occurs within the requirement signature of its own protocol.
+static bool isSelfDerivedProtocolRequirementInProtocol(
+ const RequirementSource *source,
+ ProtocolDecl *selfProto,
+ GenericSignatureBuilder &builder) {
+ assert(source->isProtocolRequirement());
+
+ // This can only happen if the requirement points comes from the protocol
+ // itself.
+ if (source->getProtocolDecl() != selfProto) return false;
+
+ // This only applies if the parent is not the anchor for computing the
+ // requirement signature. Anywhere else, we can use the protocol requirement.
+ if (source->parent->kind == RequirementSource::RequirementSignatureSelf)
+ return false;
+
+ // If the relative type of the protocol requirement itself is in the
+ // same equivalence class as what we've proven with this requirement,
+ // it's a self-derived requirement.
+ return
+ source->getAffectedPotentialArchetype()->getEquivalenceClassIfPresent() ==
+ builder.resolveEquivalenceClass(source->getStoredType(),
+ ArchetypeResolutionKind::AlreadyKnown);
+}
+
const RequirementSource *RequirementSource::getMinimalConformanceSource(
PotentialArchetype *currentPA,
ProtocolDecl *proto,
@@ -607,6 +633,7 @@
};
bool sawProtocolRequirement = false;
+ ProtocolDecl *requirementSignatureSelfProto = nullptr;
PotentialArchetype *rootPA = nullptr;
Optional<std::pair<const RequirementSource *, const RequirementSource *>>
@@ -625,14 +652,25 @@
// The parent potential archetype must conform to the protocol in which
// this requirement resides. Add this constraint.
- auto startOfPath =
- addConstraint(parentPA, source->getProtocolDecl(), source->parent);
- if (!startOfPath) return false;
+ if (auto startOfPath =
+ addConstraint(parentPA, source->getProtocolDecl(),
+ source->parent)) {
+ // We found a redundant subpath; record it and stop the algorithm.
+ assert(startOfPath != source->parent);
+ redundantSubpath = { startOfPath, source->parent };
+ return true;
+ }
- // We found a redundant subpath; record it and stop the algorithm.
- assert(startOfPath != source->parent);
- redundantSubpath = { startOfPath, source->parent };
- return true;
+ // If this is a self-derived protocol requirement, fail.
+ if (requirementSignatureSelfProto &&
+ isSelfDerivedProtocolRequirementInProtocol(
+ source,
+ requirementSignatureSelfProto,
+ *currentPA->getBuilder()))
+ return true;
+
+ // No redundancy thus far.
+ return false;
}
case Parent:
@@ -645,12 +683,17 @@
case EquivalentType:
return false;
+ case RequirementSignatureSelf:
+ // Note the protocol whose requirement signature the requirement is
+ // based on.
+ requirementSignatureSelfProto = source->getProtocolDecl();
+ LLVM_FALLTHROUGH;
+
case Explicit:
case Inferred:
case QuietlyInferred:
case NestedTypeNameMatch:
case ConcreteTypeBinding:
- case RequirementSignatureSelf:
rootPA = parentPA;
return false;
}
@@ -4712,7 +4755,8 @@
template<typename T>
bool removeSelfDerived(std::vector<Constraint<T>> &constraints,
ProtocolDecl *proto,
- bool dropDerivedViaConcrete = true) {
+ bool dropDerivedViaConcrete = true,
+ bool allCanBeSelfDerived = false) {
bool anyDerivedViaConcrete = false;
Optional<Constraint<T>> remainingConcrete;
SmallVector<Constraint<T>, 4> minimalSources;
@@ -4780,7 +4824,8 @@
if (constraints.empty() && remainingConcrete)
constraints.push_back(*remainingConcrete);
- assert(!constraints.empty() && "All constraints were self-derived!");
+ assert((!constraints.empty() || allCanBeSelfDerived) &&
+ "All constraints were self-derived!");
return anyDerivedViaConcrete;
}
} // end anonymous namespace
@@ -5536,7 +5581,8 @@
// Remove self-derived constraints.
if (removeSelfDerived(constraints, /*proto=*/nullptr,
- /*dropDerivedViaConcrete=*/false))
+ /*dropDerivedViaConcrete=*/false,
+ /*allCanBeSelfDerived=*/true))
anyDerivedViaConcrete = true;
// Sort the constraints, so we get a deterministic ordering of diagnostics.
@@ -5633,7 +5679,9 @@
auto &constraints = entry.second;
// Remove derived-via-concrete constraints.
- (void)removeSelfDerived(constraints, /*proto=*/nullptr);
+ (void)removeSelfDerived(constraints, /*proto=*/nullptr,
+ /*dropDerivedViaConcrete=*/true,
+ /*allCanBeSelfDerived=*/true);
}
}
diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp
index 7146adc..1979883 100644
--- a/lib/AST/Module.cpp
+++ b/lib/AST/Module.cpp
@@ -663,13 +663,11 @@
if (auto inherited = dyn_cast<InheritedProtocolConformance>(conformance)) {
// Dig out the conforming nominal type.
auto rootConformance = inherited->getRootNormalConformance();
- auto conformingNominal
+ auto conformingClass
= rootConformance->getType()->getClassOrBoundGenericClass();
// Map up to our superclass's type.
- Type superclassTy = type->getSuperclass();
- while (superclassTy->getAnyNominal() != conformingNominal)
- superclassTy = superclassTy->getSuperclass();
+ auto superclassTy = type->getSuperclassForDecl(conformingClass);
// Compute the conformance for the inherited type.
auto inheritedConformance = lookupConformance(superclassTy, protocol);
@@ -1214,7 +1212,7 @@
return false;
}
-const clang::Module *ModuleDecl::findUnderlyingClangModule() {
+const clang::Module *ModuleDecl::findUnderlyingClangModule() const {
for (auto *FU : getFiles()) {
if (auto *Mod = FU->getUnderlyingClangModule())
return Mod;
diff --git a/lib/ClangImporter/ClangAdapter.cpp b/lib/ClangImporter/ClangAdapter.cpp
index e0155aa..04daaf81 100644
--- a/lib/ClangImporter/ClangAdapter.cpp
+++ b/lib/ClangImporter/ClangAdapter.cpp
@@ -437,7 +437,7 @@
importer::getSwiftNewtypeAttr(const clang::TypedefNameDecl *decl,
ImportNameVersion version) {
// Newtype was introduced in Swift 3
- if (version < ImportNameVersion::Swift3 )
+ if (version <= ImportNameVersion::swift2())
return nullptr;
return retrieveNewTypeAttr(decl);
}
@@ -448,7 +448,7 @@
clang::Sema &clangSema,
ImportNameVersion version) {
// Newtype was introduced in Swift 3
- if (version < ImportNameVersion::Swift3 )
+ if (version <= ImportNameVersion::swift2())
return nullptr;
auto varDecl = dyn_cast<clang::VarDecl>(decl);
diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp
index 7728fbb..e87a9f1 100644
--- a/lib/ClangImporter/ClangImporter.cpp
+++ b/lib/ClangImporter/ClangImporter.cpp
@@ -1650,7 +1650,7 @@
BridgingHeaderExplicitlyRequested(!opts.BridgingHeader.empty()),
DisableAdapterModules(opts.DisableAdapterModules),
IsReadingBridgingPCH(false),
- CurrentVersion(nameVersionFromOptions(ctx.LangOpts)),
+ CurrentVersion(ImportNameVersion::fromOptions(ctx.LangOpts)),
BridgingHeaderLookupTable(new SwiftLookupTable(nullptr)),
platformAvailability(ctx.LangOpts),
nameImporter() {}
@@ -2508,32 +2508,34 @@
bool anyMatching = false;
TypeDecl *originalDecl = nullptr;
- owner.forEachDistinctName(clangTypeDecl, [&](ImportedName newName,
- ImportNameVersion nameVersion){
+ owner.forEachDistinctName(clangTypeDecl,
+ [&](ImportedName newName,
+ ImportNameVersion nameVersion) -> bool {
if (anyMatching)
- return;
+ return true;
if (!newName.getDeclName().isSimpleName(name))
- return;
+ return true;
auto decl = dyn_cast_or_null<TypeDecl>(
owner.importDeclReal(clangTypeDecl, nameVersion));
if (!decl)
- return;
+ return false;
if (!originalDecl)
originalDecl = decl;
else if (originalDecl == decl)
- return;
+ return true;
auto *importedContext = decl->getDeclContext()->
getAsNominalTypeOrNominalTypeExtensionContext();
if (importedContext != baseType)
- return;
+ return true;
assert(decl->getFullName().matchesRef(name) &&
"importFullName behaved differently from importDecl");
results.push_back(decl);
anyMatching = true;
+ return true;
});
}
@@ -2859,6 +2861,13 @@
return owner.getClangASTContext();
}
+std::string ClangModuleUnit::getExportedModuleName() const {
+ if (clangModule && !clangModule->ExportAsModule.empty())
+ return clangModule->ExportAsModule;
+
+ return getParentModule()->getName().str();
+}
+
ModuleDecl *ClangModuleUnit::getAdapterModule() const {
if (!clangModule)
return nullptr;
@@ -3150,10 +3159,8 @@
const clang::NamedDecl *recentClangDecl =
clangDecl->getMostRecentDecl();
- forEachImportNameVersionFromCurrent(CurrentVersion,
- [&](ImportNameVersion nameVersion) {
- if (nameVersion == CurrentVersion)
- return;
+ CurrentVersion.forEachOtherImportNameVersion(
+ [&](ImportNameVersion nameVersion) {
if (anyMatching)
return;
@@ -3211,12 +3218,12 @@
forEachDistinctName(clangDecl,
[&](ImportedName importedName,
- ImportNameVersion nameVersion) {
+ ImportNameVersion nameVersion) -> bool {
// Import the declaration.
auto decl =
cast_or_null<ValueDecl>(importDeclReal(clangDecl, nameVersion));
if (!decl)
- return;
+ return false;
// If the name we found matches, report the declaration.
// FIXME: If we didn't need to check alternate decls here, we could avoid
@@ -3232,6 +3239,7 @@
consumer.foundDecl(alternate, DeclVisibilityKind::DynamicLookup);
}
}
+ return true;
});
}
}
@@ -3323,3 +3331,23 @@
return Impl.importFullName(D, Impl.CurrentVersion, preferredName).
getDeclName();
}
+
+bool swift::isInOverlayModuleForImportedModule(const DeclContext *overlayDC,
+ const DeclContext *importedDC) {
+ overlayDC = overlayDC->getModuleScopeContext();
+ importedDC = importedDC->getModuleScopeContext();
+
+ auto importedClangModuleUnit = dyn_cast<ClangModuleUnit>(importedDC);
+ if (!importedClangModuleUnit)
+ return false;
+
+ auto overlayModule = overlayDC->getParentModule();
+ if (overlayModule == importedClangModuleUnit->getAdapterModule())
+ return true;
+
+ // Is this a private module that's re-exported to the public (overlay) name?
+ auto clangModule =
+ importedClangModuleUnit->getClangModule()->getTopLevelModule();
+ return !clangModule->ExportAsModule.empty() &&
+ clangModule->ExportAsModule == overlayModule->getName().str();
+}
diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp
index e88a2a9..e539e2b 100644
--- a/lib/ClangImporter/ImportDecl.cpp
+++ b/lib/ClangImporter/ImportDecl.cpp
@@ -349,11 +349,17 @@
void ClangImporter::Implementation::forEachDistinctName(
const clang::NamedDecl *decl,
- llvm::function_ref<void(ImportedName, ImportNameVersion)> action) {
+ llvm::function_ref<bool(ImportedName, ImportNameVersion)> action) {
using ImportNameKey = std::pair<DeclName, EffectiveClangContext>;
SmallVector<ImportNameKey, 8> seenNames;
- forEachImportNameVersionFromCurrent(CurrentVersion,
- [&](ImportNameVersion nameVersion) {
+
+ ImportedName newName = importFullName(decl, CurrentVersion);
+ ImportNameKey key(newName, newName.getEffectiveContext());
+ if (action(newName, CurrentVersion))
+ seenNames.push_back(key);
+
+ CurrentVersion.forEachOtherImportNameVersion(
+ [&](ImportNameVersion nameVersion) {
// Check to see if the name is different.
ImportedName newName = importFullName(decl, nameVersion);
ImportNameKey key(newName, newName.getEffectiveContext());
@@ -365,8 +371,8 @@
});
if (seen)
return;
- seenNames.push_back(key);
- action(newName, nameVersion);
+ if (action(newName, nameVersion))
+ seenNames.push_back(key);
});
}
@@ -1927,7 +1933,7 @@
Optional<ImportedName> &correctSwiftName) {
ImportNameVersion canonicalVersion = getActiveSwiftVersion();
if (isa<clang::TypeDecl>(D) || isa<clang::ObjCContainerDecl>(D)) {
- canonicalVersion = ImportNameVersion::ForTypes;
+ canonicalVersion = ImportNameVersion::forTypes();
}
correctSwiftName = None;
@@ -2113,36 +2119,38 @@
// If we're importing a global as a member, we need to provide the
// effective context.
Impl.printSwiftName(
- correctSwiftName,
+ correctSwiftName, getActiveSwiftVersion(),
/*fullyQualified=*/correctSwiftName.importAsMember(), os);
}
- unsigned majorVersion = majorVersionNumberForNameVersion(getVersion());
DeclAttribute *attr;
- if (isActiveSwiftVersion() || getVersion() == ImportNameVersion::Raw) {
+ if (isActiveSwiftVersion() || getVersion() == ImportNameVersion::raw()) {
// "Raw" is the Objective-C name, which was never available in Swift.
// Variants within the active version are usually declarations that
// have been superseded, like the accessors of a property.
attr = AvailableAttr::createPlatformAgnostic(
ctx, /*Message*/StringRef(), ctx.AllocateCopy(renamed.str()),
PlatformAgnosticAvailabilityKind::UnavailableInSwift);
- } else if (getVersion() < getActiveSwiftVersion()) {
- // A Swift 2 name, for example, was obsoleted in Swift 3.
- attr = AvailableAttr::createPlatformAgnostic(
- ctx, /*Message*/StringRef(), ctx.AllocateCopy(renamed.str()),
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
- clang::VersionTuple(majorVersion + 1));
} else {
- // Future names are introduced in their future version.
- assert(getVersion() > getActiveSwiftVersion());
- attr = new (ctx) AvailableAttr(
- SourceLoc(), SourceRange(), PlatformKind::none,
- /*Message*/StringRef(), ctx.AllocateCopy(renamed.str()),
- /*Introduced*/clang::VersionTuple(majorVersion), SourceRange(),
- /*Deprecated*/clang::VersionTuple(), SourceRange(),
- /*Obsoleted*/clang::VersionTuple(), SourceRange(),
- PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
- /*Implicit*/false);
+ unsigned majorVersion = getVersion().majorVersionNumber();
+ if (getVersion() < getActiveSwiftVersion()) {
+ // A Swift 2 name, for example, was obsoleted in Swift 3.
+ attr = AvailableAttr::createPlatformAgnostic(
+ ctx, /*Message*/StringRef(), ctx.AllocateCopy(renamed.str()),
+ PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
+ clang::VersionTuple(majorVersion + 1));
+ } else {
+ // Future names are introduced in their future version.
+ assert(getVersion() > getActiveSwiftVersion());
+ attr = new (ctx) AvailableAttr(
+ SourceLoc(), SourceRange(), PlatformKind::none,
+ /*Message*/StringRef(), ctx.AllocateCopy(renamed.str()),
+ /*Introduced*/clang::VersionTuple(majorVersion), SourceRange(),
+ /*Deprecated*/clang::VersionTuple(), SourceRange(),
+ /*Obsoleted*/clang::VersionTuple(), SourceRange(),
+ PlatformAgnosticAvailabilityKind::SwiftVersionSpecific,
+ /*Implicit*/false);
+ }
}
decl->getAttrs().add(attr);
@@ -2663,31 +2671,33 @@
case EnumKind::Unknown:
Impl.forEachDistinctName(constant,
[&](ImportedName newName,
- ImportNameVersion nameVersion) {
+ ImportNameVersion nameVersion) -> bool {
Decl *imported = Impl.importDecl(constant, nameVersion);
if (!imported)
- return;
+ return false;
if (nameVersion == getActiveSwiftVersion())
enumeratorDecl = imported;
else
variantDecls.push_back(imported);
+ return true;
});
break;
case EnumKind::Options:
Impl.forEachDistinctName(constant,
[&](ImportedName newName,
- ImportNameVersion nameVersion) {
+ ImportNameVersion nameVersion) -> bool {
if (!contextIsEnum(newName))
- return;
+ return true;
SwiftDeclConverter converter(Impl, nameVersion);
Decl *imported =
converter.importOptionConstant(constant, decl, result);
if (!imported)
- return;
+ return false;
if (nameVersion == getActiveSwiftVersion())
enumeratorDecl = imported;
else
variantDecls.push_back(imported);
+ return true;
});
break;
case EnumKind::Enum: {
@@ -2735,18 +2745,19 @@
Impl.forEachDistinctName(constant,
[&](ImportedName newName,
- ImportNameVersion nameVersion) {
+ ImportNameVersion nameVersion) -> bool {
if (nameVersion == getActiveSwiftVersion())
- return;
+ return true;
if (!contextIsEnum(newName))
- return;
+ return true;
SwiftDeclConverter converter(Impl, nameVersion);
Decl *imported =
converter.importEnumCase(constant, decl, cast<EnumDecl>(result),
enumeratorDecl);
if (!imported)
- return;
+ return false;
variantDecls.push_back(imported);
+ return true;
});
break;
}
@@ -4823,7 +4834,7 @@
// we don't care.
Decl *importedDecl = nullptr;
if (getVersion() >= getActiveSwiftVersion())
- importedDecl = Impl.importDecl(decl, ImportNameVersion::ForTypes);
+ importedDecl = Impl.importDecl(decl, ImportNameVersion::forTypes());
if (!importedDecl && getVersion() != getActiveSwiftVersion())
importedDecl = Impl.importDecl(decl, getActiveSwiftVersion());
auto typeDecl = dyn_cast_or_null<TypeDecl>(importedDecl);
@@ -6894,9 +6905,7 @@
{
// Render a swift_name string.
llvm::raw_svector_ostream os(renamed);
- printSwiftName(importedName,
- /*fullyQualified=*/true,
- os);
+ printSwiftName(importedName, CurrentVersion, /*fullyQualified=*/true, os);
}
return SwiftContext.AllocateCopy(StringRef(renamed));
@@ -8023,9 +8032,9 @@
continue;
forEachDistinctName(
- decl, [&](ImportedName newName, ImportNameVersion nameVersion) {
- addMemberAndAlternatesToExtension(decl, newName, nameVersion, ext);
- });
+ decl, [&](ImportedName newName, ImportNameVersion nameVersion) -> bool {
+ return addMemberAndAlternatesToExtension(decl, newName, nameVersion, ext);
+ });
}
}
@@ -8043,29 +8052,30 @@
return result;
}
-void ClangImporter::Implementation::addMemberAndAlternatesToExtension(
+bool ClangImporter::Implementation::addMemberAndAlternatesToExtension(
clang::NamedDecl *decl, ImportedName newName, ImportNameVersion nameVersion,
ExtensionDecl *ext) {
// Quickly check the context and bail out if it obviously doesn't
// belong here.
if (auto *importDC = newName.getEffectiveContext().getAsDeclContext())
if (importDC->isTranslationUnit())
- return;
+ return true;
// Then try to import the decl under the specified name.
auto *member = importDecl(decl, nameVersion);
if (!member)
- return;
+ return false;
member = findMemberThatWillLandInAnExtensionContext(member);
if (!member || member->getDeclContext() != ext)
- return;
+ return true;
ext->addMember(member);
for (auto alternate : getAlternateDecls(member)) {
if (alternate->getDeclContext() == ext)
ext->addMember(alternate);
}
+ return true;
}
static ExtensionDecl *
@@ -8127,26 +8137,27 @@
const clang::NamedDecl *nd, SmallVectorImpl<Decl *> &members) {
llvm::SmallPtrSet<Decl *, 4> knownAlternateMembers;
forEachDistinctName(
- nd, [&](ImportedName name, ImportNameVersion nameVersion) {
- auto member = importDecl(nd, nameVersion);
- if (!member)
- return;
+ nd, [&](ImportedName name, ImportNameVersion nameVersion) -> bool {
+ auto member = importDecl(nd, nameVersion);
+ if (!member)
+ return false;
- // If there are alternate declarations for this member, add them.
- for (auto alternate : getAlternateDecls(member)) {
- if (alternate->getDeclContext() == member->getDeclContext() &&
- knownAlternateMembers.insert(alternate).second) {
- members.push_back(alternate);
- }
- }
+ // If there are alternate declarations for this member, add them.
+ for (auto alternate : getAlternateDecls(member)) {
+ if (alternate->getDeclContext() == member->getDeclContext() &&
+ knownAlternateMembers.insert(alternate).second) {
+ members.push_back(alternate);
+ }
+ }
- // If this declaration shouldn't be visible, don't add it to
- // the list.
- if (shouldSuppressDeclImport(nd))
- return;
+ // If this declaration shouldn't be visible, don't add it to
+ // the list.
+ if (shouldSuppressDeclImport(nd))
+ return true;
- members.push_back(member);
- });
+ members.push_back(member);
+ return true;
+ });
}
void ClangImporter::Implementation::collectMembersToAdd(
diff --git a/lib/ClangImporter/ImportEnumInfo.cpp b/lib/ClangImporter/ImportEnumInfo.cpp
index 4dfb3ee..f9ac7cc 100644
--- a/lib/ClangImporter/ImportEnumInfo.cpp
+++ b/lib/ClangImporter/ImportEnumInfo.cpp
@@ -68,7 +68,7 @@
// If API notes have /removed/ a FlagEnum or EnumExtensibility attribute,
// then we don't need to check the macros.
for (auto *attr : decl->specific_attrs<clang::SwiftVersionedAttr>()) {
- if (!attr->getVersion().empty())
+ if (!attr->getIsReplacedByActive())
continue;
if (isa<clang::FlagEnumAttr>(attr->getAttrToAdd()) ||
isa<clang::EnumExtensibilityAttr>(attr->getAttrToAdd())) {
diff --git a/lib/ClangImporter/ImportName.cpp b/lib/ClangImporter/ImportName.cpp
index 2d40e02..161f1e9 100644
--- a/lib/ClangImporter/ImportName.cpp
+++ b/lib/ClangImporter/ImportName.cpp
@@ -54,39 +54,6 @@
using clang::CompilerInstance;
using clang::CompilerInvocation;
-ImportNameVersion
-importer::nameVersionFromOptions(const LangOptions &langOpts) {
- auto languageVersion = langOpts.EffectiveLanguageVersion;
- switch (languageVersion[0]) {
- default:
- llvm_unreachable("unknown swift language version");
- case 1:
- case 2:
- return ImportNameVersion::Swift2;
- case 3:
- return ImportNameVersion::Swift3;
- // Fixme: Figure out the importing story for 5 instead of falling back to 4.
- case 4:
- case 5:
- return ImportNameVersion::Swift4;
- }
-}
-
-unsigned importer::majorVersionNumberForNameVersion(ImportNameVersion version) {
- switch (version) {
- case ImportNameVersion::Raw:
- return 0;
- case ImportNameVersion::Swift2:
- return 2;
- case ImportNameVersion::Swift3:
- return 3;
- case ImportNameVersion::Swift4:
- return 4;
- }
-
- llvm_unreachable("Unhandled ImportNameVersion in switch.");
-}
-
/// Determine whether the given Clang selector matches the given
/// selector pieces.
@@ -318,10 +285,9 @@
/// Will recursively print out the fully qualified context for the given name.
/// Ends with a trailing "."
-static void
-printFullContextPrefix(ImportedName name,
- llvm::raw_ostream &os,
- ClangImporter::Implementation &Impl) {
+static void printFullContextPrefix(ImportedName name, ImportNameVersion version,
+ llvm::raw_ostream &os,
+ ClangImporter::Implementation &Impl) {
const clang::NamedDecl *newDeclContextNamed = nullptr;
switch (name.getEffectiveContext().getKind()) {
case EffectiveClangContext::UnresolvedContext:
@@ -347,12 +313,13 @@
// Now, let's print out the parent
assert(newDeclContextNamed && "should of been set");
- auto parentName = Impl.importFullName(newDeclContextNamed, name.getVersion());
- printFullContextPrefix(parentName, os, Impl);
+ auto parentName = Impl.importFullName(newDeclContextNamed, version);
+ printFullContextPrefix(parentName, version, os, Impl);
os << parentName.getDeclName() << ".";
}
void ClangImporter::Implementation::printSwiftName(ImportedName name,
+ ImportNameVersion version,
bool fullyQualified,
llvm::raw_ostream &os) {
// Property accessors.
@@ -376,7 +343,7 @@
}
if (fullyQualified)
- printFullContextPrefix(name, os, *this);
+ printFullContextPrefix(name, version, os, *this);
// Base name.
os << name.getDeclName().getBaseName();
@@ -578,17 +545,63 @@
return None;
}
-template <typename A>
-static bool matchesVersion(A *versionedAttr, ImportNameVersion version) {
- clang::VersionTuple attrVersion = versionedAttr->getVersion();
- if (attrVersion.empty())
- return version == ImportNameVersion::LAST_VERSION;
- return attrVersion.getMajor() == majorVersionNumberForNameVersion(version);
+namespace {
+/// Aggregate struct for the common members of clang::SwiftVersionedAttr and
+/// clang::SwiftVersionedRemovalAttr.
+///
+/// For a SwiftVersionedRemovalAttr, the Attr member will be null.
+struct VersionedSwiftNameInfo {
+ const clang::SwiftNameAttr *Attr;
+ clang::VersionTuple Version;
+ bool IsReplacedByActive;
+};
+
+/// The action to take upon seeing a particular versioned swift_name annotation.
+enum class VersionedSwiftNameAction {
+ /// This annotation is not interesting.
+ Ignore,
+ /// This annotation is better than whatever we have so far.
+ Use,
+ /// This annotation is better than nothing, but that's all; don't bother
+ /// recording its version.
+ UseAsFallback,
+ /// This annotation itself isn't interesting, but its version shows that the
+ /// correct answer is whatever's currently active.
+ ResetToActive
+};
+} // end anonymous namespace
+
+static VersionedSwiftNameAction
+checkVersionedSwiftName(VersionedSwiftNameInfo info,
+ clang::VersionTuple bestSoFar,
+ ImportNameVersion requestedVersion) {
+ if (!bestSoFar.empty() && bestSoFar <= info.Version)
+ return VersionedSwiftNameAction::Ignore;
+
+ if (info.IsReplacedByActive) {
+ // We know that there are no versioned names between the active version and
+ // a replacement version, because otherwise /that/ name would be active.
+ // So if replacement < requested, we want to use the old value that was
+ // replaced (but with very low priority), and otherwise we want to use the
+ // new value that is now active. (Special case: replacement = 0 means that
+ // a header annotation was replaced by an unversioned API notes annotation.)
+ if (info.Version.empty() ||
+ info.Version.getMajor() >= requestedVersion.majorVersionNumber()) {
+ return VersionedSwiftNameAction::ResetToActive;
+ }
+ if (bestSoFar.empty())
+ return VersionedSwiftNameAction::UseAsFallback;
+ return VersionedSwiftNameAction::Ignore;
+ }
+
+ if (info.Version.getMajor() < requestedVersion.majorVersionNumber())
+ return VersionedSwiftNameAction::Ignore;
+ return VersionedSwiftNameAction::Use;
}
-const clang::SwiftNameAttr *
-importer::findSwiftNameAttr(const clang::Decl *decl,
- ImportNameVersion version) {
+
+static const clang::SwiftNameAttr *
+findSwiftNameAttr(const clang::Decl *decl, ImportNameVersion version) {
#ifndef NDEBUG
if (Optional<const clang::Decl *> def = getDefinitionForClangTypeDecl(decl)) {
assert((*def == nullptr || *def == decl) &&
@@ -596,30 +609,64 @@
}
#endif
- if (version == ImportNameVersion::Raw)
+ if (version == ImportNameVersion::raw())
return nullptr;
// Handle versioned API notes for Swift 3 and later. This is the common case.
- if (version != ImportNameVersion::Swift2) {
+ if (version > ImportNameVersion::swift2()) {
+ const auto *activeAttr = decl->getAttr<clang::SwiftNameAttr>();
+ const clang::SwiftNameAttr *result = activeAttr;
+ clang::VersionTuple bestSoFar;
for (auto *attr : decl->attrs()) {
+ VersionedSwiftNameInfo info;
+
if (auto *versionedAttr = dyn_cast<clang::SwiftVersionedAttr>(attr)) {
- if (!matchesVersion(versionedAttr, version))
+ auto *added =
+ dyn_cast<clang::SwiftNameAttr>(versionedAttr->getAttrToAdd());
+ if (!added)
continue;
- if (auto *added =
- dyn_cast<clang::SwiftNameAttr>(versionedAttr->getAttrToAdd())) {
- return added;
- }
+
+ info = {added, versionedAttr->getVersion(),
+ versionedAttr->getIsReplacedByActive()};
+
+ } else if (auto *removeAttr =
+ dyn_cast<clang::SwiftVersionedRemovalAttr>(attr)) {
+ if (removeAttr->getAttrKindToRemove() != clang::attr::SwiftName)
+ continue;
+ info = {nullptr, removeAttr->getVersion(),
+ removeAttr->getIsReplacedByActive()};
+
+ } else {
+ continue;
}
- if (auto *removeAttr = dyn_cast<clang::SwiftVersionedRemovalAttr>(attr)) {
- if (!matchesVersion(removeAttr, version))
- continue;
- if (removeAttr->getAttrKindToRemove() == clang::attr::SwiftName)
- return nullptr;
+ switch (checkVersionedSwiftName(info, bestSoFar, version)) {
+ case VersionedSwiftNameAction::Ignore:
+ continue;
+ case VersionedSwiftNameAction::Use:
+ result = info.Attr;
+ bestSoFar = info.Version;
+ break;
+ case VersionedSwiftNameAction::UseAsFallback:
+ // HACK: If there's a swift_name attribute in the headers /and/ in the
+ // unversioned API notes /and/ in the active versioned API notes, there
+ // will be two "replacement" attributes, one for each of the first two
+ // cases. Prefer the first one we see, because that turns out to be the
+ // one from the API notes, which matches the semantics when there are no
+ // versioned API notes. (This isn't very principled but there's at least
+ // a test to tell us if it changes.)
+ if (result == activeAttr)
+ result = info.Attr;
+ assert(bestSoFar.empty());
+ break;
+ case VersionedSwiftNameAction::ResetToActive:
+ result = activeAttr;
+ bestSoFar = info.Version;
+ break;
}
}
- return decl->getAttr<clang::SwiftNameAttr>();
+ return result;
}
// The remainder of this function emulates the limited form of swift_name
@@ -843,7 +890,7 @@
case EnumKind::Enum:
case EnumKind::Options:
// Enums are mapped to Swift enums, Options to Swift option sets.
- if (version != ImportNameVersion::Raw) {
+ if (version != ImportNameVersion::raw()) {
res = cast<clang::DeclContext>(enumDecl);
break;
}
@@ -960,7 +1007,7 @@
switch (nameImporter.getEnumKind(ED)) {
case EnumKind::Enum:
case EnumKind::Options:
- if (version != ImportNameVersion::Raw)
+ if (version != ImportNameVersion::raw())
break;
LLVM_FALLTHROUGH;
case EnumKind::Constants:
@@ -1125,7 +1172,7 @@
static bool suppressFactoryMethodAsInit(const clang::ObjCMethodDecl *method,
ImportNameVersion version,
CtorInitializerKind initKind) {
- return (version == ImportNameVersion::Raw || method->isPropertyAccessor()) &&
+ return (version == ImportNameVersion::raw() || method->isPropertyAccessor()) &&
(initKind == CtorInitializerKind::Factory ||
initKind == CtorInitializerKind::ConvenienceFactory);
}
@@ -1136,7 +1183,7 @@
ImportedName result;
/// Whether we want a Swift 3 or later name
- bool swift3OrLaterName = version >= ImportNameVersion::Swift3;
+ bool swift3OrLaterName = version > ImportNameVersion::swift2();
// Objective-C categories and extensions don't have names, despite
// being "named" declarations.
@@ -1516,7 +1563,7 @@
// Enumeration constants may have common prefixes stripped.
bool strippedPrefix = false;
- if (version != ImportNameVersion::Raw && isa<clang::EnumConstantDecl>(D)) {
+ if (version != ImportNameVersion::raw() && isa<clang::EnumConstantDecl>(D)) {
auto enumDecl = cast<clang::EnumDecl>(D->getDeclContext());
auto enumInfo = getEnumInfo(enumDecl);
@@ -1723,7 +1770,6 @@
}
++ImportNameNumCacheMisses;
auto res = importNameImpl(decl, version, givenName);
- res.setVersion(version);
if (!givenName)
importNameCache[key] = res;
return res;
diff --git a/lib/ClangImporter/ImportName.h b/lib/ClangImporter/ImportName.h
index b8f33cc..f993b02 100644
--- a/lib/ClangImporter/ImportName.h
+++ b/lib/ClangImporter/ImportName.h
@@ -20,6 +20,7 @@
#include "ImportEnumInfo.h"
#include "SwiftLookupTable.h"
#include "swift/Basic/StringExtras.h"
+#include "swift/Basic/Version.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/Decl.h"
#include "swift/AST/ForeignErrorConvention.h"
@@ -40,78 +41,88 @@
enum { NumImportedAccessorKindBits = 3 };
/// The name version
-enum class ImportNameVersion : unsigned {
- /// Names as they appear in C/ObjC
- Raw = 0,
+class ImportNameVersion : public RelationalOperationsBase<ImportNameVersion> {
+ unsigned rawValue;
+ friend llvm::DenseMapInfo<ImportNameVersion>;
- /// Names as they appeared in Swift 2 family
- Swift2,
+ enum AsConstExpr_t { AsConstExpr };
- /// Names as they appeared in Swift 3 family
- Swift3,
+ constexpr ImportNameVersion() : rawValue(0) {}
+ constexpr ImportNameVersion(unsigned version, AsConstExpr_t)
+ : rawValue(version) {}
+ explicit ImportNameVersion(unsigned version) : rawValue(version) {
+ assert(version >= 2 && "only Swift 2 and later are supported");
+ }
+public:
+ /// Map a language version into an import name version.
+ static ImportNameVersion fromOptions(const LangOptions &langOpts) {
+ return ImportNameVersion(langOpts.EffectiveLanguageVersion[0]);
+ }
- /// Names as they appeared in Swift 4 family
- Swift4,
+ unsigned majorVersionNumber() const {
+ assert(*this != ImportNameVersion::raw());
+ return rawValue;
+ }
- /// A placeholder for the latest version, to be used in loops and such.
- LAST_VERSION = Swift4,
+ bool operator==(ImportNameVersion other) const {
+ return rawValue == other.rawValue;
+ }
+ bool operator<(ImportNameVersion other) const {
+ return rawValue < other.rawValue;
+ }
+
+ /// Calls \p action for each name version other than this one, first going
+ /// backwards until ImportNameVersion::raw(), and then going forwards to
+ /// ImportNameVersion::maxVersion().
+ ///
+ /// This is the most useful order for importing compatibility stubs.
+ void forEachOtherImportNameVersion(
+ llvm::function_ref<void(ImportNameVersion)> action) const {
+ assert(*this >= ImportNameVersion::swift2());
+
+ ImportNameVersion nameVersion = *this;
+ while (nameVersion > ImportNameVersion::swift2()) {
+ --nameVersion.rawValue;
+ action(nameVersion);
+ }
+
+ action(ImportNameVersion::raw());
+
+ nameVersion = *this;
+ while (nameVersion < ImportNameVersion::maxVersion()) {
+ ++nameVersion.rawValue;
+ action(nameVersion);
+ }
+ }
+
+ /// Names as they appear in C/ObjC.
+ static constexpr inline ImportNameVersion raw() {
+ return ImportNameVersion{};
+ }
+
+ /// Names as they appeared in Swift 2 family.
+ static constexpr inline ImportNameVersion swift2() {
+ return ImportNameVersion{2, AsConstExpr};
+ }
+
+ /// The latest supported version.
+ ///
+ /// FIXME: All other version information is in Version.h. Can this go there
+ /// instead?
+ static constexpr inline ImportNameVersion maxVersion() {
+ return ImportNameVersion{5, AsConstExpr};
+ }
/// The version which should be used for importing types, which need to have
/// one canonical definition.
///
/// FIXME: Is this supposed to be the /newest/ version, or a canonical
/// version that lasts forever as part of the ABI?
- ForTypes = Swift4
+ static constexpr inline ImportNameVersion forTypes() {
+ return ImportNameVersion::maxVersion();
+ }
};
-static inline ImportNameVersion &operator++(ImportNameVersion &value) {
- assert(value != ImportNameVersion::LAST_VERSION);
- value = static_cast<ImportNameVersion>(static_cast<unsigned>(value) + 1);
- return value;
-}
-
-static inline ImportNameVersion &operator--(ImportNameVersion &value) {
- assert(value != ImportNameVersion::Raw);
- value = static_cast<ImportNameVersion>(static_cast<unsigned>(value) - 1);
- return value;
-}
-
-/// Calls \p action for each name version, starting with \p current, then going
-/// backwards until ImportNameVersion::Raw, and then finally going forwards to
-/// ImportNameVersion::LAST_VERSION.
-///
-/// This is the most useful order for importing compatibility stubs.
-static inline void forEachImportNameVersionFromCurrent(
- ImportNameVersion current,
- llvm::function_ref<void(ImportNameVersion)> action) {
- action(current);
- ImportNameVersion nameVersion = current;
- while (nameVersion != ImportNameVersion::Raw) {
- --nameVersion;
- action(nameVersion);
- }
- nameVersion = current;
- while (nameVersion != ImportNameVersion::LAST_VERSION) {
- ++nameVersion;
- action(nameVersion);
- }
-}
-
-/// Calls \p action for each name version, starting with ImportNameVersion::Raw
-/// and going forwards.
-static inline void
-forEachImportNameVersion(llvm::function_ref<void(ImportNameVersion)> action) {
- auto limit = static_cast<unsigned>(ImportNameVersion::LAST_VERSION);
- for (unsigned raw = 0; raw <= limit; ++raw)
- action(static_cast<ImportNameVersion>(raw));
-}
-
-/// Map a language version into an import name version.
-ImportNameVersion nameVersionFromOptions(const LangOptions &langOpts);
-
-/// Map an import name version into a language version.
-unsigned majorVersionNumberForNameVersion(ImportNameVersion version);
-
/// Describes a name that was imported from Clang.
class ImportedName {
friend class NameImporter;
@@ -141,11 +152,6 @@
/// For an initializer, the kind of initializer to import.
CtorInitializerKind initKind;
- /// The version of Swift this name corresponds to.
- ///
- /// \see ImportNameVersion
- unsigned rawVersion : 2;
-
/// What kind of accessor this name refers to, if any.
ImportedAccessorKind accessorKind : NumImportedAccessorKindBits;
@@ -167,9 +173,9 @@
Info()
: errorInfo(), selfIndex(), initKind(CtorInitializerKind::Designated),
- rawVersion(), accessorKind(ImportedAccessorKind::None),
- hasCustomName(false), droppedVariadic(false), importAsMember(false),
- hasSelfIndex(false), hasErrorInfo(false) {}
+ accessorKind(ImportedAccessorKind::None), hasCustomName(false),
+ droppedVariadic(false), importAsMember(false), hasSelfIndex(false),
+ hasErrorInfo(false) {}
} info;
public:
@@ -189,16 +195,6 @@
effectiveContext = ctx;
}
- /// The highest version of Swift that this name comes from
- ImportNameVersion getVersion() const {
- return static_cast<ImportNameVersion>(info.rawVersion);
- }
-
- void setVersion(ImportNameVersion version) {
- info.rawVersion = static_cast<unsigned>(version);
- assert(getVersion() == version && "not enough bits");
- }
-
/// For an initializer, the kind of initializer to import.
CtorInitializerKind getInitKind() const { return info.initKind; }
@@ -272,11 +268,6 @@
/// in "Notification", or it there would be nothing left.
StringRef stripNotification(StringRef name);
-/// Find the swift_name attribute associated with this declaration, if any,
-/// appropriate for \p version.
-const clang::SwiftNameAttr *findSwiftNameAttr(const clang::Decl *decl,
- ImportNameVersion version);
-
/// Class to determine the Swift name of foreign entities. Currently fairly
/// stateless and borrows from the ClangImporter::Implementation, but in the
/// future will be more self-contained and encapsulated.
@@ -387,7 +378,7 @@
return (ImportNameVersion)DMIU::getTombstoneKey();
}
static unsigned getHashValue(const ImportNameVersion &Val) {
- return DMIU::getHashValue((unsigned)Val);
+ return DMIU::getHashValue(Val.rawValue);
}
static bool isEqual(const ImportNameVersion &LHS,
const ImportNameVersion &RHS) {
diff --git a/lib/ClangImporter/ImporterImpl.h b/lib/ClangImporter/ImporterImpl.h
index 2d63bcd..d904d35 100644
--- a/lib/ClangImporter/ImporterImpl.h
+++ b/lib/ClangImporter/ImporterImpl.h
@@ -641,7 +641,9 @@
/// Print an imported name as a string suitable for the swift_name attribute,
/// or the 'Rename' field of AvailableAttr.
- void printSwiftName(importer::ImportedName, bool fullyQualified,
+ void printSwiftName(importer::ImportedName name,
+ importer::ImportNameVersion version,
+ bool fullyQualified,
llvm::raw_ostream &os);
/// \brief Import the given Clang identifier into Swift.
@@ -1130,7 +1132,14 @@
void insertMembersAndAlternates(const clang::NamedDecl *nd,
SmallVectorImpl<Decl *> &members);
void loadAllMembersIntoExtension(Decl *D, uint64_t extra);
- void addMemberAndAlternatesToExtension(
+
+ /// Imports \p decl under \p nameVersion with the name \p newName, and adds
+ /// it and its alternates to \p ext.
+ ///
+ /// \returns true if \p decl was successfully imported, whether or not it was
+ /// ultimately added to \p ext. This matches the behavior of
+ /// forEachDistinctName's callback.
+ bool addMemberAndAlternatesToExtension(
clang::NamedDecl *decl, importer::ImportedName newName,
importer::ImportNameVersion nameVersion, ExtensionDecl *ext);
@@ -1221,11 +1230,14 @@
/// will eventually reference that declaration, the contexts will still be
/// considered distinct.
///
- /// The names are generated in the same order as
- /// forEachImportNameVersionFromCurrent. The current name is always first.
+ /// If \p action returns false, the current name will \e not be added to the
+ /// set of seen names.
+ ///
+ /// The active name is always first, followed by the other names in the order
+ /// of ImportNameVersion::forEachOtherImportNameVersion.
void forEachDistinctName(
const clang::NamedDecl *decl,
- llvm::function_ref<void(importer::ImportedName,
+ llvm::function_ref<bool(importer::ImportedName,
importer::ImportNameVersion)> action);
/// Dump the Swift-specific name lookup tables we generate.
diff --git a/lib/ClangImporter/SwiftLookupTable.cpp b/lib/ClangImporter/SwiftLookupTable.cpp
index 176509e..5e4d6f6 100644
--- a/lib/ClangImporter/SwiftLookupTable.cpp
+++ b/lib/ClangImporter/SwiftLookupTable.cpp
@@ -1625,8 +1625,8 @@
}
// If we have a name to import as, add this entry to the table.
- ImportNameVersion currentVersion =
- nameVersionFromOptions(nameImporter.getLangOpts());
+ auto currentVersion =
+ ImportNameVersion::fromOptions(nameImporter.getLangOpts());
if (auto importedName = nameImporter.importName(named, currentVersion)) {
SmallPtrSet<DeclName, 8> distinctNames;
distinctNames.insert(importedName.getDeclName());
@@ -1640,9 +1640,8 @@
ArrayRef<Identifier>()),
named, importedName.getEffectiveContext());
- forEachImportNameVersion([&] (ImportNameVersion alternateVersion) {
- if (alternateVersion == currentVersion)
- return;
+ currentVersion.forEachOtherImportNameVersion(
+ [&](ImportNameVersion alternateVersion) {
auto alternateName = nameImporter.importName(named, alternateVersion);
if (!alternateName)
return;
diff --git a/lib/Demangling/Demangler.cpp b/lib/Demangling/Demangler.cpp
index 665b7a2..a46e359 100644
--- a/lib/Demangling/Demangler.cpp
+++ b/lib/Demangling/Demangler.cpp
@@ -1297,15 +1297,65 @@
case 'k': {
auto nodeKind = c == 'K' ? Node::Kind::KeyPathGetterThunkHelper
: Node::Kind::KeyPathSetterThunkHelper;
- auto type = popNode();
- auto sigOrDecl = popNode();
- if (sigOrDecl &&
- sigOrDecl->getKind() == Node::Kind::DependentGenericSignature) {
- auto decl = popNode();
- return createWithChildren(nodeKind, decl, sigOrDecl, type);
+ std::vector<NodePointer> types;
+ auto node = popNode();
+ if (!node || node->getKind() != Node::Kind::Type)
+ return nullptr;
+ do {
+ types.push_back(node);
+ node = popNode();
+ } while (node && node->getKind() == Node::Kind::Type);
+
+ NodePointer result;
+ if (node) {
+ if (node->getKind() == Node::Kind::DependentGenericSignature) {
+ auto decl = popNode();
+ result = createWithChildren(nodeKind, decl, /*sig*/ node);
+ } else {
+ result = createWithChild(nodeKind, /*decl*/ node);
+ }
} else {
- return createWithChildren(nodeKind, sigOrDecl, type);
+ return nullptr;
}
+ for (auto i = types.rbegin(), e = types.rend(); i != e; ++i) {
+ result->addChild(*i, *this);
+ }
+ return result;
+ }
+ case 'H':
+ case 'h': {
+ auto nodeKind = c == 'H' ? Node::Kind::KeyPathEqualsThunkHelper
+ : Node::Kind::KeyPathHashThunkHelper;
+ NodePointer genericSig = nullptr;
+ std::vector<NodePointer> types;
+
+ auto node = popNode();
+ if (node) {
+ if (node->getKind() == Node::Kind::DependentGenericSignature) {
+ genericSig = node;
+ } else if (node->getKind() == Node::Kind::Type) {
+ types.push_back(node);
+ } else {
+ return nullptr;
+ }
+ } else {
+ return nullptr;
+ }
+
+ while (auto node = popNode()) {
+ if (node->getKind() != Node::Kind::Type) {
+ return nullptr;
+ }
+ types.push_back(node);
+ }
+
+ NodePointer result = createNode(nodeKind);
+ for (auto i = types.rbegin(), e = types.rend(); i != e; ++i) {
+ result->addChild(*i, *this);
+ }
+ if (genericSig)
+ result->addChild(genericSig, *this);
+ return result;
}
case 'v': {
int Idx = demangleIndex();
diff --git a/lib/Demangling/NodePrinter.cpp b/lib/Demangling/NodePrinter.cpp
index 1a617b3..7ed8fae 100644
--- a/lib/Demangling/NodePrinter.cpp
+++ b/lib/Demangling/NodePrinter.cpp
@@ -342,6 +342,8 @@
case Node::Kind::Initializer:
case Node::Kind::KeyPathGetterThunkHelper:
case Node::Kind::KeyPathSetterThunkHelper:
+ case Node::Kind::KeyPathEqualsThunkHelper:
+ case Node::Kind::KeyPathHashThunkHelper:
case Node::Kind::LazyProtocolWitnessTableAccessor:
case Node::Kind::LazyProtocolWitnessTableCacheVariable:
case Node::Kind::LocalDeclName:
@@ -1238,6 +1240,29 @@
print(Node->getChild(2));
}
return nullptr;
+ case Node::Kind::KeyPathEqualsThunkHelper:
+ case Node::Kind::KeyPathHashThunkHelper: {
+ Printer << "key path index "
+ << (Node->getKind() == Node::Kind::KeyPathEqualsThunkHelper
+ ? "equality" : "hash")
+ << " operator for ";
+
+ auto lastChild = Node->getChild(Node->getNumChildren() - 1);
+ auto lastType = Node->getNumChildren();
+ if (lastChild->getKind() == Node::Kind::DependentGenericSignature) {
+ print(lastChild);
+ lastType--;
+ }
+
+ Printer << "(";
+ for (unsigned i = 0; i < lastType; ++i) {
+ if (i != 0)
+ Printer << ", ";
+ print(Node->getChild(i));
+ }
+ Printer << ")";
+ return nullptr;
+ }
case Node::Kind::FieldOffset: {
print(Node->getChild(0)); // directness
Printer << "field offset for ";
diff --git a/lib/Demangling/OldRemangler.cpp b/lib/Demangling/OldRemangler.cpp
index 0f790ca..cb5e0d2 100644
--- a/lib/Demangling/OldRemangler.cpp
+++ b/lib/Demangling/OldRemangler.cpp
@@ -1716,6 +1716,16 @@
mangleChildNodes(node);
}
+void Remangler::mangleKeyPathEqualsThunkHelper(Node *node) {
+ Out << "TH";
+ mangleChildNodes(node);
+}
+
+void Remangler::mangleKeyPathHashThunkHelper(Node *node) {
+ Out << "Th";
+ mangleChildNodes(node);
+}
+
void Remangler::mangleProtocolListWithClass(Node *node) {
Out << "Xc";
mangleChildNode(node, 1);
diff --git a/lib/Demangling/Remangler.cpp b/lib/Demangling/Remangler.cpp
index 13110e5..194fa1c 100644
--- a/lib/Demangling/Remangler.cpp
+++ b/lib/Demangling/Remangler.cpp
@@ -1517,6 +1517,16 @@
Buffer << "Tk";
}
+void Remangler::mangleKeyPathEqualsThunkHelper(Node *node) {
+ mangleChildNodes(node);
+ Buffer << "TH";
+}
+
+void Remangler::mangleKeyPathHashThunkHelper(Node *node) {
+ mangleChildNodes(node);
+ Buffer << "Th";
+}
+
void Remangler::mangleReturnType(Node *node) {
mangleArgumentTuple(node);
}
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 40461ac..0a12441 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -957,9 +957,6 @@
Opts.EnableExperimentalPropertyBehaviors |=
Args.hasArg(OPT_enable_experimental_property_behaviors);
- Opts.EnableExperimentalKeyPathComponents |=
- Args.hasArg(OPT_enable_experimental_keypath_components);
-
Opts.EnableClassResilience |=
Args.hasArg(OPT_enable_class_resilience);
diff --git a/lib/IDE/Refactoring.cpp b/lib/IDE/Refactoring.cpp
index 7bf51d8..905e5b3 100644
--- a/lib/IDE/Refactoring.cpp
+++ b/lib/IDE/Refactoring.cpp
@@ -1257,13 +1257,7 @@
/// Find all tokens included by an expression.
llvm::ArrayRef<Token> getExprSlice(Expr *E) {
- SourceLoc StartLoc = E->getStartLoc();
- SourceLoc EndLoc = E->getEndLoc();
- auto StartIt = token_lower_bound(AllTokens, StartLoc);
- auto EndIt = token_lower_bound(AllTokens, EndLoc);
- assert(StartIt->getLoc() == StartLoc);
- assert(EndIt->getLoc() == EndLoc);
- return AllTokens.slice(StartIt - AllTokens.begin(), EndIt - StartIt + 1);
+ return slice_token_array(AllTokens, E->getStartLoc(), E->getEndLoc());
}
SimilarExprCollector(SourceManager &SM, Expr* SelectedExpr,
@@ -1328,15 +1322,11 @@
Collector.walk(BS);
if (ExtractRepeated) {
- // Tokenize the brace statement; all expressions should have their tokens
- // in this array.
- auto AllTokens = TheFile->getAllTokens();
- auto StartIt = token_lower_bound(AllTokens, BS->getStartLoc());
- auto EndIt = token_lower_bound(AllTokens, BS->getEndLoc());
-
// Collect all expressions we are going to extract.
SimilarExprCollector(SM, SelectedExpr,
- AllTokens.slice(StartIt - AllTokens.begin(), EndIt - StartIt + 1),
+ slice_token_array(TheFile->getAllTokens(),
+ BS->getStartLoc(),
+ BS->getEndLoc()),
AllExpressions).walk(BS);
} else {
AllExpressions.insert(SelectedExpr);
@@ -1458,6 +1448,113 @@
EditConsumer).performChange();
}
+struct CollapsibleNestedIfInfo {
+ IfStmt *OuterIf;
+ IfStmt *InnerIf;
+ bool FinishedOuterIf;
+ bool FoundNonCollapsibleItem;
+ CollapsibleNestedIfInfo():
+ OuterIf(nullptr), InnerIf(nullptr),
+ FinishedOuterIf(false), FoundNonCollapsibleItem(false) {}
+ bool isValid() {
+ return OuterIf && InnerIf && FinishedOuterIf && !FoundNonCollapsibleItem;
+ }
+};
+
+static CollapsibleNestedIfInfo findCollapseNestedIfTarget(ResolvedCursorInfo CursorInfo) {
+ if (CursorInfo.Kind != CursorInfoKind::StmtStart)
+ return CollapsibleNestedIfInfo();
+ struct IfStmtFinder: public SourceEntityWalker {
+ SourceLoc StartLoc;
+ CollapsibleNestedIfInfo IfInfo;
+ IfStmtFinder(SourceLoc StartLoc): StartLoc(StartLoc), IfInfo() {}
+ bool finishedInnerIfButNotFinishedOuterIf() {
+ return IfInfo.InnerIf && !IfInfo.FinishedOuterIf;
+ }
+ bool walkToStmtPre(Stmt *S) {
+ if (finishedInnerIfButNotFinishedOuterIf()) {
+ IfInfo.FoundNonCollapsibleItem = true;
+ return false;
+ }
+
+ bool StmtIsOuterIfBrace =
+ IfInfo.OuterIf && !IfInfo.InnerIf && S->getKind() == StmtKind::Brace;
+ if (StmtIsOuterIfBrace) {
+ return true;
+ }
+
+ auto *IFS = dyn_cast<IfStmt>(S);
+ if (!IFS) {
+ return false;
+ }
+ if (!IfInfo.OuterIf) {
+ IfInfo.OuterIf = IFS;
+ return true;
+ } else {
+ IfInfo.InnerIf = IFS;
+ return false;
+ }
+ }
+ bool walkToStmtPost(Stmt *S) {
+ assert(S != IfInfo.InnerIf && "Should not traverse inner if statement");
+ if (S == IfInfo.OuterIf) {
+ IfInfo.FinishedOuterIf = true;
+ }
+ return true;
+ }
+ bool walkToDeclPre(Decl *D, CharSourceRange Range) {
+ if (finishedInnerIfButNotFinishedOuterIf()) {
+ IfInfo.FoundNonCollapsibleItem = true;
+ return false;
+ }
+ return true;
+ }
+ bool walkToExprPre(Expr *E) {
+ if (finishedInnerIfButNotFinishedOuterIf()) {
+ IfInfo.FoundNonCollapsibleItem = true;
+ return false;
+ }
+ return true;
+ }
+
+ } Walker(CursorInfo.TrailingStmt->getStartLoc());
+ Walker.walk(CursorInfo.TrailingStmt);
+ return Walker.IfInfo;
+}
+
+bool RefactoringActionCollapseNestedIfExpr::isApplicable(ResolvedCursorInfo Tok) {
+ return findCollapseNestedIfTarget(Tok).isValid();
+}
+
+bool RefactoringActionCollapseNestedIfExpr::performChange() {
+ auto Target = findCollapseNestedIfTarget(CursorInfo);
+ if (!Target.isValid())
+ return true;
+ auto OuterIfConds = Target.OuterIf->getCond().vec();
+ auto InnerIfConds = Target.InnerIf->getCond().vec();
+
+ llvm::SmallString<64> DeclBuffer;
+ llvm::raw_svector_ostream OS(DeclBuffer);
+ OS << tok::kw_if << " ";
+ for (auto CI = OuterIfConds.begin(); CI != OuterIfConds.end(); ++CI) {
+ OS << (CI != OuterIfConds.begin() ? ", " : "");
+ OS << Lexer::getCharSourceRangeFromSourceRange(
+ SM, CI->getSourceRange()).str();
+ }
+ for (auto CI = InnerIfConds.begin(); CI != InnerIfConds.end(); ++CI) {
+ OS << ", " << Lexer::getCharSourceRangeFromSourceRange(
+ SM, CI->getSourceRange()).str();
+ }
+ auto ThenStatementText = Lexer::getCharSourceRangeFromSourceRange(
+ SM, Target.InnerIf->getThenStmt()->getSourceRange()).str();
+ OS << " " << ThenStatementText;
+
+ auto SourceRange = Lexer::getCharSourceRangeFromSourceRange(
+ SM, Target.OuterIf->getSourceRange());
+ EditConsumer.accept(SM, SourceRange, DeclBuffer.str());
+ return false;
+}
+
/// The helper class analyzes a given nominal decl or an extension decl to
/// decide whether stubs are required to filled in and the context in which
/// these stubs should be filled.
diff --git a/lib/IDE/SyntaxModel.cpp b/lib/IDE/SyntaxModel.cpp
index 5d75bbe..d6465b0 100644
--- a/lib/IDE/SyntaxModel.cpp
+++ b/lib/IDE/SyntaxModel.cpp
@@ -165,6 +165,15 @@
break;
}
+ case tok::unknown: {
+ if (Tok.getRawText().startswith("\"")) {
+ // This is an invalid string literal
+ Kind = SyntaxNodeKind::String;
+ break;
+ }
+ continue;
+ }
+
default:
continue;
}
@@ -227,6 +236,7 @@
"radar:[a-zA-Z0-9;/?:@\\&=+$,\\-_.!~*'()%#]+";
class ModelASTWalker : public ASTWalker {
+ ArrayRef<Token> AllTokensInFile;
const LangOptions &LangOpts;
const SourceManager &SM;
unsigned BufferID;
@@ -242,9 +252,12 @@
SyntaxModelWalker &Walker;
ArrayRef<SyntaxNode> TokenNodes;
- ModelASTWalker(const LangOptions &LangOpts, const SourceManager &SM,
- unsigned BufferID, SyntaxModelWalker &Walker)
- : LangOpts(LangOpts), SM(SM), BufferID(BufferID), Walker(Walker) { }
+ ModelASTWalker(const SourceFile &File, SyntaxModelWalker &Walker)
+ : AllTokensInFile(File.getAllTokens()),
+ LangOpts(File.getASTContext().LangOpts),
+ SM(File.getASTContext().SourceMgr),
+ BufferID(File.getBufferID().getValue()),
+ Walker(Walker) { }
void visitSourceFile(SourceFile &SrcFile, ArrayRef<SyntaxNode> Tokens);
@@ -267,7 +280,7 @@
typedef std::pair<const DeclAttribute *, SourceRange> DeclAttributeAndRange;
bool handleSpecialDeclAttribute(const DeclAttribute *Decl,
- std::vector<Token> &Toks);
+ ArrayRef<Token> Toks);
bool handleAttrRanges(ArrayRef<DeclAttributeAndRange> DeclRanges);
bool shouldPassBraceStructureNode(BraceStmt *S);
@@ -383,8 +396,7 @@
} // anonymous namespace
bool SyntaxModelContext::walk(SyntaxModelWalker &Walker) {
- ModelASTWalker ASTWalk(Impl.LangOpts, Impl.SrcMgr,
- *Impl.SrcFile.getBufferID(), Walker);
+ ModelASTWalker ASTWalk(Impl.SrcFile, Walker);
ASTWalk.visitSourceFile(Impl.SrcFile, Impl.TokenNodes);
return true;
}
@@ -947,7 +959,7 @@
}
bool ModelASTWalker::handleSpecialDeclAttribute(const DeclAttribute *D,
- std::vector<Token> &Toks) {
+ ArrayRef<Token> Toks) {
if (!D)
return false;
if (isa<AvailableAttr>(D)) {
@@ -1004,12 +1016,8 @@
SourceLoc BeginLoc = DeclRanges.front().second.Start;
- std::vector<Token> Toks = swift::tokenize(
- LangOpts, SM, BufferID,
- SM.getLocOffsetInBuffer(BeginLoc, BufferID),
- SM.getLocOffsetInBuffer(DeclRanges.back().second.End, BufferID),
- /*KeepComments=*/true,
- /*TokenizeInterpolatedString=*/false);
+ auto Toks = slice_token_array(AllTokensInFile, BeginLoc,
+ DeclRanges.back().second.End);
auto passAttrNode = [&](SourceRange AttrRange) -> bool {
SourceRange Range = AttrRange;
diff --git a/lib/IRGen/GenConstant.cpp b/lib/IRGen/GenConstant.cpp
index 0838635..b855f0a 100644
--- a/lib/IRGen/GenConstant.cpp
+++ b/lib/IRGen/GenConstant.cpp
@@ -22,6 +22,7 @@
#include "TypeInfo.h"
#include "StructLayout.h"
#include "swift/Basic/Range.h"
+#include "swift/SIL/SILModule.h"
using namespace swift;
using namespace irgen;
@@ -71,18 +72,24 @@
}
static llvm::Constant *emitConstantValue(IRGenModule &IGM, SILValue operand) {
- if (auto *SI = dyn_cast<StructInst>(operand))
+ if (auto *SI = dyn_cast<StructInst>(operand)) {
return emitConstantStruct(IGM, SI);
- else if (auto *TI = dyn_cast<TupleInst>(operand))
+ } else if (auto *TI = dyn_cast<TupleInst>(operand)) {
return emitConstantTuple(IGM, TI);
- else if (auto *ILI = dyn_cast<IntegerLiteralInst>(operand))
+ } else if (auto *ILI = dyn_cast<IntegerLiteralInst>(operand)) {
return emitConstantInt(IGM, ILI);
- else if (auto *FLI = dyn_cast<FloatLiteralInst>(operand))
+ } else if (auto *FLI = dyn_cast<FloatLiteralInst>(operand)) {
return emitConstantFP(IGM, FLI);
- else if (auto *SLI = dyn_cast<StringLiteralInst>(operand))
+ } else if (auto *SLI = dyn_cast<StringLiteralInst>(operand)) {
return emitAddrOfConstantString(IGM, SLI);
- else
+ } else if (auto *BI = dyn_cast<BuiltinInst>(operand)) {
+ assert(IGM.getSILModule().getBuiltinInfo(BI->getName()).ID ==
+ BuiltinValueKind::PtrToInt);
+ llvm::Constant *ptr = emitConstantValue(IGM, BI->getArguments()[0]);
+ return llvm::ConstantExpr::getPtrToInt(ptr, IGM.IntPtrTy);
+ } else {
llvm_unreachable("Unsupported SILInstruction in static initializer!");
+ }
}
namespace {
diff --git a/lib/IRGen/GenHeap.cpp b/lib/IRGen/GenHeap.cpp
index 4558772..3f789d9 100644
--- a/lib/IRGen/GenHeap.cpp
+++ b/lib/IRGen/GenHeap.cpp
@@ -837,7 +837,7 @@
/// Emit a unary call to perform a ref-counting operation.
///
-/// \param fn - expected signature 'void (T)'
+/// \param fn - expected signature 'void (T)' or 'T (T)'
static void emitUnaryRefCountCall(IRGenFunction &IGF,
llvm::Constant *fn,
llvm::Value *value) {
@@ -847,9 +847,13 @@
// Instead of casting the input, we cast the function type.
// This tends to produce less IR, but might be evil.
- if (value->getType() != getTypeOfFunction(fn)->getParamType(0)) {
+ auto origFnType = getTypeOfFunction(fn);
+ if (value->getType() != origFnType->getParamType(0)) {
+ auto resultTy = origFnType->getReturnType() == IGF.IGM.VoidTy
+ ? IGF.IGM.VoidTy
+ : value->getType();
llvm::FunctionType *fnType =
- llvm::FunctionType::get(IGF.IGM.VoidTy, value->getType(), false);
+ llvm::FunctionType::get(resultTy, value->getType(), false);
fn = llvm::ConstantExpr::getBitCast(fn, fnType->getPointerTo());
}
@@ -861,7 +865,7 @@
/// Emit a copy-like call to perform a ref-counting operation.
///
-/// \param fn - expected signature 'void (T, T)'
+/// \param fn - expected signature 'void (T, T)' or 'T (T, T)'
static void emitCopyLikeCall(IRGenFunction &IGF,
llvm::Constant *fn,
llvm::Value *dest,
@@ -875,10 +879,14 @@
// Instead of casting the inputs, we cast the function type.
// This tends to produce less IR, but might be evil.
- if (dest->getType() != getTypeOfFunction(fn)->getParamType(0)) {
+ auto origFnType = getTypeOfFunction(fn);
+ if (dest->getType() != origFnType->getParamType(0)) {
llvm::Type *paramTypes[] = { dest->getType(), dest->getType() };
+ auto resultTy = origFnType->getReturnType() == IGF.IGM.VoidTy
+ ? IGF.IGM.VoidTy
+ : dest->getType();
llvm::FunctionType *fnType =
- llvm::FunctionType::get(IGF.IGM.VoidTy, paramTypes, false);
+ llvm::FunctionType::get(resultTy, paramTypes, false);
fn = llvm::ConstantExpr::getBitCast(fn, fnType->getPointerTo());
}
@@ -923,7 +931,7 @@
/// Emit a call to a function with a storeWeak-like signature.
///
-/// \param fn - expected signature 'void (Weak*, T)'
+/// \param fn - expected signature 'void (Weak*, T)' or 'Weak* (Weak*, T)'
static void emitStoreWeakLikeCall(IRGenFunction &IGF,
llvm::Constant *fn,
llvm::Value *addr,
@@ -938,10 +946,14 @@
// Instead of casting the inputs, we cast the function type.
// This tends to produce less IR, but might be evil.
- if (value->getType() != getTypeOfFunction(fn)->getParamType(1)) {
+ auto origFnType = getTypeOfFunction(fn);
+ if (value->getType() != origFnType->getParamType(1)) {
llvm::Type *paramTypes[] = { addr->getType(), value->getType() };
+ auto resultTy = origFnType->getReturnType() == IGF.IGM.VoidTy
+ ? IGF.IGM.VoidTy
+ : addr->getType();
llvm::FunctionType *fnType =
- llvm::FunctionType::get(IGF.IGM.VoidTy, paramTypes, false);
+ llvm::FunctionType::get(resultTy, paramTypes, false);
fn = llvm::ConstantExpr::getBitCast(fn, fnType->getPointerTo());
}
diff --git a/lib/IRGen/GenKeyPath.cpp b/lib/IRGen/GenKeyPath.cpp
index d58f606..95c8d0f 100644
--- a/lib/IRGen/GenKeyPath.cpp
+++ b/lib/IRGen/GenKeyPath.cpp
@@ -30,6 +30,7 @@
#include "MetadataLayout.h"
#include "ProtocolInfo.h"
#include "StructLayout.h"
+#include "TypeInfo.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/IR/Module.h"
#include "swift/SIL/SILInstruction.h"
@@ -47,15 +48,44 @@
using namespace swift;
using namespace irgen;
-enum GetterOrSetter {
+enum KeyPathAccessor {
Getter,
Setter,
+ Equals,
+ Hash,
};
+static void
+bindPolymorphicArgumentsFromComponentIndices(IRGenFunction &IGF,
+ const KeyPathPatternComponent &component,
+ GenericEnvironment *genericEnv,
+ ArrayRef<GenericRequirement> requirements,
+ llvm::Value *args,
+ llvm::Value *size) {
+ if (!genericEnv)
+ return;
+
+ // The generic environment is marshaled into the end of the component
+ // argument area inside the instance. Bind the generic information out of
+ // the buffer.
+ if (!component.getComputedPropertyIndices().empty()) {
+ auto genericArgsSize = llvm::ConstantInt::get(IGF.IGM.SizeTy,
+ requirements.size() * IGF.IGM.getPointerSize().getValue());
+
+ auto genericArgsOffset = IGF.Builder.CreateSub(size, genericArgsSize);
+ args = IGF.Builder.CreateInBoundsGEP(args, genericArgsOffset);
+ }
+ bindFromGenericRequirementsBuffer(IGF, requirements,
+ Address(args, IGF.IGM.getPointerAlignment()),
+ [&](CanType t) {
+ return genericEnv->mapTypeIntoContext(t)->getCanonicalType();
+ });
+}
+
static llvm::Function *
getAccessorForComputedComponent(IRGenModule &IGM,
const KeyPathPatternComponent &component,
- GetterOrSetter whichAccessor,
+ KeyPathAccessor whichAccessor,
GenericEnvironment *genericEnv,
ArrayRef<GenericRequirement> requirements) {
SILFunction *accessor;
@@ -66,6 +96,12 @@
case Setter:
accessor = component.getComputedPropertySetter();
break;
+ case Equals:
+ accessor = component.getComputedPropertyIndexEquals();
+ break;
+ case Hash:
+ accessor = component.getComputedPropertyIndexHash();
+ break;
}
auto accessorFn = IGM.getAddrOfSILFunction(accessor, NotForDefinition);
@@ -75,42 +111,82 @@
return accessorFn;
}
- auto accessorFnTy = accessorFn->getType()->getPointerElementType();
+ auto accessorFnTy = cast<llvm::FunctionType>(
+ accessorFn->getType()->getPointerElementType());;
// Otherwise, we need a thunk to unmarshal the generic environment from the
// argument area. It'd be nice to have a good way to represent this
// directly in SIL, of course...
- auto thunkType = llvm::FunctionType::get(
- IGM.VoidTy,
- { /*sret or newValue*/ accessorFnTy->getFunctionParamType(0),
- /*base*/ accessorFnTy->getFunctionParamType(1),
- /*arg*/ IGM.Int8PtrTy },
- /*vararg*/ false);
const char *thunkName;
- unsigned numArgsToForward = 2;
+ unsigned numArgsToForward;
+
switch (whichAccessor) {
case Getter:
thunkName = "keypath_get";
+ numArgsToForward = 2;
break;
case Setter:
thunkName = "keypath_set";
+ numArgsToForward = 2;
+ break;
+ case Equals:
+ thunkName = "keypath_equals";
+ numArgsToForward = 2;
+ break;
+ case Hash:
+ thunkName = "keypath_hash";
+ numArgsToForward = 1;
break;
}
+
+ SmallVector<llvm::Type *, 4> thunkParams;
+ for (unsigned i = 0; i < numArgsToForward; ++i)
+ thunkParams.push_back(accessorFnTy->getParamType(i));
+
+ switch (whichAccessor) {
+ case Getter:
+ case Setter:
+ thunkParams.push_back(IGM.Int8PtrTy);
+ break;
+ case Equals:
+ case Hash:
+ break;
+ }
+ thunkParams.push_back(IGM.SizeTy);
+
+ auto thunkType = llvm::FunctionType::get(accessorFnTy->getReturnType(),
+ thunkParams,
+ /*vararg*/ false);
auto accessorThunk = llvm::Function::Create(thunkType,
llvm::GlobalValue::PrivateLinkage, thunkName, IGM.getModule());
accessorThunk->setAttributes(IGM.constructInitialAttributes());
- // Original accessor's args should be @in or @out, meaning they won't be
- // captured or aliased.
- accessorThunk->addAttribute(1, llvm::Attribute::NoCapture);
- accessorThunk->addAttribute(1, llvm::Attribute::NoAlias);
- accessorThunk->addAttribute(2, llvm::Attribute::NoCapture);
- accessorThunk->addAttribute(2, llvm::Attribute::NoAlias);
- // Getter's output is sret.
- if (whichAccessor == Getter)
- accessorThunk->addAttribute(1, llvm::Attribute::StructRet);
accessorThunk->setCallingConv(IGM.SwiftCC);
-
+
+ switch (whichAccessor) {
+ case Getter:
+ // Original accessor's args should be @in or @out, meaning they won't be
+ // captured or aliased.
+ accessorThunk->addAttribute(1, llvm::Attribute::NoCapture);
+ accessorThunk->addAttribute(1, llvm::Attribute::NoAlias);
+ accessorThunk->addAttribute(2, llvm::Attribute::NoCapture);
+ accessorThunk->addAttribute(2, llvm::Attribute::NoAlias);
+ // Output is sret.
+ accessorThunk->addAttribute(1, llvm::Attribute::StructRet);
+ break;
+ case Setter:
+ // Original accessor's args should be @in or @out, meaning they won't be
+ // captured or aliased.
+ accessorThunk->addAttribute(1, llvm::Attribute::NoCapture);
+ accessorThunk->addAttribute(1, llvm::Attribute::NoAlias);
+ accessorThunk->addAttribute(2, llvm::Attribute::NoCapture);
+ accessorThunk->addAttribute(2, llvm::Attribute::NoAlias);
+ break;
+ case Equals:
+ case Hash:
+ break;
+ }
+
{
IRGenFunction IGF(IGM, accessorThunk);
if (IGM.DebugInfo)
@@ -120,35 +196,46 @@
Explosion forwardedArgs;
forwardedArgs.add(params.claim(numArgsToForward));
- // The generic environment is marshaled into the beginning of the component
- // argument area inside the instance. Bind the generic information out of
- // the buffer, and advance past it.
- auto componentArgsBuf = params.claimNext();
- bindFromGenericRequirementsBuffer(IGF, requirements,
- Address(componentArgsBuf, IGM.getPointerAlignment()),
- [&](CanType t) {
- if (!genericEnv)
- return t;
- return genericEnv->mapTypeIntoContext(t)->getCanonicalType();
- });
-
- /* TODO: If the underlying accessor wants index arguments, advance the
- * pointer past the generic requirements here to pass down. */
-
+ llvm::Value *componentArgsBuf;
+ switch (whichAccessor) {
+ case Getter:
+ case Setter:
+ // The component arguments are passed alongside the base being projected.
+ componentArgsBuf = params.claimNext();
+ // Pass the argument pointer down to the underlying function.
+ if (!component.getComputedPropertyIndices().empty()) {
+ forwardedArgs.add(componentArgsBuf);
+ }
+ break;
+ case Equals:
+ case Hash:
+ // We're operating directly on the component argument buffer.
+ componentArgsBuf = forwardedArgs.getAll()[0];
+ break;
+ }
+ auto componentArgsBufSize = params.claimNext();
+ bindPolymorphicArgumentsFromComponentIndices(IGF, component,
+ genericEnv, requirements,
+ componentArgsBuf,
+ componentArgsBufSize);
+
// Use the bound generic metadata to form a call to the original generic
// accessor.
- WitnessMetadata witnessMetadata;
+ WitnessMetadata ignoreWitnessMetadata;
auto forwardingSubs = genericEnv->getGenericSignature()->getSubstitutionMap(
genericEnv->getForwardingSubstitutions());
emitPolymorphicArguments(IGF, accessor->getLoweredFunctionType(),
forwardingSubs,
- &witnessMetadata,
+ &ignoreWitnessMetadata,
forwardedArgs);
auto fnPtr = FunctionPointer::forDirect(IGM, accessorFn,
accessor->getLoweredFunctionType());
- IGF.Builder.CreateCall(fnPtr, forwardedArgs.claimAll());
+ auto call = IGF.Builder.CreateCall(fnPtr, forwardedArgs.claimAll());
- IGF.Builder.CreateRetVoid();
+ if (call->getType()->isVoidTy())
+ IGF.Builder.CreateRetVoid();
+ else
+ IGF.Builder.CreateRet(call);
}
return accessorThunk;
@@ -171,19 +258,53 @@
{
IRGenFunction IGF(IGM, layoutFn);
- // TODO: We would need to unmarshal generic arguments to be able to
- // compute the layout of dependent subscript indexes.
- (void)IGF.collectParameters().claimNext();
+ // Unmarshal the generic environment from the argument buffer.
+ auto parameters = IGF.collectParameters();
+ auto args = parameters.claimNext();
- // Base size is one pointer for each generic requirement; base alignment
- // is pointer alignment.
- llvm::Value *size = llvm::ConstantInt::get(IGM.SizeTy,
- IGM.getPointerSize().getValue() * requirements.size());
- llvm::Value *alignMask = llvm::ConstantInt::get(IGM.SizeTy,
- IGM.getPointerAlignment().getValue() - 1);
+ if (genericEnv) {
+ bindFromGenericRequirementsBuffer(IGF, requirements,
+ Address(args, IGF.IGM.getPointerAlignment()),
+ [&](CanType t) {
+ return genericEnv->mapTypeIntoContext(t)->getCanonicalType();
+ });
+ }
+
+ // Run through the captured index types to determine the size and alignment
+ // needed. Start with pointer alignment for the generic environment.
+ llvm::Value *size = llvm::ConstantInt::get(IGM.SizeTy, 0);
+ llvm::Value *alignMask = llvm::ConstantInt::get(IGM.SizeTy, 0);
+
+ for (auto &index : component.getComputedPropertyIndices()) {
+ auto ty = genericEnv
+ ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), index.LoweredType)
+ : index.LoweredType;
+ auto &ti = IGM.getTypeInfo(ty);
+ auto indexSize = ti.getSize(IGF, ty);
+ auto indexAlign = ti.getAlignmentMask(IGF, ty);
- // TODO: Combine layout of captured index values
+ auto notIndexAlign = IGF.Builder.CreateNot(indexAlign);
+
+ size = IGF.Builder.CreateAdd(size, indexAlign);
+ size = IGF.Builder.CreateAnd(size, notIndexAlign);
+ size = IGF.Builder.CreateAdd(size, indexSize);
+
+ alignMask = IGF.Builder.CreateOr(alignMask, indexAlign);
+ }
+ // If there's generic environment to capture, then it's stored as a block
+ // of pointer-aligned words after the captured values.
+
+ auto genericsSize = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerSize().getValue() * requirements.size());
+ auto genericsAlign = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerAlignment().getValue() - 1);
+ auto notGenericsAlign = llvm::ConstantExpr::getNot(genericsAlign);
+ size = IGF.Builder.CreateAdd(size, genericsAlign);
+ size = IGF.Builder.CreateAnd(size, notGenericsAlign);
+ size = IGF.Builder.CreateAdd(size, genericsSize);
+ alignMask = IGF.Builder.CreateOr(alignMask, genericsAlign);
+
llvm::Value *retValue = IGF.Builder.CreateInsertValue(
llvm::UndefValue::get(retTy), size, 0);
retValue = IGF.Builder.CreateInsertValue(
@@ -202,27 +323,184 @@
ArrayRef<GenericRequirement> requirements) {
// If the only thing we're capturing is generic environment, then we can
// use a prefab witness table from the runtime.
- // TODO: If there were subscript indexes, we'd need to generate something.
- if (auto existing =
- IGM.Module.getNamedGlobal("swift_keyPathGenericWitnessTable"))
- return existing;
+ if (component.getComputedPropertyIndices().empty()) {
+ if (auto existing =
+ IGM.Module.getNamedGlobal("swift_keyPathGenericWitnessTable"))
+ return existing;
+
+ auto linkInfo = LinkInfo::get(IGM, "swift_keyPathGenericWitnessTable",
+ SILLinkage::PublicExternal,
+ /*fragile*/ false,
+ /*sil only*/ false,
+ NotForDefinition,
+ /*weak imported*/ false);
+
+ return createVariable(IGM, linkInfo,
+ IGM.Int8PtrTy, IGM.getPointerAlignment());
+ }
- auto linkInfo = LinkInfo::get(IGM, "swift_keyPathGenericWitnessTable",
- SILLinkage::PublicExternal,
- /*fragile*/ false,
- /*sil only*/ false,
- NotForDefinition,
- /*weak imported*/ false);
+ // Are the index values trivial?
+ bool isTrivial = true;
+ for (auto &component : component.getComputedPropertyIndices()) {
+ auto ty = genericEnv
+ ? genericEnv->mapTypeIntoContext(IGM.getSILModule(), component.LoweredType)
+ : component.LoweredType;
+ auto &ti = IGM.getTypeInfo(ty);
+ isTrivial &= ti.isPOD(ResilienceExpansion::Minimal);
+ }
- return createVariable(IGM, linkInfo,
- IGM.Int8PtrTy, IGM.getPointerAlignment());
+ llvm::Constant *destroy;
+ llvm::Constant *copy;
+ if (isTrivial) {
+ // We can use prefab witnesses for handling trivial copying and destruction.
+ // A null destructor witness signals that the payload is trivial.
+ destroy = llvm::ConstantPointerNull::get(IGM.Int8PtrTy);
+ copy = IGM.getCopyKeyPathTrivialIndicesFn();
+ } else {
+ // Generate a destructor for this set of indices.
+ {
+ auto destroyType = llvm::FunctionType::get(IGM.VoidTy,
+ {IGM.Int8PtrTy, IGM.SizeTy},
+ /*vararg*/ false);
+ auto destroyFn = llvm::Function::Create(destroyType,
+ llvm::GlobalValue::PrivateLinkage, "keypath_destroy", IGM.getModule());
+ destroy = destroyFn;
+
+ IRGenFunction IGF(IGM, destroyFn);
+ if (IGM.DebugInfo)
+ IGM.DebugInfo->emitArtificialFunction(IGF, destroyFn);
+
+ auto params = IGF.collectParameters();
+ auto componentArgsBuf = params.claimNext();
+ auto componentArgsBufSize = params.claimNext();
+ bindPolymorphicArgumentsFromComponentIndices(IGF, component,
+ genericEnv, requirements,
+ componentArgsBuf,
+ componentArgsBufSize);
+
+ llvm::Value *offset = nullptr;
+ for (auto &component : component.getComputedPropertyIndices()) {
+ auto ty = genericEnv
+ ? genericEnv->mapTypeIntoContext(IGM.getSILModule(),
+ component.LoweredType)
+ : component.LoweredType;
+ auto &ti = IGM.getTypeInfo(ty);
+ if (offset) {
+ auto align = ti.getAlignmentMask(IGF, ty);
+ auto notAlign = IGF.Builder.CreateNot(align);
+ offset = IGF.Builder.CreateAdd(offset, align);
+ offset = IGF.Builder.CreateAnd(offset, notAlign);
+ } else {
+ offset = llvm::ConstantInt::get(IGM.SizeTy, 0);
+ }
+ auto elt = IGF.Builder.CreateInBoundsGEP(componentArgsBuf, offset);
+ auto eltAddr = ti.getAddressForPointer(
+ IGF.Builder.CreateBitCast(elt, ti.getStorageType()->getPointerTo()));
+ ti.destroy(IGF, eltAddr, ty);
+ auto size = ti.getSize(IGF, ty);
+ offset = IGF.Builder.CreateAdd(offset, size);
+ }
+ IGF.Builder.CreateRetVoid();
+ }
+ // Generate a copier for this set of indices.
+ {
+ auto copyType = llvm::FunctionType::get(IGM.VoidTy,
+ {IGM.Int8PtrTy, IGM.Int8PtrTy,
+ IGM.SizeTy},
+ /*vararg*/ false);
+ auto copyFn = llvm::Function::Create(copyType,
+ llvm::GlobalValue::PrivateLinkage, "keypath_copy", IGM.getModule());
+ copy = copyFn;
+
+ IRGenFunction IGF(IGM, copyFn);
+ if (IGM.DebugInfo)
+ IGM.DebugInfo->emitArtificialFunction(IGF, copyFn);
+
+ auto params = IGF.collectParameters();
+ auto sourceArgsBuf = params.claimNext();
+ auto destArgsBuf = params.claimNext();
+ auto componentArgsBufSize = params.claimNext();
+ bindPolymorphicArgumentsFromComponentIndices(IGF, component,
+ genericEnv, requirements,
+ sourceArgsBuf,
+ componentArgsBufSize);
+
+ // Copy over the index values.
+ llvm::Value *offset = nullptr;
+ for (auto &component : component.getComputedPropertyIndices()) {
+ auto ty = genericEnv
+ ? genericEnv->mapTypeIntoContext(IGM.getSILModule(),
+ component.LoweredType)
+ : component.LoweredType;
+ auto &ti = IGM.getTypeInfo(ty);
+ if (offset) {
+ auto align = ti.getAlignmentMask(IGF, ty);
+ auto notAlign = IGF.Builder.CreateNot(align);
+ offset = IGF.Builder.CreateAdd(offset, align);
+ offset = IGF.Builder.CreateAnd(offset, notAlign);
+ } else {
+ offset = llvm::ConstantInt::get(IGM.SizeTy, 0);
+ }
+ auto sourceElt = IGF.Builder.CreateInBoundsGEP(sourceArgsBuf, offset);
+ auto destElt = IGF.Builder.CreateInBoundsGEP(destArgsBuf, offset);
+ auto sourceEltAddr = ti.getAddressForPointer(
+ IGF.Builder.CreateBitCast(sourceElt,
+ ti.getStorageType()->getPointerTo()));
+ auto destEltAddr = ti.getAddressForPointer(
+ IGF.Builder.CreateBitCast(destElt,
+ ti.getStorageType()->getPointerTo()));
+
+ ti.initializeWithCopy(IGF, destEltAddr, sourceEltAddr, ty);
+ auto size = ti.getSize(IGF, ty);
+ offset = IGF.Builder.CreateAdd(offset, size);
+ }
+
+ // Copy over the generic environment.
+ if (genericEnv) {
+ auto envAlignMask = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerAlignment().getMaskValue());
+ auto notAlignMask = IGF.Builder.CreateNot(envAlignMask);
+ offset = IGF.Builder.CreateAdd(offset, envAlignMask);
+ offset = IGF.Builder.CreateAnd(offset, notAlignMask);
+
+ auto sourceEnv = IGF.Builder.CreateInBoundsGEP(sourceArgsBuf, offset);
+ auto destEnv = IGF.Builder.CreateInBoundsGEP(destArgsBuf, offset);
+
+ IGF.Builder.CreateMemCpy(destEnv, sourceEnv,
+ IGM.getPointerSize().getValue() * requirements.size(),
+ IGM.getPointerAlignment().getValue());
+ }
+
+ IGF.Builder.CreateRetVoid();
+ }
+ }
+
+ auto equals = getAccessorForComputedComponent(IGM, component, Equals,
+ genericEnv, requirements);
+ auto hash = getAccessorForComputedComponent(IGM, component, Hash,
+ genericEnv, requirements);
+
+ auto witnesses = llvm::ConstantStruct::getAnon({destroy, copy, equals, hash});
+ return new llvm::GlobalVariable(IGM.Module, witnesses->getType(),
+ /*constant*/ true,
+ llvm::GlobalValue::PrivateLinkage,
+ witnesses,
+ "keypath_witnesses");
}
+/// Information about each index operand for a key path pattern that is used
+/// to lay out and consume the argument packet.
+struct KeyPathIndexOperand {
+ SILType LoweredType;
+ const KeyPathPatternComponent *LastUser;
+};
+
static llvm::Constant *
getInitializerForComputedComponent(IRGenModule &IGM,
- const KeyPathPatternComponent &component,
- GenericEnvironment *genericEnv,
- ArrayRef<GenericRequirement> requirements) {
+ const KeyPathPatternComponent &component,
+ ArrayRef<KeyPathIndexOperand> operands,
+ GenericEnvironment *genericEnv,
+ ArrayRef<GenericRequirement> requirements) {
auto fnTy = llvm::FunctionType::get(IGM.VoidTy,
{ /*src*/ IGM.Int8PtrTy,
/*dest*/ IGM.Int8PtrTy }, /*vararg*/ false);
@@ -233,16 +511,111 @@
{
IRGenFunction IGF(IGM, initFn);
auto params = IGF.collectParameters();
+ // Pointer to the argument packet passed into swift_getKeyPath
auto src = params.claimNext();
+ // Pointer to the destination component's argument buffer
auto dest = params.claimNext();
- // Transfer all of the requirements into the destination instance.
- IGF.Builder.CreateMemCpy(dest, src,
- IGM.getPointerSize().getValue() * requirements.size(),
- IGM.getPointerAlignment().getValue());
+ SmallVector<Address, 4> srcAddresses;
+ int lastOperandNeeded = -1;
+ for (auto &index : component.getComputedPropertyIndices()) {
+ lastOperandNeeded = std::max(lastOperandNeeded, (int)index.Operand);
+ }
- // TODO: Copy over subscript index values.
+ llvm::Value *offset;
+ if (genericEnv) {
+ // We'll copy over the generic environment after we copy in the indexes.
+ offset = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerSize().getValue() * requirements.size());
+
+ // Bind the generic environment from the argument buffer.
+ bindFromGenericRequirementsBuffer(IGF, requirements,
+ Address(src, IGF.IGM.getPointerAlignment()),
+ [&](CanType t) {
+ return genericEnv->mapTypeIntoContext(t)->getCanonicalType();
+ });
+
+ } else {
+ offset = llvm::ConstantInt::get(IGM.SizeTy, 0);
+ }
+
+ // Figure out the offsets of the operands in the source buffer.
+ for (int i = 0; i <= lastOperandNeeded; ++i) {
+ auto ty = genericEnv
+ ? genericEnv->mapTypeIntoContext(IGM.getSILModule(),
+ operands[i].LoweredType)
+ : operands[i].LoweredType;
+
+ auto &ti = IGM.getTypeInfo(ty);
+
+ if (i != 0 || genericEnv) {
+ auto alignMask = ti.getAlignmentMask(IGF, ty);
+ auto notAlignMask = IGF.Builder.CreateNot(alignMask);
+ offset = IGF.Builder.CreateAdd(offset, alignMask);
+ offset = IGF.Builder.CreateAnd(offset, notAlignMask);
+ }
+
+ auto ptr = IGF.Builder.CreateInBoundsGEP(src, offset);
+ auto addr = ti.getAddressForPointer(IGF.Builder.CreateBitCast(
+ ptr, ti.getStorageType()->getPointerTo()));
+ srcAddresses.push_back(addr);
+
+ auto size = ti.getSize(IGF, ty);
+ offset = IGF.Builder.CreateAdd(offset, size);
+ }
+
+ offset = llvm::ConstantInt::get(IGM.SizeTy, 0);
+
+ // Transfer the operands we want into the destination buffer.
+ for (unsigned i : indices(component.getComputedPropertyIndices())) {
+ auto &index = component.getComputedPropertyIndices()[i];
+
+ auto ty = genericEnv
+ ? genericEnv->mapTypeIntoContext(IGM.getSILModule(),
+ index.LoweredType)
+ : index.LoweredType;
+
+ auto &ti = IGM.getTypeInfo(ty);
+
+ if (i != 0) {
+ auto alignMask = ti.getAlignmentMask(IGF, ty);
+ auto notAlignMask = IGF.Builder.CreateNot(alignMask);
+ offset = IGF.Builder.CreateAdd(offset, alignMask);
+ offset = IGF.Builder.CreateAnd(offset, notAlignMask);
+ }
+
+ auto ptr = IGF.Builder.CreateInBoundsGEP(dest, offset);
+ auto destAddr = ti.getAddressForPointer(IGF.Builder.CreateBitCast(
+ ptr, ti.getStorageType()->getPointerTo()));
+
+ // The last component using an operand can move the value out of the
+ // buffer.
+ if (&component == operands[index.Operand].LastUser) {
+ ti.initializeWithTake(IGF, destAddr, srcAddresses[index.Operand], ty);
+ } else {
+ ti.initializeWithCopy(IGF, destAddr, srcAddresses[index.Operand], ty);
+ }
+ auto size = ti.getSize(IGF, ty);
+ offset = IGF.Builder.CreateAdd(offset, size);
+ }
+
+ // Transfer the generic environment.
+ if (genericEnv) {
+ auto destGenericEnv = dest;
+ if (!component.getComputedPropertyIndices().empty()) {
+ auto genericEnvAlignMask = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerAlignment().getMaskValue());
+ auto notGenericEnvAlignMask = IGF.Builder.CreateNot(genericEnvAlignMask);
+ offset = IGF.Builder.CreateAdd(offset, genericEnvAlignMask);
+ offset = IGF.Builder.CreateAnd(offset, notGenericEnvAlignMask);
+ destGenericEnv = IGF.Builder.CreateInBoundsGEP(dest, offset);
+ }
+
+ IGF.Builder.CreateMemCpy(destGenericEnv, src,
+ IGM.getPointerSize().getValue() * requirements.size(),
+ IGM.getPointerAlignment().getValue());
+ }
IGF.Builder.CreateRetVoid();
}
return initFn;
@@ -300,8 +673,6 @@
bindFromGenericRequirementsBuffer(IGF, requirements,
Address(bindingsBufPtr, getPointerAlignment()),
[&](CanType t) {
- if (!genericEnv)
- return t;
return genericEnv->mapTypeIntoContext(t)->getCanonicalType();
});
@@ -374,6 +745,28 @@
&& "must be pointer-aligned here");
};
+ // Collect the order and types of any captured index operands, which will
+ // determine the layout of the buffer that gets passed to the initializer
+ // for each component.
+ SmallVector<KeyPathIndexOperand, 4> operands;
+ operands.resize(pattern->getNumOperands());
+ for (auto &component : pattern->getComponents()) {
+ switch (component.getKind()) {
+ case KeyPathPatternComponent::Kind::GettableProperty:
+ case KeyPathPatternComponent::Kind::SettableProperty:
+ for (auto &index : component.getComputedPropertyIndices()) {
+ operands[index.Operand].LoweredType = index.LoweredType;
+ operands[index.Operand].LastUser = &component;
+ }
+ break;
+ case KeyPathPatternComponent::Kind::StoredProperty:
+ case KeyPathPatternComponent::Kind::OptionalChain:
+ case KeyPathPatternComponent::Kind::OptionalForce:
+ case KeyPathPatternComponent::Kind::OptionalWrap:
+ break;
+ }
+ }
+
for (unsigned i : indices(pattern->getComponents())) {
assertPointerAlignment();
SILType loweredBaseTy;
@@ -585,7 +978,7 @@
fields.add(getAddrOfSILFunction(component.getComputedPropertySetter(),
NotForDefinition));
} else {
- // If there's generic context (TODO: or subscript indexes), embed as
+ // If there's generic context or subscript indexes, embed as
// arguments in the component. Thunk the SIL-level accessors to give the
// runtime implementation a polymorphically-callable interface.
@@ -611,7 +1004,7 @@
// Add an initializer function that copies generic arguments out of the
// pattern argument buffer into the instantiated object.
- fields.add(getInitializerForComputedComponent(*this, component,
+ fields.add(getInitializerForComputedComponent(*this, component, operands,
genericEnv, requirements));
}
break;
@@ -657,4 +1050,3 @@
KeyPathPatterns.insert({pattern, patternVar});
return patternVar;
}
-
diff --git a/lib/IRGen/GenMeta.cpp b/lib/IRGen/GenMeta.cpp
index 65553e3..5fab631 100644
--- a/lib/IRGen/GenMeta.cpp
+++ b/lib/IRGen/GenMeta.cpp
@@ -4034,7 +4034,14 @@
std::pair<llvm::Value *, llvm::Value *>
irgen::emitClassFragileInstanceSizeAndAlignMask(IRGenFunction &IGF,
ClassDecl *theClass,
- llvm::Value *metadata) {
+ llvm::Value *metadata) {
+ // FIXME: The below checks should capture this property already, but
+ // resilient class metadata layout is not fully implemented yet.
+ auto expansion = IGF.IGM.getResilienceExpansionForLayout(theClass);
+ if (IGF.IGM.isResilient(theClass, expansion)) {
+ return emitClassResilientInstanceSizeAndAlignMask(IGF, theClass, metadata);
+ }
+
// If the class has fragile fixed layout, return the constant size and
// alignment.
if (llvm::Constant *size
diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp
index 33e2b70..9252938 100644
--- a/lib/IRGen/IRGenSIL.cpp
+++ b/lib/IRGen/IRGenSIL.cpp
@@ -4597,25 +4597,76 @@
auto pattern = IGM.getAddrOfKeyPathPattern(I->getPattern(), I->getLoc());
// Build up the argument vector to instantiate the pattern here.
llvm::Value *args;
- if (!I->getSubstitutions().empty()) {
+ if (!I->getSubstitutions().empty() || !I->getAllOperands().empty()) {
auto sig = I->getPattern()->getGenericSignature();
- auto subs = sig->getSubstitutionMap(I->getSubstitutions());
+ SubstitutionMap subs;
+ if (sig)
+ subs = sig->getSubstitutionMap(I->getSubstitutions());
SmallVector<GenericRequirement, 4> requirements;
enumerateGenericSignatureRequirements(sig,
[&](GenericRequirement reqt) { requirements.push_back(reqt); });
- auto argsBufTy = llvm::ArrayType::get(IGM.TypeMetadataPtrTy,
- requirements.size());
- auto argsBuf = createAlloca(argsBufTy, IGM.getPointerAlignment(),
- "keypath_args");
- emitInitOfGenericRequirementsBuffer(*this, requirements, argsBuf,
- [&](GenericRequirement reqt) -> llvm::Value * {
- return emitGenericRequirementFromSubstitutions(*this, sig,
- *IGM.getSwiftModule(),
- reqt, subs);
- });
- args = Builder.CreateBitCast(argsBuf.getAddress(), IGM.Int8PtrTy);
+ llvm::Value *argsBufSize;
+ llvm::Value *argsBufAlign;
+
+ if (!I->getSubstitutions().empty()) {
+ argsBufSize = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerSize().getValue() * requirements.size());
+ argsBufAlign = llvm::ConstantInt::get(IGM.SizeTy,
+ IGM.getPointerAlignment().getMaskValue());
+ } else {
+ argsBufSize = llvm::ConstantInt::get(IGM.SizeTy, 0);
+ argsBufAlign = llvm::ConstantInt::get(IGM.SizeTy, 0);
+ }
+
+ SmallVector<llvm::Value *, 4> operandOffsets;
+ for (unsigned i : indices(I->getAllOperands())) {
+ auto operand = I->getAllOperands()[i].get();
+ auto &ti = getTypeInfo(operand->getType());
+ auto ty = operand->getType();
+ auto alignMask = ti.getAlignmentMask(*this, ty);
+ if (i != 0) {
+ auto notAlignMask = Builder.CreateNot(alignMask);
+ argsBufSize = Builder.CreateAdd(argsBufSize, alignMask);
+ argsBufSize = Builder.CreateAnd(argsBufSize, notAlignMask);
+ }
+ operandOffsets.push_back(argsBufSize);
+ auto size = ti.getSize(*this, ty);
+ argsBufSize = Builder.CreateAdd(argsBufSize, size);
+ argsBufAlign = Builder.CreateOr(argsBufAlign, alignMask);
+ }
+
+ auto argsBufInst = Builder.CreateAlloca(IGM.Int8Ty, argsBufSize);
+ // TODO: over-alignment?
+ argsBufInst->setAlignment(16);
+
+ Address argsBuf(argsBufInst, Alignment(16));
+
+ if (!I->getSubstitutions().empty()) {
+ emitInitOfGenericRequirementsBuffer(*this, requirements, argsBuf,
+ [&](GenericRequirement reqt) -> llvm::Value * {
+ return emitGenericRequirementFromSubstitutions(*this, sig,
+ *IGM.getSwiftModule(),
+ reqt, subs);
+ });
+ }
+
+ for (unsigned i : indices(I->getAllOperands())) {
+ auto operand = I->getAllOperands()[i].get();
+ auto &ti = getTypeInfo(operand->getType());
+ auto ptr = Builder.CreateInBoundsGEP(argsBufInst, operandOffsets[i]);
+ auto addr = ti.getAddressForPointer(
+ Builder.CreateBitCast(ptr, ti.getStorageType()->getPointerTo()));
+ if (operand->getType().isAddress()) {
+ ti.initializeWithTake(*this, addr, getLoweredAddress(operand),
+ operand->getType());
+ } else {
+ Explosion operandValue = getLoweredExplosion(operand);
+ cast<LoadableTypeInfo>(ti).initialize(*this, operandValue, addr);
+ }
+ }
+ args = argsBufInst;
} else {
// No arguments necessary, so the argument ought to be ignored by any
// callbacks in the pattern.
diff --git a/lib/Parse/Lexer.cpp b/lib/Parse/Lexer.cpp
index 6e8edae..833ff62 100644
--- a/lib/Parse/Lexer.cpp
+++ b/lib/Parse/Lexer.cpp
@@ -2643,3 +2643,13 @@
return StringRef(StartOfLine, EndOfIndentation - StartOfLine);
}
+
+ArrayRef<Token> swift::
+slice_token_array(ArrayRef<Token> AllTokens, SourceLoc StartLoc,
+ SourceLoc EndLoc) {
+ assert(StartLoc.isValid() && EndLoc.isValid());
+ auto StartIt = token_lower_bound(AllTokens, StartLoc);
+ auto EndIt = token_lower_bound(AllTokens, EndLoc);
+ assert(StartIt->getLoc() == StartLoc && EndIt->getLoc() == EndLoc);
+ return AllTokens.slice(StartIt - AllTokens.begin(), EndIt - StartIt + 1);
+}
diff --git a/lib/ParseSIL/ParseSIL.cpp b/lib/ParseSIL/ParseSIL.cpp
index fae55b8..0e1526f 100644
--- a/lib/ParseSIL/ParseSIL.cpp
+++ b/lib/ParseSIL/ParseSIL.cpp
@@ -27,6 +27,7 @@
#include "swift/SIL/SILDebugScope.h"
#include "swift/SIL/SILModule.h"
#include "swift/SIL/SILUndef.h"
+#include "swift/SIL/TypeLowering.h"
#include "swift/Subsystems.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/SaveAndRestore.h"
@@ -139,7 +140,7 @@
SILModule &SILMod;
SILParserTUState &TUState;
SILFunction *F = nullptr;
- GenericEnvironment *GenericEnv = nullptr;
+ GenericEnvironment *ContextGenericEnv = nullptr;
FunctionOwnershipEvaluator OwnershipEvaluator;
private:
@@ -281,6 +282,12 @@
TypeLoc = P.Tok.getLoc();
return parseASTType(result);
}
+ bool parseASTType(CanType &result,
+ SourceLoc &TypeLoc,
+ GenericEnvironment *env) {
+ TypeLoc = P.Tok.getLoc();
+ return parseASTType(result, env);
+ }
bool parseSILOwnership(ValueOwnershipKind &OwnershipKind) {
// We parse here @ <identifier>.
if (!P.consumeIf(tok::at_sign)) {
@@ -294,8 +301,9 @@
diag::expected_sil_value_ownership_kind);
}
bool parseSILType(SILType &Result,
- GenericEnvironment *&genericEnv,
- bool IsFuncDecl = false);
+ GenericEnvironment *&parsedGenericEnv,
+ bool IsFuncDecl = false,
+ GenericEnvironment *parentGenericEnv = nullptr);
bool parseSILType(SILType &Result) {
GenericEnvironment *IgnoredEnv;
return parseSILType(Result, IgnoredEnv);
@@ -305,9 +313,10 @@
return parseSILType(Result);
}
bool parseSILType(SILType &Result, SourceLoc &TypeLoc,
- GenericEnvironment *&GenericEnv) {
+ GenericEnvironment *&parsedGenericEnv,
+ GenericEnvironment *parentGenericEnv = nullptr) {
TypeLoc = P.Tok.getLoc();
- return parseSILType(Result, GenericEnv);
+ return parseSILType(Result, parsedGenericEnv, false, parentGenericEnv);
}
/// @}
@@ -971,7 +980,7 @@
"Unexpected stage during parsing!");
if (GenericEnv == nullptr)
- GenericEnv = this->GenericEnv;
+ GenericEnv = ContextGenericEnv;
if (!DC)
DC = &P.SF;
@@ -1041,9 +1050,10 @@
/// '$' '*'? attribute-list (generic-params)? type
///
bool SILParser::parseSILType(SILType &Result,
- GenericEnvironment *&GenericEnv,
- bool IsFuncDecl){
- GenericEnv = nullptr;
+ GenericEnvironment *&ParsedGenericEnv,
+ bool IsFuncDecl,
+ GenericEnvironment *OuterGenericEnv) {
+ ParsedGenericEnv = nullptr;
if (P.parseToken(tok::sil_dollar, diag::expected_sil_type))
return true;
@@ -1108,12 +1118,12 @@
// Save the top-level function generic environment if there was one.
if (auto fnType = dyn_cast<FunctionTypeRepr>(TyR.get()))
if (auto env = fnType->getGenericEnvironment())
- GenericEnv = env;
+ ParsedGenericEnv = env;
// Apply attributes to the type.
TypeLoc Ty = P.applyAttributeToType(TyR.get(), attrs, specifier, specifierLoc);
- if (performTypeLocChecking(Ty, /*IsSILType=*/true, nullptr))
+ if (performTypeLocChecking(Ty, /*IsSILType=*/true, OuterGenericEnv))
return true;
Result = SILType::getPrimitiveType(Ty.getType()->getCanonicalType(),
@@ -2417,6 +2427,7 @@
GenericEnvironment *patternEnv = nullptr;
CanType rootType;
StringRef objcString;
+ SmallVector<SILType, 4> operandTypes;
{
Scope genericsScope(&P, ScopeKind::Generics);
generics = P.maybeParseGenericParams().getPtrOrNull();
@@ -2472,6 +2483,9 @@
VarDecl *idProperty = nullptr;
SILFunction *getter = nullptr;
SILFunction *setter = nullptr;
+ SILFunction *equals = nullptr;
+ SILFunction *hash = nullptr;
+ SmallVector<KeyPathPatternComponent::Index, 4> indexes;
while (true) {
Identifier subKind;
SourceLoc subKindLoc;
@@ -2505,6 +2519,88 @@
bool isSetter = subKind.str()[0] == 's';
if (parseSILFunctionRef(InstLoc, isSetter ? setter : getter))
return true;
+ } else if (subKind.str() == "indices") {
+ if (P.parseToken(tok::l_square,
+ diag::expected_tok_in_sil_instr, "["))
+ return true;
+
+ while (true) {
+ unsigned index;
+ CanType formalTy;
+ SILType loweredTy;
+ if (P.parseToken(tok::oper_prefix,
+ diag::expected_tok_in_sil_instr, "%")
+ || P.parseToken(tok::sil_dollar,
+ diag::expected_tok_in_sil_instr, "$"))
+ return true;
+
+ if (!P.Tok.is(tok::integer_literal)
+ || P.Tok.getText().getAsInteger(0, index))
+ return true;
+
+ P.consumeToken(tok::integer_literal);
+
+ SourceLoc formalTyLoc;
+ SourceLoc loweredTyLoc;
+ GenericEnvironment *ignoredParsedEnv;
+ if (P.parseToken(tok::colon,
+ diag::expected_tok_in_sil_instr, ":")
+ || P.parseToken(tok::sil_dollar,
+ diag::expected_tok_in_sil_instr, "$")
+ || parseASTType(formalTy, formalTyLoc, patternEnv)
+ || P.parseToken(tok::colon,
+ diag::expected_tok_in_sil_instr, ":")
+ || parseSILType(loweredTy, loweredTyLoc,
+ ignoredParsedEnv, patternEnv))
+ return true;
+
+ if (patternEnv)
+ loweredTy = SILType::getPrimitiveType(
+ patternEnv
+ ->mapTypeOutOfContext(loweredTy.getSwiftRValueType())
+ ->getCanonicalType(),
+ loweredTy.getCategory());
+
+ // Formal type must be hashable.
+ auto proto = P.Context.getProtocol(KnownProtocolKind::Hashable);
+ Type contextFormalTy = formalTy;
+ if (patternEnv)
+ contextFormalTy = patternEnv->mapTypeIntoContext(formalTy);
+ auto lookup = P.SF.getParentModule()->lookupConformance(
+ contextFormalTy, proto);
+ if (!lookup) {
+ P.diagnose(formalTyLoc,
+ diag::sil_keypath_index_not_hashable,
+ formalTy);
+ return true;
+ }
+ auto conformance = ProtocolConformanceRef(*lookup);
+
+ indexes.push_back({index, formalTy, loweredTy, conformance});
+
+ operandTypes.resize(index+1);
+ if (operandTypes[index] && operandTypes[index] != loweredTy) {
+ P.diagnose(loweredTyLoc,
+ diag::sil_keypath_index_operand_type_conflict,
+ index,
+ operandTypes[index].getSwiftRValueType(),
+ loweredTy.getSwiftRValueType());
+ return true;
+ }
+ operandTypes[index] = loweredTy;
+
+ if (P.consumeIf(tok::comma))
+ continue;
+ if (P.consumeIf(tok::r_square))
+ break;
+ return true;
+ }
+ } else if (subKind.str() == "indices_equals") {
+ if (parseSILFunctionRef(InstLoc, equals))
+ return true;
+ } else if (subKind.str() == "indices_hash") {
+ if (parseSILFunctionRef(InstLoc, hash))
+ return true;
} else {
P.diagnose(subKindLoc, diag::sil_keypath_unknown_component_kind,
subKind);
@@ -2542,15 +2638,24 @@
else
llvm_unreachable("no id?!");
- // TODO: indexes
+ auto indexesCopy = P.Context.AllocateCopy(indexes);
+
+ if (!indexes.empty() && (!equals || !hash)) {
+ P.diagnose(componentLoc,
+ diag::sil_keypath_computed_property_missing_part,
+ isSettable);
+ }
+
if (isSettable) {
components.push_back(
KeyPathPatternComponent::forComputedSettableProperty(
- id, getter, setter, {}, componentTy));
+ id, getter, setter,
+ indexesCopy, equals, hash, componentTy));
} else {
components.push_back(
KeyPathPatternComponent::forComputedGettableProperty(
- id, getter, {}, componentTy));
+ id, getter,
+ indexesCopy, equals, hash, componentTy));
}
} else if (componentKind.str() == "optional_wrap"
|| componentKind.str() == "optional_chain"
@@ -2595,7 +2700,7 @@
SmallVector<ParsedSubstitution, 4> parsedSubs;
SmallVector<Substitution, 4> subs;
- if (parseSubstitutions(parsedSubs, GenericEnv))
+ if (parseSubstitutions(parsedSubs, ContextGenericEnv))
return true;
if (!parsedSubs.empty()) {
@@ -2608,6 +2713,40 @@
return true;
}
+ SubstitutionMap subMap;
+ if (patternEnv && patternEnv->getGenericSignature())
+ subMap = patternEnv->getGenericSignature()->getSubstitutionMap(subs);
+
+ SmallVector<SILValue, 4> operands;
+
+ if (P.consumeIf(tok::l_paren)) {
+ Lowering::GenericContextScope scope(SILMod.Types,
+ patternEnv ? patternEnv->getGenericSignature()->getCanonicalSignature()
+ : nullptr);
+ while (true) {
+ SILValue v;
+
+ if (operands.size() >= operandTypes.size()
+ || !operandTypes[operands.size()]) {
+ P.diagnose(P.Tok, diag::sil_keypath_no_use_of_operand_in_pattern,
+ operands.size());
+ return true;
+ }
+
+ auto ty = operandTypes[operands.size()].subst(SILMod, subMap);
+
+ if (parseValueRef(v, ty, RegularLocation(P.Tok.getLoc()), B))
+ return true;
+ operands.push_back(v);
+
+ if (P.consumeIf(tok::comma))
+ continue;
+ if (P.consumeIf(tok::r_paren))
+ break;
+ return true;
+ }
+ }
+
if (parseSILDebugLocation(InstLoc, B))
return true;
@@ -2618,7 +2757,7 @@
rootType, components.back().getComponentType(),
components, objcString);
- ResultVal = B.createKeyPath(InstLoc, pattern, subs, Ty);
+ ResultVal = B.createKeyPath(InstLoc, pattern, subs, operands, Ty);
break;
}
@@ -4793,7 +4932,7 @@
if (P.consumeIf(tok::l_brace)) {
isDefinition = true;
- FunctionState.GenericEnv = GenericEnv;
+ FunctionState.ContextGenericEnv = GenericEnv;
FunctionState.F->setGenericEnvironment(GenericEnv);
if (GenericEnv && !SpecAttrs.empty()) {
@@ -5309,7 +5448,7 @@
auto conf = WitnessState.parseProtocolConformance(proto,
witnessEnv,
false/*localScope*/);
- WitnessState.GenericEnv = witnessEnv;
+ WitnessState.ContextGenericEnv = witnessEnv;
NormalProtocolConformance *theConformance = conf ?
dyn_cast<NormalProtocolConformance>(conf) : nullptr;
diff --git a/lib/SIL/LoopInfo.cpp b/lib/SIL/LoopInfo.cpp
index 416ffb6..1e2cc87 100644
--- a/lib/SIL/LoopInfo.cpp
+++ b/lib/SIL/LoopInfo.cpp
@@ -60,10 +60,11 @@
}
// We can't have a phi of two openexistential instructions of different UUID.
- SILInstruction *OEI = dyn_cast<OpenExistentialAddrInst>(I);
- if (OEI || (OEI = dyn_cast<OpenExistentialRefInst>(I)) ||
- (OEI = dyn_cast<OpenExistentialMetatypeInst>(I))) {
- for (auto *UI : OEI->getUses())
+ if (isa<OpenExistentialAddrInst>(I) || isa<OpenExistentialRefInst>(I) ||
+ isa<OpenExistentialMetatypeInst>(I) ||
+ isa<OpenExistentialValueInst>(I) || isa<OpenExistentialBoxInst>(I) ||
+ isa<OpenExistentialBoxValueInst>(I)) {
+ for (auto *UI : I->getUses())
if (!contains(UI->getUser()))
return false;
return true;
diff --git a/lib/SIL/SIL.cpp b/lib/SIL/SIL.cpp
index 5e5bbd2..090173b 100644
--- a/lib/SIL/SIL.cpp
+++ b/lib/SIL/SIL.cpp
@@ -117,16 +117,12 @@
if (C->isBehaviorConformance())
return (definition ? SILLinkage::Private : SILLinkage::PrivateExternal);
- ModuleDecl *conformanceModule = C->getDeclContext()->getParentModule();
-
// If the conformance was synthesized by the ClangImporter, give it
// shared linkage.
- auto typeDecl = C->getType()->getNominalOrBoundGenericNominal();
- auto typeUnit = typeDecl->getModuleScopeContext();
- if (isa<ClangModuleUnit>(typeUnit)
- && conformanceModule == typeUnit->getParentModule())
+ if (isa<ClangModuleUnit>(C->getDeclContext()->getModuleScopeContext()))
return SILLinkage::Shared;
+ auto typeDecl = C->getType()->getNominalOrBoundGenericNominal();
AccessLevel access = std::min(C->getProtocol()->getEffectiveAccess(),
typeDecl->getEffectiveAccess());
switch (access) {
diff --git a/lib/SIL/SILDeclRef.cpp b/lib/SIL/SILDeclRef.cpp
index 6fc3285..1acb152 100644
--- a/lib/SIL/SILDeclRef.cpp
+++ b/lib/SIL/SILDeclRef.cpp
@@ -15,6 +15,8 @@
#include "swift/AST/AnyFunctionRef.h"
#include "swift/AST/ASTContext.h"
#include "swift/AST/ASTMangler.h"
+#include "swift/AST/Initializer.h"
+#include "swift/AST/ParameterList.h"
#include "swift/ClangImporter/ClangImporter.h"
#include "swift/ClangImporter/ClangModule.h"
#include "swift/SIL/SILLinkage.h"
@@ -538,6 +540,19 @@
dc = closure->getLocalContext();
else {
auto *d = getDecl();
+
+ // Default argument generators are serialized if the function was
+ // type-checked in Swift 4 mode.
+ if (kind == SILDeclRef::Kind::DefaultArgGenerator) {
+ auto *afd = cast<AbstractFunctionDecl>(d);
+ switch (afd->getDefaultArgumentResilienceExpansion()) {
+ case ResilienceExpansion::Minimal:
+ return IsSerialized;
+ case ResilienceExpansion::Maximal:
+ return IsNotSerialized;
+ }
+ }
+
dc = getDecl()->getInnermostDeclContext();
// Enum element constructors are serialized if the enum is
diff --git a/lib/SIL/SILGlobalVariable.cpp b/lib/SIL/SILGlobalVariable.cpp
index 15a3383..bffc48f 100644
--- a/lib/SIL/SILGlobalVariable.cpp
+++ b/lib/SIL/SILGlobalVariable.cpp
@@ -76,12 +76,13 @@
return &StaticInitializerBlock.back();
}
-bool SILGlobalVariable::isValidStaticInitializerInst(const SILInstruction *I) {
+bool SILGlobalVariable::isValidStaticInitializerInst(const SILInstruction *I,
+ SILModule &M) {
switch (I->getKind()) {
case ValueKind::BuiltinInst: {
auto *bi = cast<BuiltinInst>(I);
- switch (bi->getBuiltinInfo().ID) {
- case BuiltinValueKind::FPTrunc:
+ switch (M.getBuiltinInfo(bi->getName()).ID) {
+ case BuiltinValueKind::PtrToInt:
if (isa<LiteralInst>(bi->getArguments()[0]))
return true;
break;
diff --git a/lib/SIL/SILInstruction.cpp b/lib/SIL/SILInstruction.cpp
index 72e37d2..90fc0f3 100644
--- a/lib/SIL/SILInstruction.cpp
+++ b/lib/SIL/SILInstruction.cpp
@@ -928,6 +928,7 @@
return true;
case ValueKind::UnconditionalCheckedCastAddrInst:
+ case ValueKind::UnconditionalCheckedCastValueInst:
return true;
case ValueKind::CheckedCastAddrBranchInst: {
diff --git a/lib/SIL/SILInstructions.cpp b/lib/SIL/SILInstructions.cpp
index 6c51e50..e3fa6c5 100644
--- a/lib/SIL/SILInstructions.cpp
+++ b/lib/SIL/SILInstructions.cpp
@@ -2045,13 +2045,19 @@
switch (component.getComputedPropertyId().getKind()) {
case KeyPathPatternComponent::ComputedPropertyId::DeclRef:
// Mark the vtable entry as used somehow?
- return;
+ break;
case KeyPathPatternComponent::ComputedPropertyId::Function:
forFunction(component.getComputedPropertyId().getFunction());
- return;
+ break;
case KeyPathPatternComponent::ComputedPropertyId::Property:
- return;
+ break;
}
+
+ if (auto equals = component.getComputedPropertyIndexEquals())
+ forFunction(equals);
+ if (auto hash = component.getComputedPropertyIndexHash())
+ forFunction(hash);
+ return;
}
}
@@ -2078,6 +2084,7 @@
return existing;
// Determine the number of operands.
+ int maxOperandNo = -1;
for (auto component : components) {
switch (component.getKind()) {
case KeyPathPatternComponent::Kind::StoredProperty:
@@ -2088,14 +2095,15 @@
case KeyPathPatternComponent::Kind::GettableProperty:
case KeyPathPatternComponent::Kind::SettableProperty:
- assert(component.getComputedPropertyIndices().empty()
- && "todo");
+ for (auto &index : component.getComputedPropertyIndices()) {
+ maxOperandNo = std::max(maxOperandNo, (int)index.Operand);
+ }
}
}
auto newPattern = KeyPathPattern::create(M, signature, rootType, valueType,
components, objcString,
- 0 /*todo: num operands*/);
+ maxOperandNo + 1);
M.KeyPathPatterns.InsertNode(newPattern, insertPos);
return newPattern;
}
@@ -2183,8 +2191,12 @@
break;
}
}
- assert(component.getComputedPropertyIndices().empty()
- && "todo");
+ for (auto &index : component.getComputedPropertyIndices()) {
+ ID.AddInteger(index.Operand);
+ ID.AddPointer(index.FormalType.getPointer());
+ ID.AddPointer(index.LoweredType.getOpaqueValue());
+ ID.AddPointer(index.Hashable.getOpaqueValue());
+ }
break;
}
}
@@ -2194,23 +2206,35 @@
KeyPathInst::create(SILDebugLocation Loc,
KeyPathPattern *Pattern,
SubstitutionList Subs,
+ ArrayRef<SILValue> Args,
SILType Ty,
SILFunction &F) {
- auto totalSize = totalSizeToAlloc<Substitution>(Subs.size());
+ assert(Args.size() == Pattern->getNumOperands()
+ && "number of key path args doesn't match pattern");
+
+ auto totalSize = totalSizeToAlloc<Substitution, Operand>
+ (Subs.size(), Args.size());
void *mem = F.getModule().allocateInst(totalSize, alignof(Substitution));
- return ::new (mem) KeyPathInst(Loc, Pattern, Subs, Ty);
+ return ::new (mem) KeyPathInst(Loc, Pattern, Subs, Args, Ty);
}
KeyPathInst::KeyPathInst(SILDebugLocation Loc,
KeyPathPattern *Pattern,
SubstitutionList Subs,
+ ArrayRef<SILValue> Args,
SILType Ty)
: SILInstruction(ValueKind::KeyPathInst, Loc, Ty),
- Pattern(Pattern), NumSubstitutions(Subs.size())
+ Pattern(Pattern), NumSubstitutions(Subs.size()),
+ NumOperands(Pattern->getNumOperands())
{
auto *subsBuf = getTrailingObjects<Substitution>();
std::uninitialized_copy(Subs.begin(), Subs.end(), subsBuf);
+ auto *operandsBuf = getTrailingObjects<Operand>();
+ for (unsigned i = 0; i < Args.size(); ++i) {
+ ::new ((void*)&operandsBuf[i]) Operand(this, Args[i]);
+ }
+
// Increment the use of any functions referenced from the keypath pattern.
for (auto component : Pattern->getComponents()) {
component.incrementRefCounts();
@@ -2224,8 +2248,7 @@
MutableArrayRef<Operand>
KeyPathInst::getAllOperands() {
- // TODO: subscript indexes
- return {};
+ return {getTrailingObjects<Operand>(), NumOperands};
}
KeyPathInst::~KeyPathInst() {
@@ -2236,7 +2259,9 @@
for (auto component : Pattern->getComponents()) {
component.decrementRefCounts();
}
- // TODO: destroy operands
+ // Destroy operands.
+ for (auto &operand : getAllOperands())
+ operand.~Operand();
}
KeyPathPattern *KeyPathInst::getPattern() const {
diff --git a/lib/SIL/SILOwnershipVerifier.cpp b/lib/SIL/SILOwnershipVerifier.cpp
index 914d589..7a01698 100644
--- a/lib/SIL/SILOwnershipVerifier.cpp
+++ b/lib/SIL/SILOwnershipVerifier.cpp
@@ -449,8 +449,6 @@
NO_OPERAND_INST(StrongRetainUnowned)
NO_OPERAND_INST(UnownedRetain)
NO_OPERAND_INST(Unreachable)
-// TODO: Some key path components will have operands
-NO_OPERAND_INST(KeyPath)
#undef NO_OPERAND_INST
/// Instructions whose arguments are always compatible with one convention.
@@ -1144,6 +1142,18 @@
return {true, UseLifetimeConstraint::MustBeLive};
}
+OwnershipUseCheckerResult
+OwnershipCompatibilityUseChecker::visitKeyPathInst(KeyPathInst *I) {
+ // KeyPath moves the value in memory out of address operands, but the
+ // ownership checker doesn't reason about that yet.
+ if (isAddressOrTrivialType()) {
+ return {compatibleWithOwnership(ValueOwnershipKind::Trivial),
+ UseLifetimeConstraint::MustBeLive};
+ }
+ return {compatibleWithOwnership(ValueOwnershipKind::Owned),
+ UseLifetimeConstraint::MustBeInvalidated};
+}
+
//===----------------------------------------------------------------------===//
// Builtin Use Checker
//===----------------------------------------------------------------------===//
diff --git a/lib/SIL/SILPrinter.cpp b/lib/SIL/SILPrinter.cpp
index 3ff1f37..586da8c 100644
--- a/lib/SIL/SILPrinter.cpp
+++ b/lib/SIL/SILPrinter.cpp
@@ -1907,8 +1907,26 @@
*this << " : "
<< component.getComputedPropertySetter()->getLoweredType();
}
- assert(component.getComputedPropertyIndices().empty()
- && "todo");
+
+ if (!component.getComputedPropertyIndices().empty()) {
+ *this << ", indices [";
+ interleave(component.getComputedPropertyIndices(),
+ [&](const KeyPathPatternComponent::Index &i) {
+ *this << "%$" << i.Operand << " : $"
+ << i.FormalType << " : "
+ << i.LoweredType;
+ }, [&]{
+ *this << ", ";
+ });
+ *this << "], indices_equals ";
+ component.getComputedPropertyIndexEquals()->printName(PrintState.OS);
+ *this << " : "
+ << component.getComputedPropertyIndexEquals()->getLoweredType();
+ *this << ", indices_hash ";
+ component.getComputedPropertyIndexHash()->printName(PrintState.OS);
+ *this << " : "
+ << component.getComputedPropertyIndexHash()->getLoweredType();
+ }
break;
}
case KeyPathPatternComponent::Kind::OptionalWrap:
@@ -1938,6 +1956,18 @@
*this << ' ';
printSubstitutions(KPI->getSubstitutions());
}
+ if (!KPI->getAllOperands().empty()) {
+ *this << " (";
+
+ interleave(KPI->getAllOperands(),
+ [&](const Operand &operand) {
+ *this << Ctx.getID(operand.get());
+ }, [&]{
+ *this << ", ";
+ });
+
+ *this << ")";
+ }
}
};
} // end anonymous namespace
diff --git a/lib/SIL/SILVerifier.cpp b/lib/SIL/SILVerifier.cpp
index 7fd2e1f..492f941 100644
--- a/lib/SIL/SILVerifier.cpp
+++ b/lib/SIL/SILVerifier.cpp
@@ -3748,8 +3748,7 @@
case KeyPathPatternComponent::Kind::GettableProperty:
case KeyPathPatternComponent::Kind::SettableProperty: {
- require(component.getComputedPropertyIndices().empty(),
- "subscripts not implemented");
+ bool hasIndices = !component.getComputedPropertyIndices().empty();
// Getter should be <Sig...> @convention(thin) (@in Base) -> @out Result
{
@@ -3760,14 +3759,25 @@
SILFunctionTypeRepresentation::Thin,
"getter should be a thin function");
- // TODO: indexes
- require(substGetterType->getNumParameters() == 1,
+ require(substGetterType->getNumParameters() == 1 + hasIndices,
"getter should have one parameter");
- auto baseParam = substGetterType->getSelfParameter();
- require(baseParam.getConvention() == ParameterConvention::Indirect_In,
+ auto baseParam = substGetterType->getParameters()[0];
+ require(baseParam.getConvention() ==
+ ParameterConvention::Indirect_In,
"getter base parameter should be @in");
require(baseParam.getType() == loweredBaseTy.getSwiftRValueType(),
"getter base parameter should match base of component");
+
+ if (hasIndices) {
+ auto indicesParam = substGetterType->getParameters()[1];
+ require(indicesParam.getConvention()
+ == ParameterConvention::Direct_Unowned,
+ "indices pointer should be trivial");
+ require(indicesParam.getType()->getAnyNominal()
+ == C.getUnsafeRawPointerDecl(),
+ "indices pointer should be an UnsafeRawPointer");
+ }
+
require(substGetterType->getNumResults() == 1,
"getter should have one result");
auto result = substGetterType->getResults()[0];
@@ -3788,22 +3798,33 @@
require(substSetterType->getRepresentation() ==
SILFunctionTypeRepresentation::Thin,
- "getter should be a thin function");
+ "setter should be a thin function");
- // TODO: indexes
- require(substSetterType->getNumParameters() == 2,
+ require(substSetterType->getNumParameters() == 2 + hasIndices,
"setter should have two parameters");
- auto baseParam = substSetterType->getSelfParameter();
+
+ auto newValueParam = substSetterType->getParameters()[0];
+ require(newValueParam.getConvention() ==
+ ParameterConvention::Indirect_In,
+ "setter value parameter should be @in");
+
+ auto baseParam = substSetterType->getParameters()[1];
require(baseParam.getConvention() ==
ParameterConvention::Indirect_In
|| baseParam.getConvention() ==
ParameterConvention::Indirect_Inout,
"setter base parameter should be @in or @inout");
- auto newValueParam = substSetterType->getParameters()[0];
- require(newValueParam.getConvention() ==
- ParameterConvention::Indirect_In,
- "setter value parameter should be @in");
+ if (hasIndices) {
+ auto indicesParam = substSetterType->getParameters()[2];
+ require(indicesParam.getConvention()
+ == ParameterConvention::Direct_Unowned,
+ "indices pointer should be trivial");
+ require(indicesParam.getType()->getAnyNominal()
+ == C.getUnsafeRawPointerDecl(),
+ "indices pointer should be an UnsafeRawPointer");
+ }
+
require(newValueParam.getType() ==
loweredComponentTy.getSwiftRValueType(),
"setter value should match the maximal abstraction of the "
@@ -3812,6 +3833,86 @@
require(substSetterType->getNumResults() == 0,
"setter should have no results");
}
+
+ for (auto &index : component.getComputedPropertyIndices()) {
+ auto opIndex = index.Operand;
+ auto contextType =
+ index.LoweredType.subst(F.getModule(), patternSubs);
+ requireSameType(contextType,
+ KPI->getAllOperands()[opIndex].get()->getType(),
+ "operand must match type required by pattern");
+ require(isLoweringOf(index.LoweredType, index.FormalType),
+ "pattern index formal type doesn't match lowered type");
+ }
+
+ if (!component.getComputedPropertyIndices().empty()) {
+ // Equals should be
+ // <Sig...> @convention(thin) (RawPointer, RawPointer) -> Bool
+ {
+ auto equals = component.getComputedPropertyIndexEquals();
+ require(equals, "key path pattern with indexes must have equals "
+ "operator");
+
+ auto substEqualsType = equals->getLoweredFunctionType()
+ ->substGenericArgs(F.getModule(), KPI->getSubstitutions());
+
+ require(substEqualsType->getParameters().size() == 2,
+ "must have two arguments");
+ for (unsigned i = 0; i < 2; ++i) {
+ auto param = substEqualsType->getParameters()[i];
+ require(param.getConvention()
+ == ParameterConvention::Direct_Unowned,
+ "indices pointer should be trivial");
+ require(param.getType()->getAnyNominal()
+ == C.getUnsafeRawPointerDecl(),
+ "indices pointer should be an UnsafeRawPointer");
+ }
+
+ require(substEqualsType->getResults().size() == 1,
+ "must have one result");
+
+ require(substEqualsType->getResults()[0].getConvention()
+ == ResultConvention::Unowned,
+ "result should be unowned");
+ require(substEqualsType->getResults()[0].getType()->getAnyNominal()
+ == C.getBoolDecl(),
+ "result should be Bool");
+ }
+ {
+ // Hash should be
+ // <Sig...> @convention(thin) (RawPointer) -> Int
+ auto hash = component.getComputedPropertyIndexHash();
+ require(hash, "key path pattern with indexes must have hash "
+ "operator");
+
+ auto substHashType = hash->getLoweredFunctionType()
+ ->substGenericArgs(F.getModule(), KPI->getSubstitutions());
+
+ require(substHashType->getParameters().size() == 1,
+ "must have two arguments");
+ auto param = substHashType->getParameters()[0];
+ require(param.getConvention()
+ == ParameterConvention::Direct_Unowned,
+ "indices pointer should be trivial");
+ require(param.getType()->getAnyNominal()
+ == C.getUnsafeRawPointerDecl(),
+ "indices pointer should be an UnsafeRawPointer");
+
+ require(substHashType->getResults().size() == 1,
+ "must have one result");
+
+ require(substHashType->getResults()[0].getConvention()
+ == ResultConvention::Unowned,
+ "result should be unowned");
+ require(substHashType->getResults()[0].getType()->getAnyNominal()
+ == C.getIntDecl(),
+ "result should be Int");
+ }
+ } else {
+ require(!component.getComputedPropertyIndexEquals()
+ && !component.getComputedPropertyIndexHash(),
+ "component without indexes must not have equals/hash");
+ }
break;
}
@@ -4393,7 +4494,8 @@
// Verify the static initializer.
for (const SILInstruction &I : StaticInitializerBlock) {
- assert(isValidStaticInitializerInst(&I) && "illegal static initializer");
+ assert(isValidStaticInitializerInst(&I, getModule()) &&
+ "illegal static initializer");
if (&I == &StaticInitializerBlock.back()) {
assert(I.use_empty() && "Init value must not have another use");
} else {
diff --git a/lib/SIL/SILWitnessTable.cpp b/lib/SIL/SILWitnessTable.cpp
index da7a6a2..8fe13cd 100644
--- a/lib/SIL/SILWitnessTable.cpp
+++ b/lib/SIL/SILWitnessTable.cpp
@@ -23,6 +23,7 @@
#include "swift/AST/ASTMangler.h"
#include "swift/AST/Module.h"
#include "swift/AST/ProtocolConformance.h"
+#include "swift/ClangImporter/ClangModule.h"
#include "swift/SIL/SILModule.h"
#include "llvm/ADT/SmallString.h"
@@ -160,6 +161,11 @@
bool SILWitnessTable::conformanceIsSerialized(ProtocolConformance *conformance,
ResilienceStrategy strategy,
bool silSerializeWitnessTables) {
+ // Serialize witness tables for conformances synthesized by
+ // the ClangImporter.
+ if (isa<ClangModuleUnit>(conformance->getDeclContext()->getModuleScopeContext()))
+ return true;
+
auto *nominal = conformance->getType()->getAnyNominal();
// Only serialize if the witness table is sufficiently static, and resilience
// is explicitly enabled for this compilation or if we serialize all eligible
diff --git a/lib/SIL/TypeLowering.cpp b/lib/SIL/TypeLowering.cpp
index a698928..b9207d0 100644
--- a/lib/SIL/TypeLowering.cpp
+++ b/lib/SIL/TypeLowering.cpp
@@ -1116,7 +1116,7 @@
class OpaqueValueTypeLowering : public LeafLoadableTypeLowering {
public:
OpaqueValueTypeLowering(SILType type)
- : LeafLoadableTypeLowering(type, IsAddressOnly, IsReferenceCounted) {}
+ : LeafLoadableTypeLowering(type, IsAddressOnly, IsNotReferenceCounted) {}
void emitCopyInto(SILBuilder &B, SILLocation loc,
SILValue src, SILValue dest, IsTake_t isTake,
diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp
index fd15d36..5dfc2e1 100644
--- a/lib/SILGen/SILGen.cpp
+++ b/lib/SILGen/SILGen.cpp
@@ -649,11 +649,10 @@
void SILGenModule::emitAbstractFuncDecl(AbstractFunctionDecl *AFD) {
// Emit any default argument generators.
- {
- auto paramLists = AFD->getParameterLists();
- if (AFD->getDeclContext()->isTypeContext())
- paramLists = paramLists.slice(1);
- emitDefaultArgGenerators(AFD, paramLists);
+ if (!isa<DestructorDecl>(AFD)) {
+ unsigned paramListIndex = AFD->getDeclContext()->isTypeContext() ? 1 : 0;
+ auto *paramList = AFD->getParameterLists()[paramListIndex];
+ emitDefaultArgGenerators(AFD, paramList);
}
// If this is a function at global scope, it may close over a global variable.
@@ -1015,15 +1014,13 @@
}
void SILGenModule::emitDefaultArgGenerators(SILDeclRef::Loc decl,
- ArrayRef<ParameterList*> paramLists) {
+ ParameterList *paramList) {
unsigned index = 0;
- for (auto paramList : paramLists) {
- for (auto param : *paramList) {
- if (auto defaultArg = param->getDefaultValue())
- emitDefaultArgGenerator(SILDeclRef::getDefaultArgGenerator(decl, index),
- defaultArg, param->getDefaultArgumentKind());
- ++index;
- }
+ for (auto param : *paramList) {
+ if (auto defaultArg = param->getDefaultValue())
+ emitDefaultArgGenerator(SILDeclRef::getDefaultArgGenerator(decl, index),
+ defaultArg, param->getDefaultArgumentKind());
+ ++index;
}
}
diff --git a/lib/SILGen/SILGen.h b/lib/SILGen/SILGen.h
index ed0f26f..5f41b31 100644
--- a/lib/SILGen/SILGen.h
+++ b/lib/SILGen/SILGen.h
@@ -271,9 +271,9 @@
/// Emits the stored property initializer for the given pattern.
void emitStoredPropertyInitialization(PatternBindingDecl *pd, unsigned i);
- /// Emits the default argument generator for the given function.
+ /// Emits default argument generators for the given parameter list.
void emitDefaultArgGenerators(SILDeclRef::Loc decl,
- ArrayRef<ParameterList*> paramLists);
+ ParameterList *paramList);
/// Emits the curry thunk between two uncurry levels of a function.
void emitCurryThunk(SILDeclRef thunk);
diff --git a/lib/SILGen/SILGenConvert.cpp b/lib/SILGen/SILGenConvert.cpp
index c370c88..38d9033 100644
--- a/lib/SILGen/SILGenConvert.cpp
+++ b/lib/SILGen/SILGenConvert.cpp
@@ -577,9 +577,9 @@
FormalEvaluationScope writebackScope(*this);
ManagedValue nsError =
- emitRValueForPropertyLoad(
+ emitRValueForStorageLoad(
loc, nativeError, concreteFormalType,
- /*super*/ false, nsErrorVar, nsErrorVarSubstitutions,
+ /*super*/ false, nsErrorVar, RValue(), nsErrorVarSubstitutions,
AccessSemantics::Ordinary, nsErrorType, SGFContext())
.getAsSingleValue(*this, loc);
diff --git a/lib/SILGen/SILGenExpr.cpp b/lib/SILGen/SILGenExpr.cpp
index 3be283f..6c8723f 100644
--- a/lib/SILGen/SILGenExpr.cpp
+++ b/lib/SILGen/SILGenExpr.cpp
@@ -31,6 +31,7 @@
#include "swift/AST/ForeignErrorConvention.h"
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/ASTMangler.h"
+#include "swift/AST/ProtocolConformance.h"
#include "swift/AST/SubstitutionMap.h"
#include "swift/AST/Types.h"
#include "swift/Basic/SourceManager.h"
@@ -1050,9 +1051,13 @@
}
static AbstractionPattern
-getOrigFormalRValueType(SILGenFunction &SGF, VarDecl *field) {
- auto origType = SGF.SGM.Types.getAbstractionPattern(field);
- return origType.getReferenceStorageReferentType();
+getFormalStorageAbstractionPattern(SILGenFunction &SGF, AbstractStorageDecl *field) {
+ if (auto var = dyn_cast<VarDecl>(field)) {
+ auto origType = SGF.SGM.Types.getAbstractionPattern(var);
+ return origType.getReferenceStorageReferentType();
+ }
+ auto sub = cast<SubscriptDecl>(field);
+ return SGF.SGM.Types.getAbstractionPattern(sub);
}
static SILDeclRef getRValueAccessorDeclRef(SILGenFunction &SGF,
@@ -1153,31 +1158,33 @@
/// Produce a singular RValue for a load from the specified property. This is
/// designed to work with RValue ManagedValue bases that are either +0 or +1.
-RValue SILGenFunction::emitRValueForPropertyLoad(
+RValue SILGenFunction::emitRValueForStorageLoad(
SILLocation loc, ManagedValue base, CanType baseFormalType,
- bool isSuper, VarDecl *field, SubstitutionList substitutions,
+ bool isSuper, AbstractStorageDecl *storage, RValue indexes,
+ SubstitutionList substitutions,
AccessSemantics semantics, Type propTy, SGFContext C,
bool isBaseGuaranteed) {
AccessStrategy strategy =
- field->getAccessStrategy(semantics, AccessKind::Read);
+ storage->getAccessStrategy(semantics, AccessKind::Read);
// If we should call an accessor of some kind, do so.
if (strategy != AccessStrategy::Storage) {
- auto accessor = getRValueAccessorDeclRef(*this, field, strategy);
+ auto accessor = getRValueAccessorDeclRef(*this, storage, strategy);
ArgumentSource baseRV = prepareAccessorBaseArg(loc, base,
baseFormalType,
accessor);
AbstractionPattern origFormalType =
- getOrigFormalRValueType(*this, field);
+ getFormalStorageAbstractionPattern(*this, storage);
auto substFormalType = propTy->getCanonicalType();
- return emitRValueWithAccessor(*this, loc, field, substitutions,
- std::move(baseRV), RValue(),
+ return emitRValueWithAccessor(*this, loc, storage, substitutions,
+ std::move(baseRV), std::move(indexes),
isSuper, strategy, accessor,
origFormalType, substFormalType, C);
}
-
+ assert(isa<VarDecl>(storage) && "only properties should have storage");
+ auto field = cast<VarDecl>(storage);
assert(field->hasStorage() &&
"Cannot directly access value without storage");
@@ -1211,7 +1218,7 @@
auto &lowering = getTypeLowering(substFormalType);
// Check for an abstraction difference.
- AbstractionPattern origFormalType = getOrigFormalRValueType(*this, field);
+ AbstractionPattern origFormalType = getFormalStorageAbstractionPattern(*this, field);
bool hasAbstractionChange = false;
auto &abstractedTL = getTypeLowering(origFormalType, substFormalType);
if (!origFormalType.isExactType(substFormalType)) {
@@ -2392,12 +2399,12 @@
assert(baseFormalType->isMaterializable());
RValue result =
- SGF.emitRValueForPropertyLoad(Expr, base, baseFormalType,
- Expr->isSuper(),
- Field,
- Expr->getMember().getSubstitutions(),
- Expr->getAccessSemantics(),
- Expr->getType(), Context);
+ SGF.emitRValueForStorageLoad(Expr, base, baseFormalType,
+ Expr->isSuper(),
+ Field, {},
+ Expr->getMember().getSubstitutions(),
+ Expr->getAccessSemantics(),
+ Expr->getType(), Context);
return result;
}
@@ -2434,13 +2441,13 @@
// And then emit our property using whether or not base is at +0 to
// discriminate whether or not the base was guaranteed.
RValue result =
- SGF.emitRValueForPropertyLoad(Expr, base, baseFormalType,
- Expr->isSuper(),
- Field,
- Expr->getMember().getSubstitutions(),
- Expr->getAccessSemantics(),
- Expr->getType(), Context,
- base.isPlusZeroRValueOrTrivial());
+ SGF.emitRValueForStorageLoad(Expr, base, baseFormalType,
+ Expr->isSuper(),
+ Field, {},
+ Expr->getMember().getSubstitutions(),
+ Expr->getAccessSemantics(),
+ Expr->getType(), Context,
+ base.isPlusZeroRValueOrTrivial());
return std::move(result);
}
};
@@ -2887,17 +2894,19 @@
static ManagedValue
emitKeyPathRValueBase(SILGenFunction &subSGF,
- VarDecl *property,
- SILLocation loc,
- SILValue paramArg,
- CanType &baseType) {
+ AbstractStorageDecl *storage,
+ SILLocation loc,
+ SILValue paramArg,
+ CanType &baseType,
+ SubstitutionList &subs,
+ SmallVectorImpl<Substitution> &subsBuf) {
auto paramOrigValue = subSGF.emitManagedRValueWithCleanup(paramArg);
auto paramSubstValue = subSGF.emitOrigToSubstValue(loc, paramOrigValue,
AbstractionPattern::getOpaque(),
baseType);
// Upcast a class instance to the property's declared type if necessary.
- if (auto propertyClass = dyn_cast<ClassDecl>(property->getDeclContext())) {
+ if (auto propertyClass = dyn_cast<ClassDecl>(storage->getDeclContext())) {
if (baseType->getClassOrBoundGenericClass() != propertyClass) {
baseType = baseType->getSuperclassForDecl(propertyClass)
->getCanonicalType();
@@ -2907,8 +2916,10 @@
}
// …or pop open an existential container.
else if (baseType->isAnyExistentialType()) {
- ArchetypeType *opened;
- baseType = baseType->openAnyExistentialType(opened)->getCanonicalType();
+ auto opened = subs[0].getReplacement()->castTo<ArchetypeType>();
+ assert(opened->isOpenedExistential());
+
+ baseType = opened->getCanonicalType();
auto openedOpaqueValue = subSGF.emitOpenExistential(loc, paramSubstValue,
opened, subSGF.SGM.getLoweredType(baseType),
AccessKind::Read);
@@ -2923,13 +2934,57 @@
return paramSubstValue;
}
+/// Helper function to load the captured indexes out of a key path component
+/// in order to invoke the accessors on that key path. A component with captured
+/// indexes passes down a pointer to those captures to the accessor thunks,
+/// which we can copy out of to produce values we can pass to the real
+/// accessor functions.
+static RValue loadIndexValuesForKeyPathComponent(SILGenFunction &SGF,
+ SILLocation loc,
+ ArrayRef<KeyPathPatternComponent::Index> indexes,
+ SILValue pointer) {
+ // If no indexes, do nothing.
+ if (indexes.empty())
+ return RValue();
+
+ SmallVector<TupleTypeElt, 2> indexElts;
+ for (auto &elt : indexes) {
+ indexElts.push_back(SGF.F.mapTypeIntoContext(elt.FormalType));
+ }
+
+ auto indexTupleTy = TupleType::get(indexElts, SGF.getASTContext())
+ ->getCanonicalType();
+ RValue indexValue(indexTupleTy);
+
+ auto indexLoweredTy = SGF.getLoweredType(indexTupleTy);
+ auto addr = SGF.B.createPointerToAddress(loc, pointer,
+ indexLoweredTy.getAddressType(),
+ /*isStrict*/ false);
+
+ for (unsigned i : indices(indexes)) {
+ SILValue eltAddr = addr;
+ if (indexes.size() > 1) {
+ eltAddr = SGF.B.createTupleElementAddr(loc, eltAddr, i);
+ }
+ auto ty = SGF.F.mapTypeIntoContext(indexes[i].LoweredType);
+ auto value = SGF.emitLoad(loc, eltAddr,
+ SGF.getTypeLowering(ty),
+ SGFContext(), IsNotTake);
+ indexValue.addElement(SGF, value, indexes[i].FormalType, loc);
+ }
+
+ return indexValue;
+}
+
static SILFunction *getOrCreateKeyPathGetter(SILGenFunction &SGF,
- SILLocation loc,
- VarDecl *property,
- AccessStrategy strategy,
- GenericEnvironment *genericEnv,
- CanType baseType,
- CanType propertyType) {
+ SILLocation loc,
+ AbstractStorageDecl *property,
+ SubstitutionList subs,
+ AccessStrategy strategy,
+ GenericEnvironment *genericEnv,
+ ArrayRef<KeyPathPatternComponent::Index> indexes,
+ CanType baseType,
+ CanType propertyType) {
auto genericSig = genericEnv
? genericEnv->getGenericSignature()->getCanonicalSignature()
: nullptr;
@@ -2944,8 +2999,15 @@
propertyType);
}
- SILParameterInfo param(loweredBaseTy.getSwiftRValueType(),
- ParameterConvention::Indirect_In);
+ SmallVector<SILParameterInfo, 2> params;
+ params.push_back({loweredBaseTy.getSwiftRValueType(),
+ ParameterConvention::Indirect_In});
+ auto &C = SGF.getASTContext();
+ if (!indexes.empty())
+ params.push_back({C.getUnsafeRawPointerDecl()->getDeclaredType()
+ ->getCanonicalType(),
+ ParameterConvention::Direct_Unowned});
+
SILResultInfo result(loweredPropTy.getSwiftRValueType(),
ResultConvention::Indirect);
@@ -2953,11 +3015,18 @@
SILFunctionType::ExtInfo(SILFunctionType::Representation::Thin,
/*pseudogeneric*/ false),
ParameterConvention::Direct_Unowned,
- param, result, None, SGF.getASTContext());
+ params, result, None, SGF.getASTContext());
// Find the function and see if we already created it.
+ SmallVector<CanType, 2> interfaceSubs;
+ for (auto &sub : subs) {
+ interfaceSubs.push_back(
+ GenericEnvironment::mapTypeOutOfContext(genericEnv, sub.getReplacement())
+ ->getCanonicalType());
+ }
auto name = Mangle::ASTMangler()
- .mangleKeyPathGetterThunkHelper(property, genericSig, baseType);
+ .mangleKeyPathGetterThunkHelper(property, genericSig, baseType,
+ interfaceSubs);
auto thunk = SGF.SGM.M.getOrCreateSharedFunction(loc, name,
signature,
IsBare,
@@ -2980,28 +3049,35 @@
SILGenFunction subSGF(SGM, *thunk);
auto entry = thunk->begin();
auto resultArgTy = result.getSILStorageType();
- auto paramArgTy = param.getSILStorageType();
+ auto baseArgTy = params[0].getSILStorageType();
if (genericEnv) {
resultArgTy = genericEnv->mapTypeIntoContext(subSGF.SGM.M, resultArgTy);
- paramArgTy = genericEnv->mapTypeIntoContext(subSGF.SGM.M, paramArgTy);
+ baseArgTy = genericEnv->mapTypeIntoContext(subSGF.SGM.M, baseArgTy);
}
auto resultArg = entry->createFunctionArgument(resultArgTy);
- auto paramArg = entry->createFunctionArgument(paramArgTy);
+ auto baseArg = entry->createFunctionArgument(baseArgTy);
+ SILValue indexPtrArg;
+ if (!indexes.empty()) {
+ auto indexArgTy = params[1].getSILStorageType();
+ indexPtrArg = entry->createFunctionArgument(indexArgTy);
+ }
Scope scope(subSGF, loc);
+ SmallVector<Substitution, 2> subsBuf;
+
auto paramSubstValue = emitKeyPathRValueBase(subSGF, property,
- loc, paramArg,
- baseType);
-
- auto subs = baseType->getContextSubstitutionMap(subSGF.SGM.M.getSwiftModule(),
- property->getInnermostDeclContext()->getInnermostTypeContext());
- SmallVector<Substitution, 4> subsList;
- if (subs.getGenericSignature())
- subs.getGenericSignature()->getSubstitutions(subs, subsList);
- auto resultSubst = subSGF.emitRValueForPropertyLoad(loc, paramSubstValue,
- baseType, /*super*/false, property,
- subsList, AccessSemantics::Ordinary,
+ loc, baseArg,
+ baseType, subs, subsBuf);
+
+ RValue indexValue = loadIndexValuesForKeyPathComponent(subSGF, loc,
+ indexes,
+ indexPtrArg);
+
+ auto resultSubst = subSGF.emitRValueForStorageLoad(loc, paramSubstValue,
+ baseType, /*super*/false,
+ property, std::move(indexValue),
+ subs, AccessSemantics::Ordinary,
propertyType, SGFContext())
.getAsSingleValue(subSGF, loc);
if (resultSubst.getType().getAddressType() != resultArg->getType())
@@ -3018,12 +3094,14 @@
}
SILFunction *getOrCreateKeyPathSetter(SILGenFunction &SGF,
- SILLocation loc,
- VarDecl *property,
- AccessStrategy strategy,
- GenericEnvironment *genericEnv,
- CanType baseType,
- CanType propertyType) {
+ SILLocation loc,
+ AbstractStorageDecl *property,
+ SubstitutionList subs,
+ AccessStrategy strategy,
+ GenericEnvironment *genericEnv,
+ ArrayRef<KeyPathPatternComponent::Index> indexes,
+ CanType baseType,
+ CanType propertyType) {
auto genericSig = genericEnv
? genericEnv->getGenericSignature()->getCanonicalSignature()
: nullptr;
@@ -3038,27 +3116,42 @@
propertyType);
}
- SILParameterInfo propParam(loweredPropTy.getSwiftRValueType(),
- ParameterConvention::Indirect_In);
+ auto &C = SGF.getASTContext();
- SILParameterInfo baseParam(loweredBaseTy.getSwiftRValueType(),
- property->isSetterMutating()
- ? ParameterConvention::Indirect_Inout
- : ParameterConvention::Indirect_In);
+ SmallVector<SILParameterInfo, 3> params;
+ // property value
+ params.push_back({loweredPropTy.getSwiftRValueType(),
+ ParameterConvention::Indirect_In});
+ // base
+ params.push_back({loweredBaseTy.getSwiftRValueType(),
+ property->isSetterMutating()
+ ? ParameterConvention::Indirect_Inout
+ : ParameterConvention::Indirect_In});
+ // indexes
+ if (!indexes.empty())
+ params.push_back({C.getUnsafeRawPointerDecl()->getDeclaredType()
+ ->getCanonicalType(),
+ ParameterConvention::Direct_Unowned});
auto signature = SILFunctionType::get(genericSig,
SILFunctionType::ExtInfo(SILFunctionType::Representation::Thin,
/*pseudogeneric*/ false),
ParameterConvention::Direct_Unowned,
- {propParam, baseParam}, {}, None, SGF.getASTContext());
+ params, {}, None, SGF.getASTContext());
// Mangle the name of the thunk to see if we already created it.
SmallString<64> nameBuf;
- // Find the function and see if we already created it.
+ SmallVector<CanType, 2> interfaceSubs;
+ for (auto &sub : subs) {
+ interfaceSubs.push_back(
+ GenericEnvironment::mapTypeOutOfContext(genericEnv, sub.getReplacement())
+ ->getCanonicalType());
+ }
auto name = Mangle::ASTMangler().mangleKeyPathSetterThunkHelper(property,
- genericSig,
- baseType);
+ genericSig,
+ baseType,
+ interfaceSubs);
auto thunk = SGF.SGM.M.getOrCreateSharedFunction(loc, name,
signature,
IsBare,
@@ -3080,16 +3173,26 @@
SILGenFunction subSGF(SGM, *thunk);
auto entry = thunk->begin();
- auto valueArgTy = propParam.getSILStorageType();
- auto baseArgTy = baseParam.getSILStorageType();
+ auto valueArgTy = params[0].getSILStorageType();
+ auto baseArgTy = params[1].getSILStorageType();
if (genericEnv) {
valueArgTy = genericEnv->mapTypeIntoContext(subSGF.SGM.M, valueArgTy);
baseArgTy = genericEnv->mapTypeIntoContext(subSGF.SGM.M, baseArgTy);
}
auto valueArg = entry->createFunctionArgument(valueArgTy);
auto baseArg = entry->createFunctionArgument(baseArgTy);
+ SILValue indexPtrArg;
+ if (!indexes.empty()) {
+ auto indexArgTy = params[2].getSILStorageType();
+ indexPtrArg = entry->createFunctionArgument(indexArgTy);
+ }
+
Scope scope(subSGF, loc);
+
+ RValue indexValue = loadIndexValuesForKeyPathComponent(subSGF, loc,
+ indexes,
+ indexPtrArg);
auto valueOrig = subSGF.emitManagedRValueWithCleanup(valueArg);
auto valueSubst = subSGF.emitOrigToSubstValue(loc, valueOrig,
@@ -3097,10 +3200,12 @@
propertyType);
LValue lv;
+ SmallVector<Substitution, 2> subsBuf;
+
if (!property->isSetterMutating()) {
auto baseSubst = emitKeyPathRValueBase(subSGF, property,
loc, baseArg,
- baseType);
+ baseType, subs, subsBuf);
lv = LValue::forValue(baseSubst, baseType);
} else {
@@ -3111,8 +3216,9 @@
// Open an existential lvalue, if necessary.
if (baseType->isAnyExistentialType()) {
- ArchetypeType *opened;
- baseType = baseType->openAnyExistentialType(opened)->getCanonicalType();
+ auto opened = subs[0].getReplacement()->castTo<ArchetypeType>();
+ assert(opened->isOpenedExistential());
+ baseType = opened->getCanonicalType();
lv = subSGF.emitOpenExistentialLValue(loc, std::move(lv),
CanArchetypeType(opened),
baseType,
@@ -3120,16 +3226,18 @@
}
}
- auto subs = baseType->getContextSubstitutionMap(subSGF.SGM.M.getSwiftModule(),
- property->getInnermostDeclContext()->getInnermostTypeContext());
- SmallVector<Substitution, 4> subsList;
- if (subs.getGenericSignature())
- subs.getGenericSignature()->getSubstitutions(subs, subsList);
-
LValueOptions lvOptions;
- lv.addMemberVarComponent(subSGF, loc, property, subsList, lvOptions,
- /*super*/ false, AccessKind::Write,
- AccessSemantics::Ordinary, strategy, propertyType);
+ if (auto var = dyn_cast<VarDecl>(property)) {
+ lv.addMemberVarComponent(subSGF, loc, var, subs, lvOptions,
+ /*super*/ false, AccessKind::Write,
+ AccessSemantics::Ordinary, strategy, propertyType);
+ } else {
+ auto sub = cast<SubscriptDecl>(property);
+ lv.addMemberSubscriptComponent(subSGF, loc, sub, subs, lvOptions,
+ /*super*/ false, AccessKind::Write,
+ AccessSemantics::Ordinary, strategy, propertyType,
+ std::move(indexValue));
+ }
subSGF.emitAssignToLValue(loc,
RValue(subSGF, loc, propertyType, valueSubst),
@@ -3141,14 +3249,341 @@
return thunk;
}
+static void
+getOrCreateKeyPathEqualsAndHash(SILGenFunction &SGF,
+ SILLocation loc,
+ GenericEnvironment *genericEnv,
+ ArrayRef<KeyPathPatternComponent::Index> indexes,
+ SILFunction *&equals,
+ SILFunction *&hash) {
+ if (indexes.empty()) {
+ equals = nullptr;
+ hash = nullptr;
+ return;
+ }
+
+ auto genericSig = genericEnv
+ ? genericEnv->getGenericSignature()->getCanonicalSignature()
+ : nullptr;
+
+ auto &C = SGF.getASTContext();
+ auto unsafeRawPointerTy = C.getUnsafeRawPointerDecl()->getDeclaredType()
+ ->getCanonicalType();
+ auto boolTy = C.getBoolDecl()->getDeclaredType()->getCanonicalType();
+ auto intTy = C.getIntDecl()->getDeclaredType()->getCanonicalType();
+
+ auto hashableProto = C.getProtocol(KnownProtocolKind::Hashable);
+
+ SmallVector<CanType, 4> indexTypes;
+ indexTypes.reserve(indexes.size());
+ for (auto &index : indexes)
+ indexTypes.push_back(index.FormalType);
+
+ SmallVector<TupleTypeElt, 2> indexElts;
+ for (auto &elt : indexes) {
+ indexElts.push_back(SGF.F.mapTypeIntoContext(elt.FormalType));
+ }
+
+ auto indexTupleTy = TupleType::get(indexElts, SGF.getASTContext())
+ ->getCanonicalType();
+ RValue indexValue(indexTupleTy);
+
+ auto indexLoweredTy = SGF.getLoweredType(indexTupleTy);
+ auto &SGM = SGF.SGM;
+ // Get or create the equals witness
+ [&unsafeRawPointerTy, &boolTy, &genericSig, &C, &indexTypes, &equals, &loc,
+ &SGM, &genericEnv, &indexLoweredTy, &hashableProto, &indexes]{
+ // (RawPointer, RawPointer) -> Bool
+ SmallVector<SILParameterInfo, 2> params;
+ params.push_back({unsafeRawPointerTy,
+ ParameterConvention::Direct_Unowned});
+ params.push_back({unsafeRawPointerTy,
+ ParameterConvention::Direct_Unowned});
+
+ SmallVector<SILResultInfo, 1> results;
+ results.push_back({boolTy, ResultConvention::Unowned});
+
+ auto signature = SILFunctionType::get(genericSig,
+ SILFunctionType::ExtInfo(SILFunctionType::Representation::Thin,
+ /*pseudogeneric*/ false),
+ ParameterConvention::Direct_Unowned,
+ params, results, None, C);
+
+ // Mangle the name of the thunk to see if we already created it.
+ SmallString<64> nameBuf;
+
+ auto name = Mangle::ASTMangler().mangleKeyPathEqualsHelper(indexTypes,
+ genericSig);
+ equals = SGM.M.getOrCreateSharedFunction(loc, name,
+ signature,
+ IsBare,
+ IsNotTransparent,
+ IsNotSerialized,
+ IsThunk);
+ if (!equals->empty()) {
+ return;
+ }
+
+ SILGenFunction subSGF(SGM, *equals);
+ equals->setGenericEnvironment(genericEnv);
+ auto entry = equals->begin();
+ auto lhsPtr = entry->createFunctionArgument(params[0].getSILStorageType());
+ auto rhsPtr = entry->createFunctionArgument(params[1].getSILStorageType());
+
+ Scope scope(subSGF, loc);
+
+ auto lhsAddr = subSGF.B.createPointerToAddress(loc, lhsPtr,
+ indexLoweredTy.getAddressType(),
+ /*isStrict*/ false);
+ auto rhsAddr = subSGF.B.createPointerToAddress(loc, rhsPtr,
+ indexLoweredTy.getAddressType(),
+ /*isStrict*/ false);
+
+ // Compare each pair of index values using the == witness from the
+ // conformance.
+ auto equatableProtocol = C.getProtocol(KnownProtocolKind::Equatable);
+ auto equalsMethod = equatableProtocol->lookupDirect(C.Id_EqualsOperator)[0];
+ auto equalsRef = SILDeclRef(equalsMethod);
+ auto equalsTy = subSGF.SGM.Types.getConstantType(equalsRef);
+
+ auto hashableSig = C.getExistentialSignature(
+ hashableProto->getDeclaredType()->getCanonicalType(),
+ SGM.M.getSwiftModule());
+
+ auto isFalseBB = subSGF.createBasicBlock();
+ auto i1Ty = SILType::getBuiltinIntegerType(1, C);
+ for (unsigned i : indices(indexes)) {
+ auto &index = indexes[i];
+
+ auto formalTy = index.FormalType;
+ auto hashable = index.Hashable;
+ if (genericEnv) {
+ formalTy = genericEnv->mapTypeIntoContext(formalTy)->getCanonicalType();
+ hashable = hashable.subst(index.FormalType,
+ [&](Type t) -> Type { return genericEnv->mapTypeIntoContext(t); },
+ LookUpConformanceInSignature(*genericSig));
+ }
+
+ // Get the Equatable conformance from the Hashable conformance
+ auto subMap = hashableSig->getSubstitutionMap(
+ Substitution(formalTy, hashable));
+ auto equatable = *subMap
+ .lookupConformance(CanType(hashableSig->getGenericParams()[0]),
+ equatableProtocol);
+ auto equatableSub = Substitution(formalTy,
+ C.AllocateCopy(ArrayRef<ProtocolConformanceRef>(equatable)));
+
+ auto equalsWitness = subSGF.B.createWitnessMethod(loc,
+ formalTy, equatable,
+ equalsRef, equalsTy);
+
+ auto equalsSubstTy = equalsTy.castTo<SILFunctionType>()
+ ->substGenericArgs(SGM.M, equatableSub);
+ auto equalsInfo = CalleeTypeInfo(equalsSubstTy,
+ AbstractionPattern(boolTy), boolTy,
+ None,
+ ImportAsMemberStatus());
+
+ Scope branchScope(subSGF, loc);
+
+ SILValue lhsEltAddr = lhsAddr;
+ SILValue rhsEltAddr = rhsAddr;
+ if (indexes.size() > 1) {
+ lhsEltAddr = subSGF.B.createTupleElementAddr(loc, lhsEltAddr, i);
+ rhsEltAddr = subSGF.B.createTupleElementAddr(loc, rhsEltAddr, i);
+ }
+ auto lhsArg = subSGF.emitLoad(loc, lhsEltAddr,
+ subSGF.getTypeLowering(AbstractionPattern::getOpaque(), formalTy),
+ SGFContext(), IsNotTake);
+ auto rhsArg = subSGF.emitLoad(loc, rhsEltAddr,
+ subSGF.getTypeLowering(AbstractionPattern::getOpaque(), formalTy),
+ SGFContext(), IsNotTake);
+
+ if (!lhsArg.getType().isAddress()) {
+ auto lhsBuf = subSGF.emitTemporaryAllocation(loc, lhsArg.getType());
+ lhsArg.forwardInto(subSGF, loc, lhsBuf);
+ lhsArg = subSGF.emitManagedBufferWithCleanup(lhsBuf);
+
+ auto rhsBuf = subSGF.emitTemporaryAllocation(loc, rhsArg.getType());
+ rhsArg.forwardInto(subSGF, loc, rhsBuf);
+ rhsArg = subSGF.emitManagedBufferWithCleanup(rhsBuf);
+ }
+
+ auto metaty = CanMetatypeType::get(formalTy,
+ MetatypeRepresentation::Thick);
+ auto metatyValue = ManagedValue::forUnmanaged(subSGF.B.createMetatype(loc,
+ SILType::getPrimitiveObjectType(metaty)));
+ SILValue isEqual;
+ {
+ auto equalsResultPlan = ResultPlanBuilder::computeResultPlan(subSGF,
+ equalsInfo, loc, SGFContext());
+ ArgumentScope argScope(subSGF, loc);
+ isEqual = subSGF.emitApply(std::move(equalsResultPlan),
+ std::move(argScope),
+ loc,
+ ManagedValue::forUnmanaged(equalsWitness),
+ equatableSub,
+ {lhsArg, rhsArg, metatyValue},
+ equalsInfo,
+ ApplyOptions::None,
+ SGFContext())
+ .getUnmanagedSingleValue(subSGF, loc);
+ }
+
+ branchScope.pop();
+
+ auto isEqualI1 = subSGF.B.createStructExtract(loc, isEqual,
+ C.getBoolDecl()->getStoredProperties().front(), i1Ty);
+
+ auto isTrueBB = subSGF.createBasicBlock();
+
+ subSGF.B.createCondBranch(loc, isEqualI1, isTrueBB, isFalseBB);
+
+ subSGF.B.emitBlock(isTrueBB);
+ }
+
+ auto returnBB = subSGF.createBasicBlock(FunctionSection::Postmatter);
+
+ SILValue trueValue = subSGF.B.createIntegerLiteral(loc, i1Ty, 1);
+ subSGF.B.createBranch(loc, returnBB, trueValue);
+
+ subSGF.B.emitBlock(isFalseBB);
+ SILValue falseValue = subSGF.B.createIntegerLiteral(loc, i1Ty, 0);
+ subSGF.B.createBranch(loc, returnBB, falseValue);
+
+ subSGF.B.emitBlock(returnBB);
+ scope.pop();
+ SILValue returnVal = returnBB->createPHIArgument(i1Ty,
+ ValueOwnershipKind::Trivial);
+ auto returnBoolVal = subSGF.B.createStruct(loc,
+ SILType::getPrimitiveObjectType(boolTy), returnVal);
+ subSGF.B.createReturn(loc, returnBoolVal);
+ }();
+
+ // Get or create the hash witness
+ [&unsafeRawPointerTy, &intTy, &genericSig, &C, &indexTypes, &hash, &loc,
+ &SGM, &genericEnv, &indexLoweredTy, &hashableProto, &indexes]{
+ // (RawPointer) -> Int
+ SmallVector<SILParameterInfo, 1> params;
+ params.push_back({unsafeRawPointerTy,
+ ParameterConvention::Direct_Unowned});
+
+ SmallVector<SILResultInfo, 1> results;
+ results.push_back({intTy, ResultConvention::Unowned});
+
+ auto signature = SILFunctionType::get(genericSig,
+ SILFunctionType::ExtInfo(SILFunctionType::Representation::Thin,
+ /*pseudogeneric*/ false),
+ ParameterConvention::Direct_Unowned,
+ params, results, None, C);
+
+ // Mangle the name of the thunk to see if we already created it.
+ SmallString<64> nameBuf;
+
+ auto name = Mangle::ASTMangler().mangleKeyPathHashHelper(indexTypes,
+ genericSig);
+ hash = SGM.M.getOrCreateSharedFunction(loc, name,
+ signature,
+ IsBare,
+ IsNotTransparent,
+ IsNotSerialized,
+ IsThunk);
+ if (!hash->empty()) {
+ return;
+ }
+
+ SILGenFunction subSGF(SGM, *hash);
+ hash->setGenericEnvironment(genericEnv);
+ auto entry = hash->begin();
+ auto indexPtr = entry->createFunctionArgument(params[0].getSILStorageType());
+
+ Scope scope(subSGF, loc);
+
+ auto hashMethod = cast<VarDecl>(
+ hashableProto->lookupDirect(C.Id_hashValue)[0])
+ ->getGetter();
+ auto hashRef = SILDeclRef(hashMethod);
+ auto hashTy = subSGF.SGM.Types.getConstantType(hashRef);
+
+ SILValue hashCode;
+
+ // TODO: Combine hashes of the indexes. There isn't a great hash combining
+ // interface in the standard library to do this yet.
+ {
+ auto &index = indexes[0];
+
+ SILValue indexAddr = subSGF.B.createPointerToAddress(loc, indexPtr,
+ indexLoweredTy.getAddressType(),
+ /*isStrict*/ false);
+ if (indexes.size() > 1) {
+ indexAddr = subSGF.B.createTupleElementAddr(loc, indexAddr, 0);
+ }
+
+ auto formalTy = index.FormalType;
+ auto hashable = index.Hashable;
+ if (genericEnv) {
+ formalTy = genericEnv->mapTypeIntoContext(formalTy)->getCanonicalType();
+ hashable = hashable.subst(index.FormalType,
+ [&](Type t) -> Type { return genericEnv->mapTypeIntoContext(t); },
+ LookUpConformanceInSignature(*genericSig));
+ }
+
+ // Get the Equatable conformance from the Hashable conformance
+ auto hashableSub = Substitution(formalTy,
+ C.AllocateCopy(ArrayRef<ProtocolConformanceRef>(hashable)));
+
+ auto hashWitness = subSGF.B.createWitnessMethod(loc,
+ formalTy, hashable,
+ hashRef, hashTy);
+
+ auto hashSubstTy = hashTy.castTo<SILFunctionType>()
+ ->substGenericArgs(SGM.M, hashableSub);
+ auto hashInfo = CalleeTypeInfo(hashSubstTy,
+ AbstractionPattern(intTy), intTy,
+ None,
+ ImportAsMemberStatus());
+
+ auto arg = subSGF.emitLoad(loc, indexAddr,
+ subSGF.getTypeLowering(AbstractionPattern::getOpaque(), formalTy),
+ SGFContext(), IsNotTake);
+
+ if (!arg.getType().isAddress()) {
+ auto buf = subSGF.emitTemporaryAllocation(loc, arg.getType());
+ arg.forwardInto(subSGF, loc, buf);
+ arg = subSGF.emitManagedBufferWithCleanup(buf);
+ }
+
+ {
+ auto hashResultPlan = ResultPlanBuilder::computeResultPlan(subSGF,
+ hashInfo, loc, SGFContext());
+ ArgumentScope argScope(subSGF, loc);
+ hashCode = subSGF.emitApply(std::move(hashResultPlan),
+ std::move(argScope),
+ loc,
+ ManagedValue::forUnmanaged(hashWitness),
+ hashableSub,
+ {arg},
+ hashInfo,
+ ApplyOptions::None,
+ SGFContext())
+ .getUnmanagedSingleValue(subSGF, loc);
+ }
+ }
+ scope.pop();
+ subSGF.B.createReturn(loc, hashCode);
+ }();
+
+ return;
+}
+
static KeyPathPatternComponent::ComputedPropertyId
getIdForKeyPathComponentComputedProperty(SILGenFunction &SGF,
- VarDecl *property,
+ AbstractStorageDecl *storage,
AccessStrategy strategy) {
switch (strategy) {
case AccessStrategy::Storage:
// Identify reabstracted stored properties by the property itself.
- return property;
+ return cast<VarDecl>(storage);
case AccessStrategy::Addressor:
case AccessStrategy::DirectToAccessor: {
// Identify the property using its (unthunked) getter. For a
@@ -3157,17 +3592,17 @@
// TODO: If the getter has shared linkage (say it's synthesized for a
// Clang-imported thing), we'll need some other sort of
// stable identifier.
- auto getterRef = SILDeclRef(property->getGetter(), SILDeclRef::Kind::Func);
+ auto getterRef = SILDeclRef(storage->getGetter(), SILDeclRef::Kind::Func);
return SGF.SGM.getFunction(getterRef, NotForDefinition);
}
case AccessStrategy::DispatchToAccessor: {
// Identify the property by its vtable or wtable slot.
// Use the foreign selector if the decl is ObjC-imported, dynamic, or
// otherwise requires objc_msgSend for its ABI.
- return SILDeclRef(property->getGetter(), SILDeclRef::Kind::Func,
+ return SILDeclRef(storage->getGetter(), SILDeclRef::Kind::Func,
ResilienceExpansion::Minimal,
/*curried*/ false,
- /*foreign*/ property->requiresForeignGetterAndSetter());
+ /*foreign*/ storage->requiresForeignGetterAndSetter());
}
case AccessStrategy::BehaviorStorage:
llvm_unreachable("unpossible");
@@ -3184,14 +3619,7 @@
// subscript indexes.
SmallVector<KeyPathPatternComponent, 4> loweredComponents;
auto loweredTy = SGF.getLoweredType(E->getType());
-
- auto unsupported = [&](StringRef message) -> RValue {
- SGF.SGM.diagnose(E->getLoc(), diag::not_implemented, message);
-
- auto undef = SILUndef::get(loweredTy, SGF.SGM.M);
- return RValue(SGF, E, ManagedValue::forUnmanaged(undef));
- };
-
+
CanType rootTy = E->getType()->castTo<BoundGenericType>()->getGenericArgs()[0]
->getCanonicalType();
@@ -3202,6 +3630,7 @@
}
auto baseTy = rootTy;
+ SmallVector<SILValue, 4> operands;
for (auto &component : E->getComponents()) {
switch (auto kind = component.getKind()) {
@@ -3239,24 +3668,26 @@
auto id = getIdForKeyPathComponentComputedProperty(SGF, decl,
strategy);
auto getter = getOrCreateKeyPathGetter(SGF, SILLocation(E),
- decl, strategy,
+ decl, component.getDeclRef().getSubstitutions(),
+ strategy,
needsGenericContext ? SGF.F.getGenericEnvironment() : nullptr,
+ {},
oldBaseTy, baseTy);
if (decl->isSettable(decl->getDeclContext())) {
auto setter = getOrCreateKeyPathSetter(SGF, SILLocation(E),
- decl, strategy,
+ decl, component.getDeclRef().getSubstitutions(),
+ strategy,
needsGenericContext ? SGF.F.getGenericEnvironment() : nullptr,
+ {},
oldBaseTy, baseTy);
loweredComponents.push_back(
KeyPathPatternComponent::forComputedSettableProperty(id,
- getter, setter,
- {}, baseTy));
+ getter, setter, {}, nullptr, nullptr, baseTy));
} else {
loweredComponents.push_back(
KeyPathPatternComponent::forComputedGettableProperty(id,
- getter,
- {}, baseTy));
+ getter, {}, nullptr, nullptr, baseTy));
}
break;
}
@@ -3292,8 +3723,95 @@
break;
}
- case KeyPathExpr::Component::Kind::Subscript:
- return unsupported("subscript key path component");
+ case KeyPathExpr::Component::Kind::Subscript: {
+ auto decl = cast<SubscriptDecl>(component.getDeclRef().getDecl());
+ auto strategy = decl->getAccessStrategy(AccessSemantics::Ordinary,
+ AccessKind::ReadWrite);
+ auto oldBaseTy = baseTy;
+ auto baseSubscriptTy =
+ decl->getInterfaceType()->castTo<AnyFunctionType>();
+ if (auto genSubscriptTy = baseSubscriptTy->getAs<GenericFunctionType>())
+ baseSubscriptTy = genSubscriptTy
+ ->substGenericArgs(component.getDeclRef().getSubstitutions());
+ auto baseSubscriptInterfaceTy = cast<AnyFunctionType>(
+ SGF.F.mapTypeOutOfContext(baseSubscriptTy)->getCanonicalType());
+
+ baseTy = baseSubscriptInterfaceTy.getResult();
+
+ // Capturing an index value dependent on the generic context means we
+ // need the generic context captured in the key path.
+ needsGenericContext |=
+ component.getIndexExpr()->getType()->hasArchetype()
+ | baseTy->hasTypeParameter();
+
+ // Evaluate the index arguments.
+ SmallVector<RValue, 2> indexValues;
+ auto indexResult = visit(component.getIndexExpr(), SGFContext());
+ if (auto tup = indexResult.getType()->getAs<TupleType>()) {
+ std::move(indexResult).extractElements(indexValues);
+ } else {
+ indexValues.push_back(std::move(indexResult));
+ }
+
+ SmallVector<KeyPathPatternComponent::Index, 4> indexPatterns;
+ SILFunction *indexEquals = nullptr, *indexHash = nullptr;
+ for (unsigned i : indices(indexValues)) {
+ auto hashable = component.getSubscriptIndexHashableConformances()[i];
+ assert(hashable.isAbstract() ||
+ hashable.getConcrete()->getType()->isEqual(indexValues[i].getType()));
+ auto &value = indexValues[i];
+
+ auto indexTy = SGF.F.mapTypeOutOfContext(value.getType())->getCanonicalType();
+ auto indexLoweredTy = SGF.getLoweredType(value.getType());
+ indexLoweredTy = SILType::getPrimitiveType(
+ SGF.F.mapTypeOutOfContext(indexLoweredTy.getSwiftRValueType())
+ ->getCanonicalType(),
+ indexLoweredTy.getCategory());
+ indexPatterns.push_back({(unsigned)operands.size(),
+ indexTy, indexLoweredTy,
+ hashable});
+ operands.push_back(
+ std::move(indexValues[i]).forwardAsSingleValue(SGF, E));
+ }
+ getOrCreateKeyPathEqualsAndHash(SGF, SILLocation(E),
+ needsGenericContext ? SGF.F.getGenericEnvironment() : nullptr,
+ indexPatterns,
+ indexEquals, indexHash);
+
+ auto id = getIdForKeyPathComponentComputedProperty(SGF, decl, strategy);
+ auto getter = getOrCreateKeyPathGetter(SGF, SILLocation(E),
+ decl, component.getDeclRef().getSubstitutions(),
+ strategy,
+ needsGenericContext ? SGF.F.getGenericEnvironment() : nullptr,
+ indexPatterns,
+ oldBaseTy, baseTy);
+
+ auto indexPatternsCopy = SGF.getASTContext().AllocateCopy(indexPatterns);
+ if (decl->isSettable()) {
+ auto setter = getOrCreateKeyPathSetter(SGF, SILLocation(E),
+ decl, component.getDeclRef().getSubstitutions(),
+ strategy,
+ needsGenericContext ? SGF.F.getGenericEnvironment() : nullptr,
+ indexPatterns,
+ oldBaseTy, baseTy);
+ loweredComponents.push_back(
+ KeyPathPatternComponent::forComputedSettableProperty(id,
+ getter, setter,
+ indexPatternsCopy,
+ indexEquals,
+ indexHash,
+ baseTy));
+ } else {
+ loweredComponents.push_back(
+ KeyPathPatternComponent::forComputedGettableProperty(id,
+ getter,
+ indexPatternsCopy,
+ indexEquals,
+ indexHash,
+ baseTy));
+ }
+ break;
+ }
case KeyPathExpr::Component::Kind::Invalid:
case KeyPathExpr::Component::Kind::UnresolvedProperty:
@@ -3319,6 +3837,7 @@
needsGenericContext
? SGF.F.getForwardingSubstitutions()
: SubstitutionList(),
+ operands,
loweredTy);
auto value = SGF.emitManagedRValueWithCleanup(keyPath);
return RValue(SGF, E, value);
diff --git a/lib/SILGen/SILGenFunction.h b/lib/SILGen/SILGenFunction.h
index 681d125..1c93cef 100644
--- a/lib/SILGen/SILGenFunction.h
+++ b/lib/SILGen/SILGenFunction.h
@@ -1057,14 +1057,15 @@
/// \arg isBaseGuaranteed This should /only/ be set to true if we know that
/// the base value will stay alive as long as the returned RValue implying
/// that it is safe to load/use values as +0.
- RValue emitRValueForPropertyLoad(SILLocation loc,
- ManagedValue base,
- CanType baseFormalType,
- bool isSuper, VarDecl *property,
- SubstitutionList substitutions,
- AccessSemantics semantics, Type propTy,
- SGFContext C,
- bool isBaseGuaranteed = false);
+ RValue emitRValueForStorageLoad(SILLocation loc,
+ ManagedValue base,
+ CanType baseFormalType,
+ bool isSuper, AbstractStorageDecl *storage,
+ RValue indexes,
+ SubstitutionList substitutions,
+ AccessSemantics semantics, Type propTy,
+ SGFContext C,
+ bool isBaseGuaranteed = false);
void emitCaptures(SILLocation loc,
AnyFunctionRef TheClosure,
diff --git a/lib/SILOptimizer/IPO/ClosureSpecializer.cpp b/lib/SILOptimizer/IPO/ClosureSpecializer.cpp
index 8715fc1..802c014 100644
--- a/lib/SILOptimizer/IPO/ClosureSpecializer.cpp
+++ b/lib/SILOptimizer/IPO/ClosureSpecializer.cpp
@@ -49,9 +49,10 @@
/// that the release occurs in the epilog after any retains associated with
/// @owned return values.
///
-/// 3. We do not support specialization of closures with arguments passed using
-/// any indirect calling conventions besides @inout and @inout_aliasable.
-/// This is a temporary limitation.
+/// 3. In !useLoweredAddresses mode, we do not support specialization of closures
+/// with arguments passed using any indirect calling conventions besides
+/// @inout and @inout_aliasable. This is a temporary limitation that goes
+/// away with sil-opaque-values.
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "closure-specialization"
@@ -581,8 +582,9 @@
ParameterConvention ParamConv;
if (PInfo.isFormalIndirect()) {
ParamConv = PInfo.getConvention();
- assert(ParamConv == ParameterConvention::Indirect_Inout ||
- ParamConv == ParameterConvention::Indirect_InoutAliasable);
+ assert(!SILModuleConventions(M).useLoweredAddresses()
+ || ParamConv == ParameterConvention::Indirect_Inout
+ || ParamConv == ParameterConvention::Indirect_InoutAliasable);
} else {
ParamConv = ClosedOverFunConv.getSILType(PInfo).isTrivial(M)
? ParameterConvention::Direct_Unowned
diff --git a/lib/SILOptimizer/IPO/DeadFunctionElimination.cpp b/lib/SILOptimizer/IPO/DeadFunctionElimination.cpp
index 7e77c57..61b7fe4 100644
--- a/lib/SILOptimizer/IPO/DeadFunctionElimination.cpp
+++ b/lib/SILOptimizer/IPO/DeadFunctionElimination.cpp
@@ -223,6 +223,12 @@
case KeyPathPatternComponent::ComputedPropertyId::Property:
break;
}
+
+ if (auto equals = component.getComputedPropertyIndexEquals())
+ ensureAlive(equals);
+ if (auto hash = component.getComputedPropertyIndexHash())
+ ensureAlive(hash);
+
continue;
}
case KeyPathPatternComponent::Kind::StoredProperty:
diff --git a/lib/SILOptimizer/IPO/EagerSpecializer.cpp b/lib/SILOptimizer/IPO/EagerSpecializer.cpp
index c549b0e..9df86d7 100644
--- a/lib/SILOptimizer/IPO/EagerSpecializer.cpp
+++ b/lib/SILOptimizer/IPO/EagerSpecializer.cpp
@@ -626,7 +626,9 @@
ReInfo.createSpecializedType(SubstitutedType, Builder.getModule());
}
- assert(OrigArgs.size() == ReInfo.getNumArguments() && "signature mismatch");
+ assert(!substConv.useLoweredAddresses()
+ || OrigArgs.size() == ReInfo.getNumArguments() &&
+ "signature mismatch");
CallArgs.reserve(OrigArgs.size());
SILValue StoreResultTo;
diff --git a/lib/SILOptimizer/IPO/GlobalOpt.cpp b/lib/SILOptimizer/IPO/GlobalOpt.cpp
index f6d6059..09aca85 100644
--- a/lib/SILOptimizer/IPO/GlobalOpt.cpp
+++ b/lib/SILOptimizer/IPO/GlobalOpt.cpp
@@ -98,15 +98,19 @@
return type.getNominalOrBoundGenericNominal() == ArrayDecl;
}
- bool isValidUseOfObject(SILInstruction *Val, bool isCOWObject);
+ bool isValidUseOfObject(SILInstruction *Val, bool isCOWObject,
+ ApplyInst **FindStringCall = nullptr);
bool getObjectInitVals(SILValue Val,
llvm::DenseMap<VarDecl *, StoreInst *> &MemberStores,
- llvm::SmallVectorImpl<StoreInst *> &TailStores);
+ llvm::SmallVectorImpl<StoreInst *> &TailStores,
+ ApplyInst **FindStringCall);
bool handleTailAddr(int TailIdx, SILInstruction *I,
llvm::SmallVectorImpl<StoreInst *> &TailStores);
void optimizeObjectAllocation(AllocRefInst *ARI);
+ void replaceFindStringCall(ApplyInst *FindStringCall);
+
SILGlobalVariable *getVariableOfGlobalInit(SILFunction *AddrF);
bool isInLoop(SILBasicBlock *CurBB);
void placeInitializers(SILFunction *InitF, ArrayRef<ApplyInst*> Calls);
@@ -660,7 +664,8 @@
// global variable for now.
if (!isa<StructInst>(InitVal) && !isa<TupleInst>(InitVal))
return nullptr;
- } else if (!SILGlobalVariable::isValidStaticInitializerInst(&I)) {
+ } else if (!SILGlobalVariable::isValidStaticInitializerInst(&I,
+ I.getModule())) {
return nullptr;
}
}
@@ -1008,7 +1013,7 @@
/// all it's operands.
static bool isValidInitVal(SILValue V) {
if (SILInstruction *I = dyn_cast<SILInstruction>(V)) {
- if (!SILGlobalVariable::isValidStaticInitializerInst(I))
+ if (!SILGlobalVariable::isValidStaticInitializerInst(I, I->getModule()))
return false;
for (Operand &Op : I->getAllOperands()) {
@@ -1037,7 +1042,10 @@
///
/// If \p isCOWObject is true, then the object reference is wrapped into a
/// COW container. Currently this is just Array<T>.
-bool SILGlobalOpt::isValidUseOfObject(SILInstruction *I, bool isCOWObject) {
+/// If a use is a call to the findStringSwitchCase semantic call, the apply
+/// is returned in \p FindStringCall.
+bool SILGlobalOpt::isValidUseOfObject(SILInstruction *I, bool isCOWObject,
+ ApplyInst **FindStringCall) {
switch (I->getKind()) {
case ValueKind::DebugValueAddrInst:
case ValueKind::DebugValueInst:
@@ -1048,7 +1056,6 @@
return true;
case ValueKind::ReturnInst:
- case ValueKind::ApplyInst:
case ValueKind::TryApplyInst:
case ValueKind::PartialApplyInst:
case ValueKind::StoreInst:
@@ -1057,6 +1064,16 @@
/// this will do a uniqueness checking before the object is modified.
return isCOWObject;
+ case ValueKind::ApplyInst:
+ if (!isCOWObject)
+ return false;
+ // There should only be a single call to findStringSwitchCase. But even
+ // if there are multiple calls, it's not problem - we'll just optimize the
+ // last one we find.
+ if (cast<ApplyInst>(I)->hasSemantics("findStringSwitchCase"))
+ *FindStringCall = cast<ApplyInst>(I);
+ return true;
+
case ValueKind::StructInst:
if (isCOWType(I->getType())) {
// The object is wrapped into a COW container.
@@ -1097,7 +1114,7 @@
}
for (Operand *Use : getNonDebugUses(I)) {
- if (!isValidUseOfObject(Use->getUser(), isCOWObject))
+ if (!isValidUseOfObject(Use->getUser(), isCOWObject, FindStringCall))
return false;
}
return true;
@@ -1125,12 +1142,13 @@
/// Get the init values for an object's stored properties and its tail elements.
bool SILGlobalOpt::getObjectInitVals(SILValue Val,
llvm::DenseMap<VarDecl *, StoreInst *> &MemberStores,
- llvm::SmallVectorImpl<StoreInst *> &TailStores) {
+ llvm::SmallVectorImpl<StoreInst *> &TailStores,
+ ApplyInst **FindStringCall) {
for (Operand *Use : Val->getUses()) {
SILInstruction *User = Use->getUser();
if (auto *UC = dyn_cast<UpcastInst>(User)) {
// Upcast is transparent.
- if (!getObjectInitVals(UC, MemberStores, TailStores))
+ if (!getObjectInitVals(UC, MemberStores, TailStores, FindStringCall))
return false;
} else if (auto *REA = dyn_cast<RefElementAddrInst>(User)) {
// The address of a stored property.
@@ -1165,7 +1183,7 @@
return false;
}
}
- } else if (!isValidUseOfObject(User, /*isCOWObject*/false)) {
+ } else if (!isValidUseOfObject(User, /*isCOWObject*/false, FindStringCall)) {
return false;
}
}
@@ -1174,11 +1192,16 @@
class GlobalVariableMangler : public Mangle::ASTMangler {
public:
- std::string mangleOutlinedVariable(SILFunction *Context, int Idx) {
- beginManglingWithoutPrefix();
- appendOperator(Context->getName());
- appendOperator("Tv", Index(Idx));
- return finalize();
+ std::string mangleOutlinedVariable(SILFunction *F, int &uniqueIdx) {
+ std::string GlobName;
+ do {
+ beginManglingWithoutPrefix();
+ appendOperator(F->getName());
+ appendOperator("Tv", Index(uniqueIdx++));
+ GlobName = finalize();
+ } while (F->getModule().lookUpGlobalVariable(GlobName));
+
+ return GlobName;
}
};
@@ -1225,7 +1248,8 @@
llvm::DenseMap<VarDecl *, StoreInst *> MemberStores;
llvm::SmallVector<StoreInst *, 16> TailStores;
TailStores.resize(NumTailElems);
- if (!getObjectInitVals(ARI, MemberStores, TailStores))
+ ApplyInst *FindStringCall = nullptr;
+ if (!getObjectInitVals(ARI, MemberStores, TailStores, &FindStringCall))
return;
// Is there a store for all the class properties?
@@ -1243,10 +1267,8 @@
// Create a name for the outlined global variable.
GlobalVariableMangler Mangler;
- std::string GlobName;
- do {
- GlobName = Mangler.mangleOutlinedVariable(ARI->getFunction(), GlobIdx++);
- } while (Module->lookUpGlobalVariable(GlobName));
+ std::string GlobName =
+ Mangler.mangleOutlinedVariable(ARI->getFunction(), GlobIdx);
SILGlobalVariable *Glob =
SILGlobalVariable::create(*Module, SILLinkage::Private, IsNotSerialized,
@@ -1298,11 +1320,84 @@
Use->set(GVI);
}
}
+ if (FindStringCall && NumTailElems > 16) {
+ assert(&*std::next(ARI->getIterator()) != FindStringCall &&
+ "FindStringCall must not be the next instruction after ARI because "
+ "deleting it would invalidate the instruction iterator");
+ replaceFindStringCall(FindStringCall);
+ }
+
ARI->eraseFromParent();
HasChanged = true;
}
+/// Replaces a call to _findStringSwitchCase with a call to
+/// _findStringSwitchCaseWithCache which builds a cache (e.g. a Dictionary) and
+/// stores it into a global variable. Then subsequent calls to this function can
+/// do a fast lookup using the cache.
+void SILGlobalOpt::replaceFindStringCall(ApplyInst *FindStringCall) {
+ // Find the replacement function in the swift stdlib.
+ SmallVector<ValueDecl *, 1> results;
+ Module->getASTContext().lookupInSwiftModule("_findStringSwitchCaseWithCache",
+ results);
+ if (results.size() != 1)
+ return;
+
+ auto *FD = dyn_cast<FuncDecl>(results.front());
+ if (!FD)
+ return;
+
+ std::string Mangled = SILDeclRef(FD, SILDeclRef::Kind::Func).mangle();
+ SILFunction *replacementFunc = Module->findFunction(Mangled,
+ SILLinkage::PublicExternal);
+ if (!replacementFunc)
+ return;
+
+ SILFunctionType *FTy = replacementFunc->getLoweredFunctionType();
+ if (FTy->getNumParameters() != 3)
+ return;
+
+ SILType cacheType = FTy->getParameters()[2].getSILStorageType().getObjectType();
+ NominalTypeDecl *cacheDecl = cacheType.getNominalOrBoundGenericNominal();
+ if (!cacheDecl)
+ return;
+ SILType wordTy = cacheType.getFieldType(
+ cacheDecl->getStoredProperties().front(), *Module);
+
+ GlobalVariableMangler Mangler;
+ std::string GlobName =
+ Mangler.mangleOutlinedVariable(FindStringCall->getFunction(), GlobIdx);
+
+ // Create an "opaque" global variable which is passed as inout to
+ // _findStringSwitchCaseWithCache and into which the function stores the
+ // "cache".
+ SILGlobalVariable *CacheVar =
+ SILGlobalVariable::create(*Module, SILLinkage::Private, IsNotSerialized,
+ GlobName, cacheType);
+
+ SILLocation Loc = FindStringCall->getLoc();
+ SILBuilder StaticInitBuilder(CacheVar);
+ auto *Zero = StaticInitBuilder.createIntegerLiteral(Loc, wordTy, 0);
+ StaticInitBuilder.createStruct(ArtificialUnreachableLocation(), cacheType,
+ {Zero, Zero});
+
+ SILBuilder B(FindStringCall);
+ GlobalAddrInst *CacheAddr = B.createGlobalAddr(FindStringCall->getLoc(),
+ CacheVar);
+ FunctionRefInst *FRI = B.createFunctionRef(FindStringCall->getLoc(),
+ replacementFunc);
+ ApplyInst *NewCall = B.createApply(FindStringCall->getLoc(), FRI,
+ FindStringCall->getSubstitutions(),
+ { FindStringCall->getArgument(0),
+ FindStringCall->getArgument(1),
+ CacheAddr },
+ FindStringCall->isNonThrowing());
+
+ FindStringCall->replaceAllUsesWith(NewCall);
+ FindStringCall->eraseFromParent();
+}
+
/// Optimize access to the global variable, which is known
/// to have a constant value. Replace all loads from the
/// global address by invocations of a getter that returns
diff --git a/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp b/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp
index 74d6e22..54ca827 100644
--- a/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp
+++ b/lib/SILOptimizer/IPO/GlobalPropertyOpt.cpp
@@ -68,18 +68,15 @@
#ifndef NDEBUG
friend raw_ostream &operator<<(raw_ostream &os, const Entry &entry) {
- if (entry.Field) {
- os << "field " << entry.Field->getName() << '\n';
- } else if (!entry.Value) {
- os << "unknown-address\n";
- } else if (auto *Inst = dyn_cast<SILInstruction>(entry.Value)) {
- os << Inst->getParent()->getParent()->getName() << ": " << entry.Value;
- } else if (auto *Arg = dyn_cast<SILArgument>(entry.Value)) {
- os << Arg->getParent()->getParent()->getName() << ": " << entry.Value;
- } else {
- os << entry.Value;
- }
- return os;
+ if (entry.Field)
+ return os << "field " << entry.Field->getName() << '\n';
+ if (!entry.Value)
+ return os << "unknown-address\n";
+ if (auto *Inst = dyn_cast<SILInstruction>(entry.Value))
+ os << Inst->getFunction()->getName() << ": " << entry.Value;
+ if (auto *Arg = dyn_cast<SILArgument>(entry.Value))
+ return os << Arg->getFunction()->getName() << ": " << entry.Value;
+ return os << entry.Value;
}
#endif
};
diff --git a/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp b/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp
index 9ee8f8f..70ba575 100644
--- a/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp
+++ b/lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp
@@ -967,18 +967,17 @@
static void createArgumentRelease(SILBuilder &Builder, ArgumentDescriptor &AD) {
auto &F = Builder.getFunction();
- if (AD.PInfo->getConvention() == ParameterConvention::Direct_Owned) {
- Builder.createReleaseValue(RegularLocation(SourceLoc()),
- F.getArguments()[AD.Index],
- Builder.getDefaultAtomicity());
- return;
- }
- if (AD.PInfo->getConvention() == ParameterConvention::Indirect_In) {
+ SILArgument *Arg = F.getArguments()[AD.Index];
+ if (Arg->getType().isAddress()) {
+ assert(AD.PInfo->getConvention() == ParameterConvention::Indirect_In
+ && F.getConventions().useLoweredAddresses());
Builder.createDestroyAddr(RegularLocation(SourceLoc()),
F.getArguments()[AD.Index]);
return;
}
- llvm_unreachable("Parameter convention is not supported");
+ Builder.createReleaseValue(RegularLocation(SourceLoc()),
+ F.getArguments()[AD.Index],
+ Builder.getDefaultAtomicity());
}
/// Set up epilogue work for the thunk arguments based in the given argument.
diff --git a/lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp b/lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp
index b5fd8c9..3d8267f 100644
--- a/lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp
+++ b/lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp
@@ -173,7 +173,8 @@
// If we have an address only type, do nothing.
SILType Type = Value->getType();
- assert(Type.isLoadable(Module) &&
+ assert(!SILModuleConventions(Module).useLoweredAddresses()
+ || Type.isLoadable(Module) &&
"release_value should never be called on a non-loadable type.");
if (!shouldExpand(Module, Type.getObjectType()))
@@ -199,8 +200,9 @@
// If we have an address only type, do nothing.
SILType Type = Value->getType();
- assert(Type.isLoadable(Module) && "Copy Value can only be called on loadable "
- "types.");
+ assert(!SILModuleConventions(Module).useLoweredAddresses()
+ || Type.isLoadable(Module) &&
+ "Copy Value can only be called on loadable types.");
if (!shouldExpand(Module, Type.getObjectType()))
return false;
diff --git a/lib/SILOptimizer/Utils/ConstantFolding.cpp b/lib/SILOptimizer/Utils/ConstantFolding.cpp
index 4e5635b..a7f05bb 100644
--- a/lib/SILOptimizer/Utils/ConstantFolding.cpp
+++ b/lib/SILOptimizer/Utils/ConstantFolding.cpp
@@ -77,10 +77,12 @@
default : llvm_unreachable("Invalid case");
case BuiltinValueKind::SDiv:
return lhs.sdiv_ov(rhs, Overflow);
- case BuiltinValueKind::SRem:
+ case BuiltinValueKind::SRem: {
// Check for overflow
- lhs.sdiv_ov(rhs, Overflow);
+ APInt Div = lhs.sdiv_ov(rhs, Overflow);
+ (void)Div;
return lhs.srem(rhs);
+ }
case BuiltinValueKind::UDiv:
Overflow = false;
return lhs.udiv(rhs);
diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp
index d1e143d..fc9e7f0 100644
--- a/lib/Sema/CSApply.cpp
+++ b/lib/Sema/CSApply.cpp
@@ -1314,6 +1314,7 @@
->getElementType(0);
Type valueTy;
+ Type baseTy;
bool resultIsLValue;
if (auto nom = keyPathTTy->getAs<NominalType>()) {
@@ -1324,12 +1325,14 @@
valueTy = OptionalType::get(valueTy);
resultIsLValue = false;
base = cs.coerceToRValue(base);
+ baseTy = cs.getType(base);
} else {
llvm_unreachable("unknown key path class!");
}
} else {
auto keyPathBGT = keyPathTTy->castTo<BoundGenericType>();
-
+ baseTy = keyPathBGT->getGenericArgs()[0];
+
if (keyPathBGT->getDecl()
== cs.getASTContext().getPartialKeyPathDecl()) {
// PartialKeyPath<T> is rvalue T -> rvalue Any
@@ -1357,6 +1360,12 @@
llvm_unreachable("unknown key path class!");
}
}
+
+ // Coerce the base if its anticipated type doesn't match - say we're
+ // applying a keypath with an existential base to a concrete base.
+ if (baseTy->isExistentialType() && !cs.getType(base)->isExistentialType()) {
+ base = coerceToType(base, baseTy, locator);
+ }
}
if (resultIsLValue)
valueTy = LValueType::get(valueTy);
@@ -3919,7 +3928,12 @@
E->setMethod(method);
return E;
}
-
+
+ private:
+ // Key path components we need to
+ SmallVector<std::pair<KeyPathExpr *, unsigned>, 4>
+ KeyPathSubscriptComponents;
+ public:
Expr *visitKeyPathExpr(KeyPathExpr *E) {
if (E->isObjC()) {
cs.setType(E, cs.getType(E->getObjCStringLiteralExpr()));
@@ -4069,12 +4083,17 @@
resolvedTy = simplifyType(resolvedTy);
auto ref = ConcreteDeclRef(cs.getASTContext(), subscript, subs);
+
component = KeyPathExpr::Component
::forSubscriptWithPrebuiltIndexExpr(ref,
origComponent.getIndexExpr(),
origComponent.getSubscriptLabels(),
resolvedTy,
- origComponent.getLoc());
+ origComponent.getLoc(),
+ {});
+ // Save a reference to the component so we can do a post-pass to check
+ // the Hashable conformance of the indexes.
+ KeyPathSubscriptComponents.push_back({E, resolvedComponents.size()});
break;
}
case KeyPathExpr::Component::Kind::OptionalChain: {
@@ -4216,6 +4235,47 @@
.fixItInsert(cast->getStartLoc(), "(")
.fixItInsertAfter(cast->getEndLoc(), ")");
}
+
+ // Look at key path subscript components to verify that they're hashable.
+ for (auto componentRef : KeyPathSubscriptComponents) {
+ auto &component = componentRef.first
+ ->getMutableComponents()[componentRef.second];
+ // We need to be able to hash the captured index values in order for
+ // KeyPath itself to be hashable, so check that all of the subscript
+ // index components are hashable and collect their conformances here.
+ SmallVector<ProtocolConformanceRef, 2> hashables;
+ bool allIndexesHashable = true;
+ ArrayRef<TupleTypeElt> indexTypes;
+ TupleTypeElt singleIndexTypeBuf;
+ if (auto tup = component.getIndexExpr()->getType()
+ ->getAs<TupleType>()) {
+ indexTypes = tup->getElements();
+ } else {
+ singleIndexTypeBuf = component.getIndexExpr()->getType();
+ indexTypes = singleIndexTypeBuf;
+ }
+
+ auto hashable =
+ cs.getASTContext().getProtocol(KnownProtocolKind::Hashable);
+ for (auto indexType : indexTypes) {
+ auto conformance =
+ cs.TC.conformsToProtocol(indexType.getType(), hashable,
+ cs.DC, ConformanceCheckFlags::Used
+ |ConformanceCheckFlags::InExpression);
+ if (!conformance) {
+ cs.TC.diagnose(component.getIndexExpr()->getLoc(),
+ diag::expr_keypath_subscript_index_not_hashable,
+ indexType.getType());
+ allIndexesHashable = false;
+ continue;
+ }
+ hashables.push_back(*conformance);
+ }
+
+ if (allIndexesHashable) {
+ component.setSubscriptIndexHashableConformances(hashables);
+ }
+ }
// Set the final types on the expression.
cs.setExprTypes(result);
diff --git a/lib/Sema/CSBindings.cpp b/lib/Sema/CSBindings.cpp
index 3b0a42a..a175413 100644
--- a/lib/Sema/CSBindings.cpp
+++ b/lib/Sema/CSBindings.cpp
@@ -20,11 +20,10 @@
using namespace swift;
using namespace constraints;
-std::pair<ConstraintSystem::PotentialBindings, TypeVariableType *>
+Optional<ConstraintSystem::PotentialBindings>
ConstraintSystem::determineBestBindings() {
// Look for potential type variable bindings.
- TypeVariableType *bestTypeVar = nullptr;
- PotentialBindings bestBindings;
+ Optional<PotentialBindings> bestBindings;
for (auto typeVar : getTypeVariables()) {
// Skip any type variables that are bound.
if (typeVar->getImpl().hasRepresentativeOrFixed())
@@ -42,13 +41,11 @@
// If these are the first bindings, or they are better than what
// we saw before, use them instead.
- if (!bestTypeVar || bindings < bestBindings) {
+ if (!bestBindings || bindings < *bestBindings)
bestBindings = std::move(bindings);
- bestTypeVar = typeVar;
- }
}
- return std::make_pair(bestBindings, bestTypeVar);
+ return bestBindings;
}
/// Find the set of type variables that are inferable from the given type.
@@ -141,38 +138,7 @@
getConstraintGraph().gatherConstraints(
typeVar, constraints, ConstraintGraph::GatheringKind::EquivalenceClass);
- PotentialBindings result;
- Optional<unsigned> lastSupertypeIndex;
-
- // Local function to add a potential binding to the list of bindings,
- // coalescing supertype bounds when we are able to compute the meet.
- auto addPotentialBinding = [&](PotentialBinding binding,
- bool allowJoinMeet = true) {
- assert(!binding.BindingType->is<ErrorType>());
- // If this is a non-defaulted supertype binding, check whether we can
- // combine it with another supertype binding by computing the 'join' of the
- // types.
- if (binding.Kind == AllowedBindingKind::Supertypes &&
- !binding.BindingType->hasTypeVariable() && !binding.DefaultedProtocol &&
- !binding.isDefaultableBinding() && allowJoinMeet) {
- if (lastSupertypeIndex) {
- // Can we compute a join?
- auto &lastBinding = result.Bindings[*lastSupertypeIndex];
- auto lastType = lastBinding.BindingType->getWithoutSpecifierType();
- auto bindingType = binding.BindingType->getWithoutSpecifierType();
- if (auto join = Type::join(lastType, bindingType)) {
- // Replace the last supertype binding with the join. We're done.
- lastBinding.BindingType = join;
- return;
- }
- }
-
- // Record this as the most recent supertype index.
- lastSupertypeIndex = result.Bindings.size();
- }
-
- result.Bindings.push_back(std::move(binding));
- };
+ PotentialBindings result(typeVar);
// Consider each of the constraints related to this type variable.
llvm::SmallPtrSet<CanType, 4> exactTypes;
@@ -227,7 +193,7 @@
auto dynamicType = constraint->getFirstType();
if (auto *tv = dynamicType->getAs<TypeVariableType>()) {
if (tv->getImpl().getRepresentative(nullptr) == typeVar)
- return {};
+ return {typeVar};
}
// This is right-hand side, let's continue.
@@ -284,8 +250,8 @@
continue;
result.foundLiteralBinding(constraint->getProtocol());
- addPotentialBinding({defaultType, AllowedBindingKind::Subtypes,
- constraint->getProtocol()});
+ result.addPotentialBinding({defaultType, AllowedBindingKind::Subtypes,
+ constraint->getProtocol()});
continue;
}
@@ -311,8 +277,8 @@
if (!matched) {
result.foundLiteralBinding(constraint->getProtocol());
exactTypes.insert(defaultType->getCanonicalType());
- addPotentialBinding({defaultType, AllowedBindingKind::Subtypes,
- constraint->getProtocol()});
+ result.addPotentialBinding({defaultType, AllowedBindingKind::Subtypes,
+ constraint->getProtocol()});
}
continue;
@@ -484,10 +450,12 @@
}
if (exactTypes.insert(type->getCanonicalType()).second)
- addPotentialBinding({type, kind, None}, /*allowJoinMeet=*/!adjustedIUO);
+ result.addPotentialBinding({type, kind, None},
+ /*allowJoinMeet=*/!adjustedIUO);
if (alternateType &&
exactTypes.insert(alternateType->getCanonicalType()).second)
- addPotentialBinding({alternateType, kind, None}, /*allowJoinMeet=*/false);
+ result.addPotentialBinding({alternateType, kind, None},
+ /*allowJoinMeet=*/false);
}
// If we have any literal constraints, check whether there is already a
@@ -565,7 +533,7 @@
continue;
++result.NumDefaultableBindings;
- addPotentialBinding(
+ result.addPotentialBinding(
{type, AllowedBindingKind::Exact, None, constraint->getLocator()});
}
diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp
index c9bd360..98eaefe 100644
--- a/lib/Sema/CSDiag.cpp
+++ b/lib/Sema/CSDiag.cpp
@@ -2560,7 +2560,7 @@
->getAsNominalTypeOrNominalTypeExtensionContext();
SmallString<32> typeName;
llvm::raw_svector_ostream typeNameStream(typeName);
- typeNameStream << nominal->getName() << ".";
+ typeNameStream << nominal->getSelfInterfaceType() << ".";
Diag->fixItInsert(loc, typeNameStream.str());
return;
diff --git a/lib/Sema/CSSolver.cpp b/lib/Sema/CSSolver.cpp
index 8f14d32..a01baec 100644
--- a/lib/Sema/CSSolver.cpp
+++ b/lib/Sema/CSSolver.cpp
@@ -1783,21 +1783,15 @@
Constraint *disjunction, SmallVectorImpl<Solution> &solutions,
FreeTypeVariableBinding allowFreeTypeVariables) {
- TypeVariableType *bestTypeVar = nullptr;
- PotentialBindings bestBindings;
- std::tie(bestBindings, bestTypeVar) = determineBestBindings();
+ auto bestBindings = determineBestBindings();
// If we have a binding that does not involve type variables, and is
- // not fully bound, and is either not a literal or is a collection
- // literal, or we have no disjunction to attempt instead, go ahead
- // and try the bindings for this type variable.
- if (bestBindings &&
- (!disjunction ||
- (!bestBindings.InvolvesTypeVariables && !bestBindings.FullyBound &&
- (bestBindings.LiteralBinding == LiteralBindingKind::None ||
- bestBindings.LiteralBinding == LiteralBindingKind::Collection)))) {
- return tryTypeVariableBindings(solverState->depth, bestTypeVar,
- bestBindings.Bindings, solutions,
+ // not fully bound, or we have no disjunction to attempt instead,
+ // go ahead and try the bindings for this type variable.
+ if (bestBindings && (!disjunction || (!bestBindings->InvolvesTypeVariables &&
+ !bestBindings->FullyBound))) {
+ return tryTypeVariableBindings(solverState->depth, bestBindings->TypeVar,
+ bestBindings->Bindings, solutions,
allowFreeTypeVariables);
}
diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp
index 27309bf..3d2d286 100644
--- a/lib/Sema/CodeSynthesis.cpp
+++ b/lib/Sema/CodeSynthesis.cpp
@@ -2109,6 +2109,12 @@
access = std::min(access, superclassCtor->getFormalAccess());
ctor->setAccess(access);
+ // Inherit the @_versioned attribute.
+ if (superclassCtor->getAttrs().hasAttribute<VersionedAttr>()) {
+ auto *clonedAttr = new (ctx) VersionedAttr(/*implicit=*/true);
+ ctor->getAttrs().add(clonedAttr);
+ }
+
// Make sure the constructor is only as available as its superclass's
// constructor.
AvailabilityInference::applyInferredAvailableAttrs(ctor, superclassCtor, ctx);
@@ -2123,7 +2129,6 @@
if (auto objcAttr = superclassCtor->getAttrs().getAttribute<ObjCAttr>()) {
if (objcAttr->hasName()) {
auto *clonedAttr = objcAttr->clone(ctx);
- // Set it to implicit to disable printing it for SIL.
clonedAttr->setImplicit(true);
ctor->getAttrs().add(clonedAttr);
}
diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h
index e1a82c7..5246a6d 100644
--- a/lib/Sema/ConstraintSystem.h
+++ b/lib/Sema/ConstraintSystem.h
@@ -2551,8 +2551,10 @@
};
struct PotentialBindings {
- typedef std::tuple<bool, bool, bool, bool, unsigned char,
- bool, unsigned int> BindingScore;
+ typedef std::tuple<bool, bool, bool, bool, bool,
+ unsigned char, unsigned int> BindingScore;
+
+ TypeVariableType *TypeVar;
/// The set of potential bindings.
SmallVector<PotentialBinding, 4> Bindings;
@@ -2575,6 +2577,11 @@
/// Is this type variable on the RHS of a BindParam constraint?
bool IsRHSOfBindParam = false;
+ /// Tracks the position of the last known supertype in the group.
+ Optional<unsigned> lastSupertypeIndex;
+
+ PotentialBindings(TypeVariableType *typeVar) : TypeVar(typeVar) {}
+
/// Determine whether the set of bindings is non-empty.
explicit operator bool() const { return !Bindings.empty(); }
@@ -2588,8 +2595,8 @@
b.FullyBound,
b.IsRHSOfBindParam,
b.SubtypeOfExistentialType,
- static_cast<unsigned char>(b.LiteralBinding),
b.InvolvesTypeVariables,
+ static_cast<unsigned char>(b.LiteralBinding),
-(b.Bindings.size() - b.NumDefaultableBindings));
}
@@ -2619,6 +2626,38 @@
}
}
+ /// \brief Add a potential binding to the list of bindings,
+ /// coalescing supertype bounds when we are able to compute the meet.
+ void addPotentialBinding(PotentialBinding binding,
+ bool allowJoinMeet = true) {
+ assert(!binding.BindingType->is<ErrorType>());
+
+ // If this is a non-defaulted supertype binding,
+ // check whether we can combine it with another
+ // supertype binding by computing the 'join' of the types.
+ if (binding.Kind == AllowedBindingKind::Supertypes &&
+ !binding.BindingType->hasTypeVariable() &&
+ !binding.DefaultedProtocol && !binding.isDefaultableBinding() &&
+ allowJoinMeet) {
+ if (lastSupertypeIndex) {
+ // Can we compute a join?
+ auto &lastBinding = Bindings[*lastSupertypeIndex];
+ auto lastType = lastBinding.BindingType->getWithoutSpecifierType();
+ auto bindingType = binding.BindingType->getWithoutSpecifierType();
+ if (auto join = Type::join(lastType, bindingType)) {
+ // Replace the last supertype binding with the join. We're done.
+ lastBinding.BindingType = join;
+ return;
+ }
+ }
+
+ // Record this as the most recent supertype index.
+ lastSupertypeIndex = Bindings.size();
+ }
+
+ Bindings.push_back(std::move(binding));
+ }
+
void dump(llvm::raw_ostream &out,
unsigned indent = 0) const LLVM_ATTRIBUTE_USED {
out.indent(indent);
@@ -2682,7 +2721,7 @@
Optional<Type> checkTypeOfBinding(TypeVariableType *typeVar, Type type,
bool *isNilLiteral = nullptr);
- std::pair<PotentialBindings, TypeVariableType *> determineBestBindings();
+ Optional<PotentialBindings> determineBestBindings();
PotentialBindings getPotentialBindings(TypeVariableType *typeVar);
bool
diff --git a/lib/Sema/DerivedConformanceCodable.cpp b/lib/Sema/DerivedConformanceCodable.cpp
index b3a53f1..a0b6b10 100644
--- a/lib/Sema/DerivedConformanceCodable.cpp
+++ b/lib/Sema/DerivedConformanceCodable.cpp
@@ -802,8 +802,7 @@
}
encodeDecl->setInterfaceType(interfaceType);
- encodeDecl->setAccess(std::max(target->getFormalAccess(),
- AccessLevel::Internal));
+ encodeDecl->setAccess(target->getFormalAccess());
// If the type was not imported, the derived conformance is either from the
// type itself or an extension, in which case we will emit the declaration
@@ -1149,8 +1148,7 @@
initDecl->setInterfaceType(interfaceType);
initDecl->setInitializerInterfaceType(initializerType);
- initDecl->setAccess(std::max(target->getFormalAccess(),
- AccessLevel::Internal));
+ initDecl->setAccess(target->getFormalAccess());
// If the type was not imported, the derived conformance is either from the
// type itself or an extension, in which case we will emit the declaration
diff --git a/lib/Sema/DerivedConformanceCodingKey.cpp b/lib/Sema/DerivedConformanceCodingKey.cpp
index f9d0edc..8293912 100644
--- a/lib/Sema/DerivedConformanceCodingKey.cpp
+++ b/lib/Sema/DerivedConformanceCodingKey.cpp
@@ -181,8 +181,7 @@
}
initDecl->setInterfaceType(allocIfaceType);
initDecl->setInitializerInterfaceType(initIfaceType);
- initDecl->setAccess(std::max(AccessLevel::Internal,
- enumDecl->getFormalAccess()));
+ initDecl->setAccess(enumDecl->getFormalAccess());
// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
diff --git a/lib/Sema/DerivedConformanceEquatableHashable.cpp b/lib/Sema/DerivedConformanceEquatableHashable.cpp
index 746edbf..95578b2 100644
--- a/lib/Sema/DerivedConformanceEquatableHashable.cpp
+++ b/lib/Sema/DerivedConformanceEquatableHashable.cpp
@@ -296,11 +296,7 @@
FunctionType::ExtInfo());
}
eqDecl->setInterfaceType(interfaceTy);
-
- // Since we can't insert the == operator into the same FileUnit as the enum,
- // itself, we have to give it at least internal access.
- eqDecl->setAccess(std::max(enumDecl->getFormalAccess(),
- AccessLevel::Internal));
+ copyFormalAccess(eqDecl, enumDecl);
// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
@@ -430,8 +426,7 @@
AnyFunctionType::ExtInfo());
getterDecl->setInterfaceType(interfaceType);
- getterDecl->setAccess(std::max(AccessLevel::Internal,
- enumDecl->getFormalAccess()));
+ copyFormalAccess(getterDecl, enumDecl);
// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
@@ -447,7 +442,7 @@
hashValueDecl->setInterfaceType(intType);
hashValueDecl->makeComputed(SourceLoc(), getterDecl,
nullptr, nullptr, SourceLoc());
- hashValueDecl->setAccess(getterDecl->getFormalAccess());
+ copyFormalAccess(hashValueDecl, enumDecl);
Pattern *hashValuePat = new (C) NamedPattern(hashValueDecl, /*implicit*/true);
hashValuePat->setType(intType);
diff --git a/lib/Sema/DerivedConformanceRawRepresentable.cpp b/lib/Sema/DerivedConformanceRawRepresentable.cpp
index a17f4e6..c3fb22a 100644
--- a/lib/Sema/DerivedConformanceRawRepresentable.cpp
+++ b/lib/Sema/DerivedConformanceRawRepresentable.cpp
@@ -22,6 +22,7 @@
#include "swift/AST/Pattern.h"
#include "swift/AST/ParameterList.h"
#include "swift/AST/Types.h"
+#include "llvm/ADT/APInt.h"
#include "DerivedConformances.h"
using namespace swift;
@@ -194,13 +195,27 @@
}
#endif
+ bool isStringEnum =
+ (rawTy->getNominalOrBoundGenericNominal() == C.getStringDecl());
+ llvm::SmallVector<Expr *, 16> stringExprs;
+
Type enumType = parentDC->getDeclaredTypeInContext();
auto selfDecl = cast<ConstructorDecl>(initDecl)->getImplicitSelfDecl();
SmallVector<ASTNode, 4> cases;
+ unsigned Idx = 0;
for (auto elt : enumDecl->getAllElements()) {
- auto litExpr = cloneRawLiteralExpr(C, elt->getRawValueExpr());
+ LiteralExpr *litExpr = cloneRawLiteralExpr(C, elt->getRawValueExpr());
+ if (isStringEnum) {
+ // In case of a string enum we are calling the _findStringSwitchCase
+ // function from the library and switching on the returned Int value.
+ stringExprs.push_back(litExpr);
+ llvm::SmallString<16> IdxAsStringBuffer;
+ APInt(64, Idx).toStringUnsigned(IdxAsStringBuffer);
+ StringRef IndexAsString(C.AllocateCopy(IdxAsStringBuffer.str()));
+ litExpr = new (C) IntegerLiteralExpr(IndexAsString, SourceLoc());
+ }
auto litPat = new (C) ExprPattern(litExpr, /*isResolved*/ true,
nullptr, nullptr);
litPat->setImplicit();
@@ -225,6 +240,7 @@
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem,
/*HasBoundDecls=*/false, SourceLoc(),
body));
+ Idx++;
}
auto anyPat = new (C) AnyPattern(SourceLoc());
@@ -241,7 +257,22 @@
auto rawDecl = initDecl->getParameterList(1)->get(0);
auto rawRef = new (C) DeclRefExpr(rawDecl, DeclNameLoc(), /*implicit*/true);
- auto switchStmt = SwitchStmt::create(LabeledStmtInfo(), SourceLoc(), rawRef,
+ Expr *switchArg = rawRef;
+ if (isStringEnum) {
+ // Call _findStringSwitchCase with an array of strings as argument.
+ auto *Fun = new (C) UnresolvedDeclRefExpr(
+ C.getIdentifier("_findStringSwitchCase"),
+ DeclRefKind::Ordinary, DeclNameLoc());
+ auto *strArray = ArrayExpr::create(C, SourceLoc(), stringExprs, {},
+ SourceLoc());;
+ Identifier tableId = C.getIdentifier("cases");
+ Identifier strId = C.getIdentifier("string");
+ auto *Args = TupleExpr::createImplicit(C, {strArray, rawRef},
+ {tableId, strId});
+ auto *CallExpr = CallExpr::create(C, Fun, Args, {}, {}, false, false);
+ switchArg = CallExpr;
+ }
+ auto switchStmt = SwitchStmt::create(LabeledStmtInfo(), SourceLoc(), switchArg,
SourceLoc(), cases, SourceLoc(), C);
auto body = BraceStmt::create(C, SourceLoc(),
ASTNode(switchStmt),
@@ -318,8 +349,7 @@
}
initDecl->setInterfaceType(allocIfaceType);
initDecl->setInitializerInterfaceType(initIfaceType);
- initDecl->setAccess(std::max(AccessLevel::Internal,
- enumDecl->getFormalAccess()));
+ copyFormalAccess(initDecl, enumDecl);
// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
diff --git a/lib/Sema/DerivedConformances.cpp b/lib/Sema/DerivedConformances.cpp
index 8506b5a..f3a4033 100644
--- a/lib/Sema/DerivedConformances.cpp
+++ b/lib/Sema/DerivedConformances.cpp
@@ -171,8 +171,7 @@
interfaceType = FunctionType::get({selfParam}, interfaceType,
FunctionType::ExtInfo());
getterDecl->setInterfaceType(interfaceType);
- getterDecl->setAccess(std::max(typeDecl->getFormalAccess(),
- AccessLevel::Internal));
+ copyFormalAccess(getterDecl, typeDecl);
// If the enum was not imported, the derived conformance is either from the
// enum itself or an extension, in which case we will emit the declaration
@@ -202,7 +201,7 @@
propDecl->setImplicit();
propDecl->makeComputed(SourceLoc(), getterDecl, nullptr, nullptr,
SourceLoc());
- propDecl->setAccess(getterDecl->getFormalAccess());
+ copyFormalAccess(propDecl, typeDecl);
propDecl->setInterfaceType(propertyInterfaceType);
// If this is supposed to be a final property, mark it as such.
@@ -225,3 +224,14 @@
return {propDecl, pbDecl};
}
+
+void DerivedConformance::copyFormalAccess(ValueDecl *dest, ValueDecl *source) {
+ dest->setAccess(source->getFormalAccess());
+
+ // Inherit the @_versioned attribute.
+ if (source->getAttrs().hasAttribute<VersionedAttr>()) {
+ auto &ctx = source->getASTContext();
+ auto *clonedAttr = new (ctx) VersionedAttr(/*implicit=*/true);
+ dest->getAttrs().add(clonedAttr);
+ }
+}
diff --git a/lib/Sema/DerivedConformances.h b/lib/Sema/DerivedConformances.h
index 9b56a26..1d78a86 100644
--- a/lib/Sema/DerivedConformances.h
+++ b/lib/Sema/DerivedConformances.h
@@ -145,6 +145,9 @@
/// Build a reference to the 'self' decl of a derived function.
DeclRefExpr *createSelfDeclRef(AbstractFunctionDecl *fn);
+/// Copy access from the source decl to the destination decl.
+void copyFormalAccess(ValueDecl *dest, ValueDecl *source);
+
}
}
diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp
index a0d659f..63d7375 100644
--- a/lib/Sema/TypeCheckAttr.cpp
+++ b/lib/Sema/TypeCheckAttr.cpp
@@ -22,8 +22,8 @@
#include "swift/AST/NameLookup.h"
#include "swift/AST/ParameterList.h"
#include "swift/AST/Types.h"
+#include "swift/ClangImporter/ClangImporter.h"
#include "swift/Parse/Lexer.h"
-#include "swift/ClangImporter/ClangModule.h" // FIXME: SDK overlay semantics
#include "llvm/Support/Debug.h"
using namespace swift;
@@ -1327,19 +1327,7 @@
if (!classDecl)
return false;
- // The class must be defined in Objective-C.
- if (!classDecl->hasClangNode())
- return false;
-
- // Find the Clang module unit that stores the class.
- auto classModuleUnit
- = dyn_cast<ClangModuleUnit>(classDecl->getModuleScopeContext());
- if (!classModuleUnit)
- return false;
-
- // Check whether the extension is in the overlay.
- auto extModule = ext->getDeclContext()->getParentModule();
- return extModule == classModuleUnit->getAdapterModule();
+ return isInOverlayModuleForImportedModule(ext, classDecl);
}
void AttributeChecker::visitRequiredAttr(RequiredAttr *attr) {
diff --git a/lib/Sema/TypeCheckConstraints.cpp b/lib/Sema/TypeCheckConstraints.cpp
index 77b4566..162a3f9 100644
--- a/lib/Sema/TypeCheckConstraints.cpp
+++ b/lib/Sema/TypeCheckConstraints.cpp
@@ -1460,12 +1460,6 @@
expr = UDE->getBase();
} else if (auto SE = dyn_cast<SubscriptExpr>(expr)) {
- if (!TC.Context.LangOpts.EnableExperimentalKeyPathComponents) {
- TC.diagnose(SE->getLoc(),
- diag::expr_swift_keypath_unimplemented_component,
- "subscript");
- }
-
// .[0] or just plain [0]
components.push_back(
KeyPathExpr::Component::forUnresolvedSubscriptWithPrebuiltIndexExpr(
diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp
index a927aa3..6b59ab4 100644
--- a/lib/Sema/TypeCheckDecl.cpp
+++ b/lib/Sema/TypeCheckDecl.cpp
@@ -440,7 +440,7 @@
Type superclassTy;
SourceRange superclassRange;
llvm::SmallSetVector<ProtocolDecl *, 4> allProtocols;
- llvm::SmallDenseMap<CanType, SourceRange> inheritedTypes;
+ llvm::SmallDenseMap<CanType, std::pair<unsigned, SourceRange>> inheritedTypes;
addImplicitConformances(*this, decl, allProtocols);
for (unsigned i = 0, n = inheritedClause.size(); i != n; ++i) {
auto &inherited = inheritedClause[i];
@@ -475,15 +475,33 @@
CanType inheritedCanTy = inheritedTy->getCanonicalType();
auto knownType = inheritedTypes.find(inheritedCanTy);
if (knownType != inheritedTypes.end()) {
+ // If the duplicated type is 'AnyObject', check whether the first was
+ // written as 'class'. Downgrade the error to a warning in such cases
+ // for backward compatibility with Swift <= 4.
+ if (!Context.LangOpts.isSwiftVersionAtLeast(5) &&
+ inheritedTy->isAnyObject() &&
+ (isa<ProtocolDecl>(decl) || isa<AbstractTypeParamDecl>(decl)) &&
+ Lexer::getTokenAtLocation(Context.SourceMgr,
+ knownType->second.second.Start)
+ .is(tok::kw_class)) {
+ SourceLoc classLoc = knownType->second.second.Start;
+ SourceRange removeRange = getRemovalRange(knownType->second.first);
+
+ diagnose(classLoc, diag::duplicate_anyobject_class_inheritance)
+ .fixItRemoveChars(removeRange.Start, removeRange.End);
+ inherited.setInvalidType(Context);
+ continue;
+ }
+
auto removeRange = getRemovalRange(i);
diagnose(inherited.getSourceRange().Start,
diag::duplicate_inheritance, inheritedTy)
.fixItRemoveChars(removeRange.Start, removeRange.End)
- .highlight(knownType->second);
+ .highlight(knownType->second.second);
inherited.setInvalidType(Context);
continue;
}
- inheritedTypes[inheritedCanTy] = inherited.getSourceRange();
+ inheritedTypes[inheritedCanTy] = { i, inherited.getSourceRange() };
// If this is a protocol or protocol composition type, record the
// protocols.
@@ -4103,6 +4121,7 @@
Misc,
GenericTypes,
Classes,
+ ProtocolExtensions
};
auto unimplementedStatic = [&](unsigned diagSel) {
auto staticLoc = PBD->getStaticLoc();
@@ -4120,6 +4139,8 @@
// Stored type variables in a generic context need to logically
// occur once per instantiation, which we don't yet handle.
+ } else if (DC->getAsProtocolExtensionContext()) {
+ unimplementedStatic(ProtocolExtensions);
} else if (DC->isGenericContext()
&& !DC->getGenericSignatureOfContext()->areAllParamsConcrete()) {
unimplementedStatic(GenericTypes);
diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp
index f5687ec..425dc59 100644
--- a/lib/Sema/TypeCheckProtocol.cpp
+++ b/lib/Sema/TypeCheckProtocol.cpp
@@ -5429,9 +5429,9 @@
if (Proto->isSpecificProtocol(KnownProtocolKind::ObjectiveCBridgeable)) {
if (auto nominal = Adoptee->getAnyNominal()) {
if (!TC.Context.isTypeBridgedInExternalModule(nominal)) {
- auto nominalModule = nominal->getParentModule();
- auto conformanceModule = DC->getParentModule();
- if (nominalModule->getName() != conformanceModule->getName()) {
+ if (nominal->getParentModule() != DC->getParentModule() &&
+ !isInOverlayModuleForImportedModule(DC, nominal)) {
+ auto nominalModule = nominal->getParentModule();
TC.diagnose(Loc, diag::nonlocal_bridged_to_objc, nominal->getName(),
Proto->getName(), nominalModule->getName());
}
diff --git a/lib/Sema/TypeCheckStmt.cpp b/lib/Sema/TypeCheckStmt.cpp
index ecd7f5a..4d85138 100644
--- a/lib/Sema/TypeCheckStmt.cpp
+++ b/lib/Sema/TypeCheckStmt.cpp
@@ -1279,14 +1279,6 @@
ParameterList *params,
unsigned &nextArgIndex,
AbstractFunctionDecl *func) {
- // In Swift 4 mode, default argument bodies are inlined into the
- // caller.
- auto expansion = func->getResilienceExpansion();
- if (!tc.Context.isSwiftVersion3() &&
- func->getFormalAccessScope(/*useDC=*/nullptr,
- /*respectVersionedAttr=*/true).isPublic())
- expansion = ResilienceExpansion::Minimal;
-
for (auto ¶m : *params) {
++nextArgIndex;
if (!param->getDefaultValue() || !param->hasType() ||
@@ -1296,9 +1288,6 @@
Expr *e = param->getDefaultValue();
auto initContext = param->getDefaultArgumentInitContext();
- cast<DefaultArgumentInitializer>(initContext)
- ->changeResilienceExpansion(expansion);
-
// Type-check the initializer, then flag that we did so.
auto resultTy = tc.typeCheckExpression(
e, initContext, TypeLoc::withoutLoc(param->getType()),
@@ -1317,6 +1306,24 @@
}
}
+/// Check the default arguments that occur within this pattern.
+static void checkDefaultArguments(TypeChecker &tc,
+ AbstractFunctionDecl *func) {
+ // In Swift 4 mode, default argument bodies are inlined into the
+ // caller.
+ auto expansion = func->getResilienceExpansion();
+ if (!tc.Context.isSwiftVersion3() &&
+ func->getFormalAccessScope(/*useDC=*/nullptr,
+ /*respectVersionedAttr=*/true).isPublic())
+ expansion = ResilienceExpansion::Minimal;
+
+ func->setDefaultArgumentResilienceExpansion(expansion);
+
+ unsigned nextArgIndex = 0;
+ for (auto paramList : func->getParameterLists())
+ checkDefaultArguments(tc, paramList, nextArgIndex, func);
+}
+
bool TypeChecker::typeCheckAbstractFunctionBodyUntil(AbstractFunctionDecl *AFD,
SourceLoc EndTypeCheckLoc) {
validateDecl(AFD);
@@ -1358,10 +1365,7 @@
// named function or an anonymous func expression.
bool TypeChecker::typeCheckFunctionBodyUntil(FuncDecl *FD,
SourceLoc EndTypeCheckLoc) {
- // Check the default argument definitions.
- unsigned nextArgIndex = 0;
- for (auto paramList : FD->getParameterLists())
- checkDefaultArguments(*this, paramList, nextArgIndex, FD);
+ checkDefaultArguments(*this, FD);
// Clang imported inline functions do not have a Swift body to
// typecheck.
@@ -1464,10 +1468,7 @@
bool TypeChecker::typeCheckConstructorBodyUntil(ConstructorDecl *ctor,
SourceLoc EndTypeCheckLoc) {
- // Check the default argument definitions.
- unsigned nextArgIndex = 0;
- for (auto paramList : ctor->getParameterLists())
- checkDefaultArguments(*this, paramList, nextArgIndex, ctor);
+ checkDefaultArguments(*this, ctor);
BraceStmt *body = ctor->getBody();
if (!body)
diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp
index 7003372..9df52e5 100644
--- a/lib/Serialization/Deserialization.cpp
+++ b/lib/Serialization/Deserialization.cpp
@@ -24,6 +24,7 @@
#include "swift/AST/PrettyStackTrace.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/ClangImporter/ClangImporter.h"
+#include "swift/ClangImporter/ClangModule.h"
#include "swift/Serialization/BCReadingExtras.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "swift/Basic/Defer.h"
@@ -1098,6 +1099,23 @@
return None;
}
+/// Determine whether the two modules are re-exported to the same module.
+static bool reExportedToSameModule(const ModuleDecl *fromModule,
+ const ModuleDecl *toModule) {
+ auto fromClangModule
+ = dyn_cast<ClangModuleUnit>(fromModule->getFiles().front());
+ if (!fromClangModule)
+ return false;
+
+ auto toClangModule
+ = dyn_cast<ClangModuleUnit>(toModule->getFiles().front());
+ if (!toClangModule)
+ return false;
+
+ return fromClangModule->getExportedModuleName() ==
+ toClangModule->getExportedModuleName();
+}
+
/// Remove values from \p values that don't match the expected type or module.
///
/// Any of \p expectedTy, \p expectedModule, or \p expectedGenericSig can be
@@ -1130,7 +1148,8 @@
// FIXME: Should be able to move a value from an extension in a derived
// module to the original definition in a base module.
if (expectedModule && !value->hasClangNode() &&
- value->getModuleContext() != expectedModule)
+ value->getModuleContext() != expectedModule &&
+ !reExportedToSameModule(value->getModuleContext(), expectedModule))
return true;
// If we're expecting a member within a constrained extension with a
@@ -1942,6 +1961,17 @@
return None;
}
+static
+Optional<swift::ResilienceExpansion> getActualResilienceExpansion(uint8_t raw) {
+ switch (serialization::ResilienceExpansion(raw)) {
+ case serialization::ResilienceExpansion::Minimal:
+ return swift::ResilienceExpansion::Minimal;
+ case serialization::ResilienceExpansion::Maximal:
+ return swift::ResilienceExpansion::Maximal;
+ }
+ return None;
+}
+
void ModuleFile::configureStorage(AbstractStorageDecl *decl,
unsigned rawStorageKind,
serialization::DeclID getter,
@@ -2570,6 +2600,7 @@
TypeID interfaceID;
DeclID overriddenID;
bool needsNewVTableEntry, firstTimeRequired;
+ uint8_t rawDefaultArgumentResilienceExpansion;
unsigned numArgNames;
ArrayRef<uint64_t> argNameAndDependencyIDs;
@@ -2581,6 +2612,7 @@
overriddenID,
rawAccessLevel,
needsNewVTableEntry,
+ rawDefaultArgumentResilienceExpansion,
firstTimeRequired,
numArgNames,
argNameAndDependencyIDs);
@@ -2687,6 +2719,16 @@
if (auto overriddenCtor = cast_or_null<ConstructorDecl>(overridden.get()))
ctor->setOverriddenDecl(overriddenCtor);
ctor->setNeedsNewVTableEntry(needsNewVTableEntry);
+
+ if (auto defaultArgumentResilienceExpansion = getActualResilienceExpansion(
+ rawDefaultArgumentResilienceExpansion)) {
+ ctor->setDefaultArgumentResilienceExpansion(
+ *defaultArgumentResilienceExpansion);
+ } else {
+ error();
+ return nullptr;
+ }
+
break;
}
@@ -2825,6 +2867,7 @@
DeclID overriddenID;
DeclID accessorStorageDeclID;
bool needsNewVTableEntry;
+ uint8_t rawDefaultArgumentResilienceExpansion;
ArrayRef<uint64_t> nameAndDependencyIDs;
decls_block::FuncLayout::readRecord(scratch, contextID, isImplicit,
@@ -2837,6 +2880,7 @@
numNameComponentsBiased,
rawAddressorKind, rawAccessLevel,
needsNewVTableEntry,
+ rawDefaultArgumentResilienceExpansion,
nameAndDependencyIDs);
// Resolve the name ids.
@@ -2974,6 +3018,16 @@
fn->setImplicit();
fn->setDynamicSelf(hasDynamicSelf);
fn->setNeedsNewVTableEntry(needsNewVTableEntry);
+
+ if (auto defaultArgumentResilienceExpansion = getActualResilienceExpansion(
+ rawDefaultArgumentResilienceExpansion)) {
+ fn->setDefaultArgumentResilienceExpansion(
+ *defaultArgumentResilienceExpansion);
+ } else {
+ error();
+ return nullptr;
+ }
+
break;
}
diff --git a/lib/Serialization/DeserializeSIL.cpp b/lib/Serialization/DeserializeSIL.cpp
index a2a9d23..4000929 100644
--- a/lib/Serialization/DeserializeSIL.cpp
+++ b/lib/Serialization/DeserializeSIL.cpp
@@ -707,7 +707,7 @@
"Expect 5 numbers for SILDeclRef");
SILDeclRef DRef(cast<ValueDecl>(MF->getDecl(ListOfValues[NextIdx])),
(SILDeclRef::Kind)ListOfValues[NextIdx+1],
- (ResilienceExpansion)ListOfValues[NextIdx+2],
+ (swift::ResilienceExpansion)ListOfValues[NextIdx+2],
/*isCurried=*/false, ListOfValues[NextIdx+4] > 0);
if (ListOfValues[NextIdx+3] < DRef.getUncurryLevel())
DRef = DRef.asCurried();
@@ -2106,7 +2106,6 @@
auto valueTy = MF->getType(ListOfValues[nextValue++]);
auto numComponents = ListOfValues[nextValue++];
auto numOperands = ListOfValues[nextValue++];
- assert(numOperands == 0 && "operands not implemented yet");
auto numSubstitutions = ListOfValues[nextValue++];
auto objcString = MF->getIdentifier(ListOfValues[nextValue++]).str();
auto numGenericParams = ListOfValues[nextValue++];
@@ -2118,6 +2117,7 @@
}
SmallVector<KeyPathPatternComponent, 4> components;
+ components.reserve(numComponents);
while (numComponents-- > 0) {
auto kind =
(KeyPathComponentKindEncoding)ListOfValues[nextValue++];
@@ -2142,6 +2142,36 @@
}
};
+ ArrayRef<KeyPathPatternComponent::Index> indices;
+ SILFunction *indicesEquals = nullptr;
+ SILFunction *indicesHash = nullptr;
+
+ auto handleComputedIndices = [&] {
+ SmallVector<KeyPathPatternComponent::Index, 4> indicesBuf;
+ auto numIndexes = ListOfValues[nextValue++];
+ indicesBuf.reserve(numIndexes);
+ while (numIndexes-- > 0) {
+ unsigned operand = ListOfValues[nextValue++];
+ auto formalType = MF->getType(ListOfValues[nextValue++]);
+ auto loweredType = MF->getType(ListOfValues[nextValue++]);
+ auto loweredCategory = (SILValueCategory)ListOfValues[nextValue++];
+ auto conformance = MF->readConformance(SILCursor);
+ indicesBuf.push_back({
+ operand, formalType->getCanonicalType(),
+ SILType::getPrimitiveType(loweredType->getCanonicalType(),
+ loweredCategory),
+ conformance});
+ }
+
+ indices = MF->getContext().AllocateCopy(indicesBuf);
+ if (!indices.empty()) {
+ auto indicesEqualsName = MF->getIdentifier(ListOfValues[nextValue++]);
+ auto indicesHashName = MF->getIdentifier(ListOfValues[nextValue++]);
+ indicesEquals = getFuncForReference(indicesEqualsName.str());
+ indicesHash = getFuncForReference(indicesHashName.str());
+ }
+ };
+
switch (kind) {
case KeyPathComponentKindEncoding::StoredProperty: {
auto decl = cast<VarDecl>(MF->getDecl(ListOfValues[nextValue++]));
@@ -2153,9 +2183,10 @@
auto id = handleComputedId();
auto getterName = MF->getIdentifier(ListOfValues[nextValue++]);
auto getter = getFuncForReference(getterName.str());
+ handleComputedIndices();
components.push_back(
- KeyPathPatternComponent::forComputedGettableProperty(id, getter, {},
- type));
+ KeyPathPatternComponent::forComputedGettableProperty(
+ id, getter, indices, indicesEquals, indicesHash, type));
break;
}
case KeyPathComponentKindEncoding::SettableProperty: {
@@ -2164,10 +2195,10 @@
auto getter = getFuncForReference(getterName.str());
auto setterName = MF->getIdentifier(ListOfValues[nextValue++]);
auto setter = getFuncForReference(setterName.str());
+ handleComputedIndices();
components.push_back(
- KeyPathPatternComponent::forComputedSettableProperty(id,
- getter, setter,
- {}, type));
+ KeyPathPatternComponent::forComputedSettableProperty(
+ id, getter, setter, indices, indicesEquals, indicesHash, type));
break;
}
case KeyPathComponentKindEncoding::OptionalChain:
@@ -2205,7 +2236,18 @@
components,
objcString);
- ResultVal = Builder.createKeyPath(Loc, pattern, substitutions, kpTy);
+ SmallVector<SILValue, 4> operands;
+
+ operands.reserve(numOperands);
+ while (numOperands-- > 0) {
+ auto opValue = ListOfValues[nextValue++];
+ auto opTy = MF->getType(ListOfValues[nextValue++]);
+ auto opCat = (SILValueCategory)ListOfValues[nextValue++];
+ operands.push_back(getLocalValue(opValue, getSILType(opTy, opCat)));
+ }
+
+ ResultVal = Builder.createKeyPath(Loc, pattern,
+ substitutions, operands, kpTy);
break;
}
case ValueKind::MarkUninitializedBehaviorInst:
diff --git a/lib/Serialization/ModuleFile.cpp b/lib/Serialization/ModuleFile.cpp
index b4d1f8a..c8929ed 100644
--- a/lib/Serialization/ModuleFile.cpp
+++ b/lib/Serialization/ModuleFile.cpp
@@ -21,9 +21,9 @@
#include "swift/AST/USRGeneration.h"
#include "swift/Basic/Range.h"
#include "swift/ClangImporter/ClangImporter.h"
+#include "swift/ClangImporter/ClangModule.h"
#include "swift/Serialization/BCReadingExtras.h"
#include "swift/Serialization/SerializedModuleLoader.h"
-
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
@@ -1562,9 +1562,20 @@
}
if (nominal->getParent()->isModuleScopeContext()) {
- Identifier moduleName = nominal->getParentModule()->getName();
+ auto parentModule = nominal->getParentModule();
+ StringRef moduleName = parentModule->getName().str();
+
+ // If the originating module is a private module whose interface is
+ // re-exported via public module, check the name of the public module.
+ std::string exportedModuleName;
+ if (auto clangModuleUnit =
+ dyn_cast<ClangModuleUnit>(parentModule->getFiles().front())) {
+ exportedModuleName = clangModuleUnit->getExportedModuleName();
+ moduleName = exportedModuleName;
+ }
+
for (auto item : *iter) {
- if (item.first != moduleName.str())
+ if (item.first != moduleName)
continue;
Expected<Decl *> declOrError = getDeclChecked(item.second);
if (!declOrError) {
diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp
index 9385ccd..82c443d 100644
--- a/lib/Serialization/Serialization.cpp
+++ b/lib/Serialization/Serialization.cpp
@@ -37,7 +37,6 @@
#include "swift/ClangImporter/ClangModule.h"
#include "swift/Serialization/SerializationOptions.h"
-#include "clang/Basic/Module.h"
// FIXME: We're just using CompilerInstance::createOutputFile.
// This API should be sunk down to LLVM.
#include "clang/Frontend/CompilerInstance.h"
@@ -531,6 +530,16 @@
if (M == clangImporter->getImportedHeaderModule())
return OBJC_HEADER_MODULE_ID;
+ // If we're referring to a member of a private module that will be
+ // re-exported via a public module, record the public module's name.
+ if (auto clangModuleUnit =
+ dyn_cast<ClangModuleUnit>(M->getFiles().front())) {
+ auto exportedModuleName =
+ M->getASTContext().getIdentifier(
+ clangModuleUnit->getExportedModuleName());
+ return addDeclBaseNameRef(exportedModuleName);
+ }
+
assert(!M->getName().empty());
return addDeclBaseNameRef(M->getName());
}
@@ -1005,6 +1014,15 @@
llvm_unreachable("bad addressor kind");
}
+static uint8_t getRawStableResilienceExpansion(swift::ResilienceExpansion e) {
+ switch (e) {
+ case swift::ResilienceExpansion::Minimal:
+ return uint8_t(serialization::ResilienceExpansion::Minimal);
+ case swift::ResilienceExpansion::Maximal:
+ return uint8_t(serialization::ResilienceExpansion::Maximal);
+ }
+}
+
void Serializer::writeParameterList(const ParameterList *PL) {
using namespace decls_block;
@@ -2950,6 +2968,9 @@
uint8_t rawAccessLevel = getRawStableAccessLevel(fn->getFormalAccess());
uint8_t rawAddressorKind =
getRawStableAddressorKind(fn->getAddressorKind());
+ uint8_t rawDefaultArgumentResilienceExpansion =
+ getRawStableResilienceExpansion(
+ fn->getDefaultArgumentResilienceExpansion());
Type ty = fn->getInterfaceType();
for (auto dependency : collectDependenciesFromType(ty->getCanonicalType()))
@@ -2978,6 +2999,7 @@
rawAddressorKind,
rawAccessLevel,
fn->needsNewVTableEntry(),
+ rawDefaultArgumentResilienceExpansion,
nameComponentsAndDependencies);
writeGenericParams(fn->getGenericParams());
@@ -3090,6 +3112,9 @@
nameComponentsAndDependencies.push_back(addTypeRef(dependency));
uint8_t rawAccessLevel = getRawStableAccessLevel(ctor->getFormalAccess());
+ uint8_t rawDefaultArgumentResilienceExpansion =
+ getRawStableResilienceExpansion(
+ ctor->getDefaultArgumentResilienceExpansion());
bool firstTimeRequired = ctor->isRequired();
if (auto *overridden = ctor->getOverriddenDecl())
@@ -3113,6 +3138,7 @@
addDeclRef(ctor->getOverriddenDecl()),
rawAccessLevel,
ctor->needsNewVTableEntry(),
+ rawDefaultArgumentResilienceExpansion,
firstTimeRequired,
ctor->getFullName().getArgumentNames().size(),
nameComponentsAndDependencies);
diff --git a/lib/Serialization/SerializeSIL.cpp b/lib/Serialization/SerializeSIL.cpp
index b8e2ce4..b759524 100644
--- a/lib/Serialization/SerializeSIL.cpp
+++ b/lib/Serialization/SerializeSIL.cpp
@@ -1865,6 +1865,8 @@
ListOfValues.push_back(0);
}
+ SmallVector<ProtocolConformanceRef, 4> hashableConformances;
+
for (auto &component : pattern->getComponents()) {
auto handleComponentCommon = [&](KeyPathComponentKindEncoding kind) {
ListOfValues.push_back((unsigned)kind);
@@ -1889,6 +1891,25 @@
break;
}
};
+ auto handleComputedIndices
+ = [&](const KeyPathPatternComponent &component) {
+ auto indices = component.getComputedPropertyIndices();
+ ListOfValues.push_back(indices.size());
+ for (auto &index : indices) {
+ ListOfValues.push_back(index.Operand);
+ ListOfValues.push_back(S.addTypeRef(index.FormalType));
+ ListOfValues.push_back(
+ S.addTypeRef(index.LoweredType.getSwiftRValueType()));
+ ListOfValues.push_back((unsigned)index.LoweredType.getCategory());
+ hashableConformances.push_back(index.Hashable);
+ }
+ if (!indices.empty()) {
+ ListOfValues.push_back(
+ addSILFunctionRef(component.getComputedPropertyIndexEquals()));
+ ListOfValues.push_back(
+ addSILFunctionRef(component.getComputedPropertyIndexHash()));
+ }
+ };
switch (component.getKind()) {
case KeyPathPatternComponent::Kind::StoredProperty:
@@ -1900,8 +1921,7 @@
handleComputedId(component.getComputedPropertyId());
ListOfValues.push_back(
addSILFunctionRef(component.getComputedPropertyGetter()));
- assert(component.getComputedPropertyIndices().empty()
- && "indices not implemented");
+ handleComputedIndices(component);
break;
case KeyPathPatternComponent::Kind::SettableProperty:
handleComponentCommon(KeyPathComponentKindEncoding::SettableProperty);
@@ -1910,8 +1930,7 @@
addSILFunctionRef(component.getComputedPropertyGetter()));
ListOfValues.push_back(
addSILFunctionRef(component.getComputedPropertySetter()));
- assert(component.getComputedPropertyIndices().empty()
- && "indices not implemented");
+ handleComputedIndices(component);
break;
case KeyPathPatternComponent::Kind::OptionalChain:
handleComponentCommon(KeyPathComponentKindEncoding::OptionalChain);
@@ -1925,12 +1944,21 @@
}
}
- assert(KPI->getAllOperands().empty() && "operands not implemented yet");
+ for (auto &operand : KPI->getAllOperands()) {
+ auto value = operand.get();
+ ListOfValues.push_back(addValueRef(value));
+ ListOfValues.push_back(S.addTypeRef(value->getType().getSwiftRValueType()));
+ ListOfValues.push_back((unsigned)value->getType().getCategory());
+ }
+
SILOneTypeValuesLayout::emitRecord(Out, ScratchRecord,
SILAbbrCodes[SILOneTypeValuesLayout::Code], (unsigned)SI.getKind(),
S.addTypeRef(KPI->getType().getSwiftRValueType()),
(unsigned)KPI->getType().getCategory(),
ListOfValues);
+ for (auto conformance : hashableConformances) {
+ S.writeConformance(conformance, SILAbbrCodes);
+ }
S.writeGenericRequirements(reqts, SILAbbrCodes);
S.writeSubstitutions(KPI->getSubstitutions(), SILAbbrCodes);
diff --git a/lib/Serialization/SerializedModuleLoader.cpp b/lib/Serialization/SerializedModuleLoader.cpp
index 7eecc56..09aa5f8 100644
--- a/lib/Serialization/SerializedModuleLoader.cpp
+++ b/lib/Serialization/SerializedModuleLoader.cpp
@@ -614,7 +614,7 @@
return File.getModuleFilename();
}
-const clang::Module *SerializedASTFile::getUnderlyingClangModule() {
+const clang::Module *SerializedASTFile::getUnderlyingClangModule() const {
if (auto *ShadowedModule = File.getShadowedModule())
return ShadowedModule->findUnderlyingClangModule();
return nullptr;
diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb
index 59c6bfd..89d2303 100644
--- a/stdlib/public/Platform/glibc.modulemap.gyb
+++ b/stdlib/public/Platform/glibc.modulemap.gyb
@@ -428,6 +428,12 @@
export *
}
}
+% if CMAKE_SDK in ["LINUX", "FREEBSD"]:
+ module sysexits {
+ header "${GLIBC_INCLUDE_PATH}/sysexits.h"
+ export *
+ }
+% end
module termios {
header "${GLIBC_INCLUDE_PATH}/termios.h"
export *
diff --git a/stdlib/public/SDK/Foundation/Data.swift b/stdlib/public/SDK/Foundation/Data.swift
index cb5391b..99bb93f 100644
--- a/stdlib/public/SDK/Foundation/Data.swift
+++ b/stdlib/public/SDK/Foundation/Data.swift
@@ -27,6 +27,10 @@
internal func __NSDataInvokeDeallocatorFree(_ mem: UnsafeMutableRawPointer, _ length: Int) {
free(mem)
}
+
+internal func __NSDataIsCompact(_ data: NSData) -> Bool {
+ return data._isCompact()
+}
#else
@@ -98,47 +102,140 @@
public var _needToZero: Bool
public var _deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?
public var _backing: Backing = .swift
+ public var _offset: Int
public var bytes: UnsafeRawPointer? {
@inline(__always)
get {
switch _backing {
case .swift:
- return UnsafeRawPointer(_bytes)
+ return UnsafeRawPointer(_bytes)?.advanced(by: -_offset)
case .immutable:
- return UnsafeRawPointer(_bytes)
+ return UnsafeRawPointer(_bytes)?.advanced(by: -_offset)
case .mutable:
- return UnsafeRawPointer(_bytes)
+ return UnsafeRawPointer(_bytes)?.advanced(by: -_offset)
case .customReference(let d):
- return d.bytes
+ return d.bytes.advanced(by: -_offset)
case .customMutableReference(let d):
- return d.bytes
+ return d.bytes.advanced(by: -_offset)
+ }
+ }
+ }
+
+ @discardableResult
+ public func withUnsafeBytes<Result>(in range: Range<Int>, apply: (UnsafeRawBufferPointer) throws -> Result) rethrows -> Result {
+ switch _backing {
+ case .swift: fallthrough
+ case .immutable: fallthrough
+ case .mutable:
+ return try apply(UnsafeRawBufferPointer(start: _bytes?.advanced(by: range.lowerBound - _offset), count: Swift.min(range.count, _length)))
+ case .customReference(let d):
+ if d._isCompact() {
+ let len = d.length
+ guard len > 0 else {
+ return try apply(UnsafeRawBufferPointer(start: nil, count: 0))
+ }
+ return try apply(UnsafeRawBufferPointer(start: d.bytes.advanced(by: range.lowerBound - _offset), count: Swift.min(range.count, len)))
+ } else {
+ var buffer = UnsafeMutableRawBufferPointer.allocate(count: range.count)
+ defer { buffer.deallocate() }
+ let sliceRange = NSRange(location: range.lowerBound - _offset, length: range.count)
+ var enumerated = 0
+ d.enumerateBytes { (ptr, byteRange, stop) in
+ if NSIntersectionRange(sliceRange, byteRange).length > 0 {
+ let lower = Swift.max(byteRange.location, sliceRange.location)
+ let upper = Swift.min(byteRange.location + byteRange.length, sliceRange.location + sliceRange.length)
+ let offset = lower - byteRange.location
+ let effectiveRange = NSRange(location: lower, length: upper - lower)
+ if effectiveRange == sliceRange {
+ memcpy(buffer.baseAddress!, ptr, effectiveRange.length)
+ stop.pointee = true
+ } else {
+ memcpy(buffer.baseAddress!.advanced(by: enumerated), ptr, effectiveRange.length)
+ }
+ enumerated += byteRange.length
+ } else if sliceRange.location + sliceRange.length < byteRange.location {
+ stop.pointee = true
+ }
+ }
+ return try apply(UnsafeRawBufferPointer(buffer))
+ }
+ case .customMutableReference(let d):
+ if d._isCompact() {
+ let len = d.length
+ guard len > 0 else {
+ return try apply(UnsafeRawBufferPointer(start: nil, count: 0))
+ }
+ return try apply(UnsafeRawBufferPointer(start: d.bytes.advanced(by: range.lowerBound - _offset), count: Swift.min(range.count, len)))
+ } else {
+ var buffer = UnsafeMutableRawBufferPointer.allocate(count: range.count)
+ defer { buffer.deallocate() }
+ let sliceRange = NSRange(location: range.lowerBound - _offset, length: range.count)
+ var enumerated = 0
+ d.enumerateBytes { (ptr, byteRange, stop) in
+ if NSIntersectionRange(sliceRange, byteRange).length > 0 {
+ let lower = Swift.max(byteRange.location, sliceRange.location)
+ let upper = Swift.min(byteRange.location + byteRange.length, sliceRange.location + sliceRange.length)
+ let effectiveRange = NSRange(location: lower, length: upper - lower)
+ if effectiveRange == sliceRange {
+ memcpy(buffer.baseAddress!, ptr, effectiveRange.length)
+ stop.pointee = true
+ } else {
+ memcpy(buffer.baseAddress!.advanced(by: enumerated), ptr, effectiveRange.length)
+ }
+ enumerated += byteRange.length
+ } else if sliceRange.location + sliceRange.length < byteRange.location {
+ stop.pointee = true
+ }
+ }
+ return try apply(UnsafeRawBufferPointer(buffer))
}
}
}
+ @discardableResult
+ public func withUnsafeMutableBytes<Result>(in range: Range<Int>, apply: (UnsafeMutableRawBufferPointer) throws -> Result) rethrows -> Result {
+ switch _backing {
+ case .swift: fallthrough
+ case .mutable:
+ return try apply(UnsafeMutableRawBufferPointer(start: _bytes!.advanced(by:range.lowerBound - _offset), count: Swift.min(range.count, _length - range.lowerBound)))
+ case .customMutableReference(let d):
+ let len = d.length
+ return try apply(UnsafeMutableRawBufferPointer(start: d.mutableBytes.advanced(by:range.lowerBound - _offset), count: Swift.min(range.count, len - range.lowerBound)))
+ case .immutable(let d):
+ let data = d.mutableCopy() as! NSMutableData
+ _backing = .mutable(data)
+ _bytes = data.mutableBytes
+ return try apply(UnsafeMutableRawBufferPointer(start: _bytes!.advanced(by:range.lowerBound - _offset), count: Swift.min(range.count, _length - range.lowerBound)))
+ case .customReference(let d):
+ let data = d.mutableCopy() as! NSMutableData
+ _backing = .customMutableReference(data)
+ let len = data.length
+ return try apply(UnsafeMutableRawBufferPointer(start: data.mutableBytes.advanced(by:range.lowerBound - _offset), count: Swift.min(range.count, len - range.lowerBound)))
+ }
+ }
+
public var mutableBytes: UnsafeMutableRawPointer? {
@inline(__always)
get {
switch _backing {
case .swift:
- return _bytes
+ return _bytes?.advanced(by: -_offset)
case .immutable(let d):
let data = d.mutableCopy() as! NSMutableData
data.length = length
_backing = .mutable(data)
_bytes = data.mutableBytes
- return data.mutableBytes
+ return _bytes?.advanced(by: -_offset)
case .mutable:
- return _bytes
+ return _bytes?.advanced(by: -_offset)
case .customReference(let d):
let data = d.mutableCopy() as! NSMutableData
data.length = length
_backing = .customMutableReference(data)
- _bytes = data.mutableBytes
- return data.mutableBytes
+ return data.mutableBytes.advanced(by: -_offset)
case .customMutableReference(let d):
- return d.mutableBytes
+ return d.mutableBytes.advanced(by: -_offset)
}
}
}
@@ -176,32 +273,34 @@
}
}
- public func enumerateBytes(_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Data.Index, _ stop: inout Bool) -> Void) {
- var stop: Bool = false
+ public func enumerateBytes(in range: Range<Int>, _ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Data.Index, _ stop: inout Bool) -> Void) {
+ var stopv: Bool = false
+ var data: NSData
switch _backing {
- case .swift:
- block(UnsafeBufferPointer<UInt8>(start: _bytes?.assumingMemoryBound(to: UInt8.self), count: _length), 0, &stop)
- case .immutable:
- block(UnsafeBufferPointer<UInt8>(start: _bytes?.assumingMemoryBound(to: UInt8.self), count: _length), 0, &stop)
- case .mutable:
- block(UnsafeBufferPointer<UInt8>(start: _bytes?.assumingMemoryBound(to: UInt8.self), count: _length), 0, &stop)
+ case .swift: fallthrough
+ case .immutable: fallthrough
+ case .mutable:
+ block(UnsafeBufferPointer<UInt8>(start: _bytes?.advanced(by: range.lowerBound - _offset).assumingMemoryBound(to: UInt8.self), count: Swift.min(range.count, _length)), 0, &stopv)
+ return
case .customReference(let d):
- d.enumerateBytes { (ptr, range, stop) in
- var stopv = false
- let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: range.length)
- block(UnsafeBufferPointer(start: bytePtr, count: range.length), range.location, &stopv)
- if stopv {
- stop.pointee = true
- }
- }
+ data = d
+ break
case .customMutableReference(let d):
- d.enumerateBytes { (ptr, range, stop) in
- var stopv = false
- let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: range.length)
- block(UnsafeBufferPointer(start: bytePtr, count: range.length), range.location, &stopv)
- if stopv {
- stop.pointee = true
- }
+ data = d
+ break
+ }
+ data.enumerateBytes { (ptr, region, stop) in
+ // any region that is not in the range should be skipped
+ guard range.contains(region.lowerBound) || range.contains(region.upperBound) else { return }
+ var regionAdjustment = 0
+ if region.lowerBound < range.lowerBound {
+ regionAdjustment = range.lowerBound - (region.lowerBound - _offset)
+ }
+ let bytePtr = ptr.advanced(by: regionAdjustment).assumingMemoryBound(to: UInt8.self)
+ let effectiveLength = Swift.min((region.location - _offset) + region.length, range.upperBound) - (region.location - _offset)
+ block(UnsafeBufferPointer(start: bytePtr, count: effectiveLength - regionAdjustment), region.location + regionAdjustment - _offset, &stopv)
+ if stopv {
+ stop.pointee = true
}
}
}
@@ -319,7 +418,7 @@
@inline(__always)
public func append(_ bytes: UnsafeRawPointer, length: Int) {
- precondition(length >= 0, "Length of appending bytes must be positive")
+ precondition(length >= 0, "Length of appending bytes must not be negative")
switch _backing {
case .swift:
let origLength = _length
@@ -398,6 +497,43 @@
}
}
+
+ public func get(_ index: Int) -> UInt8 {
+ switch _backing {
+ case .swift: fallthrough
+ case .immutable: fallthrough
+ case .mutable:
+ return _bytes!.advanced(by: index - _offset).assumingMemoryBound(to: UInt8.self).pointee
+ case .customReference(let d):
+ if d._isCompact() {
+ return d.bytes.advanced(by: index - _offset).assumingMemoryBound(to: UInt8.self).pointee
+ } else {
+ var byte: UInt8 = 0
+ d.enumerateBytes { (ptr, range, stop) in
+ if NSLocationInRange(index, range) {
+ let offset = index - range.location - _offset
+ byte = ptr.advanced(by: offset).assumingMemoryBound(to: UInt8.self).pointee
+ stop.pointee = true
+ }
+ }
+ return byte
+ }
+ case .customMutableReference(let d):
+ if d._isCompact() {
+ return d.bytes.advanced(by: index - _offset).assumingMemoryBound(to: UInt8.self).pointee
+ } else {
+ var byte: UInt8 = 0
+ d.enumerateBytes { (ptr, range, stop) in
+ if NSLocationInRange(index, range) {
+ let offset = index - range.location - _offset
+ byte = ptr.advanced(by: offset).assumingMemoryBound(to: UInt8.self).pointee
+ stop.pointee = true
+ }
+ }
+ return byte
+ }
+ }
+ }
@inline(__always)
public func set(_ index: Int, to value: UInt8) {
@@ -405,7 +541,7 @@
case .swift:
fallthrough
case .mutable:
- _bytes!.advanced(by: index).assumingMemoryBound(to: UInt8.self).pointee = value
+ _bytes!.advanced(by: index - _offset).assumingMemoryBound(to: UInt8.self).pointee = value
default:
var theByte = value
let range = NSRange(location: index, length: 1)
@@ -427,28 +563,29 @@
}
_length = newLength
}
- _DataStorage.move(_bytes!.advanced(by: range.location), bytes!, range.length)
+ _DataStorage.move(_bytes!.advanced(by: range.location - _offset), bytes!, range.length)
case .immutable(let d):
let data = d.mutableCopy() as! NSMutableData
- data.replaceBytes(in: range, withBytes: bytes!)
+ data.replaceBytes(in: NSRange(location: range.location - _offset, length: range.length), withBytes: bytes!)
_backing = .mutable(data)
_length = data.length
_bytes = data.mutableBytes
case .mutable(let d):
- d.replaceBytes(in: range, withBytes: bytes!)
+ d.replaceBytes(in: NSRange(location: range.location - _offset, length: range.length), withBytes: bytes!)
_length = d.length
_bytes = d.mutableBytes
case .customReference(let d):
let data = d.mutableCopy() as! NSMutableData
- data.replaceBytes(in: range, withBytes: bytes!)
+ data.replaceBytes(in: NSRange(location: range.location - _offset, length: range.length), withBytes: bytes!)
_backing = .customMutableReference(data)
case .customMutableReference(let d):
- d.replaceBytes(in: range, withBytes: bytes!)
+ d.replaceBytes(in: NSRange(location: range.location - _offset, length: range.length), withBytes: bytes!)
}
}
@inline(__always)
- public func replaceBytes(in range: NSRange, with replacementBytes: UnsafeRawPointer?, length replacementLength: Int) {
+ public func replaceBytes(in range_: NSRange, with replacementBytes: UnsafeRawPointer?, length replacementLength: Int) {
+ let range = NSRange(location: range_.location - _offset, length: range_.length)
let currentLength = _length
let resultingLength = currentLength - range.length + replacementLength
switch _backing {
@@ -497,7 +634,8 @@
}
@inline(__always)
- public func resetBytes(in range: NSRange) {
+ public func resetBytes(in range_: NSRange) {
+ let range = NSRange(location: range_.location - _offset, length: range_.length)
if range.length == 0 { return }
switch _backing {
case .swift:
@@ -546,6 +684,7 @@
_capacity = capacity
_needToZero = !clear
_length = 0
+ _offset = 0
setLength(length)
}
@@ -560,10 +699,12 @@
_bytes = _DataStorage.allocate(capacity, false)!
_capacity = capacity
_needToZero = true
+ _offset = 0
}
public init(bytes: UnsafeRawPointer?, length: Int) {
precondition(length < _DataStorage.maxSize)
+ _offset = 0
if length == 0 {
_capacity = 0
_length = 0
@@ -588,8 +729,9 @@
}
}
- public init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?) {
+ public init(bytes: UnsafeMutableRawPointer?, length: Int, copy: Bool, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?, offset: Int) {
precondition(length < _DataStorage.maxSize)
+ _offset = offset
if length == 0 {
_capacity = 0
_length = 0
@@ -630,7 +772,8 @@
}
}
- public init(immutableReference: NSData) {
+ public init(immutableReference: NSData, offset: Int) {
+ _offset = offset
_bytes = UnsafeMutableRawPointer(mutating: immutableReference.bytes)
_capacity = 0
_needToZero = false
@@ -638,7 +781,8 @@
_backing = .immutable(immutableReference)
}
- public init(mutableReference: NSMutableData) {
+ public init(mutableReference: NSMutableData, offset: Int) {
+ _offset = offset
_bytes = mutableReference.mutableBytes
_capacity = 0
_needToZero = false
@@ -646,7 +790,8 @@
_backing = .mutable(mutableReference)
}
- public init(customReference: NSData) {
+ public init(customReference: NSData, offset: Int) {
+ _offset = offset
_bytes = nil
_capacity = 0
_needToZero = false
@@ -654,7 +799,8 @@
_backing = .customReference(customReference)
}
- public init(customMutableReference: NSMutableData) {
+ public init(customMutableReference: NSMutableData, offset: Int) {
+ _offset = offset
_bytes = nil
_capacity = 0
_needToZero = false
@@ -675,30 +821,30 @@
public func mutableCopy(_ range: Range<Int>) -> _DataStorage {
switch _backing {
case .swift:
- return _DataStorage(bytes: _bytes?.advanced(by: range.lowerBound), length: range.count, copy: true, deallocator: nil)
+ return _DataStorage(bytes: _bytes?.advanced(by: range.lowerBound - _offset), length: range.count, copy: true, deallocator: nil, offset: range.lowerBound)
case .immutable(let d):
if range.lowerBound == 0 && range.upperBound == _length {
- return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData, offset: range.lowerBound)
} else {
- return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData, offset: range.lowerBound)
}
case .mutable(let d):
if range.lowerBound == 0 && range.upperBound == _length {
- return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData, offset: range.lowerBound)
} else {
- return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData, offset: range.lowerBound)
}
case .customReference(let d):
if range.lowerBound == 0 && range.upperBound == _length {
- return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData, offset: range.lowerBound)
} else {
- return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData, offset: range.lowerBound)
}
case .customMutableReference(let d):
if range.lowerBound == 0 && range.upperBound == _length {
- return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.mutableCopy() as! NSMutableData, offset: range.lowerBound)
} else {
- return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData)
+ return _DataStorage(mutableReference: d.subdata(with: NSRange(location: range.lowerBound, length: range.count))._bridgeToObjectiveC().mutableCopy() as! NSMutableData, offset: range.lowerBound)
}
}
}
@@ -710,26 +856,26 @@
switch _backing {
case .swift:
- return try work(NSData(bytesNoCopy: _bytes!.advanced(by: range.lowerBound), length: range.count, freeWhenDone: false))
+ return try work(NSData(bytesNoCopy: _bytes!.advanced(by: range.lowerBound - _offset), length: range.count, freeWhenDone: false))
case .immutable(let d):
guard range.lowerBound == 0 && range.upperBound == _length else {
- return try work(NSData(bytesNoCopy: _bytes!.advanced(by: range.lowerBound), length: range.count, freeWhenDone: false))
+ return try work(NSData(bytesNoCopy: _bytes!.advanced(by: range.lowerBound - _offset), length: range.count, freeWhenDone: false))
}
return try work(d)
case .mutable(let d):
guard range.lowerBound == 0 && range.upperBound == _length else {
- return try work(NSData(bytesNoCopy: _bytes!.advanced(by: range.lowerBound), length: range.count, freeWhenDone: false))
+ return try work(NSData(bytesNoCopy: _bytes!.advanced(by: range.lowerBound - _offset), length: range.count, freeWhenDone: false))
}
return try work(d)
case .customReference(let d):
guard range.lowerBound == 0 && range.upperBound == _length else {
- return try work(NSData(bytesNoCopy: UnsafeMutableRawPointer(mutating: d.bytes.advanced(by: range.lowerBound)), length: range.count, freeWhenDone: false))
+ return try work(NSData(bytesNoCopy: UnsafeMutableRawPointer(mutating: d.bytes.advanced(by: range.lowerBound - _offset)), length: range.count, freeWhenDone: false))
}
return try work(d)
case .customMutableReference(let d):
guard range.lowerBound == 0 && range.upperBound == _length else {
- return try work(NSData(bytesNoCopy: UnsafeMutableRawPointer(mutating: d.bytes.advanced(by: range.lowerBound)), length: range.count, freeWhenDone: false))
+ return try work(NSData(bytesNoCopy: UnsafeMutableRawPointer(mutating: d.bytes.advanced(by: range.lowerBound - _offset)), length: range.count, freeWhenDone: false))
}
return try work(d)
}
@@ -766,26 +912,14 @@
}
}
- public var hashValue: Int {
- switch _backing {
- case .customReference(let d):
- return d.hash
- case .customMutableReference(let d):
- return d.hash
- default:
- let len = _length
- return Int(bitPattern: CFHashBytes(_bytes?.assumingMemoryBound(to: UInt8.self), Swift.min(len, 80)))
- }
- }
-
public func subdata(in range: Range<Data.Index>) -> Data {
switch _backing {
case .customReference(let d):
- return d.subdata(with: NSRange(location: range.lowerBound, length: range.count))
+ return d.subdata(with: NSRange(location: range.lowerBound - _offset, length: range.count))
case .customMutableReference(let d):
- return d.subdata(with: NSRange(location: range.lowerBound, length: range.count))
+ return d.subdata(with: NSRange(location: range.lowerBound - _offset, length: range.count))
default:
- return Data(bytes: _bytes!.advanced(by: range.lowerBound), count: range.count)
+ return Data(bytes: _bytes!.advanced(by: range.lowerBound - _offset), count: range.count)
}
}
}
@@ -827,7 +961,7 @@
}
#if !DEPLOYMENT_RUNTIME_SWIFT
- @objc
+ @objc override
func _isCompact() -> Bool {
return true
}
@@ -1015,7 +1149,7 @@
/// - parameter deallocator: Specifies the mechanism to free the indicated buffer, or `.none`.
public init(bytesNoCopy bytes: UnsafeMutableRawPointer, count: Int, deallocator: Deallocator) {
let whichDeallocator = deallocator._deallocator
- _backing = _DataStorage(bytes: bytes, length: count, copy: false, deallocator: whichDeallocator)
+ _backing = _DataStorage(bytes: bytes, length: count, copy: false, deallocator: whichDeallocator, offset: 0)
_sliceRange = 0..<count
}
@@ -1026,7 +1160,7 @@
/// - throws: An error in the Cocoa domain, if `url` cannot be read.
public init(contentsOf url: URL, options: Data.ReadingOptions = []) throws {
let d = try NSData(contentsOf: url, options: ReadingOptions(rawValue: options.rawValue))
- _backing = _DataStorage(immutableReference: d)
+ _backing = _DataStorage(immutableReference: d, offset: 0)
_sliceRange = 0..<d.length
}
@@ -1037,7 +1171,7 @@
/// - parameter options: Encoding options. Default value is `[]`.
public init?(base64Encoded base64String: String, options: Data.Base64DecodingOptions = []) {
if let d = NSData(base64Encoded: base64String, options: Base64DecodingOptions(rawValue: options.rawValue)) {
- _backing = _DataStorage(immutableReference: d)
+ _backing = _DataStorage(immutableReference: d, offset: 0)
_sliceRange = 0..<d.length
} else {
return nil
@@ -1052,7 +1186,7 @@
/// - parameter options: Decoding options. Default value is `[]`.
public init?(base64Encoded base64Data: Data, options: Data.Base64DecodingOptions = []) {
if let d = NSData(base64Encoded: base64Data, options: Base64DecodingOptions(rawValue: options.rawValue)) {
- _backing = _DataStorage(immutableReference: d)
+ _backing = _DataStorage(immutableReference: d, offset: 0)
_sliceRange = 0..<d.length
} else {
return nil
@@ -1073,10 +1207,10 @@
let providesConcreteBacking = (reference as AnyObject)._providesConcreteBacking?() ?? false
#endif
if providesConcreteBacking {
- _backing = _DataStorage(immutableReference: reference.copy() as! NSData)
+ _backing = _DataStorage(immutableReference: reference.copy() as! NSData, offset: 0)
_sliceRange = 0..<reference.length
} else {
- _backing = _DataStorage(customReference: reference.copy() as! NSData)
+ _backing = _DataStorage(customReference: reference.copy() as! NSData, offset: 0)
_sliceRange = 0..<reference.length
}
@@ -1094,7 +1228,11 @@
} else if let buffer = elements as? UnsafeMutableBufferPointer<UInt8> {
self.init(buffer: buffer)
} else if let data = elements as? Data {
- self.init(backing: data._backing.mutableCopy(data._sliceRange), range: 0..<data.count)
+ let len = data.count
+ let backing = data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) in
+ return _DataStorage(bytes: bytes, length: len)
+ }
+ self.init(backing: backing, range: 0..<len)
} else {
let underestimatedCount = elements.underestimatedCount
self.init(count: underestimatedCount)
@@ -1137,7 +1275,7 @@
}
@inline(__always)
set {
- precondition(count >= 0, "Count must be positive")
+ precondition(count >= 0, "count must not be negative")
if !isKnownUniquelyReferenced(&_backing) {
_backing = _backing.mutableCopy(_sliceRange)
}
@@ -1151,9 +1289,9 @@
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
@inline(__always)
public func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
- let bytes = _backing.bytes?.advanced(by: _sliceRange.lowerBound) ?? UnsafeRawPointer(bitPattern: 0xBAD0)!
- let contentPtr = bytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
- return try body(contentPtr)
+ return try _backing.withUnsafeBytes(in: _sliceRange) {
+ return try body($0.baseAddress?.assumingMemoryBound(to: ContentType.self) ?? UnsafePointer<ContentType>(bitPattern: 0xBAD0)!)
+ }
}
@@ -1166,9 +1304,9 @@
if !isKnownUniquelyReferenced(&_backing) {
_backing = _backing.mutableCopy(_sliceRange)
}
- let mutableBytes = _backing.mutableBytes?.advanced(by: _sliceRange.lowerBound) ?? UnsafeMutableRawPointer(bitPattern: 0xBAD0)!
- let contentPtr = mutableBytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
- return try body(UnsafeMutablePointer(contentPtr))
+ return try _backing.withUnsafeMutableBytes(in: _sliceRange) {
+ return try body($0.baseAddress?.assumingMemoryBound(to: ContentType.self) ?? UnsafeMutablePointer<ContentType>(bitPattern: 0xBAD0)!)
+ }
}
// MARK: -
@@ -1181,15 +1319,19 @@
/// - warning: This method does not verify that the contents at pointer have enough space to hold `count` bytes.
@inline(__always)
public func copyBytes(to pointer: UnsafeMutablePointer<UInt8>, count: Int) {
- precondition(count >= 0, "Count of bytes to copy must be positive")
+ precondition(count >= 0, "count of bytes to copy must not be negative")
if count == 0 { return }
- memcpy(UnsafeMutableRawPointer(pointer), _backing.bytes!.advanced(by: _sliceRange.lowerBound), Swift.min(count, _sliceRange.count))
+ _backing.withUnsafeBytes(in: _sliceRange) {
+ memcpy(UnsafeMutableRawPointer(pointer), $0.baseAddress!, Swift.min(count, $0.count))
+ }
}
@inline(__always)
private func _copyBytesHelper(to pointer: UnsafeMutableRawPointer, from range: NSRange) {
if range.length == 0 { return }
- memcpy(UnsafeMutableRawPointer(pointer), _backing.bytes!.advanced(by: range.location), Swift.min(range.length, _sliceRange.count))
+ _backing.withUnsafeBytes(in: range.lowerBound..<range.upperBound) {
+ memcpy(UnsafeMutableRawPointer(pointer), $0.baseAddress!, Swift.min(range.length, $0.count))
+ }
}
/// Copy a subset of the contents of the data to a pointer.
@@ -1297,27 +1439,20 @@
/// In some cases, (for example, a `Data` backed by a `dispatch_data_t`, the bytes may be stored discontiguously. In those cases, this function invokes the closure for each contiguous region of bytes.
/// - parameter block: The closure to invoke for each region of data. You may stop the enumeration by setting the `stop` parameter to `true`.
public func enumerateBytes(_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
- _backing.enumerateBytes(block)
+ _backing.enumerateBytes(in: _sliceRange, block)
}
@inline(__always)
public mutating func append(_ bytes: UnsafePointer<UInt8>, count: Int) {
- precondition(count >= 0, "Count must be positive")
if count == 0 { return }
- if !isKnownUniquelyReferenced(&_backing) {
- _backing = _backing.mutableCopy(_sliceRange)
- }
- _backing.append(bytes, length: count)
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.upperBound + count)
+ append(UnsafeBufferPointer(start: bytes, count: count))
}
@inline(__always)
public mutating func append(_ other: Data) {
- if !isKnownUniquelyReferenced(&_backing) {
- _backing = _backing.mutableCopy(_sliceRange)
+ other.enumerateBytes { (buffer, _, _) in
+ append(buffer)
}
- _backing.append(other._backing, startingAt: other._sliceRange.lowerBound, endingAt: other._sliceRange.upperBound)
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.upperBound + other.count)
}
/// Append a buffer of bytes to the data.
@@ -1329,22 +1464,26 @@
if !isKnownUniquelyReferenced(&_backing) {
_backing = _backing.mutableCopy(_sliceRange)
}
- _backing.append(buffer.baseAddress!, length: buffer.count * MemoryLayout<SourceType>.stride)
+ _backing.replaceBytes(in: NSRange(location: _sliceRange.upperBound, length: _backing.length - (_sliceRange.upperBound - _backing._offset)), with: buffer.baseAddress, length: buffer.count * MemoryLayout<SourceType>.stride)
_sliceRange = _sliceRange.lowerBound..<(_sliceRange.upperBound + buffer.count * MemoryLayout<SourceType>.stride)
}
@inline(__always)
public mutating func append<S : Sequence>(contentsOf newElements: S) where S.Iterator.Element == Iterator.Element {
let estimatedCount = newElements.underestimatedCount
- var idx = count
- count += estimatedCount
- for byte in newElements {
- let newIndex = idx + 1
- if newIndex > count {
- count = newIndex
+ guard estimatedCount > 0 else {
+ for byte in newElements {
+ append(byte)
}
- self[idx] = byte
- idx = newIndex
+ return
+ }
+ _withStackOrHeapBuffer(estimatedCount) { allocation in
+ let buffer = UnsafeMutableBufferPointer(start: allocation.pointee.memory.assumingMemoryBound(to: UInt8.self), count: estimatedCount)
+ var (iterator, endPoint) = newElements._copyContents(initializing: buffer)
+ append(buffer.baseAddress!, count: endPoint - buffer.startIndex)
+ while let byte = iterator.next() {
+ append(byte)
+ }
}
}
@@ -1364,16 +1503,15 @@
@inline(__always)
public mutating func resetBytes(in range: Range<Index>) {
// it is worth noting that the range here may be out of bounds of the Data itself (which triggers a growth)
- precondition(range.lowerBound >= 0, "Ranges must be positive bounds")
- precondition(range.upperBound >= 0, "Ranges must be positive bounds")
+ precondition(range.lowerBound >= 0, "Ranges must not be negative bounds")
+ precondition(range.upperBound >= 0, "Ranges must not be negative bounds")
let range = NSMakeRange(range.lowerBound, range.upperBound - range.lowerBound)
if !isKnownUniquelyReferenced(&_backing) {
_backing = _backing.mutableCopy(_sliceRange)
}
_backing.resetBytes(in: range)
- if _sliceRange.count < range.location + range.length {
- let newLength = range.location + range.length
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.lowerBound + newLength)
+ if _sliceRange.upperBound < range.upperBound {
+ _sliceRange = _sliceRange.lowerBound..<range.upperBound
}
}
@@ -1386,34 +1524,16 @@
/// - parameter data: The replacement data.
@inline(__always)
public mutating func replaceSubrange(_ subrange: Range<Index>, with data: Data) {
- _validateRange(subrange)
- let nsRange = NSMakeRange(subrange.lowerBound, subrange.upperBound - subrange.lowerBound)
let cnt = data.count
- if !isKnownUniquelyReferenced(&_backing) {
- _backing = _backing.mutableCopy(_sliceRange)
+ data.withUnsafeBytes {
+ replaceSubrange(subrange, with: $0, count: cnt)
}
- let resultingLength = data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Int in
- let currentLength = _backing.length
- _backing.replaceBytes(in: nsRange, with: bytes, length: cnt)
- return currentLength - nsRange.length + cnt
- }
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.lowerBound + resultingLength)
}
@inline(__always)
public mutating func replaceSubrange(_ subrange: CountableRange<Index>, with data: Data) {
- _validateRange(subrange)
- let nsRange = NSMakeRange(subrange.lowerBound, subrange.upperBound - subrange.lowerBound)
- let cnt = data.count
- if !isKnownUniquelyReferenced(&_backing) {
- _backing = _backing.mutableCopy(_sliceRange)
- }
- let resultingLength = data.withUnsafeBytes { (bytes: UnsafePointer<UInt8>) -> Int in
- let currentLength = _backing.length
- _backing.replaceBytes(in: nsRange, with: bytes, length: cnt)
- return currentLength - nsRange.length + cnt
- }
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.lowerBound + resultingLength)
+ let range: Range<Int> = subrange.lowerBound..<subrange.upperBound
+ replaceSubrange(range, with: data)
}
/// Replace a region of bytes in the data with new bytes from a buffer.
@@ -1425,17 +1545,8 @@
/// - parameter buffer: The replacement bytes.
@inline(__always)
public mutating func replaceSubrange<SourceType>(_ subrange: Range<Index>, with buffer: UnsafeBufferPointer<SourceType>) {
- _validateRange(subrange)
- let nsRange = NSMakeRange(subrange.lowerBound, subrange.upperBound - subrange.lowerBound)
- let bufferCount = buffer.count * MemoryLayout<SourceType>.stride
-
- if !isKnownUniquelyReferenced(&_backing) {
- _backing = _backing.mutableCopy(_sliceRange)
- }
- let currentLength = _backing.length
- _backing.replaceBytes(in: nsRange, with: buffer.baseAddress, length: bufferCount)
- let resultingLength = currentLength - nsRange.length + bufferCount
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.lowerBound + resultingLength)
+ guard buffer.count > 0 else { return }
+ replaceSubrange(subrange, with: buffer.baseAddress!, count: buffer.count * MemoryLayout<SourceType>.stride)
}
/// Replace a region of bytes in the data with new bytes from a collection.
@@ -1446,39 +1557,18 @@
/// - parameter subrange: The range in the data to replace.
/// - parameter newElements: The replacement bytes.
@inline(__always)
- public mutating func replaceSubrange<ByteCollection : Collection>(_ subrange: Range<Index>, with newElements: ByteCollection)
- where ByteCollection.Iterator.Element == Data.Iterator.Element {
- _validateRange(subrange)
- // Calculate this once, it may not be O(1)
- let replacementCount: Int = numericCast(newElements.count)
- let currentCount = self.count
- let subrangeCount = subrange.count
-
- _validateRange(subrange)
-
- let resultCount = currentCount - subrangeCount + replacementCount
- if resultCount != currentCount {
- // This may realloc.
- // In the future, if we keep the malloced pointer and count inside this struct/ref instead of deferring to NSData, we may be able to do this more efficiently.
- self.count = resultCount
+ public mutating func replaceSubrange<ByteCollection : Collection>(_ subrange: Range<Index>, with newElements: ByteCollection) where ByteCollection.Iterator.Element == Data.Iterator.Element {
+ _validateRange(subrange)
+ let totalCount: Int = numericCast(newElements.count)
+ _withStackOrHeapBuffer(totalCount) { conditionalBuffer in
+ let buffer = UnsafeMutableBufferPointer(start: conditionalBuffer.pointee.memory.assumingMemoryBound(to: UInt8.self), count: totalCount)
+ var (iterator, index) = newElements._copyContents(initializing: buffer)
+ while let byte = iterator.next() {
+ buffer[index] = byte
+ index = buffer.index(after: index)
}
-
- let shift = resultCount - currentCount
- let start = subrange.lowerBound
-
- self.withUnsafeMutableBytes { (bytes : UnsafeMutablePointer<UInt8>) -> Void in
- if shift != 0 {
- let destination = bytes + start + replacementCount
- let source = bytes + start + subrangeCount
- memmove(destination, source, currentCount - start - subrangeCount)
- }
-
- if replacementCount != 0 {
- let buf = UnsafeMutableBufferPointer(start: bytes + start, count: replacementCount)
- var (it,idx) = newElements._copyContents(initializing: buf)
- precondition(it.next() == nil && idx == buf.endIndex, "newElements iterator returned different count to newElements.count")
- }
- }
+ replaceSubrange(subrange, with: conditionalBuffer.pointee.memory, count: totalCount)
+ }
}
@inline(__always)
@@ -1488,10 +1578,10 @@
if !isKnownUniquelyReferenced(&_backing) {
_backing = _backing.mutableCopy(_sliceRange)
}
- let currentLength = _backing.length
+ let upper = _sliceRange.upperBound
_backing.replaceBytes(in: nsRange, with: bytes, length: cnt)
- let resultingLength = currentLength - nsRange.length + cnt
- _sliceRange = _sliceRange.lowerBound..<(_sliceRange.lowerBound + resultingLength)
+ let resultingUpper = upper - nsRange.length + cnt
+ _sliceRange = _sliceRange.lowerBound..<resultingUpper
}
/// Return a new copy of the data in a specified range.
@@ -1534,7 +1624,15 @@
/// The hash value for the data.
public var hashValue: Int {
- return _backing.hashValue
+ var hashValue = 0
+ let hashRange: Range<Int> = _sliceRange.lowerBound..<Swift.min(_sliceRange.lowerBound + 80, _sliceRange.upperBound)
+ _withStackOrHeapBuffer(hashRange.count) { buffer in
+ _backing.withUnsafeBytes(in: hashRange) {
+ memcpy(buffer.pointee.memory, $0.baseAddress!, hashRange.count)
+ }
+ hashValue = Int(bitPattern: CFHashBytes(buffer.pointee.memory.assumingMemoryBound(to: UInt8.self), hashRange.count))
+ }
+ return hashValue
}
@inline(__always)
@@ -1557,7 +1655,7 @@
@inline(__always)
get {
_validateIndex(index)
- return _backing.bytes!.advanced(by: index).assumingMemoryBound(to: UInt8.self).pointee
+ return _backing.get(index)
}
@inline(__always)
set {
@@ -1770,7 +1868,7 @@
// Minimal size data is output as an array
if nBytes < 64 {
- children.append((label: "bytes", value: Array(self[0..<nBytes])))
+ children.append((label: "bytes", value: Array(self[startIndex..<Swift.min(nBytes + startIndex, endIndex)])))
}
let m = Mirror(self, children:children, displayStyle: Mirror.DisplayStyle.struct)
@@ -1868,4 +1966,3 @@
}
}
}
-
diff --git a/stdlib/public/SDK/Foundation/JSONEncoder.swift b/stdlib/public/SDK/Foundation/JSONEncoder.swift
index c46da27..9901552 100644
--- a/stdlib/public/SDK/Foundation/JSONEncoder.swift
+++ b/stdlib/public/SDK/Foundation/JSONEncoder.swift
@@ -1767,7 +1767,7 @@
fileprivate func unbox(_ value: Any, as type: Int.Type) throws -> Int? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1782,7 +1782,7 @@
fileprivate func unbox(_ value: Any, as type: Int8.Type) throws -> Int8? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1797,7 +1797,7 @@
fileprivate func unbox(_ value: Any, as type: Int16.Type) throws -> Int16? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1812,7 +1812,7 @@
fileprivate func unbox(_ value: Any, as type: Int32.Type) throws -> Int32? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1827,7 +1827,7 @@
fileprivate func unbox(_ value: Any, as type: Int64.Type) throws -> Int64? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1842,7 +1842,7 @@
fileprivate func unbox(_ value: Any, as type: UInt.Type) throws -> UInt? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1857,7 +1857,7 @@
fileprivate func unbox(_ value: Any, as type: UInt8.Type) throws -> UInt8? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1872,7 +1872,7 @@
fileprivate func unbox(_ value: Any, as type: UInt16.Type) throws -> UInt16? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1887,7 +1887,7 @@
fileprivate func unbox(_ value: Any, as type: UInt32.Type) throws -> UInt32? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1902,7 +1902,7 @@
fileprivate func unbox(_ value: Any, as type: UInt64.Type) throws -> UInt64? {
guard !(value is NSNull) else { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1917,7 +1917,7 @@
fileprivate func unbox(_ value: Any, as type: Float.Type) throws -> Float? {
guard !(value is NSNull) else { return nil }
- if let number = value as? NSNumber {
+ if let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse {
// We are willing to return a Float by losing precision:
// * If the original value was integral,
// * and the integral value was > Float.greatestFiniteMagnitude, we will fail
@@ -1963,7 +1963,7 @@
fileprivate func unbox(_ value: Any, as type: Double.Type) throws -> Double? {
guard !(value is NSNull) else { return nil }
- if let number = value as? NSNumber {
+ if let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse {
// We are always willing to return the number as a Double:
// * If the original value was integral, it is guaranteed to fit in a Double; we are willing to lose precision past 2^53 if you encoded a UInt64 but requested a Double
// * If it was a Float or Double, you will get back the precise value
diff --git a/stdlib/public/SDK/Foundation/PlistEncoder.swift b/stdlib/public/SDK/Foundation/PlistEncoder.swift
index 8bf01e7..059e237 100644
--- a/stdlib/public/SDK/Foundation/PlistEncoder.swift
+++ b/stdlib/public/SDK/Foundation/PlistEncoder.swift
@@ -1549,7 +1549,7 @@
fileprivate func unbox(_ value: Any, as type: Int.Type) throws -> Int? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1564,7 +1564,7 @@
fileprivate func unbox(_ value: Any, as type: Int8.Type) throws -> Int8? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1579,7 +1579,7 @@
fileprivate func unbox(_ value: Any, as type: Int16.Type) throws -> Int16? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1594,7 +1594,7 @@
fileprivate func unbox(_ value: Any, as type: Int32.Type) throws -> Int32? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1609,7 +1609,7 @@
fileprivate func unbox(_ value: Any, as type: Int64.Type) throws -> Int64? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1624,7 +1624,7 @@
fileprivate func unbox(_ value: Any, as type: UInt.Type) throws -> UInt? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1639,7 +1639,7 @@
fileprivate func unbox(_ value: Any, as type: UInt8.Type) throws -> UInt8? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1654,7 +1654,7 @@
fileprivate func unbox(_ value: Any, as type: UInt16.Type) throws -> UInt16? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1669,7 +1669,7 @@
fileprivate func unbox(_ value: Any, as type: UInt32.Type) throws -> UInt32? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1684,7 +1684,7 @@
fileprivate func unbox(_ value: Any, as type: UInt64.Type) throws -> UInt64? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1699,7 +1699,7 @@
fileprivate func unbox(_ value: Any, as type: Float.Type) throws -> Float? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
@@ -1714,7 +1714,7 @@
fileprivate func unbox(_ value: Any, as type: Double.Type) throws -> Double? {
if let string = value as? String, string == _plistNull { return nil }
- guard let number = value as? NSNumber else {
+ guard let number = value as? NSNumber, number !== kCFBooleanTrue, number !== kCFBooleanFalse else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}
diff --git a/stdlib/public/SwiftShims/FoundationOverlayShims.h b/stdlib/public/SwiftShims/FoundationOverlayShims.h
index af77954..53ef214 100644
--- a/stdlib/public/SwiftShims/FoundationOverlayShims.h
+++ b/stdlib/public/SwiftShims/FoundationOverlayShims.h
@@ -14,6 +14,9 @@
#import <objc/runtime.h>
#import <objc/message.h>
#import <sys/fcntl.h>
+#import <alloca.h>
+#import <stdlib.h>
+#import <malloc/malloc.h>
#import "FoundationShimSupport.h"
#import "NSCalendarShims.h"
@@ -29,3 +32,41 @@
#import "NSLocaleShims.h"
#import "NSTimeZoneShims.h"
#import "NSUndoManagerShims.h"
+
+typedef struct {
+ void *_Nonnull memory;
+ size_t capacity;
+ _Bool onStack;
+} _ConditionalAllocationBuffer;
+
+static inline _Bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuffer *_Nonnull buffer, size_t amt) {
+ size_t amount = malloc_good_size(amt);
+ if (amount <= buffer->capacity) { return true; }
+ void *newMemory;
+ if (buffer->onStack) {
+ newMemory = malloc(amount);
+ if (newMemory == NULL) { return false; }
+ memcpy(newMemory, buffer->memory, buffer->capacity);
+ buffer->onStack = false;
+ } else {
+ newMemory = realloc(buffer->memory, amount);
+ if (newMemory == NULL) { return false; }
+ }
+ if (newMemory == NULL) { return false; }
+ buffer->memory = newMemory;
+ buffer->capacity = amount;
+ return true;
+}
+
+static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
+ _ConditionalAllocationBuffer buffer;
+ buffer.capacity = malloc_good_size(amount);
+ buffer.onStack = (pthread_main_np() != 0 ? buffer.capacity < 2048 : buffer.capacity < 512);
+ buffer.memory = buffer.onStack ? alloca(buffer.capacity) : malloc(buffer.capacity);
+ if (buffer.memory == NULL) { return false; }
+ applier(&buffer);
+ if (!buffer.onStack) {
+ free(buffer.memory);
+ }
+ return true;
+}
diff --git a/stdlib/public/SwiftShims/LibcShims.h b/stdlib/public/SwiftShims/LibcShims.h
index d1cba7f..bb26a49 100644
--- a/stdlib/public/SwiftShims/LibcShims.h
+++ b/stdlib/public/SwiftShims/LibcShims.h
@@ -114,28 +114,28 @@
// TLS - thread local storage
#if defined(__ANDROID__)
-typedef int __swift_pthread_key_t;
+typedef int __swift_thread_key_t;
#elif defined(__linux__)
-typedef unsigned int __swift_pthread_key_t;
+typedef unsigned int __swift_thread_key_t;
#elif defined(__FreeBSD__)
-typedef int __swift_pthread_key_t;
+typedef int __swift_thread_key_t;
+#elif defined(_WIN32)
+typedef unsigned long __swift_thread_key_t;
#else
-typedef unsigned long __swift_pthread_key_t;
+typedef unsigned long __swift_thread_key_t;
#endif
SWIFT_RUNTIME_STDLIB_INTERFACE
-int _swift_stdlib_pthread_key_create(
- __swift_pthread_key_t * _Nonnull key, void
- (* _Nullable destructor)(void * _Nullable )
-);
+int
+_swift_stdlib_thread_key_create(__swift_thread_key_t * _Nonnull key,
+ void (* _Nullable destructor)(void * _Nullable));
SWIFT_RUNTIME_STDLIB_INTERFACE
-void * _Nullable _swift_stdlib_pthread_getspecific(__swift_pthread_key_t key);
+void * _Nullable _swift_stdlib_thread_getspecific(__swift_thread_key_t key);
SWIFT_RUNTIME_STDLIB_INTERFACE
-int _swift_stdlib_pthread_setspecific(
- __swift_pthread_key_t key, const void * _Nullable value
-);
+int _swift_stdlib_thread_setspecific(__swift_thread_key_t key,
+ const void * _Nullable value);
// TODO: Remove horrible workaround when importer does Float80 <-> long double.
#if (defined __i386__ || defined __x86_64__) && !defined _MSC_VER
diff --git a/stdlib/public/SwiftShims/NSDataShims.h b/stdlib/public/SwiftShims/NSDataShims.h
index de64023..a4baabd 100644
--- a/stdlib/public/SwiftShims/NSDataShims.h
+++ b/stdlib/public/SwiftShims/NSDataShims.h
@@ -20,4 +20,8 @@
FOUNDATION_EXPORT const NSDataDeallocator NSDataDeallocatorFree;
FOUNDATION_EXPORT const NSDataDeallocator NSDataDeallocatorNone;
+@interface NSData (FoundationSPI)
+- (BOOL)_isCompact;
+@end
+
NS_END_DECLS
diff --git a/stdlib/public/core/CMakeLists.txt b/stdlib/public/core/CMakeLists.txt
index 9c163d3..7befaf3 100644
--- a/stdlib/public/core/CMakeLists.txt
+++ b/stdlib/public/core/CMakeLists.txt
@@ -107,6 +107,7 @@
REPL.swift
Reverse.swift
Runtime.swift.gyb
+ RuntimeFunctionCounters.swift
SipHash.swift.gyb
SentinelCollection.swift
Sequence.swift
@@ -130,6 +131,7 @@
StringInterpolation.swift
StringLegacy.swift
StringRangeReplaceableCollection.swift.gyb
+ StringSwitch.swift
StringIndexConversions.swift
StringUnicodeScalarView.swift
StringUTF16.swift
diff --git a/stdlib/public/core/ExistentialCollection.swift.gyb b/stdlib/public/core/ExistentialCollection.swift.gyb
index 96d4ffe..1b4e3eb 100644
--- a/stdlib/public/core/ExistentialCollection.swift.gyb
+++ b/stdlib/public/core/ExistentialCollection.swift.gyb
@@ -556,7 +556,7 @@
}
% else:
@_versioned
- //@_inlineable
+ @_inlineable
internal init(_base: S) {
self._base = _base
super.init(
diff --git a/stdlib/public/core/GroupInfo.json b/stdlib/public/core/GroupInfo.json
index 5bc3821..8653c3a 100644
--- a/stdlib/public/core/GroupInfo.json
+++ b/stdlib/public/core/GroupInfo.json
@@ -22,6 +22,7 @@
"StringInterpolation.swift",
"StringLegacy.swift",
"StringRangeReplaceableCollection.swift",
+ "StringSwitch.swift",
"StringUTF16.swift",
"StringUTF8.swift",
"StringUnicodeScalarView.swift",
@@ -164,6 +165,7 @@
"Print.swift",
"REPL.swift",
"Runtime.swift",
+ "RuntimeFunctionCounters.swift",
"Shims.swift",
"ThreadLocalStorage.swift",
"Unmanaged.swift",
diff --git a/stdlib/public/core/KeyPath.swift b/stdlib/public/core/KeyPath.swift
index 23c621f..61e0a4d 100644
--- a/stdlib/public/core/KeyPath.swift
+++ b/stdlib/public/core/KeyPath.swift
@@ -472,9 +472,6 @@
return false
}
if let arg1 = argument1, let arg2 = argument2 {
- // TODO: Sizes may differ if one key path was formed in a context
- // capturing generic arguments and one wasn't.
- _sanityCheck(arg1.data.count == arg2.data.count)
return arg1.witnesses.pointee.equals(
arg1.data.baseAddress.unsafelyUnwrapped,
arg2.data.baseAddress.unsafelyUnwrapped,
@@ -556,23 +553,26 @@
internal final class MutatingWritebackBuffer<CurValue, NewValue> {
let previous: AnyObject?
let base: UnsafeMutablePointer<CurValue>
- let set: @convention(thin) (NewValue, inout CurValue, UnsafeRawPointer) -> ()
+ let set: @convention(thin) (NewValue, inout CurValue, UnsafeRawPointer, Int) -> ()
let argument: UnsafeRawPointer
+ let argumentSize: Int
var value: NewValue
deinit {
- set(value, &base.pointee, argument)
+ set(value, &base.pointee, argument, argumentSize)
}
init(previous: AnyObject?,
base: UnsafeMutablePointer<CurValue>,
- set: @escaping @convention(thin) (NewValue, inout CurValue, UnsafeRawPointer) -> (),
+ set: @escaping @convention(thin) (NewValue, inout CurValue, UnsafeRawPointer, Int) -> (),
argument: UnsafeRawPointer,
+ argumentSize: Int,
value: NewValue) {
self.previous = previous
self.base = base
self.set = set
self.argument = argument
+ self.argumentSize = argumentSize
self.value = value
}
}
@@ -581,23 +581,26 @@
internal final class NonmutatingWritebackBuffer<CurValue, NewValue> {
let previous: AnyObject?
let base: CurValue
- let set: @convention(thin) (NewValue, CurValue, UnsafeRawPointer) -> ()
+ let set: @convention(thin) (NewValue, CurValue, UnsafeRawPointer, Int) -> ()
let argument: UnsafeRawPointer
+ let argumentSize: Int
var value: NewValue
deinit {
- set(value, base, argument)
+ set(value, base, argument, argumentSize)
}
init(previous: AnyObject?,
base: CurValue,
- set: @escaping @convention(thin) (NewValue, CurValue, UnsafeRawPointer) -> (),
+ set: @escaping @convention(thin) (NewValue, CurValue, UnsafeRawPointer, Int) -> (),
argument: UnsafeRawPointer,
+ argumentSize: Int,
value: NewValue) {
self.previous = previous
self.base = base
self.set = set
self.argument = argument
+ self.argumentSize = argumentSize
self.value = value
}
}
@@ -929,7 +932,6 @@
case .computed:
// Fields are pointer-aligned after the header
componentSize += Header.pointerAlignmentSkew
- // TODO: nontrivial arguments need to be copied by value witness
buffer.storeBytes(of: _computedIDValue,
toByteOffset: MemoryLayout<Int>.size,
as: Int.self)
@@ -1015,9 +1017,11 @@
.mutatingGetSet(id: _, get: let rawGet, set: _, argument: let argument),
.nonmutatingGetSet(id: _, get: let rawGet, set: _, argument: let argument):
typealias Getter
- = @convention(thin) (CurValue, UnsafeRawPointer) -> NewValue
+ = @convention(thin) (CurValue, UnsafeRawPointer, Int) -> NewValue
let get = unsafeBitCast(rawGet, to: Getter.self)
- return .continue(get(base, argument?.data.baseAddress ?? rawGet))
+ return .continue(get(base,
+ argument?.data.baseAddress ?? rawGet,
+ argument?.data.count ?? 0))
case .optionalChain:
// TODO: IUO shouldn't be a first class type
@@ -1079,9 +1083,9 @@
case .mutatingGetSet(id: _, get: let rawGet, set: let rawSet,
argument: let argument):
typealias Getter
- = @convention(thin) (CurValue, UnsafeRawPointer) -> NewValue
+ = @convention(thin) (CurValue, UnsafeRawPointer, Int) -> NewValue
typealias Setter
- = @convention(thin) (NewValue, inout CurValue, UnsafeRawPointer) -> ()
+ = @convention(thin) (NewValue, inout CurValue, UnsafeRawPointer, Int) -> ()
let get = unsafeBitCast(rawGet, to: Getter.self)
let set = unsafeBitCast(rawSet, to: Setter.self)
@@ -1089,11 +1093,13 @@
mutating: base.assumingMemoryBound(to: CurValue.self))
let argValue = argument?.data.baseAddress ?? rawGet
+ let argSize = argument?.data.count ?? 0
let writeback = MutatingWritebackBuffer(previous: keepAlive,
- base: baseTyped,
- set: set,
- argument: argValue,
- value: get(baseTyped.pointee, argValue))
+ base: baseTyped,
+ set: set,
+ argument: argValue,
+ argumentSize: argSize,
+ value: get(baseTyped.pointee, argValue, argSize))
keepAlive = writeback
// A maximally-abstracted, final, stored class property should have
// a stable address.
@@ -1107,20 +1113,22 @@
"nonmutating component should not appear in the middle of mutation")
typealias Getter
- = @convention(thin) (CurValue, UnsafeRawPointer) -> NewValue
+ = @convention(thin) (CurValue, UnsafeRawPointer, Int) -> NewValue
typealias Setter
- = @convention(thin) (NewValue, CurValue, UnsafeRawPointer) -> ()
+ = @convention(thin) (NewValue, CurValue, UnsafeRawPointer, Int) -> ()
let get = unsafeBitCast(rawGet, to: Getter.self)
let set = unsafeBitCast(rawSet, to: Setter.self)
let baseValue = base.assumingMemoryBound(to: CurValue.self).pointee
let argValue = argument?.data.baseAddress ?? rawGet
+ let argSize = argument?.data.count ?? 0
let writeback = NonmutatingWritebackBuffer(previous: keepAlive,
- base: baseValue,
- set: set,
- argument: argValue,
- value: get(baseValue, argValue))
+ base: baseValue,
+ set: set,
+ argument: argValue,
+ argumentSize: argSize,
+ value: get(baseValue, argValue, argSize))
keepAlive = writeback
// A maximally-abstracted, final, stored class property should have
// a stable address.
diff --git a/stdlib/public/core/RuntimeFunctionCounters.swift b/stdlib/public/core/RuntimeFunctionCounters.swift
new file mode 100644
index 0000000..7fe7d4d
--- /dev/null
+++ b/stdlib/public/core/RuntimeFunctionCounters.swift
@@ -0,0 +1,538 @@
+//===--- RuntimeFunctionCounters.swift ------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the experimental support for collecting the state of
+// runtime function counters, which are used to determine how many times
+// a given runtime function was called.
+//
+// It is possible to get the global counters, which represent the total
+// number of invocations, or per-object counters, which represent the
+// number of runtime functions calls for a specific object.
+
+/// Collect all references inside the object using Mirrors.
+/// - Parameter value: the value to be inspected
+/// - Parameter references: the array which should contain the collected
+/// references
+/// - Parameter visitedItems: the dictionary for keeping track of visited
+/// objects
+internal func _collectAllReferencesInsideObjectImpl(
+ _ value: Any,
+ references: inout [UnsafeRawPointer],
+ visitedItems: inout [ObjectIdentifier : Int]
+) {
+ // Use the structural reflection and ignore any
+ // custom reflectable overrides.
+ let mirror = Mirror(
+ legacy: _reflect(value),
+ subjectType: type(of: value))
+
+ let id: ObjectIdentifier?
+ let ref: UnsafeRawPointer?
+ if type(of: value) is AnyObject.Type {
+ // Object is a class (but not an ObjC-bridged struct)
+ let toAnyObject = _unsafeDowncastToAnyObject(fromAny: value)
+ ref = UnsafeRawPointer(Unmanaged.passUnretained(toAnyObject).toOpaque())
+ id = ObjectIdentifier(toAnyObject)
+ } else if type(of: value) is Builtin.BridgeObject.Type {
+ ref = UnsafeRawPointer(
+ Builtin.bridgeToRawPointer(value as! Builtin.BridgeObject))
+ id = nil
+ } else if type(of: value) is Builtin.NativeObject.Type {
+ ref = UnsafeRawPointer(
+ Builtin.bridgeToRawPointer(value as! Builtin.NativeObject))
+ id = nil
+ } else if let metatypeInstance = value as? Any.Type {
+ // Object is a metatype
+ id = ObjectIdentifier(metatypeInstance)
+ ref = nil
+ } else {
+ id = nil
+ ref = nil
+ }
+
+ if let theId = id {
+ // Bail if this object was seen already.
+ if visitedItems[theId] != nil {
+ return
+ }
+ // Remember that this object was seen already.
+ let identifier = visitedItems.count
+ visitedItems[theId] = identifier
+ }
+
+ // If it is a reference, add it to the result.
+ if let ref = ref {
+ references.append(ref)
+ }
+
+ // Recursively visit the children of the current value.
+ let count = mirror.children.count
+ var currentIndex = mirror.children.startIndex
+ for _ in 0..<count {
+ let (_, child) = mirror.children[currentIndex]
+ mirror.children.formIndex(after: ¤tIndex)
+ _collectAllReferencesInsideObjectImpl(
+ child,
+ references: &references,
+ visitedItems: &visitedItems)
+ }
+}
+
+// This is a namespace for runtime functions related to management
+// of runtime function counters.
+public // @testable
+struct _RuntimeFunctionCounters {
+ public typealias RuntimeFunctionCountersUpdateHandler =
+ @convention(c) (_ object: UnsafeRawPointer, _ functionId: Int64) -> Void
+
+ public static let runtimeFunctionNames =
+ getRuntimeFunctionNames()
+ public static let runtimeFunctionCountersOffsets =
+ _RuntimeFunctionCounters.getRuntimeFunctionCountersOffsets()
+ public static let numRuntimeFunctionCounters =
+ _RuntimeFunctionCounters.getNumRuntimeFunctionCounters()
+ public static let runtimeFunctionNameToIndex: [String : Int] =
+ getRuntimeFunctionNameToIndex()
+
+ /// Get the names of all runtime functions whose calls are being
+ /// tracked.
+ @_silgen_name("getRuntimeFunctionNames")
+ static public func _getRuntimeFunctionNames() ->
+ UnsafePointer<UnsafePointer<CChar>>
+
+ static public func getRuntimeFunctionNames() -> [String] {
+ let names = _RuntimeFunctionCounters._getRuntimeFunctionNames()
+ let numRuntimeFunctionCounters =
+ _RuntimeFunctionCounters.getNumRuntimeFunctionCounters()
+ var functionNames : [String] = []
+ functionNames.reserveCapacity(numRuntimeFunctionCounters)
+ for index in 0..<numRuntimeFunctionCounters {
+ let name = String(cString: names[index])
+ functionNames.append(name)
+ }
+ return functionNames
+ }
+
+ /// Get the offsets of the collected runtime function counters inside
+ /// the state.
+ @_silgen_name("getRuntimeFunctionCountersOffsets")
+ static public func getRuntimeFunctionCountersOffsets() ->
+ UnsafePointer<UInt16>
+
+ /// Get the number of different runtime functions whose calls are being
+ /// tracked.
+ @_silgen_name("getNumRuntimeFunctionCounters")
+ static public func getNumRuntimeFunctionCounters() -> Int
+
+ /// Dump all per-object runtime function counters.
+ @_silgen_name("dumpObjectsRuntimeFunctionPointers")
+ static public func dumpObjectsRuntimeFunctionPointers()
+
+ @discardableResult
+ @_silgen_name("setGlobalRuntimeFunctionCountersUpdateHandler")
+ static public func setGlobalRuntimeFunctionCountersUpdateHandler(
+ handler: RuntimeFunctionCountersUpdateHandler?
+ ) -> RuntimeFunctionCountersUpdateHandler?
+
+ /// Collect all references inside the object using Mirrors.
+ static public func collectAllReferencesInsideObject(_ value: Any) ->
+ [UnsafeRawPointer] {
+ var visited : [ObjectIdentifier : Int] = [:]
+ var references: [UnsafeRawPointer] = []
+ _collectAllReferencesInsideObjectImpl(
+ value, references: &references, visitedItems: &visited)
+ return references
+ }
+
+ /// Build a map from counter name to counter index inside the state struct.
+ static internal func getRuntimeFunctionNameToIndex() -> [String : Int] {
+ let runtimeFunctionNames = _RuntimeFunctionCounters.getRuntimeFunctionNames()
+ let numRuntimeFunctionCounters =
+ _RuntimeFunctionCounters.getNumRuntimeFunctionCounters()
+ var runtimeFunctionNameToIndex : [String : Int] = [:]
+ runtimeFunctionNameToIndex.reserveCapacity(numRuntimeFunctionCounters)
+
+ for index in 0..<numRuntimeFunctionCounters {
+ let name = runtimeFunctionNames[index]
+ runtimeFunctionNameToIndex[name] = index
+ }
+ return runtimeFunctionNameToIndex
+ }
+}
+
+/// This protocol defines a set of operations for accessing runtime function
+/// counters statistics.
+public // @testable
+protocol _RuntimeFunctionCountersStats : CustomDebugStringConvertible {
+ init()
+
+ /// Dump the current state of all counters.
+ func dump<T : TextOutputStream>(skipUnchanged: Bool, to: inout T)
+
+ /// Dump the diff between the current state and a different state of all
+ /// counters.
+ func dumpDiff<T : TextOutputStream>(
+ _ after: Self, skipUnchanged: Bool, to: inout T
+ )
+
+ /// Compute a diff between two states of runtime function counters.
+ /// Return a new state representing the diff.
+ func diff(_ other: Self) -> Self
+
+ /// Access counters by name.
+ subscript(_ counterName: String) -> UInt32 { get set }
+
+ /// Access counters by index.
+ subscript(_ index: Int) -> UInt32 { get set }
+}
+
+extension _RuntimeFunctionCountersStats {
+ /// Dump the current state of all counters.
+ public func dump(skipUnchanged: Bool) {
+ var output = _Stdout()
+ dump(skipUnchanged: skipUnchanged, to: &output)
+ }
+
+ /// Dump the diff between the current state and a different state of all
+ /// counters.
+ public func dumpDiff(_ after: Self, skipUnchanged: Bool) {
+ var output = _Stdout()
+ dumpDiff(after, skipUnchanged: skipUnchanged, to: &output)
+ }
+}
+
+extension _RuntimeFunctionCountersStats {
+ public var debugDescription: String {
+ var result = ""
+ dump(skipUnchanged: true, to: &result)
+ return result
+ }
+}
+
+// A helper type that encapsulates the logic for collecting runtime function
+// counters. This type should not be used directly. You should use its
+// wrappers GlobalRuntimeFunctionCountersState and
+// ObjectRuntimeFunctionCountersState instead.
+internal struct _RuntimeFunctionCountersState: _RuntimeFunctionCountersStats {
+ /// Reserve enough space for 64 elements.
+ typealias Counters =
+ (
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32, UInt32,
+ UInt32, UInt32, UInt32, UInt32
+ )
+
+ private var counters: Counters = (
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0), UInt32(0),
+ UInt32(0), UInt32(0), UInt32(0), UInt32(0)
+ )
+
+ // Use counter name as index.
+ subscript(_ counterName: String) -> UInt32 {
+ get {
+ if let index = _RuntimeFunctionCounters.runtimeFunctionNameToIndex[counterName] {
+ return self[index]
+ }
+ fatalError("Unknown counter name: \(counterName)")
+ }
+
+ set {
+ if let index = _RuntimeFunctionCounters.runtimeFunctionNameToIndex[counterName] {
+ self[index] = newValue
+ return
+ }
+ fatalError("Unknown counter name: \(counterName)")
+ }
+ }
+
+ subscript(_ index: Int) -> UInt32 {
+ @inline(never)
+ get {
+ if (index >= _RuntimeFunctionCounters.numRuntimeFunctionCounters) {
+ fatalError("Counter index should be in the range " +
+ "0..<\(_RuntimeFunctionCounters.numRuntimeFunctionCounters)")
+ }
+ var tmpCounters = counters
+ let counter: UInt32 = withUnsafePointer(to: &tmpCounters) { ptr in
+ return ptr.withMemoryRebound(to: UInt32.self, capacity: 64) { buf in
+ return buf[index]
+ }
+ }
+ return counter
+ }
+
+ @inline(never)
+ set {
+ if (index >= _RuntimeFunctionCounters.numRuntimeFunctionCounters) {
+ fatalError("Counter index should be in the range " +
+ "0..<\(_RuntimeFunctionCounters.numRuntimeFunctionCounters)")
+ }
+ withUnsafeMutablePointer(to: &counters) {
+ $0.withMemoryRebound(to: UInt32.self, capacity: 64) {
+ $0[index] = newValue
+ }
+ }
+ }
+ }
+}
+
+extension _RuntimeFunctionCounters {
+ @_silgen_name("getObjectRuntimeFunctionCounters")
+ static internal func getObjectRuntimeFunctionCounters(
+ _ object: UnsafeRawPointer, _ result: inout _RuntimeFunctionCountersState)
+
+ @_silgen_name("getGlobalRuntimeFunctionCounters")
+ static internal func getGlobalRuntimeFunctionCounters(
+ _ result: inout _RuntimeFunctionCountersState)
+
+ @_silgen_name("setGlobalRuntimeFunctionCounters")
+ static internal func setGlobalRuntimeFunctionCounters(
+ _ state: inout _RuntimeFunctionCountersState)
+
+ @_silgen_name("setObjectRuntimeFunctionCounters")
+ static internal func setObjectRuntimeFunctionCounters(
+ _ object: UnsafeRawPointer,
+ _ state: inout _RuntimeFunctionCountersState)
+
+ @discardableResult
+ @_silgen_name("setGlobalRuntimeFunctionCountersMode")
+ static
+ public // @testable
+ func setGlobalRuntimeFunctionCountersMode(enable: Bool) -> Bool
+
+ @discardableResult
+ @_silgen_name("setPerObjectRuntimeFunctionCountersMode")
+ static
+ public // @testable
+ func setPerObjectRuntimeFunctionCountersMode(enable: Bool) -> Bool
+
+ /// Enable runtime function counters updates by the runtime.
+ static
+ public // @testable
+ func enableRuntimeFunctionCountersUpdates(
+ mode: (globalMode: Bool, perObjectMode: Bool) = (true, true)) {
+ _RuntimeFunctionCounters.setGlobalRuntimeFunctionCountersMode(
+ enable: mode.globalMode)
+ _RuntimeFunctionCounters.setPerObjectRuntimeFunctionCountersMode(
+ enable: mode.perObjectMode)
+ }
+
+ /// Disable runtime function counters updates by the runtime.
+ static
+ public // @testable
+ func disableRuntimeFunctionCountersUpdates() ->
+ (globalMode: Bool, perObjectMode: Bool) {
+ let oldGlobalMode =
+ _RuntimeFunctionCounters.setGlobalRuntimeFunctionCountersMode(
+ enable: false)
+ let oldPerObjectMode =
+ _RuntimeFunctionCounters.setPerObjectRuntimeFunctionCountersMode(
+ enable: false)
+ return (oldGlobalMode, oldPerObjectMode)
+ }
+}
+
+extension _RuntimeFunctionCountersStats {
+ typealias Counters = _RuntimeFunctionCounters
+ @inline(never)
+ public // @testable
+ func dump<T : TextOutputStream>(skipUnchanged: Bool, to: inout T) {
+ for i in 0..<Counters.numRuntimeFunctionCounters {
+ if skipUnchanged && self[i] == 0 {
+ continue
+ }
+ print("counter \(i) : " +
+ "\(Counters.runtimeFunctionNames[i])" +
+ " at offset: " +
+ "\(Counters.runtimeFunctionCountersOffsets[i]):" +
+ " \(self[i])", to: &to)
+ }
+ }
+
+ @inline(never)
+ public // @testable
+ func dumpDiff<T : TextOutputStream>(
+ _ after: Self, skipUnchanged: Bool, to: inout T
+ ) {
+ for i in 0..<Counters.numRuntimeFunctionCounters {
+ if self[i] == 0 && after[i] == 0 {
+ continue
+ }
+ if skipUnchanged && self[i] == after[i] {
+ continue
+ }
+ print("counter \(i) : " +
+ "\(Counters.runtimeFunctionNames[i])" +
+ " at offset: " +
+ "\(Counters.runtimeFunctionCountersOffsets[i]): " +
+ "before \(self[i]) " +
+ "after \(after[i])" + " diff=\(after[i]-self[i])", to: &to)
+ }
+ }
+
+ public // @testable
+ func diff(_ other: Self) -> Self {
+ var result = Self()
+ for i in 0..<Counters.numRuntimeFunctionCounters {
+ result[i] = other[i] - self[i]
+ }
+ return result
+ }
+}
+
+/// This type should be used to collect statistics about the global runtime
+/// function pointers.
+public // @testable
+struct _GlobalRuntimeFunctionCountersState: _RuntimeFunctionCountersStats {
+ var state = _RuntimeFunctionCountersState()
+
+ public init() {
+ getGlobalRuntimeFunctionCounters()
+ }
+
+ mutating public func getGlobalRuntimeFunctionCounters() {
+ _RuntimeFunctionCounters.getGlobalRuntimeFunctionCounters(&state)
+ }
+
+ mutating public func setGlobalRuntimeFunctionCounters() {
+ _RuntimeFunctionCounters.setGlobalRuntimeFunctionCounters(&state)
+ }
+
+ public subscript(_ index: String) -> UInt32 {
+ get {
+ return state[index]
+ }
+ set {
+ state[index] = newValue
+ }
+ }
+
+ public subscript(_ index: Int) -> UInt32 {
+ get {
+ return state[index]
+ }
+ set {
+ state[index] = newValue
+ }
+ }
+}
+
+/// This type should be used to collect statistics about object runtime
+/// function pointers.
+public // @testable
+struct _ObjectRuntimeFunctionCountersState: _RuntimeFunctionCountersStats {
+ var state = _RuntimeFunctionCountersState()
+
+ // Initialize with the counters for a given object.
+ public init(_ p: UnsafeRawPointer) {
+ getObjectRuntimeFunctionCounters(p)
+ }
+
+ public init() {
+ }
+
+ mutating public func getObjectRuntimeFunctionCounters(_ o: UnsafeRawPointer) {
+ _RuntimeFunctionCounters.getObjectRuntimeFunctionCounters(o, &state)
+ }
+
+ mutating public func setObjectRuntimeFunctionCounters(_ o: UnsafeRawPointer) {
+ _RuntimeFunctionCounters.setObjectRuntimeFunctionCounters(o, &state)
+ }
+
+ public subscript(_ index: String) -> UInt32 {
+ get {
+ return state[index]
+ }
+ set {
+ state[index] = newValue
+ }
+ }
+
+ public subscript(_ index: Int) -> UInt32 {
+ get {
+ return state[index]
+ }
+ set {
+ state[index] = newValue
+ }
+ }
+}
+
+/// Collects all references inside an object.
+/// Runtime counters tracking is disabled for the duration of this operation
+/// so that it does not affect those counters.
+public // @testable
+func _collectReferencesInsideObject(_ value: Any) -> [UnsafeRawPointer] {
+ let savedMode = _RuntimeFunctionCounters.disableRuntimeFunctionCountersUpdates()
+ // Collect all references inside the object
+ let refs = _RuntimeFunctionCounters.collectAllReferencesInsideObject(value)
+ _RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates(mode: savedMode)
+ return refs
+}
+
+/// A helper method to measure how global and per-object function counters
+/// were changed during execution of a closure provided as a parameter.
+/// Returns counter diffs for global counters and for the object-specific
+/// counters related to a given object.
+public // @testable
+func _measureRuntimeFunctionCountersDiffs(
+ objects: [UnsafeRawPointer], _ body: () -> Void) ->
+ (_GlobalRuntimeFunctionCountersState, [_ObjectRuntimeFunctionCountersState]) {
+ let savedMode =
+ _RuntimeFunctionCounters.disableRuntimeFunctionCountersUpdates()
+ let globalCountersBefore = _GlobalRuntimeFunctionCountersState()
+ var objectsCountersBefore: [_ObjectRuntimeFunctionCountersState] = []
+ for object in objects {
+ objectsCountersBefore.append(_ObjectRuntimeFunctionCountersState(object))
+ }
+ // Enable counters updates.
+ _RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates(
+ mode: (globalMode: true, perObjectMode: true))
+ // Execute the provided user's code.
+ body()
+ // Disable counters updates.
+ _RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates(
+ mode: (globalMode: false, perObjectMode: false))
+
+ let globalCountersAfter = _GlobalRuntimeFunctionCountersState()
+ var objectsCountersDiff: [_ObjectRuntimeFunctionCountersState] = []
+ for (idx, object) in objects.enumerated() {
+ let objectCountersAfter = _ObjectRuntimeFunctionCountersState(object)
+ objectsCountersDiff.append(
+ objectsCountersBefore[idx].diff(objectCountersAfter))
+ }
+
+ _RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates(
+ mode: savedMode)
+ return (globalCountersBefore.diff(globalCountersAfter), objectsCountersDiff)
+}
diff --git a/stdlib/public/core/Stride.swift.gyb b/stdlib/public/core/Stride.swift.gyb
index eea5a78..375b831 100644
--- a/stdlib/public/core/Stride.swift.gyb
+++ b/stdlib/public/core/Stride.swift.gyb
@@ -23,6 +23,12 @@
}%
/// Conforming types are notionally continuous, one-dimensional
/// values that can be offset and measured.
+///
+/// - Important: The `Strideable` protocol provides default implementations for
+/// the equal-to (`==`) and less-than (`<`) operators that depend on the
+/// `Stride` type's implementations. If a type conforming to `Strideable`
+/// is its own `Stride` type, it must provide concrete implementations of
+/// the two operators to avoid infinite recursion.
public protocol ${Self} : ${Conformance} {
% if Self == '_Strideable':
/// A type that represents the distance between two values of `Self`.
@@ -55,6 +61,24 @@
% end
+extension Strideable where Stride == Self {
+ @available(*, deprecated, message: "Strideable conformance where 'Stride == Self' requires user-defined implementation of the '<' operator")
+ public static func < (x: Self, y: Self) -> Bool {
+ fatalError("""
+ Strideable conformance where 'Stride == Self' requires user-defined \
+ implementation of the '<' operator
+ """)
+ }
+
+ @available(*, deprecated, message: "Strideable conformance where 'Stride == Self' requires user-defined implementation of the '==' operator")
+ public static func == (x: Self, y: Self) -> Bool {
+ fatalError("""
+ Strideable conformance where 'Stride == Self' requires user-defined \
+ implementation of the '==' operator
+ """)
+ }
+}
+
extension Strideable {
@_inlineable
public static func < (x: Self, y: Self) -> Bool {
diff --git a/stdlib/public/core/StringSwitch.swift b/stdlib/public/core/StringSwitch.swift
new file mode 100644
index 0000000..5c0fedf
--- /dev/null
+++ b/stdlib/public/core/StringSwitch.swift
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+// This file contains compiler intrinsics for optimized string switch
+// implementations. All functions and types declared in this file are not
+// intended to be used by switch source directly.
+
+/// The compiler intrinsic which is called to lookup a string in a table
+/// of static string case values.
+@_semantics("stdlib_binary_only")
+@_semantics("findStringSwitchCase")
+public // COMPILER_INTRINSIC
+func _findStringSwitchCase(
+ cases: [StaticString],
+ string: String) -> Int {
+
+ for (idx, s) in cases.enumerated() {
+ if String(_builtinStringLiteral: s.utf8Start._rawValue,
+ utf8CodeUnitCount: s._utf8CodeUnitCount,
+ isASCII: s.isASCII._value) == string {
+ return idx
+ }
+ }
+ return -1
+}
+
+public // used by COMPILER_INTRINSIC
+struct _OpaqueStringSwitchCache {
+ var a: Builtin.Word
+ var b: Builtin.Word
+}
+
+internal typealias _StringSwitchCache = Dictionary<String, Int>
+
+internal struct _StringSwitchContext {
+ let cases: [StaticString]
+ let cachePtr: UnsafeMutablePointer<_StringSwitchCache>
+}
+
+/// The compiler intrinsic which is called to lookup a string in a table
+/// of static string case values.
+///
+/// The first time this function is called, a cache is built and stored
+/// in \p cache. Consecutive calls use the cache for faster lookup.
+/// The \p cases array must not change between subsequent calls with the
+/// same \p cache.
+@_semantics("stdlib_binary_only")
+@_semantics("findStringSwitchCaseWithCache")
+public // COMPILER_INTRINSIC
+func _findStringSwitchCaseWithCache(
+ cases: [StaticString],
+ string: String,
+ cache: inout _OpaqueStringSwitchCache) -> Int {
+
+ return withUnsafeMutableBytes(of: &cache) {
+ (bufPtr: UnsafeMutableRawBufferPointer) -> Int in
+
+ let oncePtr = bufPtr.baseAddress!
+ let cacheRawPtr = oncePtr + MemoryLayout<Builtin.Word>.stride
+ let cachePtr = cacheRawPtr.bindMemory(to: _StringSwitchCache.self, capacity: 1)
+ var context = _StringSwitchContext(cases: cases, cachePtr: cachePtr)
+ withUnsafeMutablePointer(to: &context) { (context) -> () in
+ Builtin.onceWithContext(oncePtr._rawValue, _createStringTableCache,
+ context._rawValue)
+ }
+ let cache = cachePtr.pointee;
+ if let idx = cache[string] {
+ return idx
+ }
+ return -1
+ }
+}
+
+/// Builds the string switch case.
+internal func _createStringTableCache(_ cacheRawPtr: Builtin.RawPointer) {
+ let context = UnsafePointer<_StringSwitchContext>(cacheRawPtr).pointee
+ var cache = _StringSwitchCache()
+ cache.reserveCapacity(context.cases.count)
+ assert(MemoryLayout<_StringSwitchCache>.size <= MemoryLayout<Builtin.Word>.size)
+
+ for (idx, s) in context.cases.enumerated() {
+ let key = String(_builtinStringLiteral: s.utf8Start._rawValue,
+ utf8CodeUnitCount: s._utf8CodeUnitCount,
+ isASCII: s.isASCII._value)
+ cache[key] = idx
+ }
+ context.cachePtr.initialize(to: cache)
+}
+
diff --git a/stdlib/public/core/ThreadLocalStorage.swift b/stdlib/public/core/ThreadLocalStorage.swift
index 02b47f3..48f8d67 100644
--- a/stdlib/public/core/ThreadLocalStorage.swift
+++ b/stdlib/public/core/ThreadLocalStorage.swift
@@ -64,7 +64,7 @@
static internal func getPointer()
-> UnsafeMutablePointer<_ThreadLocalStorage>
{
- let tlsRawPtr = _swift_stdlib_pthread_getspecific(_tlsKey)
+ let tlsRawPtr = _swift_stdlib_thread_getspecific(_tlsKey)
if _fastPath(tlsRawPtr != nil) {
return tlsRawPtr._unsafelyUnwrappedUnchecked.assumingMemoryBound(
to: _ThreadLocalStorage.self)
@@ -116,10 +116,10 @@
}
// Lazily created global key for use with pthread TLS
-internal let _tlsKey: __swift_pthread_key_t = {
- let sentinelValue = __swift_pthread_key_t.max
- var key: __swift_pthread_key_t = sentinelValue
- let success = _swift_stdlib_pthread_key_create(&key, _destroyTLS)
+internal let _tlsKey: __swift_thread_key_t = {
+ let sentinelValue = __swift_thread_key_t.max
+ var key: __swift_thread_key_t = sentinelValue
+ let success = _swift_stdlib_thread_key_create(&key, _destroyTLS)
_sanityCheck(success == 0, "somehow failed to create TLS key")
_sanityCheck(key != sentinelValue, "Didn't make a new key")
return key
@@ -129,7 +129,7 @@
internal func _initializeThreadLocalStorage()
-> UnsafeMutablePointer<_ThreadLocalStorage>
{
- _sanityCheck(_swift_stdlib_pthread_getspecific(_tlsKey) == nil,
+ _sanityCheck(_swift_stdlib_thread_getspecific(_tlsKey) == nil,
"already initialized")
// Create and initialize one.
@@ -146,7 +146,7 @@
tlsPtr.initialize(
to: _ThreadLocalStorage(_uBreakIterator: newUBreakIterator)
)
- let success = _swift_stdlib_pthread_setspecific(_tlsKey, tlsPtr)
+ let success = _swift_stdlib_thread_setspecific(_tlsKey, tlsPtr)
_sanityCheck(success == 0, "setspecific failed")
return tlsPtr
}
diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt
index 4c2709b..9937087 100644
--- a/stdlib/public/runtime/CMakeLists.txt
+++ b/stdlib/public/runtime/CMakeLists.txt
@@ -58,6 +58,7 @@
ProtocolConformance.cpp
RefCount.cpp
RuntimeEntrySymbols.cpp
+ RuntimeInvocationsTracking.cpp
"${SWIFT_SOURCE_DIR}/lib/Demangling/OldDemangler.cpp"
"${SWIFT_SOURCE_DIR}/lib/Demangling/Demangler.cpp"
"${SWIFT_SOURCE_DIR}/lib/Demangling/NodePrinter.cpp"
diff --git a/stdlib/public/runtime/Errors.cpp b/stdlib/public/runtime/Errors.cpp
index 761dc05..0ef4c02 100644
--- a/stdlib/public/runtime/Errors.cpp
+++ b/stdlib/public/runtime/Errors.cpp
@@ -20,6 +20,10 @@
# define SWIFT_SUPPORTS_BACKTRACE_REPORTING 1
#endif
+#if defined(_WIN32)
+#include <mutex>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -30,13 +34,17 @@
#include <unistd.h>
#endif
#include <stdarg.h>
+
#include "ImageInspection.h"
#include "swift/Runtime/Debug.h"
#include "swift/Runtime/Mutex.h"
#include "swift/Demangling/Demangle.h"
#include "swift/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
-#if !defined(_MSC_VER)
+
+#if defined(_MSC_VER)
+#include <DbgHelp.h>
+#else
#include <cxxabi.h>
#endif
@@ -60,9 +68,9 @@
using namespace swift;
+#if SWIFT_SUPPORTS_BACKTRACE_REPORTING
static bool getSymbolNameAddr(llvm::StringRef libraryName, SymbolInfo syminfo,
std::string &symbolName, uintptr_t &addrOut) {
-
// If we failed to find a symbol and thus dlinfo->dli_sname is nullptr, we
// need to use the hex address.
bool hasUnavailableAddress = syminfo.symbolName == nullptr;
@@ -78,17 +86,39 @@
// demangle with swift. We are taking advantage of __cxa_demangle actually
// providing failure status instead of just returning the original string like
// swift demangle.
+#if defined(_WIN32)
+ DWORD dwFlags = UNDNAME_COMPLETE;
+#if !defined(_WIN64)
+ dwFlags |= UNDNAME_32_BIT_DECODE;
+#endif
+ static std::mutex mutex;
+
+ char szUndName[1024];
+ DWORD dwResult;
+
+ {
+ std::lock_guard<std::mutex> lock(m);
+ dwResult = UnDecorateSymbolName(syminfo.symbolName, szUndName,
+ sizeof(szUndName), dwFlags);
+ }
+
+ if (dwResult == TRUE) {
+ symbolName += szUndName;
+ return true;
+ }
+#else
int status;
char *demangled = abi::__cxa_demangle(syminfo.symbolName, 0, 0, &status);
if (status == 0) {
- assert(demangled != nullptr && "If __cxa_demangle succeeds, demangled "
- "should never be nullptr");
+ assert(demangled != nullptr &&
+ "If __cxa_demangle succeeds, demangled should never be nullptr");
symbolName += demangled;
free(demangled);
return true;
}
- assert(demangled == nullptr && "If __cxa_demangle fails, demangled should "
- "be a nullptr");
+ assert(demangled == nullptr &&
+ "If __cxa_demangle fails, demangled should be a nullptr");
+#endif
// Otherwise, try to demangle with swift. If swift fails to demangle, it will
// just pass through the original output.
@@ -97,6 +127,7 @@
Demangle::DemangleOptions::SimplifiedUIDemangleOptions());
return true;
}
+#endif
void swift::dumpStackTraceEntry(unsigned index, void *framePC,
bool shortOutput) {
@@ -140,7 +171,7 @@
fprintf(stderr, "%s`%s + %td", libraryName.data(), symbolName.c_str(),
offset);
} else {
- constexpr const char *format = "%-4u %-34s 0x%0.16lx %s + %td\n";
+ constexpr const char *format = "%-4u %-34s 0x%0.16tx %s + %td\n";
fprintf(stderr, format, index, libraryName.data(), symbolAddr,
symbolName.c_str(), offset);
}
@@ -148,8 +179,8 @@
if (shortOutput) {
fprintf(stderr, "<unavailable>");
} else {
- constexpr const char *format = "%-4u 0x%0.16lx\n";
- fprintf(stderr, format, index, framePC);
+ constexpr const char *format = "%-4u 0x%0.16tx\n";
+ fprintf(stderr, format, index, reinterpret_cast<uintptr_t>(framePC));
}
#endif
}
diff --git a/stdlib/public/runtime/Exclusivity.cpp b/stdlib/public/runtime/Exclusivity.cpp
index d7e1e65..65d7816 100644
--- a/stdlib/public/runtime/Exclusivity.cpp
+++ b/stdlib/public/runtime/Exclusivity.cpp
@@ -69,7 +69,7 @@
ExclusivityFlags newFlags, void *newPC,
void *pointer) {
static std::atomic<long> reportedConflicts{0};
- constexpr unsigned maxReportedConflicts = 100;
+ constexpr long maxReportedConflicts = 100;
// Don't report more that 100 conflicts. Hopefully, this will improve
// performance in case there are conflicts inside a tight loop.
if (reportedConflicts.fetch_add(1, std::memory_order_relaxed) >=
@@ -81,9 +81,9 @@
constexpr unsigned maxAccessDescriptionLength = 50;
char message[maxMessageLength];
snprintf(message, sizeof(message),
- "Simultaneous accesses to 0x%lx, but modification requires "
+ "Simultaneous accesses to 0x%tx, but modification requires "
"exclusive access",
- (uintptr_t)pointer);
+ reinterpret_cast<uintptr_t>(pointer));
fprintf(stderr, "%s.\n", message);
char oldAccess[maxAccessDescriptionLength];
@@ -92,7 +92,7 @@
fprintf(stderr, "%s ", oldAccess);
if (oldPC) {
dumpStackTraceEntry(0, oldPC, /*shortOutput=*/true);
- fprintf(stderr, " (0x%lx).\n", (uintptr_t)oldPC);
+ fprintf(stderr, " (0x%tx).\n", reinterpret_cast<uintptr_t>(oldPC));
} else {
fprintf(stderr, "<unknown>.\n");
}
diff --git a/stdlib/public/runtime/HeapObject.cpp b/stdlib/public/runtime/HeapObject.cpp
index a2d9d6b..dd7c68a 100644
--- a/stdlib/public/runtime/HeapObject.cpp
+++ b/stdlib/public/runtime/HeapObject.cpp
@@ -24,6 +24,7 @@
#include "llvm/Support/MathExtras.h"
#include "MetadataCache.h"
#include "Private.h"
+#include "RuntimeInvocationsTracking.h"
#include "WeakReference.h"
#include "swift/Runtime/Debug.h"
#include <algorithm>
@@ -83,6 +84,8 @@
// If leak tracking is enabled, start tracking this object.
SWIFT_LEAKS_START_TRACKING_OBJECT(object);
+ SWIFT_RT_TRACK_INVOCATION(object, swift_allocObject);
+
return object;
}
@@ -92,6 +95,7 @@
object->metadata = metadata;
object->refCounts.initForNotFreeing();
+ SWIFT_RT_TRACK_INVOCATION(object, swift_initStackObject);
return object;
}
@@ -112,6 +116,7 @@
HeapObject *
swift::swift_initStaticObject(HeapMetadata const *metadata,
HeapObject *object) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_initStaticObject);
// The token is located at a negative offset from the object header.
swift_once_t *token = ((swift_once_t *)object) - 1;
@@ -297,6 +302,7 @@
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_nonatomic_retain)(HeapObject *object) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_retain);
if (isValidPointerForNativeRetain(object))
object->refCounts.incrementNonAtomic(1);
}
@@ -308,6 +314,7 @@
SWIFT_RT_ENTRY_IMPL_VISIBILITY
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_nonatomic_release)(HeapObject *object) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_release);
if (isValidPointerForNativeRetain(object))
object->refCounts.decrementAndMaybeDeinitNonAtomic(1);
}
@@ -316,6 +323,7 @@
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_retain)(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_retain);
if (isValidPointerForNativeRetain(object))
object->refCounts.increment(1);
}
@@ -329,6 +337,7 @@
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_retain_n)(HeapObject *object, uint32_t n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_retain_n);
if (isValidPointerForNativeRetain(object))
object->refCounts.increment(n);
}
@@ -342,6 +351,7 @@
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_nonatomic_retain_n)(HeapObject *object, uint32_t n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_retain_n);
if (isValidPointerForNativeRetain(object))
object->refCounts.incrementNonAtomic(n);
}
@@ -355,6 +365,7 @@
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_release)(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_release);
if (isValidPointerForNativeRetain(object))
object->refCounts.decrementAndMaybeDeinit(1);
}
@@ -368,11 +379,13 @@
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_release_n)(HeapObject *object, uint32_t n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_release_n);
if (isValidPointerForNativeRetain(object))
object->refCounts.decrementAndMaybeDeinit(n);
}
void swift::swift_setDeallocating(HeapObject *object) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_setDeallocating);
object->refCounts.decrementFromOneNonAtomic();
}
@@ -385,6 +398,7 @@
extern "C"
void SWIFT_RT_ENTRY_IMPL(swift_nonatomic_release_n)(HeapObject *object, uint32_t n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_release_n);
if (isValidPointerForNativeRetain(object))
object->refCounts.decrementAndMaybeDeinitNonAtomic(n);
}
@@ -399,6 +413,7 @@
void swift::swift_unownedRetain(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRetain);
if (!isValidPointerForNativeRetain(object))
return;
@@ -407,6 +422,7 @@
void swift::swift_unownedRelease(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRelease);
if (!isValidPointerForNativeRetain(object))
return;
@@ -425,6 +441,7 @@
void swift::swift_nonatomic_unownedRetain(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_unownedRetain);
if (!isValidPointerForNativeRetain(object))
return;
@@ -433,6 +450,7 @@
void swift::swift_nonatomic_unownedRelease(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_unownedRelease);
if (!isValidPointerForNativeRetain(object))
return;
@@ -451,6 +469,7 @@
void swift::swift_unownedRetain_n(HeapObject *object, int n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRetain_n);
if (!isValidPointerForNativeRetain(object))
return;
@@ -459,6 +478,7 @@
void swift::swift_unownedRelease_n(HeapObject *object, int n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRelease_n);
if (!isValidPointerForNativeRetain(object))
return;
@@ -476,6 +496,7 @@
void swift::swift_nonatomic_unownedRetain_n(HeapObject *object, int n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_unownedRetain_n);
if (!isValidPointerForNativeRetain(object))
return;
@@ -484,6 +505,7 @@
void swift::swift_nonatomic_unownedRelease_n(HeapObject *object, int n)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRelease_n);
if (!isValidPointerForNativeRetain(object))
return;
@@ -501,6 +523,7 @@
HeapObject *swift::swift_tryPin(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_tryPin);
assert(isValidPointerForNativeRetain(object));
// Try to set the flag. If this succeeds, the caller will be
@@ -515,6 +538,7 @@
void swift::swift_unpin(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unpin);
if (isValidPointerForNativeRetain(object))
object->refCounts.decrementAndUnpinAndMaybeDeinit();
}
@@ -526,6 +550,7 @@
HeapObject *swift::swift_nonatomic_tryPin(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_tryPin);
assert(object);
// Try to set the flag. If this succeeds, the caller will be
@@ -540,6 +565,7 @@
void swift::swift_nonatomic_unpin(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_unpin);
if (isValidPointerForNativeRetain(object))
object->refCounts.decrementAndUnpinAndMaybeDeinitNonAtomic();
}
@@ -548,6 +574,7 @@
extern "C"
HeapObject *SWIFT_RT_ENTRY_IMPL(swift_tryRetain)(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_tryRetain);
if (!isValidPointerForNativeRetain(object))
return nullptr;
@@ -570,6 +597,7 @@
void swift::swift_unownedRetainStrong(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRetainStrong);
if (!isValidPointerForNativeRetain(object))
return;
assert(object->refCounts.getUnownedCount() &&
@@ -581,6 +609,7 @@
void swift::swift_nonatomic_unownedRetainStrong(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_unownedRetainStrong);
if (!isValidPointerForNativeRetain(object))
return;
assert(object->refCounts.getUnownedCount() &&
@@ -592,6 +621,7 @@
void swift::swift_unownedRetainStrongAndRelease(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_unownedRetainStrongAndRelease);
if (!isValidPointerForNativeRetain(object))
return;
assert(object->refCounts.getUnownedCount() &&
@@ -608,6 +638,7 @@
void swift::swift_nonatomic_unownedRetainStrongAndRelease(HeapObject *object)
SWIFT_CC(RegisterPreservingCC_IMPL) {
+ SWIFT_RT_TRACK_INVOCATION(object, swift_nonatomic_unownedRetainStrongAndRelease);
if (!isValidPointerForNativeRetain(object))
return;
assert(object->refCounts.getUnownedCount() &&
@@ -738,6 +769,7 @@
SWIFT_CC(RegisterPreservingCC_IMPL) {
assert(isAlignmentMask(allocatedAlignMask));
assert(object->refCounts.isDeiniting());
+ SWIFT_RT_TRACK_INVOCATION(object, swift_deallocObject);
#ifdef SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS
memset_pattern8((uint8_t *)object + sizeof(HeapObject),
"\xAB\xAD\x1D\xEA\xF4\xEE\xD0\bB9",
diff --git a/stdlib/public/runtime/ImageInspectionWin32.cpp b/stdlib/public/runtime/ImageInspectionWin32.cpp
index fd76c94..a590b3d 100644
--- a/stdlib/public/runtime/ImageInspectionWin32.cpp
+++ b/stdlib/public/runtime/ImageInspectionWin32.cpp
@@ -109,48 +109,51 @@
return lastRet;
}
-static uint8_t *_swift_getSectionDataPE(const void *handle, const char *sectionName,
+static uint8_t *_swift_getSectionDataPE(const void *handle,
+ const char *sectionName,
unsigned long *sectionSize) {
// In Cygwin, dlopen() returns PE/COFF image pointer.
// This is relying on undocumented feature of Windows API LoadLibrary().
- unsigned char *peStart = (unsigned char *)handle;
-
+ const unsigned char *peStart = static_cast<const unsigned char *>(handle);
+
const int kLocationOfNtHeaderOffset = 0x3C;
int ntHeadersOffset =
- *reinterpret_cast<int32_t *>(peStart + kLocationOfNtHeaderOffset);
-
+ *reinterpret_cast<const int32_t *>(peStart + kLocationOfNtHeaderOffset);
+
bool assert1 =
peStart[ntHeadersOffset] == 'P' && peStart[ntHeadersOffset + 1] == 'E';
if (!assert1) {
swift::fatalError(/* flags = */ 0, "_swift_getSectionDataPE()'s finding PE failed");
}
-
- unsigned char *coff = peStart + ntHeadersOffset + 4;
-
- int16_t numberOfSections = *(int16_t *)(coff + 2);
-
+
+ const unsigned char *coff = peStart + ntHeadersOffset + 4;
+
+ int16_t numberOfSections = *reinterpret_cast<const int16_t *>(coff + 2);
+
// SizeOfOptionalHeader
- int16_t sizeOfOptionalHeader = *(int16_t *)(coff + 16);
-
+ int16_t sizeOfOptionalHeader = *reinterpret_cast<const int16_t *>(coff + 16);
+
const int kCoffFileHeaderSize = 20;
- unsigned char *sectionTableBase =
- coff + kCoffFileHeaderSize + sizeOfOptionalHeader;
-
+ const unsigned char *sectionTableBase =
+ coff + kCoffFileHeaderSize + sizeOfOptionalHeader;
+
// Section Header Record
const int kSectionRecordSize = 40;
-
- unsigned char *sectionHeader = sectionTableBase;
+
+ const unsigned char *sectionHeader = sectionTableBase;
for (int i = 0; i < numberOfSections; i++) {
- uint32_t virtualSize = *(uint32_t *)§ionHeader[8];
- uint32_t virtualAddress = *(uint32_t *)§ionHeader[12];
-
+ uint32_t virtualSize =
+ *reinterpret_cast<const uint32_t *>(§ionHeader[8]);
+ uint32_t virtualAddress =
+ *reinterpret_cast<const uint32_t *>(§ionHeader[12]);
+
char nameOfThisSection[9];
memcpy(nameOfThisSection, sectionHeader, 8);
nameOfThisSection[8] = '\0';
if (strcmp(sectionName, nameOfThisSection) == 0) {
*sectionSize = virtualSize;
- return (uint8_t *)handle + virtualAddress;
+ return const_cast<uint8_t *>(peStart + virtualAddress);
}
sectionHeader += kSectionRecordSize;
}
@@ -160,7 +163,7 @@
static int _addImageCallback(struct _swift_dl_phdr_info *info,
size_t size, const void *data) {
- const InspectArgs *inspectArgs = (InspectArgs *)data;
+ const InspectArgs *inspectArgs = static_cast<const InspectArgs *>(data);
// inspectArgs contains addImage*Block function and the section name
#if defined(_WIN32)
HMODULE handle;
diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.cpp b/stdlib/public/runtime/RuntimeInvocationsTracking.cpp
new file mode 100644
index 0000000..1f0c7ef
--- /dev/null
+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.cpp
@@ -0,0 +1,228 @@
+//===--- RuntimeInvocationsTracking.cpp - Track runtime invocations -------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// Track invocations of Swift runtime functions. This can be used for performance
+// analysis.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ADT/DenseMap.h"
+#include "RuntimeInvocationsTracking.h"
+#include "swift/Runtime/HeapObject.h"
+
+// This file is compiled always, even if assertions are disabled and no runtime
+// functions are being tracked. This is done to avoid recompiling Swift clients
+// using these APIs. They should be able to link against the standard library
+// independent of the fact whether assertions are enabled or not.
+
+#define SWIFT_RT_FUNCTION_INVOCATION_COUNTER_NAME(RT_FUNCTION) \
+ invocationCounter_##RT_FUNCTION
+
+namespace swift {
+
+// Define counters used for tracking the total number of invocations of runtime
+// functions.
+struct RuntimeFunctionCountersState {
+#define FUNCTION_TO_TRACK(RT_FUNCTION) \
+ uint32_t SWIFT_RT_FUNCTION_INVOCATION_COUNTER_NAME(RT_FUNCTION) = 0;
+// Provide one counter per runtime function being tracked.
+#include "RuntimeInvocationsTracking.def"
+};
+
+} // end namespace swift
+
+
+/// If set, global runtime function counters should be tracked.
+static bool UpdatePerObjectRuntimeFunctionCounters = false;
+/// If set, per object runtime function counters should be tracked.
+static bool UpdateGlobalRuntimeFunctionCounters = false;
+/// TODO: Add support for enabling/disabling counters on a per object basis?
+
+/// Global set of counters tracking the total number of runtime invocations.
+static RuntimeFunctionCountersState RuntimeGlobalFunctionCountersState;
+
+/// The object state cache mapping objects to the collected state associated with
+/// them.
+/// TODO: Do we need to make it thread-safe?
+static llvm::DenseMap<HeapObject *, RuntimeFunctionCountersState> RuntimeObjectStateCache;
+
+static const char *RuntimeFunctionNames[] {
+/// Define names of runtime functions.
+#define FUNCTION_TO_TRACK(RT_FUNCTION) #RT_FUNCTION,
+#include "RuntimeInvocationsTracking.def"
+ nullptr
+};
+
+#define RT_FUNCTION_ID(RT_FUNCTION) ID_##RT_FUNCTION
+
+/// Define an enum where each enumerator corresponds to a runtime function being
+/// tracked. Their order is the same as the order of the counters in the
+/// RuntimeObjectState structure.
+enum RuntimeFunctionNamesIDs : uint32_t {
+/// Defines names of enum cases for each function being tracked.
+#define FUNCTION_TO_TRACK(RT_FUNCTION) RT_FUNCTION_ID(RT_FUNCTION),
+#include "RuntimeInvocationsTracking.def"
+ ID_LastRuntimeFunctionName,
+};
+
+/// The global handler to be invoked on runtime function counters updates.
+static RuntimeFunctionCountersUpdateHandler
+ GlobalRuntimeFunctionCountersUpdateHandler;
+
+/// The offsets of the runtime function counters being tracked inside the
+/// RuntimeObjectState structure. The array is indexed by
+/// the enumerators from RuntimeFunctionNamesIDs.
+static uint16_t RuntimeFunctionCountersOffsets[] = {
+/// Define offset for each function being tracked.
+#define FUNCTION_TO_TRACK(RT_FUNCTION) \
+ (sizeof(uint16_t) * (unsigned)RT_FUNCTION_ID(RT_FUNCTION)),
+#include "RuntimeInvocationsTracking.def"
+};
+
+/// Define implementations of tracking functions.
+/// TODO: Track only objects that were registered for tracking?
+/// TODO: Perform atomic increments?
+#define FUNCTION_TO_TRACK(RT_FUNCTION) \
+ void SWIFT_RT_TRACK_INVOCATION_NAME(RT_FUNCTION)(HeapObject * object) { \
+ /* Update global counters. */ \
+ if (UpdateGlobalRuntimeFunctionCounters) { \
+ RuntimeGlobalFunctionCountersState \
+ .SWIFT_RT_FUNCTION_INVOCATION_COUNTER_NAME(RT_FUNCTION)++; \
+ if (GlobalRuntimeFunctionCountersUpdateHandler) { \
+ auto oldGlobalMode = setGlobalRuntimeFunctionCountersMode(0); \
+ auto oldPerObjectMode = setPerObjectRuntimeFunctionCountersMode(0); \
+ GlobalRuntimeFunctionCountersUpdateHandler( \
+ object, RT_FUNCTION_ID(RT_FUNCTION)); \
+ setGlobalRuntimeFunctionCountersMode(oldGlobalMode); \
+ setPerObjectRuntimeFunctionCountersMode(oldPerObjectMode); \
+ } \
+ } \
+ /* Update per object counters. */ \
+ if (UpdatePerObjectRuntimeFunctionCounters && object) { \
+ RuntimeObjectStateCache[object] \
+ .SWIFT_RT_FUNCTION_INVOCATION_COUNTER_NAME(RT_FUNCTION)++; \
+ /* TODO: Remember the order/history of operations? */ \
+ } \
+ }
+#include "RuntimeInvocationsTracking.def"
+
+/// Public APIs
+
+/// Get the runtime object state associated with an object.
+SWIFT_RT_ENTRY_VISIBILITY
+void getObjectRuntimeFunctionCounters(HeapObject *object,
+ RuntimeFunctionCountersState *result) {
+ *result = RuntimeObjectStateCache[object];
+}
+
+/// Set the runtime object state associated with an object from a provided
+/// state.
+SWIFT_RT_ENTRY_VISIBILITY
+void setObjectRuntimeFunctionCounters(HeapObject *object,
+ RuntimeFunctionCountersState *state) {
+ RuntimeObjectStateCache[object] = *state;
+}
+
+/// Get the global runtime state containing the total numbers of invocations for
+/// each runtime function of interest.
+SWIFT_RT_ENTRY_VISIBILITY
+void getGlobalRuntimeFunctionCounters(RuntimeFunctionCountersState *result) {
+ *result = RuntimeGlobalFunctionCountersState;
+}
+
+/// Set the global runtime state of function pointers from a provided state.
+SWIFT_RT_ENTRY_VISIBILITY
+void setGlobalRuntimeFunctionCounters(RuntimeFunctionCountersState *state) {
+ RuntimeGlobalFunctionCountersState = *state;
+}
+
+/// Return the names of the runtime functions being tracked.
+/// Their order is the same as the order of the counters in the
+/// RuntimeObjectState structure. All these strings are null terminated.
+SWIFT_RT_ENTRY_VISIBILITY
+const char **getRuntimeFunctionNames() {
+ return RuntimeFunctionNames;
+}
+
+/// Return the offsets of the runtime function counters being tracked.
+/// Their order is the same as the order of the counters in the
+/// RuntimeObjectState structure.
+SWIFT_RT_ENTRY_VISIBILITY
+const uint16_t *getRuntimeFunctionCountersOffsets() {
+ return RuntimeFunctionCountersOffsets;
+}
+
+/// Return the number of runtime functions being tracked.
+SWIFT_RT_ENTRY_VISIBILITY
+uint64_t getNumRuntimeFunctionCounters() {
+ return ID_LastRuntimeFunctionName;
+}
+
+static void dumpRuntimeCounters(RuntimeFunctionCountersState *State) {
+ uint32_t tmp;
+/// Define how to dump the counter for a given runtime function.
+#define FUNCTION_TO_TRACK(RT_FUNCTION) \
+ tmp = State->SWIFT_RT_FUNCTION_INVOCATION_COUNTER_NAME(RT_FUNCTION); \
+ if (tmp != 0) \
+ printf("%s = %d\n", \
+ RuntimeFunctionNames[(int)RT_FUNCTION_ID(RT_FUNCTION)], tmp);
+#include "RuntimeInvocationsTracking.def"
+}
+
+/// Dump all per-object runtime function pointers.
+SWIFT_RT_ENTRY_VISIBILITY
+void dumpObjectsRuntimeFunctionPointers() {
+ for (auto &Pair : RuntimeObjectStateCache) {
+ printf("\n\nRuntime counters for object at address %p:\n", Pair.getFirst());
+ dumpRuntimeCounters(&Pair.getSecond());
+ printf("\n");
+ }
+}
+
+/// Set mode for global runtime function counters.
+/// Return the old value of this flag.
+SWIFT_RT_ENTRY_VISIBILITY
+int setGlobalRuntimeFunctionCountersMode(int mode) {
+ int oldMode = UpdateGlobalRuntimeFunctionCounters;
+ UpdateGlobalRuntimeFunctionCounters = mode ? 1 : 0;
+ return oldMode;
+}
+
+/// Set mode for per object runtime function counters.
+/// Return the old value of this flag.
+SWIFT_RT_ENTRY_VISIBILITY
+int setPerObjectRuntimeFunctionCountersMode(int mode) {
+ int oldMode = UpdatePerObjectRuntimeFunctionCounters;
+ UpdatePerObjectRuntimeFunctionCounters = mode ? 1 : 0;
+ return oldMode;
+}
+
+/// Add the ability to call custom handlers when a counter
+/// is being updated. The handler should take the object and may be
+/// the name of the runtime function as parameters. And this handler
+/// could e.g. check some conditions and stop the program under
+/// a debuggger if a certain condition is met, like a refcount has
+/// reached a certain value.
+/// We could allow for setting global handlers or even per-object
+/// handlers.
+SWIFT_RT_ENTRY_VISIBILITY
+RuntimeFunctionCountersUpdateHandler
+setGlobalRuntimeFunctionCountersUpdateHandler(
+ RuntimeFunctionCountersUpdateHandler handler) {
+ auto oldHandler = GlobalRuntimeFunctionCountersUpdateHandler;
+ GlobalRuntimeFunctionCountersUpdateHandler = handler;
+ return oldHandler;
+}
+
+/// TODO: Provide an API to remove any counters releated to a specific object
+/// or all objects.
+/// This is useful if you want to reset the stats for some/all objects.
diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.def b/stdlib/public/runtime/RuntimeInvocationsTracking.def
new file mode 100644
index 0000000..9e636f5
--- /dev/null
+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.def
@@ -0,0 +1,59 @@
+//===--- RuntimeInvocationsTracking.def - Functions to track ----*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines x-macros used for metaprogramming with the set of
+// runtime functions, whose invocations should be tracked.
+//
+//===----------------------------------------------------------------------===//
+
+/// FUNCTION_TO_TRACK(Id)
+/// Id is the name of the runtime function to be tracked.
+
+#ifndef FUNCTION_TO_TRACK
+#error "Must define FUNCTION_TO_TRACK to include RuntimeInvocationsTracking.def"
+#endif
+
+/// Set of runtime functions that whose invocations need to be tracked.
+/// Edit this list to add new runtime functions or remove the old ones.
+FUNCTION_TO_TRACK(swift_retain)
+FUNCTION_TO_TRACK(swift_release)
+FUNCTION_TO_TRACK(swift_retain_n)
+FUNCTION_TO_TRACK(swift_release_n)
+FUNCTION_TO_TRACK(swift_nonatomic_retain)
+FUNCTION_TO_TRACK(swift_nonatomic_release)
+FUNCTION_TO_TRACK(swift_nonatomic_retain_n)
+FUNCTION_TO_TRACK(swift_nonatomic_release_n)
+FUNCTION_TO_TRACK(swift_setDeallocating)
+FUNCTION_TO_TRACK(swift_unownedRetain)
+FUNCTION_TO_TRACK(swift_unownedRelease)
+FUNCTION_TO_TRACK(swift_nonatomic_unownedRetain)
+FUNCTION_TO_TRACK(swift_nonatomic_unownedRelease)
+FUNCTION_TO_TRACK(swift_unownedRetain_n)
+FUNCTION_TO_TRACK(swift_unownedRelease_n)
+FUNCTION_TO_TRACK(swift_nonatomic_unownedRetain_n)
+FUNCTION_TO_TRACK(swift_nonatomic_unownedRelease_n)
+FUNCTION_TO_TRACK(swift_allocObject)
+FUNCTION_TO_TRACK(swift_deallocObject)
+FUNCTION_TO_TRACK(swift_initStackObject)
+FUNCTION_TO_TRACK(swift_initStaticObject)
+FUNCTION_TO_TRACK(swift_tryPin)
+FUNCTION_TO_TRACK(swift_unpin)
+FUNCTION_TO_TRACK(swift_nonatomic_tryPin)
+FUNCTION_TO_TRACK(swift_nonatomic_unpin)
+FUNCTION_TO_TRACK(swift_tryRetain)
+FUNCTION_TO_TRACK(swift_tryRelease)
+FUNCTION_TO_TRACK(swift_unownedRetainStrong)
+FUNCTION_TO_TRACK(swift_nonatomic_unownedRetainStrong)
+FUNCTION_TO_TRACK(swift_unownedRetainStrongAndRelease)
+FUNCTION_TO_TRACK(swift_nonatomic_unownedRetainStrongAndRelease)
+
+#undef FUNCTION_TO_TRACK
diff --git a/stdlib/public/runtime/RuntimeInvocationsTracking.h b/stdlib/public/runtime/RuntimeInvocationsTracking.h
new file mode 100644
index 0000000..5a3426e
--- /dev/null
+++ b/stdlib/public/runtime/RuntimeInvocationsTracking.h
@@ -0,0 +1,120 @@
+//===--- RuntimeInvocationsTracking.h ---------------------------*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See https://swift.org/LICENSE.txt for license information
+// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// Track invocations of Swift runtime functions. This can be used for
+// performance analysis.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SWIFT_STDLIB_RUNTIME_INVOCATIONS_TRACKING_H
+#define SWIFT_STDLIB_RUNTIME_INVOCATIONS_TRACKING_H
+
+#include "swift/Runtime/Config.h"
+
+#if defined(__cplusplus)
+
+namespace swift {
+struct HeapObject;
+struct RuntimeFunctionCountersState;
+} // end namespace swift
+
+using namespace swift;
+#else
+
+struct HeapObject;
+struct RuntimeFunctionCountersState;
+
+#endif
+
+/// The name of a helper function for tracking the calls of a runtime function.
+#define SWIFT_RT_TRACK_INVOCATION_NAME(RT_FUNCTION) \
+ swift_trackRuntimeInvocation_##RT_FUNCTION
+
+/// Instrument the runtime functions only if we are building with
+/// assertions enabled.
+#if !defined(NDEBUG)
+
+/// Invoke a helper function for tracking the calls of a runtime function.
+#define SWIFT_RT_TRACK_INVOCATION(OBJ, RT_FUNCTION) \
+ SWIFT_RT_TRACK_INVOCATION_NAME(RT_FUNCTION)(OBJ)
+
+#define FUNCTION_TO_TRACK(RT_FUNCTION) \
+ extern void SWIFT_RT_TRACK_INVOCATION_NAME(RT_FUNCTION)(HeapObject * OBJ);
+/// Declarations of external functions for invocations tracking.
+#include "RuntimeInvocationsTracking.def"
+
+#else
+
+/// It is just a NOP if assertions are not enabled.
+#define SWIFT_RT_TRACK_INVOCATION(OBJ, RT_FUNCTION)
+
+#endif // NDEBUG
+
+/// This type defines a callback to be called on any intercepted runtime
+/// function.
+using RuntimeFunctionCountersUpdateHandler =
+ __attribute__((swiftcall))
+ void (*)(HeapObject *object, int64_t runtimeFunctionID);
+
+/// Public APIs
+
+/// Get the runtime object state associated with an object and store it
+/// into the result.
+SWIFT_RT_ENTRY_VISIBILITY void
+getObjectRuntimeFunctionCounters(HeapObject *object,
+ RuntimeFunctionCountersState *result);
+
+/// Get the global runtime state containing the total numbers of invocations for
+/// each runtime function of interest and store it into the result.
+SWIFT_RT_ENTRY_VISIBILITY void
+getGlobalRuntimeFunctionCounters(swift::RuntimeFunctionCountersState *result);
+
+/// Return the names of the runtime functions being tracked.
+/// Their order is the same as the order of the counters in the
+/// RuntimeObjectState structure.
+SWIFT_RT_ENTRY_VISIBILITY const char **getRuntimeFunctionNames();
+
+/// Return the offsets of the runtime function counters being tracked.
+/// Their order is the same as the order of the counters in the
+/// RuntimeFunctionCountersState structure.
+SWIFT_RT_ENTRY_VISIBILITY const uint16_t *getRuntimeFunctionCountersOffsets();
+
+/// Return the number of runtime functions being tracked.
+SWIFT_RT_ENTRY_VISIBILITY uint64_t getNumRuntimeFunctionCounters();
+
+/// Dump all per-object runtime function pointers.
+SWIFT_RT_ENTRY_VISIBILITY void dumpObjectsRuntimeFunctionPointers();
+
+/// Set mode for global runtime function counters.
+/// Return the old value of this flag.
+SWIFT_RT_ENTRY_VISIBILITY int setPerObjectRuntimeFunctionCountersMode(int mode);
+
+/// Set mode for per object runtime function counters.
+/// Return the old value of this flag.
+SWIFT_RT_ENTRY_VISIBILITY int setGlobalRuntimeFunctionCountersMode(int mode);
+
+/// Set the global runtime state of function pointers from a provided state.
+SWIFT_RT_ENTRY_VISIBILITY void
+setGlobalRuntimeFunctionCounters(swift::RuntimeFunctionCountersState *state);
+
+/// Set the runtime object state associated with an object from a provided
+/// state.
+SWIFT_RT_ENTRY_VISIBILITY void
+setObjectRuntimeFunctionCounters(HeapObject *object,
+ RuntimeFunctionCountersState *state);
+
+/// Set the global runtime function counters update handler.
+extern "C" RuntimeFunctionCountersUpdateHandler
+setGlobalRuntimeFunctionCountersUpdateHandler(
+ RuntimeFunctionCountersUpdateHandler handler);
+
+#endif
diff --git a/stdlib/public/runtime/SwiftObject.mm b/stdlib/public/runtime/SwiftObject.mm
index e87e0e1..1a0d38c 100644
--- a/stdlib/public/runtime/SwiftObject.mm
+++ b/stdlib/public/runtime/SwiftObject.mm
@@ -869,7 +869,8 @@
!objectUsesNativeSwiftReferenceCounting(value));
}
-void swift::swift_unknownUnownedInit(UnownedReference *dest, void *value) {
+UnownedReference *swift::swift_unknownUnownedInit(UnownedReference *dest,
+ void *value) {
if (!value) {
dest->Value = nullptr;
} else if (isObjCForUnownedReference(value)) {
@@ -877,9 +878,11 @@
} else {
swift_unownedInit(dest, (HeapObject*) value);
}
+ return dest;
}
-void swift::swift_unknownUnownedAssign(UnownedReference *dest, void *value) {
+UnownedReference *swift::swift_unknownUnownedAssign(UnownedReference *dest,
+ void *value) {
if (!value) {
swift_unknownUnownedDestroy(dest);
dest->Value = nullptr;
@@ -898,6 +901,7 @@
swift_unownedAssign(dest, (HeapObject*) value);
}
}
+ return dest;
}
void *swift::swift_unknownUnownedLoadStrong(UnownedReference *ref) {
@@ -941,8 +945,8 @@
}
}
-void swift::swift_unknownUnownedCopyInit(UnownedReference *dest,
- UnownedReference *src) {
+UnownedReference *swift::swift_unknownUnownedCopyInit(UnownedReference *dest,
+ UnownedReference *src) {
assert(dest != src);
if (!src->Value) {
dest->Value = nullptr;
@@ -951,17 +955,19 @@
} else {
swift_unownedCopyInit(dest, src);
}
+ return dest;
}
-void swift::swift_unknownUnownedTakeInit(UnownedReference *dest,
- UnownedReference *src) {
+UnownedReference *swift::swift_unknownUnownedTakeInit(UnownedReference *dest,
+ UnownedReference *src) {
assert(dest != src);
dest->Value = src->Value;
+ return dest;
}
-void swift::swift_unknownUnownedCopyAssign(UnownedReference *dest,
- UnownedReference *src) {
- if (dest == src) return;
+UnownedReference *swift::swift_unknownUnownedCopyAssign(UnownedReference *dest,
+ UnownedReference *src) {
+ if (dest == src) return dest;
if (auto objcSrc = dyn_cast<ObjCUnownedReference>(src)) {
if (auto objcDest = dyn_cast<ObjCUnownedReference>(dest)) {
@@ -969,7 +975,7 @@
objc_destroyWeak(&objcDest->storage()->WeakRef);
objc_copyWeak(&objcDest->storage()->WeakRef,
&objcSrc->storage()->WeakRef);
- return;
+ return dest;
}
swift_unownedDestroy(dest);
@@ -982,15 +988,17 @@
swift_unownedCopyAssign(dest, src);
}
}
+ return dest;
}
-void swift::swift_unknownUnownedTakeAssign(UnownedReference *dest,
- UnownedReference *src) {
+UnownedReference *swift::swift_unknownUnownedTakeAssign(UnownedReference *dest,
+ UnownedReference *src) {
assert(dest != src);
// There's not really anything more efficient to do here than this.
swift_unknownUnownedDestroy(dest);
dest->Value = src->Value;
+ return dest;
}
bool swift::swift_unknownUnownedIsEqual(UnownedReference *ref, void *value) {
@@ -1012,12 +1020,14 @@
/************************** UNKNOWN WEAK REFERENCES **************************/
/*****************************************************************************/
-void swift::swift_unknownWeakInit(WeakReference *ref, void *value) {
- return ref->unknownInit(value);
+WeakReference *swift::swift_unknownWeakInit(WeakReference *ref, void *value) {
+ ref->unknownInit(value);
+ return ref;
}
-void swift::swift_unknownWeakAssign(WeakReference *ref, void *value) {
- return ref->unknownAssign(value);
+WeakReference *swift::swift_unknownWeakAssign(WeakReference *ref, void *value) {
+ ref->unknownAssign(value);
+ return ref;
}
void *swift::swift_unknownWeakLoadStrong(WeakReference *ref) {
@@ -1032,19 +1042,25 @@
ref->unknownDestroy();
}
-void swift::swift_unknownWeakCopyInit(WeakReference *dest, WeakReference *src) {
+WeakReference *swift::swift_unknownWeakCopyInit(WeakReference *dest,
+ WeakReference *src) {
dest->unknownCopyInit(src);
+ return dest;
}
-void swift::swift_unknownWeakTakeInit(WeakReference *dest, WeakReference *src) {
+WeakReference *swift::swift_unknownWeakTakeInit(WeakReference *dest,
+ WeakReference *src) {
dest->unknownTakeInit(src);
+ return dest;
}
-void swift::swift_unknownWeakCopyAssign(WeakReference *dest,
- WeakReference *src) {
+WeakReference *swift::swift_unknownWeakCopyAssign(WeakReference *dest,
+ WeakReference *src) {
dest->unknownCopyAssign(src);
+ return dest;
}
-void swift::swift_unknownWeakTakeAssign(WeakReference *dest,
- WeakReference *src) {
+WeakReference *swift::swift_unknownWeakTakeAssign(WeakReference *dest,
+ WeakReference *src) {
dest->unknownTakeAssign(src);
+ return dest;
}
// SWIFT_OBJC_INTEROP
diff --git a/stdlib/public/stubs/KeyPaths.cpp b/stdlib/public/stubs/KeyPaths.cpp
index 889ec10..053dc20 100644
--- a/stdlib/public/stubs/KeyPaths.cpp
+++ b/stdlib/public/stubs/KeyPaths.cpp
@@ -15,8 +15,8 @@
#include <cstdint>
#include <cstring>
-SWIFT_CC(swift)
-static void copyGenericArguments(const void *src, void *dest, size_t bytes) {
+SWIFT_RUNTIME_EXPORT SWIFT_CC(swift)
+void swift_copyKeyPathTrivialIndices(const void *src, void *dest, size_t bytes) {
memcpy(dest, src, bytes);
}
@@ -42,7 +42,7 @@
SWIFT_RUNTIME_EXPORT
void *(swift_keyPathGenericWitnessTable[]) = {
nullptr, // no destructor necessary
- (void*)(uintptr_t)copyGenericArguments,
+ (void*)(uintptr_t)swift_copyKeyPathTrivialIndices,
(void*)(uintptr_t)equateGenericArguments,
(void*)(uintptr_t)hashGenericArguments,
};
diff --git a/stdlib/public/stubs/LibcShims.cpp b/stdlib/public/stubs/LibcShims.cpp
index a483d69..b65382a 100644
--- a/stdlib/public/stubs/LibcShims.cpp
+++ b/stdlib/public/stubs/LibcShims.cpp
@@ -15,10 +15,12 @@
#include <cmath>
#if defined(_WIN32)
#include <io.h>
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h>
#else
#include <unistd.h>
-#endif
#include <pthread.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
@@ -60,7 +62,7 @@
SWIFT_RUNTIME_STDLIB_INTERFACE
__swift_size_t swift::_swift_stdlib_strlen_unsigned(const unsigned char *s) {
- return strlen((char *)s);
+ return strlen(reinterpret_cast<const char *>(s));
}
SWIFT_RUNTIME_STDLIB_INTERFACE
@@ -98,34 +100,57 @@
#endif
}
-// Guard compilation on the typedef for __swift_pthread_key_t in LibcShims.h
+#if defined(_WIN32)
+static_assert(std::is_same<__swift_thread_key_t, DWORD>::value,
+ "__swift_thread_key_t is not a DWORD");
+
+SWIFT_RUNTIME_STDLIB_INTERFACE
+int
+swift::_swift_stdlib_thread_key_create(__swift_thread_key_t * _Nonnull key,
+ void (* _Nullable destructor)(void *)) {
+ // TODO(compnerd) account for x86 CC violation (__stdcall)
+ *key = FlsAlloc(reinterpret_cast<PFLS_CALLBACK_FUNCTION>(destructor));
+ return *key != FLS_OUT_OF_INDEXES;
+}
+
+SWIFT_RUNTIME_STDLIB_INTERFACE
+void * _Nullable
+swift::_swift_stdlib_thread_getspecific(__swift_thread_key_t key) {
+ return FlsGetValue(key);
+}
+
+SWIFT_RUNTIME_STDLIB_INTERFACE
+int swift::_swift_stdlib_thread_setspecific(__swift_thread_key_t key,
+ const void * _Nullable value) {
+ return FlsSetValue(key, const_cast<void *>(value)) == TRUE;
+}
+#else
+// Guard compilation on the typedef for __swift_thread_key_t in LibcShims.h
// being identical to the platform's pthread_key_t
-static_assert(std::is_same<__swift_pthread_key_t, pthread_key_t>::value,
+static_assert(std::is_same<__swift_thread_key_t, pthread_key_t>::value,
"This platform's pthread_key_t differs. If you hit this assert, "
"fix __swift_pthread_key_t's typedef in LibcShims.h by adding an "
"#if guard and definition for your platform");
SWIFT_RUNTIME_STDLIB_INTERFACE
-int swift::_swift_stdlib_pthread_key_create(
- __swift_pthread_key_t * _Nonnull key,
- void (* _Nullable destructor)(void *)
-) {
+int
+swift::_swift_stdlib_thread_key_create(__swift_thread_key_t * _Nonnull key,
+ void (* _Nullable destructor)(void *)) {
return pthread_key_create(key, destructor);
}
SWIFT_RUNTIME_STDLIB_INTERFACE
-void * _Nullable swift::_swift_stdlib_pthread_getspecific(
- __swift_pthread_key_t key
-) {
+void * _Nullable
+swift::_swift_stdlib_thread_getspecific(__swift_thread_key_t key) {
return pthread_getspecific(key);
}
SWIFT_RUNTIME_STDLIB_INTERFACE
-int swift::_swift_stdlib_pthread_setspecific(
- __swift_pthread_key_t key, const void * _Nullable value
-) {
+int swift::_swift_stdlib_thread_setspecific(__swift_thread_key_t key,
+ const void * _Nullable value) {
return pthread_setspecific(key, value);
}
+#endif
#if defined(__APPLE__)
#include <malloc/malloc.h>
diff --git a/stdlib/public/stubs/UnicodeNormalization.cpp b/stdlib/public/stubs/UnicodeNormalization.cpp
index 950f2e4..fe3a29d 100644
--- a/stdlib/public/stubs/UnicodeNormalization.cpp
+++ b/stdlib/public/stubs/UnicodeNormalization.cpp
@@ -16,14 +16,26 @@
#include "../SwiftShims/UnicodeShims.h"
-#if !defined(__APPLE__)
-#include "swift/Basic/Lazy.h"
-#include "swift/Runtime/Config.h"
-#include "swift/Runtime/Debug.h"
+#include <stdint.h>
-#include <algorithm>
-#include <mutex>
-#include <assert.h>
+#if defined(__APPLE__)
+
+// Declare a few external functions to avoid a dependency on ICU headers.
+extern "C" {
+typedef struct UBreakIterator UBreakIterator;
+typedef enum UBreakIteratorType {} UBreakIteratorType;
+typedef enum UErrorCode {} UErrorCode;
+typedef uint16_t UChar;
+
+void ubrk_close(UBreakIterator *);
+UBreakIterator *ubrk_open(UBreakIteratorType, const char *, const UChar *,
+ int32_t, UErrorCode *);
+int32_t ubrk_preceding(UBreakIterator *, int32_t);
+int32_t ubrk_following(UBreakIterator *, int32_t);
+void ubrk_setText(UBreakIterator *, const UChar *, int32_t, UErrorCode *);
+}
+
+#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
@@ -36,6 +48,16 @@
#pragma clang diagnostic pop
+#endif
+
+#if !defined(__APPLE__)
+#include "swift/Basic/Lazy.h"
+#include "swift/Runtime/Config.h"
+#include "swift/Runtime/Debug.h"
+
+#include <algorithm>
+#include <mutex>
+#include <assert.h>
static const UCollator *MakeRootCollator() {
UErrorCode ErrorCode = U_ZERO_ERROR;
@@ -88,11 +110,7 @@
for (unsigned char c = 0; c < 128; ++c) {
UErrorCode ErrorCode = U_ZERO_ERROR;
intptr_t NumCollationElts = 0;
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
UChar Buffer[1];
-#else
- uint16_t Buffer[1];
-#endif
Buffer[0] = c;
UCollationElements *CollationIterator =
@@ -129,19 +147,13 @@
int32_t LeftLength,
const uint16_t *RightString,
int32_t RightLength) {
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
// ICU UChar type is platform dependent. In Cygwin, it is defined
// as wchar_t which size is 2. It seems that the underlying binary
// representation is same with swift utf16 representation.
// On Clang 4.0 under a recent Linux, ICU uses the built-in char16_t type.
return ucol_strcoll(GetRootCollator(),
- reinterpret_cast<const UChar *>(LeftString), LeftLength,
- reinterpret_cast<const UChar *>(RightString), RightLength);
-#else
- return ucol_strcoll(GetRootCollator(),
- LeftString, LeftLength,
- RightString, RightLength);
-#endif
+ reinterpret_cast<const UChar *>(LeftString), LeftLength,
+ reinterpret_cast<const UChar *>(RightString), RightLength);
}
/// Compares the strings via the Unicode Collation Algorithm on the root locale.
@@ -159,12 +171,8 @@
UErrorCode ErrorCode = U_ZERO_ERROR;
uiter_setUTF8(&LeftIterator, reinterpret_cast<const char *>(LeftString), LeftLength);
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
uiter_setString(&RightIterator, reinterpret_cast<const UChar *>(RightString),
RightLength);
-#else
- uiter_setString(&RightIterator, RightString, RightLength);
-#endif
uint32_t Diff = ucol_strcollIter(GetRootCollator(),
&LeftIterator, &RightIterator, &ErrorCode);
@@ -202,14 +210,9 @@
void *swift::_swift_stdlib_unicodeCollationIterator_create(
const __swift_uint16_t *Str, __swift_uint32_t Length) {
UErrorCode ErrorCode = U_ZERO_ERROR;
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
- UCollationElements *CollationIterator = ucol_openElements(
- GetRootCollator(), reinterpret_cast<const UChar *>(Str), Length,
- &ErrorCode);
-#else
- UCollationElements *CollationIterator = ucol_openElements(
- GetRootCollator(), Str, Length, &ErrorCode);
-#endif
+ UCollationElements *CollationIterator =
+ ucol_openElements(GetRootCollator(), reinterpret_cast<const UChar *>(Str),
+ Length, &ErrorCode);
if (U_FAILURE(ErrorCode)) {
swift::crash("_swift_stdlib_unicodeCollationIterator_create: ucol_openElements() failed.");
}
@@ -247,17 +250,11 @@
const uint16_t *Source,
int32_t SourceLength) {
UErrorCode ErrorCode = U_ZERO_ERROR;
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
uint32_t OutputLength = u_strToUpper(reinterpret_cast<UChar *>(Destination),
DestinationCapacity,
reinterpret_cast<const UChar *>(Source),
SourceLength,
"", &ErrorCode);
-#else
- uint32_t OutputLength = u_strToUpper(Destination, DestinationCapacity,
- Source, SourceLength,
- "", &ErrorCode);
-#endif
if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
swift::crash("u_strToUpper: Unexpected error uppercasing unicode string.");
}
@@ -274,17 +271,11 @@
const uint16_t *Source,
int32_t SourceLength) {
UErrorCode ErrorCode = U_ZERO_ERROR;
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
uint32_t OutputLength = u_strToLower(reinterpret_cast<UChar *>(Destination),
DestinationCapacity,
reinterpret_cast<const UChar *>(Source),
SourceLength,
"", &ErrorCode);
-#else
- uint32_t OutputLength = u_strToLower(Destination, DestinationCapacity,
- Source, SourceLength,
- "", &ErrorCode);
-#endif
if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
swift::crash("u_strToLower: Unexpected error lowercasing unicode string.");
}
@@ -303,28 +294,6 @@
}
}
-#if defined(__APPLE__)
-#include <stdint.h>
-extern "C" {
-// Declare a few external functions to avoid a dependency on ICU headers.
-typedef struct UBreakIterator UBreakIterator;
-typedef enum UBreakIteratorType {} UBreakIteratorType;
-typedef enum UErrorCode {} UErrorCode;
-typedef uint16_t UChar;
-
-void ubrk_close(UBreakIterator *);
-UBreakIterator *ubrk_open(UBreakIteratorType, const char *, const UChar *,
- int32_t, UErrorCode *);
-int32_t ubrk_preceding(UBreakIterator *, int32_t);
-int32_t ubrk_following(UBreakIterator *, int32_t);
-void ubrk_setText(UBreakIterator *, const UChar *, int32_t, UErrorCode *);
-}
-
-// Force an autolink with ICU
-asm(".linker_option \"-licucore\"\n");
-
-#endif // defined(__APPLE__)
-
void swift::__swift_stdlib_ubrk_close(
swift::__swift_stdlib_UBreakIterator *bi) {
ubrk_close(ptr_cast<UBreakIterator>(bi));
@@ -333,16 +302,10 @@
swift::__swift_stdlib_UBreakIterator *swift::__swift_stdlib_ubrk_open(
swift::__swift_stdlib_UBreakIteratorType type, const char *locale,
const uint16_t *text, int32_t textLength, __swift_stdlib_UErrorCode *status) {
-#if defined(__CYGWIN__) || defined( _MSC_VER) || defined(__linux__)
return ptr_cast<swift::__swift_stdlib_UBreakIterator>(
ubrk_open(static_cast<UBreakIteratorType>(type), locale,
- reinterpret_cast<const UChar*>(text), textLength,
+ reinterpret_cast<const UChar *>(text), textLength,
ptr_cast<UErrorCode>(status)));
-#else
- return ptr_cast<swift::__swift_stdlib_UBreakIterator>(
- ubrk_open(static_cast<UBreakIteratorType>(type), locale, text, textLength,
- ptr_cast<UErrorCode>(status)));
-#endif
}
int32_t
@@ -356,9 +319,18 @@
int32_t offset) {
return ubrk_following(ptr_cast<UBreakIterator>(bi), offset);
}
+
void swift::__swift_stdlib_ubrk_setText(
swift::__swift_stdlib_UBreakIterator *bi, const __swift_stdlib_UChar *text,
__swift_int32_t textLength, __swift_stdlib_UErrorCode *status) {
return ubrk_setText(ptr_cast<UBreakIterator>(bi), ptr_cast<UChar>(text),
textLength, ptr_cast<UErrorCode>(status));
}
+
+// Force an autolink with ICU
+#if defined(__MACH__)
+asm(".linker_option \"-licucore\"\n");
+#elif defined(_WIN32)
+#pragma comment(lib, "icucore.lib")
+#endif // defined(__MACH__)
+
diff --git a/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.apinotes b/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.apinotes
index 6fd1676..af8b3b3 100644
--- a/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.apinotes
+++ b/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.apinotes
@@ -65,6 +65,23 @@
Tags:
- Name: InnerInSwift4
SwiftName: Outer.Inner
+Globals:
+ - Name: multiVersionedGlobal34Notes
+ SwiftName: multiVersionedGlobal34Notes_NEW
+ - Name: multiVersionedGlobal34Both
+ SwiftName: multiVersionedGlobal34Both_NEW
+ - Name: multiVersionedGlobal345Notes
+ SwiftName: multiVersionedGlobal345Notes_NEW
+ - Name: multiVersionedGlobal345Both
+ SwiftName: multiVersionedGlobal345Both_NEW
+ - Name: multiVersionedGlobal4Notes
+ SwiftName: multiVersionedGlobal4Notes_NEW
+ - Name: multiVersionedGlobal4Both
+ SwiftName: multiVersionedGlobal4Both_NEW
+ - Name: multiVersionedGlobal45Notes
+ SwiftName: multiVersionedGlobal45Notes_NEW
+ - Name: multiVersionedGlobal45Both
+ SwiftName: multiVersionedGlobal45Both_NEW
SwiftVersions:
- Version: 3.0
Classes:
@@ -207,3 +224,72 @@
SwiftName: aliasRenamedSwift3
- Name: OptionyEnumRenamed
SwiftName: renamedSwift3
+ Globals:
+ - Name: multiVersionedGlobal34
+ SwiftName: multiVersionedGlobal34_3
+ - Name: multiVersionedGlobal34Header
+ SwiftName: multiVersionedGlobal34Header_3
+ - Name: multiVersionedGlobal34Notes
+ SwiftName: multiVersionedGlobal34Notes_3
+ - Name: multiVersionedGlobal34Both
+ SwiftName: multiVersionedGlobal34Both_3
+ - Name: multiVersionedGlobal345
+ SwiftName: multiVersionedGlobal345_3
+ - Name: multiVersionedGlobal345Header
+ SwiftName: multiVersionedGlobal345Header_3
+ - Name: multiVersionedGlobal345Notes
+ SwiftName: multiVersionedGlobal345Notes_3
+ - Name: multiVersionedGlobal345Both
+ SwiftName: multiVersionedGlobal345Both_3
+ - Version: 5
+ Globals:
+ - Name: multiVersionedGlobal345
+ SwiftName: multiVersionedGlobal345_5
+ - Name: multiVersionedGlobal345Header
+ SwiftName: multiVersionedGlobal345Header_5
+ - Name: multiVersionedGlobal345Notes
+ SwiftName: multiVersionedGlobal345Notes_5
+ - Name: multiVersionedGlobal345Both
+ SwiftName: multiVersionedGlobal345Both_5
+ - Name: multiVersionedGlobal45
+ SwiftName: multiVersionedGlobal45_5
+ - Name: multiVersionedGlobal45Header
+ SwiftName: multiVersionedGlobal45Header_5
+ - Name: multiVersionedGlobal45Notes
+ SwiftName: multiVersionedGlobal45Notes_5
+ - Name: multiVersionedGlobal45Both
+ SwiftName: multiVersionedGlobal45Both_5
+ - Version: 4 # Versions are deliberately ordered as "3, 5, 4" to catch bugs.
+ Globals:
+ - Name: multiVersionedGlobal34
+ SwiftName: multiVersionedGlobal34_4
+ - Name: multiVersionedGlobal34Header
+ SwiftName: multiVersionedGlobal34Header_4
+ - Name: multiVersionedGlobal34Notes
+ SwiftName: multiVersionedGlobal34Notes_4
+ - Name: multiVersionedGlobal34Both
+ SwiftName: multiVersionedGlobal34Both_4
+ - Name: multiVersionedGlobal345
+ SwiftName: multiVersionedGlobal345_4
+ - Name: multiVersionedGlobal345Header
+ SwiftName: multiVersionedGlobal345Header_4
+ - Name: multiVersionedGlobal345Notes
+ SwiftName: multiVersionedGlobal345Notes_4
+ - Name: multiVersionedGlobal345Both
+ SwiftName: multiVersionedGlobal345Both_4
+ - Name: multiVersionedGlobal4
+ SwiftName: multiVersionedGlobal4_4
+ - Name: multiVersionedGlobal4Header
+ SwiftName: multiVersionedGlobal4Header_4
+ - Name: multiVersionedGlobal4Notes
+ SwiftName: multiVersionedGlobal4Notes_4
+ - Name: multiVersionedGlobal4Both
+ SwiftName: multiVersionedGlobal4Both_4
+ - Name: multiVersionedGlobal45
+ SwiftName: multiVersionedGlobal45_4
+ - Name: multiVersionedGlobal45Header
+ SwiftName: multiVersionedGlobal45Header_4
+ - Name: multiVersionedGlobal45Notes
+ SwiftName: multiVersionedGlobal45Notes_4
+ - Name: multiVersionedGlobal45Both
+ SwiftName: multiVersionedGlobal45Both_4
diff --git a/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.h b/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.h
index c3a23fd..43c932c 100644
--- a/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.h
+++ b/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/APINotesFrameworkTest.h
@@ -32,6 +32,7 @@
#import <APINotesFrameworkTest/Classes.h>
#import <APINotesFrameworkTest/Enums.h>
+#import <APINotesFrameworkTest/Globals.h>
#import <APINotesFrameworkTest/ImportAsMember.h>
#import <APINotesFrameworkTest/Properties.h>
#import <APINotesFrameworkTest/Protocols.h>
diff --git a/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/Globals.h b/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/Globals.h
new file mode 100644
index 0000000..059ecd7
--- /dev/null
+++ b/test/APINotes/Inputs/custom-frameworks/APINotesFrameworkTest.framework/Headers/Globals.h
@@ -0,0 +1,23 @@
+#pragma clang assume_nonnull begin
+
+int multiVersionedGlobal4;
+int multiVersionedGlobal4Notes;
+int multiVersionedGlobal4Header __attribute__((swift_name("multiVersionedGlobal4Header_NEW")));
+int multiVersionedGlobal4Both __attribute__((swift_name("multiVersionedGlobal4Both_OLD")));
+
+int multiVersionedGlobal34;
+int multiVersionedGlobal34Notes;
+int multiVersionedGlobal34Header __attribute__((swift_name("multiVersionedGlobal34Header_NEW")));
+int multiVersionedGlobal34Both __attribute__((swift_name("multiVersionedGlobal34Both_OLD")));
+
+int multiVersionedGlobal45;
+int multiVersionedGlobal45Notes;
+int multiVersionedGlobal45Header __attribute__((swift_name("multiVersionedGlobal45Header_NEW")));
+int multiVersionedGlobal45Both __attribute__((swift_name("multiVersionedGlobal45Both_OLD")));
+
+int multiVersionedGlobal345;
+int multiVersionedGlobal345Notes;
+int multiVersionedGlobal345Header __attribute__((swift_name("multiVersionedGlobal345Header_NEW")));
+int multiVersionedGlobal345Both __attribute__((swift_name("multiVersionedGlobal345Both_OLD")));
+
+#pragma clang assume_nonnull end
diff --git a/test/APINotes/versioned-multi.swift b/test/APINotes/versioned-multi.swift
new file mode 100644
index 0000000..d479c3c
--- /dev/null
+++ b/test/APINotes/versioned-multi.swift
@@ -0,0 +1,297 @@
+// RUN: %empty-directory(%t)
+
+// RUN: %target-swift-ide-test -F %S/Inputs/custom-frameworks -print-module -source-filename %s -module-to-print=APINotesFrameworkTest -function-definitions=false -print-regular-comments -swift-version 3 | %FileCheck -check-prefix=CHECK-SWIFT-3 %s
+
+// RUN: %target-swift-ide-test -F %S/Inputs/custom-frameworks -print-module -source-filename %s -module-to-print=APINotesFrameworkTest -function-definitions=false -swift-version 4 | %FileCheck -check-prefix=CHECK-SWIFT-4 %s
+
+// RUN: %target-swift-ide-test -F %S/Inputs/custom-frameworks -print-module -source-filename %s -module-to-print=APINotesFrameworkTest -function-definitions=false -swift-version 5 | %FileCheck -check-prefix=CHECK-SWIFT-5 %s
+
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal4_4: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Notes_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4Notes: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal4Notes_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal4Notes_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4Notes_NEW: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Header_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4Header: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal4Header_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal4Header_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4Header_NEW: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Both_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4Both: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal4Both_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal4Both_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal4Both_NEW: Int32
+
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal34_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal34_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34_4: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Notes_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Notes: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal34Notes_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal34Notes_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Notes_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal34Notes_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Notes_NEW: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Header_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Header: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal34Header_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal34Header_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Header_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal34Header_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Header_NEW: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Both_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Both: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal34Both_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal34Both_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Both_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal34Both_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal34Both_NEW: Int32
+
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal45_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45_5: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Notes_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45Notes: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal45Notes_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45Notes_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45Notes_5: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Header_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45Header: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal45Header_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45Header_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45Header_5: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Both_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45Both: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal45Both_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45Both_4")
+// CHECK-SWIFT-3: var multiVersionedGlobal45Both_5: Int32
+
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal345_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal345_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345_5: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Notes_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Notes: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal345Notes_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal345Notes_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Notes_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345Notes_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Notes_5: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Header_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Header: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal345Header_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal345Header_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Header_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345Header_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Header_5: Int32
+// CHECK-SWIFT-3: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Both_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Both: Int32
+// CHECK-SWIFT-3: var multiVersionedGlobal345Both_3: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 4, renamed: "multiVersionedGlobal345Both_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Both_4: Int32
+// CHECK-SWIFT-3: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345Both_3")
+// CHECK-SWIFT-3: var multiVersionedGlobal345Both_5: Int32
+
+
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal4_4: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4Notes: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal4Notes_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal4Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4Notes_NEW: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4Header: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal4Header_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal4Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4Header_NEW: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4Both: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal4Both_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal4Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal4Both_NEW: Int32
+
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal34_4: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Notes: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Notes_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal34Notes_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal34Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Notes_NEW: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Header: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Header_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal34Header_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal34Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Header_NEW: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Both: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Both_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal34Both_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal34Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal34Both_NEW: Int32
+
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal45_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45_5: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45Notes: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal45Notes_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45Notes_5: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45Header: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal45Header_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45Header_5: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45Both: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal45Both_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal45Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal45Both_5: Int32
+
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal345_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345_5: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Notes: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Notes_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal345Notes_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345Notes_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Notes_5: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Header: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Header_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal345Header_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345Header_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Header_5: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Both: Int32
+// CHECK-SWIFT-4: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Both_3: Int32
+// CHECK-SWIFT-4: var multiVersionedGlobal345Both_4: Int32
+// CHECK-SWIFT-4: @available(swift, introduced: 5, renamed: "multiVersionedGlobal345Both_4")
+// CHECK-SWIFT-4: var multiVersionedGlobal345Both_5: Int32
+
+
+// CHECK-SWIFT-5: var multiVersionedGlobal4: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal4")
+// CHECK-SWIFT-5: var multiVersionedGlobal4_4: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Notes_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal4Notes: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal4Notes_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal4Notes_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal4Notes_NEW: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Header_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal4Header: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal4Header_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal4Header_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal4Header_NEW: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal4Both_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal4Both: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal4Both_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal4Both_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal4Both_NEW: Int32
+
+// CHECK-SWIFT-5: var multiVersionedGlobal34: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34")
+// CHECK-SWIFT-5: var multiVersionedGlobal34_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal34")
+// CHECK-SWIFT-5: var multiVersionedGlobal34_4: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Notes_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Notes: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34Notes_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Notes_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal34Notes_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Notes_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal34Notes_NEW: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Header_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Header: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34Header_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Header_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal34Header_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Header_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal34Header_NEW: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal34Both_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Both: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal34Both_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Both_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal34Both_NEW")
+// CHECK-SWIFT-5: var multiVersionedGlobal34Both_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal34Both_NEW: Int32
+
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal45_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal45_5: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Notes_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45Notes: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal45Notes_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45Notes_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal45Notes_5: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Header_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45Header: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal45Header_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45Header_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal45Header_5: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal45Both_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45Both: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal45Both_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal45Both_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal45Both_5: Int32
+
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal345_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal345_5: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Notes_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Notes: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345Notes_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Notes_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal345Notes_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Notes_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal345Notes_5: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Header_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Header: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345Header_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Header_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal345Header_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Header_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal345Header_5: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 3, renamed: "multiVersionedGlobal345Both_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Both: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 4, renamed: "multiVersionedGlobal345Both_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Both_3: Int32
+// CHECK-SWIFT-5: @available(swift, obsoleted: 5, renamed: "multiVersionedGlobal345Both_5")
+// CHECK-SWIFT-5: var multiVersionedGlobal345Both_4: Int32
+// CHECK-SWIFT-5: var multiVersionedGlobal345Both_5: Int32
diff --git a/test/ClangImporter/Inputs/privateframeworks/overlay/SomeKit.swift b/test/ClangImporter/Inputs/privateframeworks/overlay/SomeKit.swift
new file mode 100644
index 0000000..cc49600
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/overlay/SomeKit.swift
@@ -0,0 +1,49 @@
+@_exported import SomeKit
+import Foundation
+
+extension SKWidget {
+ public func extensionMethod() -> ExtensionType { return ExtensionType() }
+
+ public struct ExtensionType { }
+}
+
+extension SKWidget.ExtensionType {
+ public func foo() { }
+}
+
+extension NSObject {
+ public func doSomethingElse(_: SKWidget) { }
+}
+
+extension SKWidget.Error {
+ public func getCode(from widget: SKWidget) -> SKWidget.Error.Code {
+ return widget.getCurrentError()
+ }
+}
+
+extension SKWidget.Error.Code {
+ public var isBoom: Bool {
+ return self == .boom
+ }
+}
+
+public protocol HasAnObject {
+ var anObject: NSObject { get set }
+}
+
+extension SKWidget : HasAnObject { }
+
+@inline(__always)
+public func inlineWidgetOperations(_ widget: SKWidget) {
+ widget.extensionMethod().foo()
+ widget.someObjCMethod()
+ widget.someObjCExtensionMethod()
+ widget.doSomething(with: widget)
+ widget.doSomethingElse(widget)
+ let obj = widget.anObject
+ widget.anObject = obj
+ _ = SKWidget.Error(.boom).getCode(from: widget).isBoom
+ var hao: HasAnObject = widget
+ someKitGlobalFunc()
+ hao.anObject = widget
+}
diff --git a/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Headers/SKWidget.h b/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Headers/SKWidget.h
new file mode 100644
index 0000000..cfd710f
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Headers/SKWidget.h
@@ -0,0 +1,26 @@
+@import ObjectiveC;
+
+@interface SKWidget : NSObject
+- (void)someObjCMethod;
+@end
+
+@interface SKWidget(ObjCAPI)
+- (void)someObjCExtensionMethod;
+@property (readwrite,strong,nonnull) NSObject *anObject;
+@end
+
+@interface NSObject (SKWidget)
+- (void)doSomethingWithWidget:(nonnull SKWidget *)widget;
+@end
+
+extern NSString * _Nonnull const SKWidgetErrorDomain;
+typedef enum __attribute__((ns_error_domain(SKWidgetErrorDomain))) __attribute__((swift_name("SKWidget.Error"))) SKWidgetErrorCode : NSInteger {
+ SKWidgetErrorNone = 0,
+ SKWidgetErrorBoom = 1
+} SKWidgetErrorCode;
+
+@interface SKWidget(Erroneous)
+- (SKWidgetErrorCode)getCurrentError;
+@end
+
+extern void someKitGlobalFunc(void);
diff --git a/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Headers/SomeKit.h b/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Headers/SomeKit.h
new file mode 100644
index 0000000..17a4cc8
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Headers/SomeKit.h
@@ -0,0 +1 @@
+#import <SomeKit/SKWidget.h>
diff --git a/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Modules/module.modulemap b/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Modules/module.modulemap
new file mode 100644
index 0000000..ae4b276
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withoutprivate/SomeKit.framework/Modules/module.modulemap
@@ -0,0 +1,6 @@
+framework module SomeKit {
+ umbrella header "SomeKit.h"
+ module * {
+ export *
+ }
+}
diff --git a/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Headers/SKWidget.h b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Headers/SKWidget.h
new file mode 100644
index 0000000..dd99ff7
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Headers/SKWidget.h
@@ -0,0 +1 @@
+#import <SomeKitCore/SKWidget.h>
diff --git a/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Headers/SomeKit.h b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Headers/SomeKit.h
new file mode 100644
index 0000000..17a4cc8
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Headers/SomeKit.h
@@ -0,0 +1 @@
+#import <SomeKit/SKWidget.h>
diff --git a/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Modules/module.modulemap b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Modules/module.modulemap
new file mode 100644
index 0000000..ae4b276
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKit.framework/Modules/module.modulemap
@@ -0,0 +1,6 @@
+framework module SomeKit {
+ umbrella header "SomeKit.h"
+ module * {
+ export *
+ }
+}
diff --git a/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Headers/SKWidget.h b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Headers/SKWidget.h
new file mode 100644
index 0000000..0370e85
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Headers/SKWidget.h
@@ -0,0 +1,27 @@
+@import ObjectiveC;
+@import Foundation;
+
+@interface SKWidget : NSObject
+- (void)someObjCMethod;
+@end
+
+@interface SKWidget(ObjCAPI)
+- (void)someObjCExtensionMethod;
+@property (readwrite,strong,nonnull) NSObject *anObject;
+@end
+
+@interface NSObject (SKWidget)
+- (void)doSomethingWithWidget:(nonnull SKWidget *)widget;
+@end
+
+extern NSString * _Nonnull const SKWidgetErrorDomain;
+typedef enum __attribute__((ns_error_domain(SKWidgetErrorDomain))) __attribute__((swift_name("SKWidget.Error"))) SKWidgetErrorCode : NSInteger {
+ SKWidgetErrorNone = 0,
+ SKWidgetErrorBoom = 1
+} SKWidgetErrorCode;
+
+@interface SKWidget(Erroneous)
+- (SKWidgetErrorCode)getCurrentError;
+@end
+
+extern void someKitGlobalFunc(void);
diff --git a/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Headers/SomeKitCore.h b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Headers/SomeKitCore.h
new file mode 100644
index 0000000..dd99ff7
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Headers/SomeKitCore.h
@@ -0,0 +1 @@
+#import <SomeKitCore/SKWidget.h>
diff --git a/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Modules/module.modulemap b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Modules/module.modulemap
new file mode 100644
index 0000000..30f9770
--- /dev/null
+++ b/test/ClangImporter/Inputs/privateframeworks/withprivate/SomeKitCore.framework/Modules/module.modulemap
@@ -0,0 +1,7 @@
+framework module SomeKitCore {
+ umbrella header "SomeKitCore.h"
+ export_as SomeKit
+ module * {
+ export *
+ }
+}
diff --git a/test/ClangImporter/enum-error.swift b/test/ClangImporter/enum-error.swift
index adb476b..babf82f 100644
--- a/test/ClangImporter/enum-error.swift
+++ b/test/ClangImporter/enum-error.swift
@@ -1,14 +1,14 @@
// REQUIRES: OS=macosx
-// RUN: %target-swift-frontend -DVALUE -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=VALUE
-// RUN: %target-swift-frontend -DEMPTYCATCH -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=EMPTYCATCH
-// RUN: %target-swift-frontend -DASQEXPR -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=ASQEXPR
-// RUN: %target-swift-frontend -DASBANGEXPR -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=ASBANGEXPR
-// RUN: %target-swift-frontend -DCATCHIS -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=CATCHIS
-// RUN: %target-swift-frontend -DCATCHAS -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=CATCHAS
-// RUN: %target-swift-frontend -DGENERICONLY -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=GENERICONLY
+// RUN: %target-swift-frontend -DVALUE -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=VALUE
+// RUN: %target-swift-frontend -DEMPTYCATCH -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=EMPTYCATCH
+// RUN: %target-swift-frontend -DASQEXPR -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=ASQEXPR
+// RUN: %target-swift-frontend -DASBANGEXPR -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=ASBANGEXPR
+// RUN: %target-swift-frontend -DCATCHIS -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=CATCHIS
+// RUN: %target-swift-frontend -DCATCHAS -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=CATCHAS
+// RUN: %target-swift-frontend -DGENERICONLY -emit-sil %s -import-objc-header %S/Inputs/enum-error.h | %FileCheck %s -check-prefix=GENERICONLY
-// RUN: not %target-swift-frontend -DEXHAUSTIVE -emit-sil -sil-serialize-witness-tables %s -import-objc-header %S/Inputs/enum-error.h 2>&1 | %FileCheck %s -check-prefix=EXHAUSTIVE
+// RUN: not %target-swift-frontend -DEXHAUSTIVE -emit-sil %s -import-objc-header %S/Inputs/enum-error.h 2>&1 | %FileCheck %s -check-prefix=EXHAUSTIVE
// RUN: %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/enum-error.h -DERRORS -verify
// RUN: echo '#include "enum-error.h"' > %t.m
diff --git a/test/ClangImporter/private_frameworks.swift b/test/ClangImporter/private_frameworks.swift
new file mode 100644
index 0000000..e0005d2
--- /dev/null
+++ b/test/ClangImporter/private_frameworks.swift
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// FIXME: BEGIN -enable-source-import hackaround
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t %clang-importer-sdk-path/swift-modules/Foundation.swift
+// FIXME: END -enable-source-import hackaround
+
+// Build the overlay with private frameworks.
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -F %S/Inputs/privateframeworks/withprivate -o %t %S/Inputs/privateframeworks/overlay/SomeKit.swift
+
+// Use the overlay with private frameworks.
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withprivate %s -verify
+
+// Use the overlay without private frameworks.
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate -I %t %s
+
+// Build the overlay with public frameworks.
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -F %S/Inputs/privateframeworks/withoutprivate -o %t %S/Inputs/privateframeworks/overlay/SomeKit.swift
+
+// Use the overlay with private frameworks.
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withprivate %s -verify
+
+// Use the overlay without private frameworks.
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -o /dev/null -F %S/Inputs/privateframeworks/withoutprivate -I %t %s
+
+// REQUIRES: objc_interop
+
+import SomeKit
+
+func testWidget(widget: SKWidget) {
+ _ = widget.someObjCMethod()
+ _ = widget.someObjCExtensionMethod()
+
+ let ext = widget.extensionMethod()
+ ext.foo()
+
+ widget.doSomethingElse(widget)
+ inlineWidgetOperations(widget)
+}
+
+func testError(widget: SKWidget) {
+ let c: SKWidget.Error.Code = SKWidget.Error(.boom).getCode(from: widget)
+ if c.isBoom { }
+}
+
diff --git a/test/Compatibility/anyobject_class.swift b/test/Compatibility/anyobject_class.swift
new file mode 100644
index 0000000..d793ec0
--- /dev/null
+++ b/test/Compatibility/anyobject_class.swift
@@ -0,0 +1,7 @@
+// RUN: %target-typecheck-verify-swift -swift-version 3
+// RUN: %target-typecheck-verify-swift -swift-version 4
+// RUN: not %target-swift-frontend -tyepcheck -swift-version 5
+
+protocol P : class, AnyObject { } // expected-warning{{redundant inheritance from 'AnyObject' and Swift 3 'class' keyword}}{{14-21=}}
+// expected-warning@-1{{redundant layout constraint 'Self' : 'AnyObject'}}
+// expected-note@-2{{layout constraint constraint 'Self' : 'AnyObject' written here}}
diff --git a/test/Compatibility/dot_keywords.swift b/test/Compatibility/dot_keywords.swift
new file mode 100644
index 0000000..bbb519c
--- /dev/null
+++ b/test/Compatibility/dot_keywords.swift
@@ -0,0 +1,13 @@
+// RUN: %target-typecheck-verify-swift -swift-version 3
+
+// Static function in protocol should have `Self.` instead of its protocol name
+protocol P {}
+
+extension P {
+ static func f1() {}
+
+ func g() {
+ f1() // expected-error {{use of unresolved identifier 'f1'}}
+ }
+}
+
diff --git a/test/Constraints/array_literal.swift b/test/Constraints/array_literal.swift
index 899bb5d..851e27f 100644
--- a/test/Constraints/array_literal.swift
+++ b/test/Constraints/array_literal.swift
@@ -276,7 +276,7 @@
class Manager: Person { }
-let router = Company(
+let routerPeople = Company(
routes: [
{ () -> Employee.Type in
_ = ()
@@ -302,7 +302,7 @@
struct Beef : Pear {}
-let router = Company(
+let routerFruit = Company(
routes: [
// FIXME: implement join() for existentials
// expected-error@+1 {{cannot convert value of type '() -> Tomato.Type' to expected element type '() -> _'}}
diff --git a/test/Constraints/suspicious_bit_casts.swift b/test/Constraints/suspicious_bit_casts.swift
index 86cfec1..e75b506 100644
--- a/test/Constraints/suspicious_bit_casts.swift
+++ b/test/Constraints/suspicious_bit_casts.swift
@@ -16,6 +16,8 @@
class C<T> {}
class D: C<Int> {}
+class N<T> {}
+
func castAToB(a: A) -> B {
// expected-warning@+1{{'unsafeBitCast' from 'A' to 'B' can be replaced with 'unsafeDowncast'}} {{7-20=unsafeDowncast}}
_ = unsafeBitCast(a, to: B.self)
@@ -29,6 +31,10 @@
return unsafeBitCast(c, to: D.self)
}
+func castNToD<T>(n: N<T>) -> D {
+ return unsafeBitCast(n, to: D.self) // CHECK-NOT: warning
+}
+
func castDToC<T>(d: D) -> (C<T>, C<Int>) {
let a = unsafeBitCast(d, to: C<T>.self) // not necessarily a no-op if T != Int
// expected-warning@+1{{'unsafeBitCast' from 'D' to 'C<Int>' is unnecessary}}{{11-25=}}{{26-44=}}
diff --git a/test/IDE/Inputs/foo_swift_module.printed.comments.txt b/test/IDE/Inputs/foo_swift_module.printed.comments.txt
index 2f96926..c5013e9 100644
--- a/test/IDE/Inputs/foo_swift_module.printed.comments.txt
+++ b/test/IDE/Inputs/foo_swift_module.printed.comments.txt
@@ -11,11 +11,11 @@
postfix operator =>
-func %%%(lhs: Int, rhs: Int) -> Int
+func %%% (lhs: Int, rhs: Int) -> Int
-postfix func =->(lhs: Int) -> Int
+postfix func =-> (lhs: Int) -> Int
-postfix func =>(lhs: Int) -> Int
+postfix func => (lhs: Int) -> Int
struct BarGenericSwiftStruct1<T> {
init(t: T)
diff --git a/test/IDE/coloring.swift b/test/IDE/coloring.swift
index 24e915f..f9797b3 100644
--- a/test/IDE/coloring.swift
+++ b/test/IDE/coloring.swift
@@ -227,6 +227,15 @@
// CHECK: <str>"This is string </str>\<anchor>(</anchor>genFn({(a:<type>Int</type> -> <type>Int</type>) <kw>in</kw> a})<anchor>)</anchor><str> interpolation"</str>
"This is string \(genFn({(a:Int -> Int) in a})) interpolation"
+ // CHECK: <str>"This is unterminated</str>
+ "This is unterminated
+
+ // CHECK: <str>"This is unterminated with ignored \(interpolation) in it</str>
+ "This is unterminated with ignored \(interpolation) in it
+
+ // CHECK: <str>"This is terminated with invalid \(interpolation" + "in it"</str>
+ "This is terminated with invalid \(interpolation" + "in it"
+
// CHECK: <str>"""
// CHECK-NEXT: This is a multiline string.
// CHECK-NEXT: """</str>
@@ -236,9 +245,19 @@
// CHECK: <str>"""
// CHECK-NEXT: This is a multiline</str>\<anchor>(</anchor> <str>"interpolated"</str> <anchor>)</anchor><str>string
+ // CHECK-NEXT: </str>\<anchor>(</anchor>
+ // CHECK-NEXT: <str>"""
+ // CHECK-NEXT: inner
+ // CHECK-NEXT: """</str>
+ // CHECK-NEXT: <anchor>)</anchor><str>
// CHECK-NEXT: """</str>
"""
This is a multiline\( "interpolated" )string
+ \(
+ """
+ inner
+ """
+ )
"""
// CHECK: <str>"</str>\<anchor>(</anchor><int>1</int><anchor>)</anchor>\<anchor>(</anchor><int>1</int><anchor>)</anchor><str>"</str>
diff --git a/test/IDE/print_ast_tc_decls.swift b/test/IDE/print_ast_tc_decls.swift
index 9bc6ad6..a54496b 100644
--- a/test/IDE/print_ast_tc_decls.swift
+++ b/test/IDE/print_ast_tc_decls.swift
@@ -1101,7 +1101,7 @@
static postfix func <*>(_: Self)
}
// PASS_2500: {{^}}protocol d2600_ProtocolWithOperator1 {{{$}}
-// PASS_2500-NEXT: {{^}} postfix static func <*>(_: Self){{$}}
+// PASS_2500-NEXT: {{^}} postfix static func <*> (_: Self){{$}}
// PASS_2500-NEXT: {{^}}}{{$}}
struct d2601_TestAssignment {}
@@ -1110,7 +1110,7 @@
return 0
}
// PASS_2500-LABEL: {{^}}infix operator %%%{{$}}
-// PASS_2500: {{^}}func %%%(lhs: inout d2601_TestAssignment, rhs: d2601_TestAssignment) -> Int{{$}}
+// PASS_2500: {{^}}func %%% (lhs: inout d2601_TestAssignment, rhs: d2601_TestAssignment) -> Int{{$}}
precedencegroup BoringPrecedence {
// PASS_2500-LABEL: {{^}}precedencegroup BoringPrecedence {{{$}}
diff --git a/test/IDE/unterminated_multiline.swift b/test/IDE/unterminated_multiline.swift
new file mode 100644
index 0000000..4fd7a60
--- /dev/null
+++ b/test/IDE/unterminated_multiline.swift
@@ -0,0 +1,16 @@
+// RUN: %target-swift-ide-test -syntax-coloring -source-filename %s | %FileCheck %s
+// RUN: %target-swift-ide-test -syntax-coloring -typecheck -source-filename %s | %FileCheck %s
+
+// CHECK: <kw>let</kw> x = <str>"""
+// CHECK-NEXT: This is an unterminated
+// CHECK-NEXT: \( "multiline" )
+// CHECK-NEXT: string followed by code
+// CHECK-NEXT: ""
+// CHECK-NEXT: func foo() {}
+// CHECK-NEXT: </str>
+let x = """
+ This is an unterminated
+ \( "multiline" )
+ string followed by code
+ ""
+func foo() {}
diff --git a/test/IRGen/class_resilience.sil b/test/IRGen/class_resilience.sil
new file mode 100644
index 0000000..649c5e8
--- /dev/null
+++ b/test/IRGen/class_resilience.sil
@@ -0,0 +1,42 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
+// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class %S/../Inputs/resilient_class.swift -I %t
+// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience %s | %FileCheck %s
+// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -O %s
+
+// REQUIRES: CPU=x86_64
+
+sil_stage canonical
+
+import Builtin
+import Swift
+import SwiftShims
+
+import resilient_class
+
+// Make sure that an alloc_ref of a resilient class loads the size and alignment
+// of the instance from metadata.
+//
+// Perhaps we should not serialize allocating initializers, then this would not
+// be an issue.
+
+// CHECK-LABEL: define {{(protected )?}}swiftcc void @allocResilientOutsideParent()
+// CHECK: [[META:%.*]] = call %swift.type* @_T015resilient_class22ResilientOutsideParentCMa()
+// CHECK-NEXT: [[META_ADDR:%.*]] = bitcast %swift.type* [[META]] to i8*
+// CHECK-NEXT: [[SIZE_ADDR:%.*]] = getelementptr inbounds i8, i8* [[META_ADDR]], i32 48
+// CHECK-NEXT: [[SIZE_PTR:%.*]] = bitcast i8* [[SIZE_ADDR]] to i32*
+// CHECK-NEXT: [[SIZE_2:%.*]] = load i32, i32* [[SIZE_PTR]], align 8
+// CHECK-NEXT: [[SIZE:%.*]] = zext i32 [[SIZE_2]] to i64
+// CHECK-NEXT: [[ALIGN_ADDR:%.*]] = getelementptr inbounds i8, i8* [[META_ADDR]], i32 52
+// CHECK-NEXT: [[ALIGN_PTR:%.*]] = bitcast i8* [[ALIGN_ADDR]] to i16*
+// CHECK-NEXT: [[ALIGN_2:%.*]] = load i16, i16* [[ALIGN_PTR]], align 4
+// CHECK-NEXT: [[ALIGN:%.*]] = zext i16 [[ALIGN_2]] to i64
+// CHECK-NEXT: call noalias %swift.refcounted* @swift_rt_swift_allocObject(%swift.type* [[META]], i64 [[SIZE]], i64 [[ALIGN]])
+
+sil @allocResilientOutsideParent : $@convention(thin) () -> () {
+bb0:
+ %c = alloc_ref $ResilientOutsideParent
+ dealloc_ref %c : $ResilientOutsideParent
+ %result = tuple ()
+ return %result : $()
+}
diff --git a/test/IRGen/existentials_objc.sil b/test/IRGen/existentials_objc.sil
index 420bd81..746707c 100644
--- a/test/IRGen/existentials_objc.sil
+++ b/test/IRGen/existentials_objc.sil
@@ -80,7 +80,7 @@
// CHECK: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[U1]], i32 0, i32 1
// CHECK: store i8** %1, i8*** [[T0]], align 8
// CHECK: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[U1]], i32 0, i32 0
- // CHECK: call void @swift_unknownUnownedInit(%swift.unowned* [[T0]], %objc_object* %0)
+ // CHECK: call %swift.unowned* @swift_unknownUnownedInit(%swift.unowned* [[T0]], %objc_object* %0)
// CHECK: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[U1]], i32 0, i32 0
// CHECK: [[T1:%.*]] = call %objc_object* @swift_unknownUnownedLoadStrong(%swift.unowned* [[T0]])
@@ -112,7 +112,7 @@
// CHECK: [[DEST_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: store i8** [[SRC_WITNESS]], i8*** [[DEST_WITNESS_ADDR]]
// CHECK: [[DEST_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
- // CHECK: call void @swift_unknownWeakInit(%swift.weak* [[DEST_REF_ADDR]], %objc_object* [[SRC_REF]])
+ // CHECK: call %swift.weak* @swift_unknownWeakInit(%swift.weak* [[DEST_REF_ADDR]], %objc_object* [[SRC_REF]])
store_weak %a to [initialization] %w : $*@sil_weak CP?
// CHECK: [[SRC_REF:%.*]] = inttoptr {{.*}} %objc_object*
@@ -120,7 +120,7 @@
// CHECK: [[DEST_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: store i8** [[SRC_WITNESS]], i8*** [[DEST_WITNESS_ADDR]]
// CHECK: [[DEST_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
- // CHECK: call void @swift_unknownWeakAssign(%swift.weak* [[DEST_REF_ADDR]], %objc_object* [[SRC_REF]])
+ // CHECK: call %swift.weak* @swift_unknownWeakAssign(%swift.weak* [[DEST_REF_ADDR]], %objc_object* [[SRC_REF]])
store_weak %a to %w : $*@sil_weak CP?
// CHECK: [[SRC_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
@@ -137,7 +137,7 @@
// CHECK: [[DEST_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 0
// CHECK: [[SRC_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
- // CHECK: call void @swift_unknownWeakTakeInit(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
+ // CHECK: call %swift.weak* @swift_unknownWeakTakeInit(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
// CHECK: [[SRC_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: [[WITNESS:%.*]] = load i8**, i8*** [[SRC_WITNESS_ADDR]], align 8
// CHECK: [[DEST_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 1
@@ -146,7 +146,7 @@
// CHECK: [[DEST_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 0
// CHECK: [[SRC_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
- // CHECK: call void @swift_unknownWeakTakeAssign(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
+ // CHECK: call %swift.weak* @swift_unknownWeakTakeAssign(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
// CHECK: [[SRC_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: [[WITNESS:%.*]] = load i8**, i8*** [[SRC_WITNESS_ADDR]], align 8
// CHECK: [[DEST_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 1
@@ -155,7 +155,7 @@
// CHECK: [[DEST_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 0
// CHECK: [[SRC_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
- // CHECK: call void @swift_unknownWeakCopyInit(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
+ // CHECK: call %swift.weak* @swift_unknownWeakCopyInit(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
// CHECK: [[SRC_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: [[WITNESS:%.*]] = load i8**, i8*** [[SRC_WITNESS_ADDR]], align 8
// CHECK: [[DEST_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 1
@@ -164,7 +164,7 @@
// CHECK: [[DEST_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 0
// CHECK: [[SRC_REF_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
- // CHECK: call void @swift_unknownWeakCopyAssign(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
+ // CHECK: call %swift.weak* @swift_unknownWeakCopyAssign(%swift.weak* [[DEST_REF_ADDR]], %swift.weak* [[SRC_REF_ADDR]])
// CHECK: [[SRC_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: [[WITNESS:%.*]] = load i8**, i8*** [[SRC_WITNESS_ADDR]], align 8
// CHECK: [[DEST_WITNESS_ADDR:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* [[V]], i32 0, i32 1
diff --git a/test/IRGen/keypaths.sil b/test/IRGen/keypaths.sil
index 4cb4074..b7dbb0e 100644
--- a/test/IRGen/keypaths.sil
+++ b/test/IRGen/keypaths.sil
@@ -6,19 +6,25 @@
sil_stage canonical
import Swift
-struct S {
+struct S: Hashable {
var x: Int
let y: String
var z: C
var reabstracted: () -> ()
+
+ var hashValue: Int { get }
+ static func ==(_: S, _: S) -> Bool
}
-class C {
+class C: Hashable {
final var x: Int
final let y: String
final var z: S
var w: Int { get set }
init()
+
+ var hashValue: Int { get }
+ static func ==(_: C, _: C) -> Bool
}
sil_vtable C {}
@@ -260,23 +266,20 @@
// CHECK-LABEL: define{{( protected)?}} swiftcc void @stored_property_generics(%swift.type* %T, %swift.type* %U)
sil @stored_property_generics : $@convention(thin) <T, U> () -> () {
entry:
- // CHECK: [[PTR:%.*]] = bitcast [1 x %swift.type*]* [[ARGS:%.*]] to
+ // CHECK: [[PTR:%.*]] = bitcast i8* [[ARGS:%.*]] to
// CHECK: store %swift.type* %T, %swift.type** [[PTR]]
- // CHECK: [[ARGS_I8:%.*]] = bitcast [1 x %swift.type*]* [[ARGS]] to
- // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_I]] to i8*), i8* [[ARGS_I8]])
+ // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_I]] to i8*), i8* [[ARGS]])
%i = keypath $KeyPath<Gen<T,T>, T>, <A> (root $Gen<A, A>; stored_property #Gen.x : $A) <T>
- // CHECK: [[PTR:%.*]] = bitcast [1 x %swift.type*]* [[ARGS:%.*]] to
+ // CHECK: [[PTR:%.*]] = bitcast i8* [[ARGS:%.*]] to
// CHECK: store %swift.type* %U, %swift.type** [[PTR]]
- // CHECK: [[ARGS_I8:%.*]] = bitcast [1 x %swift.type*]* [[ARGS]] to
- // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_J]] to i8*), i8* [[ARGS_I8]])
+ // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_J]] to i8*), i8* [[ARGS]])
%j = keypath $KeyPath<Gen<U,U>, U>, <A> (root $Gen<A, A>; stored_property #Gen.y : $A) <U>
- // CHECK: [[PTR:%.*]] = bitcast [1 x %swift.type*]* [[ARGS:%.*]] to
+ // CHECK: [[PTR:%.*]] = bitcast i8* [[ARGS:%.*]] to
// CHECK: [[FOO_T:%.*]] = call %swift.type* @_T08keypaths3FooVMa(%swift.type* %T)
// CHECK: store %swift.type* [[FOO_T]], %swift.type** [[PTR]]
- // CHECK: [[ARGS_I8:%.*]] = bitcast [1 x %swift.type*]* [[ARGS]] to
- // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_I]] to i8*), i8* [[ARGS_I8]])
+ // CHECK: call %swift.refcounted* @swift_getKeyPath(i8* bitcast ({{.*}} [[KP_I]] to i8*), i8* [[ARGS]])
%i2 = keypath $KeyPath<Gen<Foo<T>,Foo<T>>, Foo<T>>, <A> (root $Gen<A, A>; stored_property #Gen.x : $A) <Foo<T>>
return undef : $()
@@ -304,3 +307,105 @@
sil @n_get : $@convention(thin) <UU, TT> (@in TT) -> @out UU
sil @n_set : $@convention(thin) <UU, TT> (@in UU, @in TT) -> ()
+
+sil @computed_property_indices : $@convention(thin) (C, S, C, S, C, S) -> () {
+entry(%0 : $C, %1 : $S, %2 : $C, %3 : $S, %4 : $C, %5 : $S):
+ %o = keypath $WritableKeyPath<S, C>, (
+ root $S;
+ settable_property $C,
+ id @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C,
+ getter @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C,
+ setter @o_set : $@convention(thin) (@in C, @in S, UnsafeRawPointer) -> (),
+ indices [%$0 : $C : $C],
+ indices_equals @o_equals : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @o_hash : $@convention(thin) (UnsafeRawPointer) -> Int
+ ) (%0)
+ %p = keypath $WritableKeyPath<S, C>, (
+ root $S;
+ settable_property $C,
+ id @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C,
+ getter @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C,
+ setter @o_set : $@convention(thin) (@in C, @in S, UnsafeRawPointer) -> (),
+ indices [%$0 : $S : $S, %$1 : $C : $C],
+ indices_equals @o_equals : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @o_hash : $@convention(thin) (UnsafeRawPointer) -> Int
+ ) (%1, %2)
+ %r = keypath $WritableKeyPath<S, S>, (
+ root $S;
+ settable_property $C,
+ id @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C,
+ getter @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C,
+ setter @o_set : $@convention(thin) (@in C, @in S, UnsafeRawPointer) -> (),
+ indices [%$0 : $S : $S, %$1 : $C : $C],
+ indices_equals @o_equals : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @o_hash : $@convention(thin) (UnsafeRawPointer) -> Int;
+ settable_property $S,
+ id @r_get : $@convention(thin) (@in C, UnsafeRawPointer) -> @out S,
+ getter @r_get : $@convention(thin) (@in C, UnsafeRawPointer) -> @out S,
+ setter @r_set : $@convention(thin) (@in S, @in C, UnsafeRawPointer) -> (),
+ indices [%$2 : $S : $S],
+ indices_equals @o_equals : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @o_hash : $@convention(thin) (UnsafeRawPointer) -> Int
+ ) (%3, %4, %5)
+
+ return undef : $()
+}
+
+sil @o_get : $@convention(thin) (@in S, UnsafeRawPointer) -> @out C
+sil @o_set : $@convention(thin) (@in C, @in S, UnsafeRawPointer) -> ()
+sil @o_equals : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool
+sil @o_hash : $@convention(thin) (UnsafeRawPointer) -> Int
+
+sil @r_get : $@convention(thin) (@in C, UnsafeRawPointer) -> @out S
+sil @r_set : $@convention(thin) (@in S, @in C, UnsafeRawPointer) -> ()
+
+sil @generic_computed_property_indices : $@convention(thin) <A: Hashable, B: Hashable> (@in A, @in B, @in A, @in B, @in A, @in B) -> () {
+entry(%0 : $*A, %1 : $*B, %2 : $*A, %3 : $*B, %4 : $*A, %5 : $*B):
+ %s = keypath $WritableKeyPath<A, B>, <X: Hashable, Y: Hashable> (
+ root $X;
+ settable_property $Y,
+ id @s_get : $@convention(thin) <T: Hashable, U: Hashable> (@in T, UnsafeRawPointer) -> @out U,
+ getter @s_get : $@convention(thin) <T: Hashable, U: Hashable> (@in T, UnsafeRawPointer) -> @out U,
+ setter @s_set : $@convention(thin) <T: Hashable, U: Hashable> (@in U, @in T, UnsafeRawPointer) -> (),
+ indices [%$0 : $X : $*X],
+ indices_equals @s_equals : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @s_hash : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer) -> Int
+ ) <A, B> (%0)
+ %t = keypath $WritableKeyPath<A, B>, <X: Hashable, Y: Hashable> (
+ root $X;
+ settable_property $Y,
+ id @s_get : $@convention(thin) <T: Hashable, U: Hashable> (@in T, UnsafeRawPointer) -> @out U,
+ getter @s_get : $@convention(thin) <T: Hashable, U: Hashable> (@in T, UnsafeRawPointer) -> @out U,
+ setter @s_set : $@convention(thin) <T: Hashable, U: Hashable> (@in U, @in T, UnsafeRawPointer) -> (),
+ indices [%$0 : $Y : $*Y, %$1 : $X : $*X],
+ indices_equals @s_equals : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @s_hash : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer) -> Int
+ ) <A, B> (%1, %2)
+ %v = keypath $WritableKeyPath<A, A>, <X: Hashable, Y: Hashable> (
+ root $X;
+ settable_property $Y,
+ id @s_get : $@convention(thin) <T: Hashable, U: Hashable> (@in T, UnsafeRawPointer) -> @out U,
+ getter @s_get : $@convention(thin) <T: Hashable, U: Hashable> (@in T, UnsafeRawPointer) -> @out U,
+ setter @s_set : $@convention(thin) <T: Hashable, U: Hashable> (@in U, @in T, UnsafeRawPointer) -> (),
+ indices [%$0 : $Y : $*Y, %$1 : $X : $*X],
+ indices_equals @s_equals : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @s_hash : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer) -> Int;
+ settable_property $X,
+ id @v_get : $@convention(thin) <T: Hashable, U: Hashable> (@in U, UnsafeRawPointer) -> @out T,
+ getter @v_get : $@convention(thin) <T: Hashable, U: Hashable> (@in U, UnsafeRawPointer) -> @out T,
+ setter @v_set : $@convention(thin) <T: Hashable, U: Hashable> (@in T, @in U, UnsafeRawPointer) -> (),
+ indices [%$2 : $Y : $*Y],
+ indices_equals @s_equals : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool,
+ indices_hash @s_hash : $@convention(thin) <T: Hashable, U: Hashable> (UnsafeRawPointer) -> Int
+ ) <A, B> (%3, %4, %5)
+
+ return undef : $()
+}
+
+sil @s_get : $@convention(thin) <A: Hashable, B: Hashable> (@in A, UnsafeRawPointer) -> @out B
+sil @s_set : $@convention(thin) <A: Hashable, B: Hashable> (@in B, @in A, UnsafeRawPointer) -> ()
+sil @s_equals : $@convention(thin) <A: Hashable, B: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool
+sil @s_hash : $@convention(thin) <A: Hashable, B: Hashable> (UnsafeRawPointer) -> Int
+
+sil @v_get : $@convention(thin) <A: Hashable, B: Hashable> (@in B, UnsafeRawPointer) -> @out A
+sil @v_set : $@convention(thin) <A: Hashable, B: Hashable> (@in A, @in B, UnsafeRawPointer) -> ()
diff --git a/test/IRGen/unowned_objc.sil b/test/IRGen/unowned_objc.sil
index 73ddf86..0d65eb5 100644
--- a/test/IRGen/unowned_objc.sil
+++ b/test/IRGen/unowned_objc.sil
@@ -58,12 +58,12 @@
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 1
// CHECK-NEXT: store i8** [[PP:%1]], i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedInit(%swift.unowned* [[T0]], [[UNKNOWN]]* [[PV:%0]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedInit(%swift.unowned* [[T0]], [[UNKNOWN]]* [[PV:%0]])
store_unowned %p to [initialization] %x : $*@sil_unowned P
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedCopyInit(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedCopyInit(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 1
// CHECK-NEXT: [[WT:%.*]] = load i8**, i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 1
@@ -81,7 +81,7 @@
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedCopyAssign(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedCopyAssign(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 1
// CHECK-NEXT: [[WT:%.*]] = load i8**, i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 1
@@ -91,12 +91,12 @@
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 1
// CHECK-NEXT: store i8** [[QP:%3]], i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedAssign(%swift.unowned* [[T0]], [[UNKNOWN]]* [[QV:%2]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedAssign(%swift.unowned* [[T0]], [[UNKNOWN]]* [[QV:%2]])
store_unowned %q to %y : $*@sil_unowned P
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedTakeAssign(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedTakeAssign(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 1
// CHECK-NEXT: [[WT:%.*]] = load i8**, i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 1
@@ -105,7 +105,7 @@
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedTakeInit(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedTakeInit(%swift.unowned* [[T0]], %swift.unowned* [[T1]])
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[Y]], i32 0, i32 1
// CHECK-NEXT: [[WT:%.*]] = load i8**, i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 1
@@ -121,7 +121,7 @@
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 1
// CHECK-NEXT: store i8** [[TP]], i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[UREF]], [[UREF]]* [[X]], i32 0, i32 0
- // CHECK-NEXT: call void @swift_unknownUnownedInit(%swift.unowned* [[T0]], [[UNKNOWN]]* [[TV]])
+ // CHECK-NEXT: call %swift.unowned* @swift_unknownUnownedInit(%swift.unowned* [[T0]], [[UNKNOWN]]* [[TV]])
store_unowned %t1 to [initialization] %x : $*@sil_unowned P
// CHECK-NEXT: call void @swift_unknownRelease([[UNKNOWN]]* [[TV]])
diff --git a/test/IRGen/weak.sil b/test/IRGen/weak.sil
index f9ebfdf..b4270f2 100644
--- a/test/IRGen/weak.sil
+++ b/test/IRGen/weak.sil
@@ -47,9 +47,9 @@
// CHECK-NEXT: [[T0:%.*]] = call [[C]]* bitcast ([[REF]]* ([[WEAK]]*)* @swift_weakLoadStrong to [[C]]* ([[WEAK]]*)*)([[WEAK]]* [[X]])
// CHECK-NEXT: %3 = ptrtoint %T4weak1CC* %2 to i64
// CHECK-NEXT: %4 = inttoptr
-// CHECK-NEXT: call void bitcast ([[WEAK]]* ([[WEAK]]*, [[REF]]*)* @swift_weakAssign to void ([[WEAK]]*, [[C]]*)*)([[WEAK]]* [[X]], [[C]]* %4)
-// CHECK-NEXT: %5 = inttoptr i64 %3 to %swift.refcounted*
-// CHECK-NEXT: call void @swift_rt_swift_release([[REF]]* %5)
+// CHECK-NEXT: call [[WEAK]]* bitcast ([[WEAK]]* ([[WEAK]]*, [[REF]]*)* @swift_weakAssign to [[WEAK]]* ([[WEAK]]*, [[C]]*)*)([[WEAK]]* [[X]], [[C]]* %4)
+// CHECK-NEXT: %6 = inttoptr i64 %3 to %swift.refcounted*
+// CHECK-NEXT: call void @swift_rt_swift_release([[REF]]* %6)
// CHECK-NEXT: ret void
struct B {
@@ -76,7 +76,7 @@
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { [[WEAK]], i8** }, { [[WEAK]], i8** }* [[X]], i32 0, i32 1
// CHECK-NEXT: store i8** [[TMPTAB]], i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { [[WEAK]], i8** }, { [[WEAK]], i8** }* [[X]], i32 0, i32 0
-// CHECK-NEXT: call void @swift_unknownWeakAssign([[WEAK]]* [[T0]], [[UNKNOWN]]* [[TMPOBJ]])
+// CHECK-NEXT: call [[WEAK]]* @swift_unknownWeakAssign([[WEAK]]* [[T0]], [[UNKNOWN]]* [[TMPOBJ]])
// CHECK: call void @_T0SqWe
sil @test_weak_alloc_stack : $@convention(thin) (Optional<P>) -> () {
@@ -95,7 +95,7 @@
// CHECK: [[T0:%.*]] = getelementptr inbounds { [[WEAK]], i8** }, { [[WEAK]], i8** }* [[X]], i32 0, i32 1
// CHECK-NEXT: store i8** [[TMPTAB:%.*]], i8*** [[T0]], align 8
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { [[WEAK]], i8** }, { [[WEAK]], i8** }* [[X]], i32 0, i32 0
-// CHECK-NEXT: call void @swift_unknownWeakInit([[WEAK]]* [[T0]], [[UNKNOWN]]* [[TMPOBJ:%.*]])
+// CHECK-NEXT: call [[WEAK]]* @swift_unknownWeakInit([[WEAK]]* [[T0]], [[UNKNOWN]]* [[TMPOBJ:%.*]])
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { [[WEAK]], i8** }, { [[WEAK]], i8** }* [[X]], i32 0, i32 0
// CHECK-NEXT: call void @swift_unknownWeakDestroy([[WEAK]]* [[T0]])
// CHECK-NEXT: bitcast
diff --git a/test/IRGen/weak_class_protocol.sil b/test/IRGen/weak_class_protocol.sil
index ad60a85..75a1877 100644
--- a/test/IRGen/weak_class_protocol.sil
+++ b/test/IRGen/weak_class_protocol.sil
@@ -14,7 +14,7 @@
// CHECK: [[WTABLE_SLOT:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 1
// CHECK: store i8** [[WTABLE]], i8*** [[WTABLE_SLOT]], align 8
// CHECK: [[INSTANCE_SLOT:%.*]] = getelementptr inbounds { %swift.weak, i8** }, { %swift.weak, i8** }* %0, i32 0, i32 0
-// CHECK-objc: call void @swift_unknownWeakAssign(%swift.weak* [[INSTANCE_SLOT]], %objc_object* [[INSTANCE]]) {{#[0-9]+}}
+// CHECK-objc: call %swift.weak* @swift_unknownWeakAssign(%swift.weak* [[INSTANCE_SLOT]], %objc_object* [[INSTANCE]]) {{#[0-9]+}}
// CHECK-native: call %swift.weak* @swift_weakAssign(%swift.weak* [[INSTANCE_SLOT]], %swift.refcounted* [[INSTANCE]]) {{#[0-9]+}}
// CHECK: ret void
// CHECK: }
diff --git a/test/SIL/Parser/keypath.sil b/test/SIL/Parser/keypath.sil
index 6fb730a..a8b99ff 100644
--- a/test/SIL/Parser/keypath.sil
+++ b/test/SIL/Parser/keypath.sil
@@ -4,12 +4,15 @@
import Swift
-struct S {
+struct S: Hashable {
var x: Int
let y: String
var z: C
+
+ var hashValue: Int { get }
+ static func ==(x: S, y: S) -> Bool
}
-class C {
+class C: Hashable {
final var x: Int
final let y: String
final var z: S
@@ -18,6 +21,9 @@
var overridable: Int {
get set
}
+
+ var hashValue: Int { get }
+ static func ==(x: C, y: C) -> Bool
}
protocol P {}
@@ -63,6 +69,15 @@
sil @set_c_int : $@convention(thin) (@in Int, @in C) -> ()
sil @get_fns_fnc : $@convention(thin) (@in @callee_owned (@in S) -> @out S) -> @out @callee_owned (@in C) -> @out C
sil @set_fns_fnc : $@convention(thin) (@in @callee_owned (@in C) -> @out C, @in @callee_owned (@in S) -> @out S) -> ()
+sil @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int
+sil @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> ()
+sil @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool
+sil @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int
+sil @get_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in A, UnsafeRawPointer) -> @out C
+sil @set_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in C, @in A, UnsafeRawPointer) -> ()
+sil @gen_subs_eq : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool
+sil @gen_subs_hash : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer) -> Int
+
// CHECK-LABEL: sil shared @computed_properties
sil shared @computed_properties : $@convention(thin) () -> () {
@@ -101,3 +116,23 @@
return undef : $()
}
+
+// CHECK-LABEL: sil @indexes
+sil @indexes : $@convention(thin) (S, C) -> () {
+// CHECK: bb0([[S:%.*]] : $S, [[C:%.*]] : $C):
+entry(%s : $S, %c : $C):
+ // CHECK: keypath $KeyPath<S, Int>, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int, setter @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> (), indices [%$0 : $S : $S, %$1 : $C : $C], indices_equals @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int) ([[S]], [[C]])
+ %a = keypath $KeyPath<S, Int>, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int, setter @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> (), indices [%$0 : $S : $S, %$1 : $C : $C], indices_equals @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int) (%s, %c)
+ // CHECK: [[T:%.*]] = alloc_stack
+ %t = alloc_stack $S
+ // CHECK: [[D:%.*]] = alloc_stack
+ %d = alloc_stack $C
+ // CHECK: keypath $KeyPath<S, Int>, <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (root $τ_0_0; settable_property $τ_0_2, id @id_a : $@convention(thin) () -> (), getter @get_gen_int_subs : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (@in τ_0_0, UnsafeRawPointer) -> @out τ_0_2, setter @set_gen_int_subs : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (@in τ_0_2, @in τ_0_0, UnsafeRawPointer) -> (), indices [%$0 : $τ_0_0 : $*τ_0_0, %$1 : $τ_0_1 : $*τ_0_1], indices_equals @gen_subs_eq : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @gen_subs_hash : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (UnsafeRawPointer) -> Int) <S, C, Int> ([[T]], [[D]])
+ %b = keypath $KeyPath<S, Int>, <τ_0_0: Hashable, Y: Hashable, Z: Hashable> (root $τ_0_0; settable_property $Z, id @id_a : $@convention(thin) () -> (), getter @get_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in A, UnsafeRawPointer) -> @out C, setter @set_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in C, @in A, UnsafeRawPointer) -> (), indices [%$0 : $τ_0_0 : $*τ_0_0, %$1 : $Y : $*Y], indices_equals @gen_subs_eq : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @gen_subs_hash : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer) -> Int) <S, C, Int> (%t, %d)
+
+ dealloc_stack %d : $*C
+ dealloc_stack %t : $*S
+
+ return undef : $()
+}
+
diff --git a/test/SIL/Serialization/keypath.sil b/test/SIL/Serialization/keypath.sil
index cfed287..53989c9 100644
--- a/test/SIL/Serialization/keypath.sil
+++ b/test/SIL/Serialization/keypath.sil
@@ -9,12 +9,15 @@
import Swift
-struct S {
+struct S: Hashable {
var x: Int
let y: String
var z: C
+
+ var hashValue: Int { get }
+ static func ==(x: S, y: S) -> Bool
}
-class C {
+class C: Hashable {
final var x: Int
final let y: String
final var z: S
@@ -23,6 +26,9 @@
var overridable: Int {
get set
}
+
+ var hashValue: Int { get }
+ static func ==(x: C, y: C) -> Bool
}
protocol P {}
@@ -68,6 +74,14 @@
sil @set_c_int : $@convention(thin) (@in Int, @in C) -> ()
sil @get_fns_fnc : $@convention(thin) (@in @callee_owned (@in S) -> @out S) -> @out @callee_owned (@in C) -> @out C
sil @set_fns_fnc : $@convention(thin) (@in @callee_owned (@in C) -> @out C, @in @callee_owned (@in S) -> @out S) -> ()
+sil @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int
+sil @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> ()
+sil @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool
+sil @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int
+sil @get_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in A, UnsafeRawPointer) -> @out C
+sil @set_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in C, @in A, UnsafeRawPointer) -> ()
+sil @gen_subs_eq : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool
+sil @gen_subs_hash : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer) -> Int
// CHECK-LABEL: sil shared @computed_properties
sil shared @computed_properties : $@convention(thin) () -> () {
@@ -107,6 +121,25 @@
return undef : $()
}
+// CHECK-LABEL: sil shared @indexes
+sil shared @indexes : $@convention(thin) (S, C) -> () {
+// CHECK: bb0([[S:%.*]] : $S, [[C:%.*]] : $C):
+entry(%s : $S, %c : $C):
+ // CHECK: keypath $KeyPath<S, Int>, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int, setter @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> (), indices [%$0 : $S : $S, %$1 : $C : $C], indices_equals @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int) ([[S]], [[C]])
+ %a = keypath $KeyPath<S, Int>, (root $S; settable_property $Int, id @id_a : $@convention(thin) () -> (), getter @get_s_int_subs : $@convention(thin) (@in S, UnsafeRawPointer) -> @out Int, setter @set_s_int_subs : $@convention(thin) (@in Int, @in S, UnsafeRawPointer) -> (), indices [%$0 : $S : $S, %$1 : $C : $C], indices_equals @subs_eq : $@convention(thin) (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @subs_hash : $@convention(thin) (UnsafeRawPointer) -> Int) (%s, %c)
+ // CHECK: [[T:%.*]] = alloc_stack
+ %t = alloc_stack $S
+ // CHECK: [[D:%.*]] = alloc_stack
+ %d = alloc_stack $C
+ // CHECK: keypath $KeyPath<S, Int>, <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (root $τ_0_0; settable_property $τ_0_2, id @id_a : $@convention(thin) () -> (), getter @get_gen_int_subs : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (@in τ_0_0, UnsafeRawPointer) -> @out τ_0_2, setter @set_gen_int_subs : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (@in τ_0_2, @in τ_0_0, UnsafeRawPointer) -> (), indices [%$0 : $τ_0_0 : $*τ_0_0, %$1 : $τ_0_1 : $*τ_0_1], indices_equals @gen_subs_eq : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @gen_subs_hash : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2 where τ_0_0 : Hashable, τ_0_1 : Hashable, τ_0_2 : Hashable> (UnsafeRawPointer) -> Int) <S, C, Int> ([[T]], [[D]])
+ %b = keypath $KeyPath<S, Int>, <τ_0_0: Hashable, Y: Hashable, Z: Hashable> (root $τ_0_0; settable_property $Z, id @id_a : $@convention(thin) () -> (), getter @get_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in A, UnsafeRawPointer) -> @out C, setter @set_gen_int_subs : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (@in C, @in A, UnsafeRawPointer) -> (), indices [%$0 : $τ_0_0 : $*τ_0_0, %$1 : $Y : $*Y], indices_equals @gen_subs_eq : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer, UnsafeRawPointer) -> Bool, indices_hash @gen_subs_hash : $@convention(thin) <A: Hashable, B: Hashable, C: Hashable> (UnsafeRawPointer) -> Int) <S, C, Int> (%t, %d)
+
+ dealloc_stack %d : $*C
+ dealloc_stack %t : $*S
+
+ return undef : $()
+}
+
sil @serialize_all : $@convention(thin) () -> () {
entry:
%0 = function_ref @stored_properties : $@convention(thin) () -> ()
@@ -114,6 +147,7 @@
%2 = function_ref @computed_properties : $@convention(thin) () -> ()
%3 = function_ref @computed_properties_generic : $@convention(thin) <D: P, E: Q, F: R> () -> ()
%4 = function_ref @optional : $@convention(thin) () -> ()
+ %5 = function_ref @indexes : $@convention(thin) (S, C) -> ()
unreachable
}
diff --git a/test/SILGen/Inputs/default_arguments_other.swift b/test/SILGen/Inputs/default_arguments_other.swift
new file mode 100644
index 0000000..a2a71e0
--- /dev/null
+++ b/test/SILGen/Inputs/default_arguments_other.swift
@@ -0,0 +1 @@
+public func otherDefaultArguments(x: Int = 0) {}
diff --git a/test/SILGen/SILDeclRef.swift b/test/SILGen/SILDeclRef.swift
index 8c2efd1..5dd2084 100644
--- a/test/SILGen/SILDeclRef.swift
+++ b/test/SILGen/SILDeclRef.swift
@@ -1,5 +1,5 @@
-// RUN: %target-swift-frontend -emit-sil -sil-serialize-witness-tables %s | %FileCheck %s
-// RUN: %target-swift-frontend -emit-sil -sil-serialize-witness-tables %s | %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -module-name="SILDeclRef" - | %FileCheck %s
+// RUN: %target-swift-frontend -emit-sil %s | %FileCheck %s
+// RUN: %target-swift-frontend -emit-sil %s | %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -module-name="SILDeclRef" - | %FileCheck %s
// Check that all SILDeclRefs are represented in the text form with a signature.
// This allows to avoid ambiguities which sometimes arise e.g. when a
@@ -62,7 +62,7 @@
// CHECK-NEXT: #Base.deinit!deallocator: _T010SILDeclRef4BaseCfD // Base.__deallocating_deinit
// CHECK-NEXT: }
-// CHECK:sil_witness_table [serialized] Base: P module SILDeclRef {
+// CHECK:sil_witness_table Base: P module SILDeclRef {
// CHECK-NEXT: method #P.foo!1: <Self where Self : P> (Self) -> () -> Int32 : @_T010SILDeclRef4BaseCAA1PA2aDP3foos5Int32VyFTW // protocol witness for P.foo()
// CHECK-NEXT: method #P.foo!1: <Self where Self : P> (Self) -> (Int32) -> () : @_T010SILDeclRef4BaseCAA1PA2aDP3fooys5Int32V1n_tFTW // protocol witness for P.foo(n:) in conformance Base
// CHECK-NEXT: }
diff --git a/test/SILGen/default_arguments.swift b/test/SILGen/default_arguments.swift
index f2ec010..75eb08a 100644
--- a/test/SILGen/default_arguments.swift
+++ b/test/SILGen/default_arguments.swift
@@ -1,5 +1,8 @@
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen %s | %FileCheck %s
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen %s | %FileCheck %s --check-prefix=NEGATIVE
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 %s | %FileCheck %s
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 %s | %FileCheck %s --check-prefix=NEGATIVE
+
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 %s | %FileCheck %s
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 %s | %FileCheck %s --check-prefix=NEGATIVE
// __FUNCTION__ used as top-level parameter produces the module name.
// CHECK-LABEL: sil @main
diff --git a/test/SILGen/default_arguments_serialized.swift b/test/SILGen/default_arguments_serialized.swift
new file mode 100644
index 0000000..3391474
--- /dev/null
+++ b/test/SILGen/default_arguments_serialized.swift
@@ -0,0 +1,60 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-swift-frontend -emit-module-path %t/default_arguments_other.swiftmodule -emit-module -swift-version 4 -primary-file %S/Inputs/default_arguments_other.swift
+
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 3 -I %t %s | %FileCheck %s --check-prefix=SWIFT3 --check-prefix=CHECK
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-silgen -swift-version 4 -I %t %s | %FileCheck %s --check-prefix=SWIFT4 --check-prefix=CHECK
+
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-sil -O -swift-version 3 -I %t %s | %FileCheck %s --check-prefix=OPT
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-sil-ownership -emit-sil -O -swift-version 4 -I %t %s | %FileCheck %s --check-prefix=OPT
+
+// Check that default arguments are serialized in Swift 4 mode.
+
+import default_arguments_other
+
+// CHECK-LABEL: sil @_T028default_arguments_serialized0A6StringSSyF : $@convention(thin) () -> @owned String
+public func defaultString() -> String { return "hi" }
+
+// SWIFT3-LABEL: sil @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytFfA_ : $@convention(thin) () -> Int
+// SWIFT4-LABEL: sil [serialized] @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytFfA_ : $@convention(thin) () -> Int
+
+// SWIFT3-LABEL: sil @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytFfA0_ : $@convention(thin) () -> @owned String
+// SWIFT4-LABEL: sil [serialized] @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytFfA0_ : $@convention(thin) () -> @owned String
+
+public func hasDefaultArguments(x: Int = 0, y: String = defaultString()) {}
+
+// CHECK-LABEL: sil @_T028default_arguments_serialized21callsDefaultArgumentsyyF : $@convention(thin) () -> ()
+// CHECK: function_ref @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytF : $@convention(thin) (Int, @owned String) -> ()
+// CHECK: function_ref @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytFfA_ : $@convention(thin) () -> Int
+// CHECK: function_ref @_T028default_arguments_serialized19hasDefaultArgumentsySi1x_SS1ytFfA0_ : $@convention(thin) () -> @owned String
+// CHECK: apply
+// CHECK: return
+public func callsDefaultArguments() {
+ hasDefaultArguments()
+}
+
+// When calling a default argument generator for a function in another module
+// that was built in Swift 4 mode, we should always treat it as serialized,
+// even if *this* module is built in Swift 3 mode.
+
+// CHECK-LABEL: sil @_T028default_arguments_serialized26callsOtherDefaultArgumentsyyF : $@convention(thin) () -> ()
+// CHECK: function_ref @_T023default_arguments_other0C16DefaultArgumentsySi1x_tF : $@convention(thin) (Int) -> ()
+// CHECK: function_ref @_T023default_arguments_other0C16DefaultArgumentsySi1x_tFfA_ : $@convention(thin) () -> Int
+// CHECK: apply
+// CHECK: return
+
+// Make sure the optimizer inlines the default argument generator from the
+// other module.
+
+// OPT-LABEL: sil @_T028default_arguments_serialized26callsOtherDefaultArgumentsyyF : $@convention(thin) () -> ()
+// OPT: [[FN:%.*]] = function_ref @_T023default_arguments_other0C16DefaultArgumentsySi1x_tF : $@convention(thin) (Int) -> () // user: %3
+// OPT: [[INT_VAL:%.*]] = integer_literal [[INT_TYPE:\$Builtin.Int(32|64)]], 0
+// OPT: [[INT:%.*]] = struct $Int ([[INT_VAL]] : [[INT_TYPE]]
+// OPT: apply [[FN]]([[INT]]) : $@convention(thin) (Int) -> ()
+// OPT: return
+public func callsOtherDefaultArguments() {
+ otherDefaultArguments()
+}
+
+// CHECK-LABEL: sil @_T023default_arguments_other0C16DefaultArgumentsySi1x_tF : $@convention(thin) (Int) -> ()
+
+// CHECK-LABEL: sil [serialized] @_T023default_arguments_other0C16DefaultArgumentsySi1x_tFfA_ : $@convention(thin) () -> Int
diff --git a/test/SILGen/external-associated-type-conformance.swift b/test/SILGen/external-associated-type-conformance.swift
index bd56b74..4d0eee3 100644
--- a/test/SILGen/external-associated-type-conformance.swift
+++ b/test/SILGen/external-associated-type-conformance.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -emit-silgen -sil-serialize-witness-tables -import-objc-header %S/Inputs/external-associated-type-conformance.h %s -enable-sil-ownership | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -import-objc-header %S/Inputs/external-associated-type-conformance.h %s -enable-sil-ownership | %FileCheck %s
// REQUIRES: objc_interop
extension BadError: LocalizedError {}
diff --git a/test/SILGen/guaranteed_self.swift b/test/SILGen/guaranteed_self.swift
index 652a5ed..cea3b0f 100644
--- a/test/SILGen/guaranteed_self.swift
+++ b/test/SILGen/guaranteed_self.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -sil-serialize-witness-tables %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
protocol Fooable {
init()
@@ -417,7 +417,7 @@
// correctly if we are asked to.
// ----------------------------------------------------------------------------
-// CHECK-LABEL: sil shared [transparent] [serialized] [thunk] @_T015guaranteed_self9FakeArrayVAA8SequenceA2aDP17_constrainElement{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in FakeElement, @in_guaranteed FakeArray) -> () {
+// CHECK-LABEL: sil private [transparent] [thunk] @_T015guaranteed_self9FakeArrayVAA8SequenceA2aDP17_constrainElement{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in FakeElement, @in_guaranteed FakeArray) -> () {
// CHECK: bb0([[ARG0_PTR:%.*]] : @trivial $*FakeElement, [[ARG1_PTR:%.*]] : @trivial $*FakeArray):
// CHECK: [[GUARANTEED_COPY_STACK_SLOT:%.*]] = alloc_stack $FakeArray
// CHECK: copy_addr [[ARG1_PTR]] to [initialization] [[GUARANTEED_COPY_STACK_SLOT]]
diff --git a/test/SILGen/keypath_application.swift b/test/SILGen/keypath_application.swift
index 4df7f8e..88cd272 100644
--- a/test/SILGen/keypath_application.swift
+++ b/test/SILGen/keypath_application.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -enable-experimental-keypath-components -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
class A {}
class B {}
diff --git a/test/SILGen/keypaths.swift b/test/SILGen/keypaths.swift
index 8ba3f4f..4f7247b 100644
--- a/test/SILGen/keypaths.swift
+++ b/test/SILGen/keypaths.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -enable-experimental-keypath-components -emit-silgen -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
struct S<T> {
var x: T
@@ -253,7 +253,7 @@
}
}
-// CHECK-LABEL: sil hidden @{{.*}}iuoKeyPaths
+// CHECK-LABEL: sil hidden @{{.*}}11iuoKeyPaths
func iuoKeyPaths() {
// CHECK: = keypath $WritableKeyPath<IUOProperty, Int>,
// CHECK-SAME: stored_property #IUOProperty.iuo
@@ -266,3 +266,59 @@
// CHECK-SAME: stored_property #IUOBlob.x
_ = \IUOProperty.iuo!.x
}
+
+struct Subscripts<T> {
+ subscript() -> T {
+ get { fatalError() }
+ set { fatalError() }
+ }
+ subscript(generic x: T) -> T {
+ get { fatalError() }
+ set { fatalError() }
+ }
+ subscript(concrete x: String) -> String {
+ get { fatalError() }
+ set { fatalError() }
+ }
+ subscript(x: String, y: String) -> String {
+ get { fatalError() }
+ set { fatalError() }
+ }
+ subscript<U>(subGeneric z: U) -> U {
+ get { fatalError() }
+ set { fatalError() }
+ }
+ subscript(mutable x: T) -> T {
+ get { fatalError() }
+ set { fatalError() }
+ }
+}
+
+// CHECK-LABEL: sil hidden @{{.*}}10subscripts
+func subscripts<T: Hashable, U: Hashable>(x: T, y: U, s: String) {
+ _ = \Subscripts<T>.[]
+ _ = \Subscripts<T>.[generic: x]
+ _ = \Subscripts<T>.[concrete: s]
+ _ = \Subscripts<T>.[s, s]
+ _ = \Subscripts<T>.[subGeneric: s]
+ _ = \Subscripts<T>.[subGeneric: x]
+ _ = \Subscripts<T>.[subGeneric: y]
+
+ _ = \Subscripts<U>.[]
+ _ = \Subscripts<U>.[generic: y]
+ _ = \Subscripts<U>.[concrete: s]
+ _ = \Subscripts<U>.[s, s]
+ _ = \Subscripts<U>.[subGeneric: s]
+ _ = \Subscripts<U>.[subGeneric: x]
+ _ = \Subscripts<U>.[subGeneric: y]
+
+ _ = \Subscripts<String>.[]
+ _ = \Subscripts<String>.[generic: s]
+ _ = \Subscripts<String>.[concrete: s]
+ _ = \Subscripts<String>.[s, s]
+ _ = \Subscripts<String>.[subGeneric: s]
+ _ = \Subscripts<String>.[subGeneric: x]
+ _ = \Subscripts<String>.[subGeneric: y]
+
+ _ = \Subscripts<T>.[s, s].count
+}
diff --git a/test/SILGen/keypaths_objc.swift b/test/SILGen/keypaths_objc.swift
index 8bbaf94..90b29fc 100644
--- a/test/SILGen/keypaths_objc.swift
+++ b/test/SILGen/keypaths_objc.swift
@@ -1,5 +1,5 @@
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-keypath-components -emit-silgen -import-objc-header %S/Inputs/keypaths_objc.h %s | %FileCheck %s
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-experimental-keypath-components -emit-ir -import-objc-header %S/Inputs/keypaths_objc.h %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -import-objc-header %S/Inputs/keypaths_objc.h %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -import-objc-header %S/Inputs/keypaths_objc.h %s
// REQUIRES: objc_interop
import Foundation
diff --git a/test/SILGen/objc_bridging_any.swift b/test/SILGen/objc_bridging_any.swift
index b2fa0d2..8645963 100644
--- a/test/SILGen/objc_bridging_any.swift
+++ b/test/SILGen/objc_bridging_any.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -Xllvm -sil-print-debuginfo -emit-silgen -sil-serialize-witness-tables %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -Xllvm -sil-print-debuginfo -emit-silgen %s | %FileCheck %s
// REQUIRES: objc_interop
import Foundation
diff --git a/test/SILGen/objc_enum.swift b/test/SILGen/objc_enum.swift
index d6e4076..7f72248 100644
--- a/test/SILGen/objc_enum.swift
+++ b/test/SILGen/objc_enum.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables > %t.out
+// RUN: %target-swift-frontend -sdk %S/Inputs -I %S/Inputs -enable-source-import %s -emit-silgen -enable-sil-ownership > %t.out
// RUN: %FileCheck -check-prefix=CHECK -check-prefix=CHECK-%target-ptrsize %s < %t.out
// RUN: %FileCheck -check-prefix=NEGATIVE %s < %t.out
diff --git a/test/SILGen/objc_imported_generic.swift b/test/SILGen/objc_imported_generic.swift
index 76b3731..119560c 100644
--- a/test/SILGen/objc_imported_generic.swift
+++ b/test/SILGen/objc_imported_generic.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen -sil-serialize-witness-tables %s -enable-sil-ownership | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen %s -enable-sil-ownership | %FileCheck %s
// For integration testing, ensure we get through IRGen too.
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -verify -DIRGEN_INTEGRATION_TEST %s
diff --git a/test/SILGen/objc_witnesses.swift b/test/SILGen/objc_witnesses.swift
index 49cfd89..0f7a154 100644
--- a/test/SILGen/objc_witnesses.swift
+++ b/test/SILGen/objc_witnesses.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen -sil-serialize-witness-tables -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
+// RUN: %target-swift-frontend -enable-sil-ownership -emit-silgen -sdk %S/Inputs -I %S/Inputs -enable-source-import %s | %FileCheck %s
// REQUIRES: objc_interop
@@ -94,7 +94,7 @@
public dynamic var spin: Float = 0.5
}
-// CHECK-LABEL: sil shared [transparent] [serialized] [thunk] @_T014objc_witnesses8PositronCAA6LeptonA2aDP4spinSfvgTW
+// CHECK-LABEL: sil private [transparent] [thunk] @_T014objc_witnesses8PositronCAA6LeptonA2aDP4spinSfvgTW
// CHECK-LABEL: sil shared [transparent] [serializable] [thunk] @_T014objc_witnesses8PositronC4spinSfvgTD
// Override of property defined in @objc extension
diff --git a/test/SILGen/shared.swift b/test/SILGen/shared.swift
index a12ebad..d372791 100644
--- a/test/SILGen/shared.swift
+++ b/test/SILGen/shared.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -sil-serialize-witness-tables %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
class RefAggregate {}
struct ValueAggregate { let x = RefAggregate() }
diff --git a/test/SILGen/testable-multifile.swift b/test/SILGen/testable-multifile.swift
index 97dd85b..c45cea5 100644
--- a/test/SILGen/testable-multifile.swift
+++ b/test/SILGen/testable-multifile.swift
@@ -3,9 +3,9 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module %S/Inputs/TestableMultifileHelper.swift -enable-testing -enable-sil-ownership -o %t
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables -I %t %s %S/testable-multifile-other.swift -module-name main | %FileCheck %s
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables -I %t %S/testable-multifile-other.swift %s -module-name main | %FileCheck %s
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables -I %t -primary-file %s %S/testable-multifile-other.swift -module-name main | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %t %s %S/testable-multifile-other.swift -module-name main | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %t %S/testable-multifile-other.swift %s -module-name main | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %t -primary-file %s %S/testable-multifile-other.swift -module-name main | %FileCheck %s
// Just make sure we don't crash later on.
// RUN: %target-swift-frontend -enable-sil-ownership -emit-ir -I %t -primary-file %s %S/testable-multifile-other.swift -module-name main -o /dev/null
@@ -62,6 +62,6 @@
// CHECK-NEXT: method #Fooable.foo!1: {{.*}} : @_T04main7FooImplVAA7FooableA2aDP3fooyyFTW
// CHECK-NEXT: }
-// CHECK-LABEL: sil_witness_table [serialized] PublicFooImpl: Fooable module main {
+// CHECK-LABEL: sil_witness_table PublicFooImpl: Fooable module main {
// CHECK-NEXT: method #Fooable.foo!1: {{.*}} : @_T04main13PublicFooImplVAA7FooableA2aDP3fooyyFTW
// CHECK-NEXT: }
diff --git a/test/SILGen/witness_accessibility.swift b/test/SILGen/witness_accessibility.swift
index 8d79e2c..721d874 100644
--- a/test/SILGen/witness_accessibility.swift
+++ b/test/SILGen/witness_accessibility.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -sil-serialize-witness-tables -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen -enable-sil-ownership %s | %FileCheck %s
public protocol P {
func publicRequirement()
@@ -39,4 +39,4 @@
// the use of the 'public' keyword inside an extension of 'R'
// should generate a warning, since it has no effect.
-// CHECK-LABEL: sil [transparent] [thunk] @_T021witness_accessibility1SVAA1PA2aDP17publicRequirementyyFTW
+// CHECK-LABEL: sil private [transparent] [thunk] @_T021witness_accessibility1SVAA1PA2aDP17publicRequirementyyFTW
diff --git a/test/SILGen/witness_same_type.swift b/test/SILGen/witness_same_type.swift
index 2ea1455..3db2003 100644
--- a/test/SILGen/witness_same_type.swift
+++ b/test/SILGen/witness_same_type.swift
@@ -1,4 +1,4 @@
-// RUN: %target-swift-frontend -emit-silgen -sil-serialize-witness-tables -enable-sil-ownership %s | %FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership %s | %FileCheck %s
// RUN: %target-swift-frontend -enable-sil-ownership -emit-ir %s
protocol Fooable {
@@ -19,7 +19,7 @@
}
// rdar://problem/19049566
-// CHECK-LABEL: sil shared [transparent] [serialized] [thunk] @_T017witness_same_type14LazySequenceOfVyxq_Gs0E0AAsAERz7ElementQzRs_r0_lsAEP12makeIterator0I0QzyFTW : $@convention(witness_method) <τ_0_0, τ_0_1 where τ_0_0 : Sequence, τ_0_1 == τ_0_0.Element> (@in_guaranteed LazySequenceOf<τ_0_0, τ_0_1>) -> @out AnyIterator<τ_0_1>
+// CHECK-LABEL: sil private [transparent] [thunk] @_T017witness_same_type14LazySequenceOfVyxq_Gs0E0AAsAERz7ElementQzRs_r0_lsAEP12makeIterator0I0QzyFTW : $@convention(witness_method) <τ_0_0, τ_0_1 where τ_0_0 : Sequence, τ_0_1 == τ_0_0.Element> (@in_guaranteed LazySequenceOf<τ_0_0, τ_0_1>) -> @out AnyIterator<τ_0_1>
public struct LazySequenceOf<SS : Sequence, A where SS.Iterator.Element == A> : Sequence {
public func makeIterator() -> AnyIterator<A> {
var opt: AnyIterator<A>?
diff --git a/test/SILGen/witness_tables.swift b/test/SILGen/witness_tables.swift
index 63edb14..3d5203e 100644
--- a/test/SILGen/witness_tables.swift
+++ b/test/SILGen/witness_tables.swift
@@ -1,8 +1,8 @@
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module > %t.sil
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module > %t.sil
// RUN: %FileCheck -check-prefix=TABLE -check-prefix=TABLE-ALL %s < %t.sil
// RUN: %FileCheck -check-prefix=SYMBOL %s < %t.sil
-// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module -enable-testing > %t.testable.sil
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -I %S/Inputs -enable-source-import %s -disable-objc-attr-requires-foundation-module -enable-testing > %t.testable.sil
// RUN: %FileCheck -check-prefix=TABLE-TESTABLE -check-prefix=TABLE-ALL %s < %t.testable.sil
// RUN: %FileCheck -check-prefix=SYMBOL-TESTABLE %s < %t.testable.sil
@@ -61,11 +61,11 @@
func requiredMethod() {}
}
// TABLE-LABEL: sil_witness_table hidden ConformingAssoc: AssocReqt module witness_tables {
-// TABLE-TESTABLE-LABEL: sil_witness_table [serialized] ConformingAssoc: AssocReqt module witness_tables {
+// TABLE-TESTABLE-LABEL: sil_witness_table ConformingAssoc: AssocReqt module witness_tables {
// TABLE-ALL-NEXT: method #AssocReqt.requiredMethod!1: {{.*}} : @_T014witness_tables15ConformingAssocVAA0D4ReqtA2aDP14requiredMethod{{[_0-9a-zA-Z]*}}FTW
// TABLE-ALL-NEXT: }
// SYMBOL: sil private [transparent] [thunk] @_T014witness_tables15ConformingAssocVAA0D4ReqtA2aDP14requiredMethod{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in_guaranteed ConformingAssoc) -> ()
-// SYMBOL-TESTABLE: sil shared [transparent] [serialized] [thunk] @_T014witness_tables15ConformingAssocVAA0D4ReqtA2aDP14requiredMethod{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in_guaranteed ConformingAssoc) -> ()
+// SYMBOL-TESTABLE: sil private [transparent] [thunk] @_T014witness_tables15ConformingAssocVAA0D4ReqtA2aDP14requiredMethod{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in_guaranteed ConformingAssoc) -> ()
struct ConformingStruct : AnyProtocol {
typealias AssocType = SomeAssoc
@@ -94,11 +94,11 @@
// SYMBOL: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP16assocTypesMethod{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in SomeAssoc, @in ConformingAssoc, @in_guaranteed ConformingStruct) -> ()
// SYMBOL: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP12staticMethod{{[_0-9a-zA-Z]*}}FZTW : $@convention(witness_method) (@in ConformingStruct, @thick ConformingStruct.Type) -> ()
// SYMBOL: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP3ltgoi{{[_0-9a-zA-Z]*}}FZTW : $@convention(witness_method) (@in ConformingStruct, @in ConformingStruct, @thick ConformingStruct.Type) -> ()
-// SYMBOL-TESTABLE: sil shared [transparent] [serialized] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP6method{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (Arg, @in ConformingStruct, @in_guaranteed ConformingStruct) -> ()
-// SYMBOL-TESTABLE: sil shared [transparent] [serialized] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP7generic{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) <τ_0_0 where τ_0_0 : ArchetypeReqt> (@in τ_0_0, @in ConformingStruct, @in_guaranteed ConformingStruct) -> ()
-// SYMBOL-TESTABLE: sil shared [transparent] [serialized] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP16assocTypesMethod{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in SomeAssoc, @in ConformingAssoc, @in_guaranteed ConformingStruct) -> ()
-// SYMBOL-TESTABLE: sil shared [transparent] [serialized] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP12staticMethod{{[_0-9a-zA-Z]*}}FZTW : $@convention(witness_method) (@in ConformingStruct, @thick ConformingStruct.Type) -> ()
-// SYMBOL-TESTABLE: sil shared [transparent] [serialized] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP3ltgoi{{[_0-9a-zA-Z]*}}FZTW : $@convention(witness_method) (@in ConformingStruct, @in ConformingStruct, @thick ConformingStruct.Type) -> ()
+// SYMBOL-TESTABLE: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP6method{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (Arg, @in ConformingStruct, @in_guaranteed ConformingStruct) -> ()
+// SYMBOL-TESTABLE: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP7generic{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) <τ_0_0 where τ_0_0 : ArchetypeReqt> (@in τ_0_0, @in ConformingStruct, @in_guaranteed ConformingStruct) -> ()
+// SYMBOL-TESTABLE: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP16assocTypesMethod{{[_0-9a-zA-Z]*}}FTW : $@convention(witness_method) (@in SomeAssoc, @in ConformingAssoc, @in_guaranteed ConformingStruct) -> ()
+// SYMBOL-TESTABLE: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP12staticMethod{{[_0-9a-zA-Z]*}}FZTW : $@convention(witness_method) (@in ConformingStruct, @thick ConformingStruct.Type) -> ()
+// SYMBOL-TESTABLE: sil private [transparent] [thunk] @_T014witness_tables16ConformingStructVAA11AnyProtocolA2aDP3ltgoi{{[_0-9a-zA-Z]*}}FZTW : $@convention(witness_method) (@in ConformingStruct, @in ConformingStruct, @thick ConformingStruct.Type) -> ()
protocol AddressOnly {}
diff --git a/test/SILGen/witness_tables_serialized.swift b/test/SILGen/witness_tables_serialized.swift
new file mode 100644
index 0000000..3d06881
--- /dev/null
+++ b/test/SILGen/witness_tables_serialized.swift
@@ -0,0 +1,15 @@
+// RUN: %target-swift-frontend -emit-silgen -enable-sil-ownership -sil-serialize-witness-tables %s | %FileCheck %s
+
+public protocol PublicProtocol {}
+
+internal protocol InternalProtocol {}
+
+public struct PublicStruct : PublicProtocol, InternalProtocol {}
+
+internal struct InternalStruct : PublicProtocol, InternalProtocol {}
+
+// CHECK-LABEL: sil_witness_table [serialized] PublicStruct: PublicProtocol
+// CHECK-LABEL: sil_witness_table hidden PublicStruct: InternalProtocol
+
+// CHECK-LABEL: sil_witness_table hidden InternalStruct: PublicProtocol
+// CHECK-LABEL: sil_witness_table hidden InternalStruct: InternalProtocol
diff --git a/test/SILOptimizer/closure_specialize_opaque.sil b/test/SILOptimizer/closure_specialize_opaque.sil
new file mode 100644
index 0000000..840a9d6
--- /dev/null
+++ b/test/SILOptimizer/closure_specialize_opaque.sil
@@ -0,0 +1,42 @@
+// RUN: %target-sil-opt -enable-sil-opaque-values -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -closure-specialize %s | %FileCheck %s
+
+struct TestView {}
+struct TestRange {}
+struct TestSlice {}
+
+// helper
+sil @closure : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> () {
+bb0(%0 : $*TestView, %1 : $TestRange, %2 : $TestSlice):
+ %1284 = tuple ()
+ return %1284 : $()
+}
+
+// helper
+sil @thunk : $@convention(thin) (@inout TestView, @owned @callee_owned (@inout TestView) -> ()) -> @out () {
+bb0(%0 : $*TestView, %1 : $@callee_owned (@inout TestView) ->()):
+ %call = apply %1(%0) : $@callee_owned (@inout TestView) -> ()
+ %1284 = tuple ()
+ return %1284 : $()
+}
+
+// Test that ClosureSpecializer can handle captured @in args, in addition to direct args.
+//
+// CHECK-LABEL: sil @testSpecializeThunk : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> () {
+// CHECK: bb0(%0 : $*TestView, %1 : $TestRange, %2 : $TestSlice):
+// CHECK: [[CLOSURE:%.*]] = function_ref @closure : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> ()
+// CHECK: [[SPECIALIZED:%.*]] = function_ref @_T05thunk7closure4main9TestRangeVAC0D5SliceVTf1nc_n : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> @out () // user: %6
+// CHECK: [[THUNK:%.*]] = function_ref @thunk : $@convention(thin) (@inout TestView, @owned @callee_owned (@inout TestView) -> ()) -> @out ()
+// CHECK: [[CALL:%.*]] = apply [[SPECIALIZED]](%0, %1, %2) : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> @out ()
+// CHECK: %{{.*}} = tuple ()
+// CHECK: return %{{.*}} : $()
+// CHECK-LABEL: } // end sil function 'testSpecializeThunk'
+sil @testSpecializeThunk : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> () {
+bb0(%0 : $*TestView, %1 : $TestRange, %2 : $TestSlice):
+ %closurefn = function_ref @closure : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> ()
+ %pa = partial_apply %closurefn(%1, %2) : $@convention(thin) (@inout TestView, TestRange, @in TestSlice) -> ()
+ %thunk = function_ref @thunk : $@convention(thin) (@inout TestView, @owned @callee_owned (@inout TestView) -> ()) -> @out ()
+ strong_retain %pa : $@callee_owned (@inout TestView) -> ()
+ %call = apply %thunk(%0, %pa) : $@convention(thin) (@inout TestView, @owned @callee_owned (@inout TestView) -> ()) -> @out ()
+ %1284 = tuple ()
+ return %1284 : $()
+}
diff --git a/test/SILOptimizer/dead_function_elimination.swift b/test/SILOptimizer/dead_function_elimination.swift
index 870e5e4..70cf52c 100644
--- a/test/SILOptimizer/dead_function_elimination.swift
+++ b/test/SILOptimizer/dead_function_elimination.swift
@@ -1,5 +1,5 @@
-// RUN: %target-swift-frontend %s -O -emit-sil -sil-serialize-witness-tables | %FileCheck %s
-// RUN: %target-swift-frontend %s -O -emit-sil -sil-serialize-witness-tables -enable-testing | %FileCheck -check-prefix=CHECK-TESTING %s
+// RUN: %target-swift-frontend %s -O -emit-sil | %FileCheck %s
+// RUN: %target-swift-frontend %s -O -emit-sil -enable-testing | %FileCheck -check-prefix=CHECK-TESTING %s
// Check if cycles are removed.
@@ -214,7 +214,7 @@
// CHECK: aliveWitness!1: {{.*}} : @{{.*}}aliveWitness
// CHECK: DeadWitness!1: {{.*}} : nil
-// CHECK-TESTING-LABEL: sil_witness_table [serialized] Adopt: Prot
+// CHECK-TESTING-LABEL: sil_witness_table Adopt: Prot
// CHECK-TESTING: DeadWitness{{.*}}: @{{.*}}DeadWitness
// CHECK-LABEL: sil_default_witness_table hidden Prot
diff --git a/test/SILOptimizer/devirt_materializeForSet.swift b/test/SILOptimizer/devirt_materializeForSet.swift
index d3edf2e..867523b 100644
--- a/test/SILOptimizer/devirt_materializeForSet.swift
+++ b/test/SILOptimizer/devirt_materializeForSet.swift
@@ -1,9 +1,9 @@
-// RUN: %target-swift-frontend -O -emit-sil -sil-serialize-witness-tables %s | %FileCheck %s
+// RUN: %target-swift-frontend -O -emit-sil %s | %FileCheck %s
// Check that compiler does not crash on the devirtualization of materializeForSet methods
// and produces a correct code.
-// CHECK-LABEL: sil shared [transparent] [serialized] [thunk] @_T024devirt_materializeForSet7BaseFooCAA0F0A2aDP3barSSvmTW
+// CHECK-LABEL: sil private [transparent] [thunk] @_T024devirt_materializeForSet7BaseFooCAA0F0A2aDP3barSSvmTW
// CHECK: checked_cast_br [exact] %{{.*}} : $BaseFoo to $ChildFoo
// CHECK: thin_function_to_pointer %{{.*}} : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout ChildFoo, @thick ChildFoo.Type) -> () to $Builtin.RawPointer
// CHECK: enum $Optional<Builtin.RawPointer>, #Optional.some!enumelt.1, %{{.*}} : $Builtin.RawPointer
diff --git a/test/SILOptimizer/funcsig_opaque.sil b/test/SILOptimizer/funcsig_opaque.sil
new file mode 100644
index 0000000..bcd8f47
--- /dev/null
+++ b/test/SILOptimizer/funcsig_opaque.sil
@@ -0,0 +1,44 @@
+// RUN: %target-sil-opt -enable-sil-opaque-values -assume-parsing-unqualified-ownership-sil -function-signature-opts %s | %FileCheck %s
+
+import Builtin
+
+struct R<T> {
+ var base: T
+}
+
+struct S {
+ var val: Builtin.Int32
+}
+
+sil @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
+
+// Test owned-to-guaranteed transformation of opaque arguments.
+//
+// CHECK-LABEL: sil [thunk] [always_inline] @testAggregateArg : $@convention(thin) (@in R<S>) -> @out () {
+// CHECK: bb0(%0 : $R<S>):
+// CHECK: [[F:%.*]] = function_ref @_T016testAggregateArgTf4g_n : $@convention(thin) (@in_guaranteed R<S>) -> @out ()
+// CHECK: [[CALL:%.*]] = apply [[F]](%0) : $@convention(thin) (@in_guaranteed R<S>) -> @out ()
+// CHECK: release_value %0 : $R<S>
+// CHECK: return [[CALL]] : $()
+// CHECK-LABEL: } // end sil function 'testAggregateArg'
+//
+// CHECK-LABEL: sil shared @_T016testAggregateArgTf4g_n : $@convention(thin) (@in_guaranteed R<S>) -> @out () {
+// CHECK: bb0(%0 : $R<S>):
+// CHECK: [[COPY:%.*]] = copy_value %0 : $R<S>
+// CHECK: retain_value %0 : $R<S>
+// CHECK: [[F:%.*]] = function_ref @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
+// CHECK: [[CALL:%.*]] = apply [[F]]([[COPY]]) : $@convention(thin) (@owned R<S>) -> ()
+// CHECK: destroy_value %0 : $R<S>
+// CHECK: return %{{.*}} : $()
+// CHECK-LABEL: } // end sil function '_T016testAggregateArgTf4g_n'
+sil @testAggregateArg : $@convention(thin) (@in R<S>) -> @out () {
+bb0(%0 : $R<S>):
+ %9 = copy_value %0 : $R<S>
+ retain_value %0 : $R<S>
+ %10 = function_ref @testAggregateArgHelper : $@convention(thin) (@owned R<S>) -> ()
+ %12 = apply %10(%9) : $@convention(thin) (@owned R<S>) -> ()
+ destroy_value %0 : $R<S>
+ release_value %0 : $R<S>
+ %1284 = tuple ()
+ return %1284 : $()
+}
diff --git a/test/SILOptimizer/sil_combine_opaque.sil b/test/SILOptimizer/sil_combine_opaque.sil
new file mode 100644
index 0000000..e99bbf9
--- /dev/null
+++ b/test/SILOptimizer/sil_combine_opaque.sil
@@ -0,0 +1,25 @@
+// RUN: %target-sil-opt -enable-sil-opaque-values -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all -sil-combine %s | %FileCheck %s
+
+struct S<T> {
+ var t : T
+}
+
+// Test SIL combine's handling of retain_value/release_value.
+//
+// CHECK-LABEL: sil @testSpecializeOpaque : $@convention(thin) <T> (@in S<T>) -> () {
+// CHECK-LABEL: bb0(%0 : $S<T>):
+// CHECK: retain_value %0 : $S<T>
+// CHECK: [[F:%.*]] = function_ref @testSpecializeOpaque : $@convention(thin) <τ_0_0> (@in S<τ_0_0>) -> ()
+// CHECK: [[CALL:%.*]] = apply [[F]]<T>(%0) : $@convention(thin) <τ_0_0> (@in S<τ_0_0>) -> ()
+// CHECK: release_value %0 : $S<T>
+// CHECK: return %{{.*}} : $()
+// CHECK-LABEL: } // end sil function 'testSpecializeOpaque'
+sil @testSpecializeOpaque : $@convention(thin) <T> (@in S<T>) -> () {
+bb0(%0 : $S<T>):
+ %retain = retain_value %0 : $S<T>
+ %f = function_ref @testSpecializeOpaque : $@convention(thin) <T> (@in S<T>) -> ()
+ %call = apply %f<T>(%0) : $@convention(thin) <τ_0_0> (@in S<τ_0_0>) -> ()
+ %release = release_value %0 : $S<T>
+ %999 = tuple ()
+ return %999 : $()
+}
diff --git a/test/SILOptimizer/static_arrays.swift b/test/SILOptimizer/static_arrays.swift
index 2774d2c..89571a2 100644
--- a/test/SILOptimizer/static_arrays.swift
+++ b/test/SILOptimizer/static_arrays.swift
@@ -30,6 +30,13 @@
// CHECK: object {{.*}} ({{[^,]*}}, [tail_elems] {{[^,]*}}, {{[^,]*}})
// CHECK-NEXT: }
+// CHECK-LABEL: outlined variable #0 of returnStaticStringArray()
+// CHECK-NEXT: sil_global private @{{.*}}returnStaticStringArray{{.*}} = {
+// CHECK-DAG: string_literal utf8 "a"
+// CHECK-DAG: string_literal utf8 "b"
+// CHECK: object {{.*}} ({{[^,]*}}, [tail_elems] {{[^,]*}}, {{[^,]*}})
+// CHECK-NEXT: }
+
// CHECK-LABEL: outlined variable #0 of passArray()
// CHECK-NEXT: sil_global private @{{.*}}passArray{{.*}} = {
// CHECK-DAG: integer_literal $Builtin.Int{{[0-9]+}}, 27
@@ -80,6 +87,14 @@
return [20, 21]
}
+// CHECK-LABEL: sil {{.*}}returnStaticStringArray{{.*}} : $@convention(thin) () -> @owned Array<StaticString> {
+// CHECK: global_value @{{.*}}returnStaticStringArray{{.*}}
+// CHECK: return
+@inline(never)
+public func returnStaticStringArray() -> [StaticString] {
+ return ["a", "b"]
+}
+
public var gg: [Int]?
@inline(never)
@@ -132,6 +147,8 @@
print(arrayLookup(1))
// CHECK-OUTPUT-NEXT: [20, 21]
print(returnArray())
+// CHECK-OUTPUT-NEXT: ["a", "b"]
+print(returnStaticStringArray())
passArray()
// CHECK-OUTPUT-NEXT: [29]
print(gg!)
diff --git a/test/SILOptimizer/string_switch.swift b/test/SILOptimizer/string_switch.swift
new file mode 100644
index 0000000..933c78d
--- /dev/null
+++ b/test/SILOptimizer/string_switch.swift
@@ -0,0 +1,135 @@
+// RUN: %target-build-swift -O %s -module-name=test -Xllvm -sil-disable-pass=FunctionSignatureOpts -o %t.out
+// RUN: %target-build-swift -O %s -module-name=test -Xllvm -sil-disable-pass=FunctionSignatureOpts -emit-sil | %FileCheck %s
+// RUN: %target-run %t.out
+// UNSUPPORTED: nonatomic_rc
+
+import StdlibUnittest
+
+// CHECK-LABEL: // SmallEnum.init(rawValue:)
+// CHECK-NEXT: sil {{.*}} @{{.*}}SmallEnum{{.*}}rawValue{{.*}} :
+// CHECK-DAG: global_value @{{.*}}SmallEnum{{.*}}rawValue{{.*}}
+// CHECK-DAG: // function_ref _findStringSwitchCase(cases:string:)
+// CHECK: return
+
+enum SmallEnum : String {
+ case c1 = "Swift"
+ case c2 = "is"
+ case c3 = "a"
+ case c4 = "general-purpose"
+ case c5 = "programming language"
+}
+
+// CHECK-LABEL: // LargeEnum.init(rawValue:)
+// CHECK-NEXT: sil {{.*}} @{{.*}}LargeEnum{{.*}}rawValue{{.*}} :
+// CHECK-DAG: global_value @{{.*}}LargeEnum{{.*}}rawValue{{.*}}
+// CHECK-DAG: // function_ref _findStringSwitchCaseWithCache(cases:string:cache:)
+// CHECK: return
+
+enum LargeEnum : String {
+ case c1 = "Swift"
+ case c2 = "is"
+ case c3 = "a"
+ case c4 = "general-purpose"
+ case c5 = "programming language"
+ case c7 = "built"
+ case c8 = "using"
+ case c10 = "modern"
+ case c11 = "approach"
+ case c12 = "to"
+ case c13 = "safety,"
+ case c14 = "performance,"
+ case c15 = "and"
+ case c16 = "software"
+ case c17 = "design"
+ case c18 = "patterns."
+ case c19 = ""
+ case c20 = "The"
+ case c21 = "goal"
+ case c22 = "of"
+ case c23 = "the"
+ case c25 = "project"
+ case c28 = "create"
+ case c30 = "best"
+ case c31 = "available"
+ case c33 = "for"
+ case c34 = "uses"
+ case c35 = "ranging"
+ case c36 = "from"
+ case c37 = "systems"
+ case c40 = "mobile"
+ case c42 = "desktop"
+ case c43 = "apps,"
+ case c44 = "scaling"
+ case c45 = "up"
+ case c47 = "cloud"
+ case c48 = "services."
+}
+
+let SmallInputs : [(String, SmallEnum)] = [
+ ("Swift", SmallEnum.c1),
+ ("is", SmallEnum.c2),
+ ("a", SmallEnum.c3),
+ ("general-purpose", SmallEnum.c4),
+ ("programming language", SmallEnum.c5),
+]
+
+let LargeInputs : [(String, LargeEnum)] = [
+ ("Swift", LargeEnum.c1),
+ ("is", LargeEnum.c2),
+ ("a", LargeEnum.c3),
+ ("general-purpose", LargeEnum.c4),
+ ("programming language", LargeEnum.c5),
+ ("built", LargeEnum.c7),
+ ("using", LargeEnum.c8),
+ ("modern", LargeEnum.c10),
+ ("approach", LargeEnum.c11),
+ ("to", LargeEnum.c12),
+ ("safety,", LargeEnum.c13),
+ ("performance,", LargeEnum.c14),
+ ("and", LargeEnum.c15),
+ ("software", LargeEnum.c16),
+ ("design", LargeEnum.c17),
+ ("patterns.", LargeEnum.c18),
+ ("", LargeEnum.c19),
+ ("The", LargeEnum.c20),
+ ("goal", LargeEnum.c21),
+ ("of", LargeEnum.c22),
+ ("the", LargeEnum.c23),
+ ("project", LargeEnum.c25),
+ ("create", LargeEnum.c28),
+ ("best", LargeEnum.c30),
+ ("available", LargeEnum.c31),
+ ("for", LargeEnum.c33),
+ ("uses", LargeEnum.c34),
+ ("ranging", LargeEnum.c35),
+ ("from", LargeEnum.c36),
+ ("systems", LargeEnum.c37),
+ ("mobile", LargeEnum.c40),
+ ("desktop", LargeEnum.c42),
+ ("apps,", LargeEnum.c43),
+ ("scaling", LargeEnum.c44),
+ ("up", LargeEnum.c45),
+ ("cloud", LargeEnum.c47),
+ ("services.", LargeEnum.c48)
+]
+
+var StringSwitchTestSuite = TestSuite("StringSwitch")
+
+StringSwitchTestSuite.test("small_enum_init") {
+ runRaceTest(trials: 10, timeoutInSeconds: 0) {
+ for i in SmallInputs {
+ expectEqual(SmallEnum(rawValue: i.0), i.1)
+ }
+ }
+}
+
+StringSwitchTestSuite.test("large_enum_init") {
+ runRaceTest(trials: 10, timeoutInSeconds: 0) {
+ for i in LargeInputs {
+ expectEqual(LargeEnum(rawValue: i.0), i.1)
+ }
+ }
+}
+
+runAllTests()
+
diff --git a/test/Serialization/Recovery/typedefs-in-enums.swift b/test/Serialization/Recovery/typedefs-in-enums.swift
index 9789de9..a38f0cf 100644
--- a/test/Serialization/Recovery/typedefs-in-enums.swift
+++ b/test/Serialization/Recovery/typedefs-in-enums.swift
@@ -54,13 +54,13 @@
// CHECK-NEXT: case noPayload
// CHECK-NEXT: case plainOldAlias(Any, UnwrappedInt)
// CHECK-NEXT: case other(Int)
-// CHECK-NEXT: static func ==(a: OkayEnum, b: OkayEnum) -> Bool
+// CHECK-NEXT: static func == (a: OkayEnum, b: OkayEnum) -> Bool
// CHECK-NEXT: }
// CHECK-RECOVERY-LABEL: enum OkayEnum {
// CHECK-RECOVERY-NEXT: case noPayload
// CHECK-RECOVERY-NEXT: case plainOldAlias(Any, Int32)
// CHECK-RECOVERY-NEXT: case other(Int)
-// CHECK-RECOVERY-NEXT: static func ==(a: OkayEnum, b: OkayEnum) -> Bool
+// CHECK-RECOVERY-NEXT: static func == (a: OkayEnum, b: OkayEnum) -> Bool
// CHECK-RECOVERY-NEXT: }
public enum OkayEnumWithSelfRefs {
diff --git a/test/Serialization/Recovery/typedefs.swift b/test/Serialization/Recovery/typedefs.swift
index a8d8ed0..e22820d 100644
--- a/test/Serialization/Recovery/typedefs.swift
+++ b/test/Serialization/Recovery/typedefs.swift
@@ -87,7 +87,7 @@
// CHECK-LABEL: extension WrappedInt : WrappedProto {
// CHECK-NEXT: func wrappedMethod()
-// CHECK-NEXT: prefix static func ***(x: WrappedInt)
+// CHECK-NEXT: prefix static func *** (x: WrappedInt)
// CHECK-NEXT: }
// CHECK-RECOVERY-NEGATIVE-NOT: extension WrappedInt
extension WrappedInt: WrappedProto {
@@ -96,11 +96,11 @@
}
// CHECK-LABEL: extension Int32 : UnwrappedProto {
// CHECK-NEXT: func unwrappedMethod()
-// CHECK-NEXT: prefix static func ***(x: UnwrappedInt)
+// CHECK-NEXT: prefix static func *** (x: UnwrappedInt)
// CHECK-NEXT: }
// CHECK-RECOVERY-LABEL: extension Int32 : UnwrappedProto {
// CHECK-RECOVERY-NEXT: func unwrappedMethod()
-// CHECK-RECOVERY-NEXT: prefix static func ***(x: Int32)
+// CHECK-RECOVERY-NEXT: prefix static func *** (x: Int32)
// CHECK-RECOVERY-NEXT: }
// CHECK-RECOVERY-NEGATIVE-NOT: extension UnwrappedInt
extension UnwrappedInt: UnwrappedProto {
diff --git a/test/Serialization/sil-imported-enums.swift b/test/Serialization/sil-imported-enums.swift
index 7b5890d..38e1f47 100644
--- a/test/Serialization/sil-imported-enums.swift
+++ b/test/Serialization/sil-imported-enums.swift
@@ -2,12 +2,12 @@
// RUN: mkdir -p %t
// FIXME: BEGIN -enable-source-import hackaround
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -sil-serialize-witness-tables -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -sil-serialize-witness-tables -o %t %clang-importer-sdk-path/swift-modules/Foundation.swift
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %clang-importer-sdk-path/swift-modules/CoreGraphics.swift
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-module -o %t %clang-importer-sdk-path/swift-modules/Foundation.swift
// FIXME: END -enable-source-import hackaround
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -sil-serialize-witness-tables -o %t -parse-as-library %S/Inputs/use_imported_enums.swift -module-name UsesImportedEnums
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil -sil-serialize-witness-tables %s | %FileCheck %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-module -o %t -parse-as-library %S/Inputs/use_imported_enums.swift -module-name UsesImportedEnums
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) -emit-sil %s | %FileCheck %s
// REQUIRES: objc_interop
diff --git a/test/SourceKit/CursorInfo/cursor_invalid.swift b/test/SourceKit/CursorInfo/cursor_invalid.swift
index e37297c..6f70d73 100644
--- a/test/SourceKit/CursorInfo/cursor_invalid.swift
+++ b/test/SourceKit/CursorInfo/cursor_invalid.swift
@@ -51,11 +51,11 @@
// RUN: %sourcekitd-test -req=cursor -pos=18:6 %s -- %s | %FileCheck -check-prefix=EQEQ1 %s
// RUN: %sourcekitd-test -req=cursor -pos=19:6 %s -- %s | %FileCheck -check-prefix=EQEQ1 %s
// Note: we can't find the operator decl so the decl kind is a fallback.
-// EQEQ1: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>==</decl.name>()
+// EQEQ1: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>== </decl.name>()
// RUN: %sourcekitd-test -req=cursor -pos=20:6 %s -- %s | %FileCheck -check-prefix=EQEQ2 %s
// Note: we can't find the operator decl so the decl kind is a fallback.
-// EQEQ2: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>==</decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>)</decl.function.free>
+// EQEQ2: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>== </decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>)</decl.function.free>
// RUN: %sourcekitd-test -req=cursor -pos=21:6 %s -- %s | %FileCheck -check-prefix=EQEQ3 %s
-// EQEQ3: <decl.function.operator.infix><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>==</decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>y</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>)</decl.function.operator.infix>
+// EQEQ3: <decl.function.operator.infix><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>== </decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>y</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>)</decl.function.operator.infix>
diff --git a/test/SourceKit/DocSupport/doc_clang_module.swift.response b/test/SourceKit/DocSupport/doc_clang_module.swift.response
index fe39879..5300eac 100644
--- a/test/SourceKit/DocSupport/doc_clang_module.swift.response
+++ b/test/SourceKit/DocSupport/doc_clang_module.swift.response
@@ -9,7 +9,7 @@
var rawValue: UInt32
- static func !=(_ lhs: FooEnum1, _ rhs: FooEnum1) -> Bool
+ static func != (_ lhs: FooEnum1, _ rhs: FooEnum1) -> Bool
}
var FooEnum1X: FooEnum1 { get }
struct FooEnum2 : Equatable, RawRepresentable {
@@ -20,7 +20,7 @@
var rawValue: UInt32
- static func !=(_ lhs: FooEnum2, _ rhs: FooEnum2) -> Bool
+ static func != (_ lhs: FooEnum2, _ rhs: FooEnum2) -> Bool
}
var FooEnum2X: FooEnum2 { get }
var FooEnum2Y: FooEnum2 { get }
@@ -32,7 +32,7 @@
var rawValue: UInt32
- static func !=(_ lhs: FooEnum3, _ rhs: FooEnum3) -> Bool
+ static func != (_ lhs: FooEnum3, _ rhs: FooEnum3) -> Bool
}
var FooEnum3X: FooEnum3 { get }
var FooEnum3Y: FooEnum3 { get }
@@ -44,7 +44,7 @@
case orderedDescending
- static func !=(_ lhs: FooComparisonResult, _ rhs: FooComparisonResult) -> Bool
+ static func != (_ lhs: FooComparisonResult, _ rhs: FooComparisonResult) -> Bool
}
struct FooRuncingOptions : OptionSet {
@@ -54,7 +54,7 @@
static var enableQuince: FooRuncingOptions { get }
- static func !=(_ lhs: FooRuncingOptions, _ rhs: FooRuncingOptions) -> Bool
+ static func != (_ lhs: FooRuncingOptions, _ rhs: FooRuncingOptions) -> Bool
convenience init(arrayLiteral arrayLiteral: FooRuncingOptions...)
}
@@ -337,7 +337,7 @@
case restricted
- static func !=(_ lhs: ABAuthorizationStatus, _ rhs: ABAuthorizationStatus) -> Bool
+ static func != (_ lhs: ABAuthorizationStatus, _ rhs: ABAuthorizationStatus) -> Bool
}
func fooSubFunc1(_ a: Int32) -> Int32
struct FooSubEnum1 : Equatable, RawRepresentable {
@@ -348,7 +348,7 @@
var rawValue: UInt32
- static func !=(_ lhs: FooSubEnum1, _ rhs: FooSubEnum1) -> Bool
+ static func != (_ lhs: FooSubEnum1, _ rhs: FooSubEnum1) -> Bool
}
var FooSubEnum1X: FooSubEnum1 { get }
var FooSubEnum1Y: FooSubEnum1 { get }
@@ -492,4487 +492,4487 @@
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 197,
+ key.offset: 198,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 199,
+ key.offset: 200,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 199,
+ key.offset: 200,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum1",
key.usr: "c:@E@FooEnum1",
- key.offset: 204,
+ key.offset: 205,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 214,
+ key.offset: 215,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 216,
+ key.offset: 217,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 216,
+ key.offset: 217,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum1",
key.usr: "c:@E@FooEnum1",
- key.offset: 221,
+ key.offset: 222,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 234,
+ key.offset: 235,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 241,
+ key.offset: 242,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 245,
+ key.offset: 246,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum1",
key.usr: "c:@E@FooEnum1",
- key.offset: 256,
+ key.offset: 257,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 267,
+ key.offset: 268,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 273,
+ key.offset: 274,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 280,
+ key.offset: 281,
key.length: 8
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Equatable",
key.usr: "s:s9EquatableP",
- key.offset: 291,
+ key.offset: 292,
key.length: 9
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "RawRepresentable",
key.usr: "s:s16RawRepresentableP",
- key.offset: 302,
+ key.offset: 303,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 326,
+ key.offset: 327,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 331,
+ key.offset: 332,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 333,
+ key.offset: 334,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 333,
+ key.offset: 334,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 343,
+ key.offset: 344,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 356,
+ key.offset: 357,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 361,
+ key.offset: 362,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 370,
+ key.offset: 371,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 361,
+ key.offset: 362,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 370,
+ key.offset: 371,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 380,
+ key.offset: 381,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 393,
+ key.offset: 394,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 397,
+ key.offset: 398,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 407,
+ key.offset: 408,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 419,
+ key.offset: 420,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 426,
+ key.offset: 427,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 434,
+ key.offset: 436,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 436,
+ key.offset: 438,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 436,
+ key.offset: 438,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum2",
key.usr: "c:@E@FooEnum2",
- key.offset: 441,
+ key.offset: 443,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 451,
+ key.offset: 453,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 453,
+ key.offset: 455,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 453,
+ key.offset: 455,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum2",
key.usr: "c:@E@FooEnum2",
- key.offset: 458,
+ key.offset: 460,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 471,
+ key.offset: 473,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 478,
+ key.offset: 480,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 482,
+ key.offset: 484,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum2",
key.usr: "c:@E@FooEnum2",
- key.offset: 493,
+ key.offset: 495,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 504,
+ key.offset: 506,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 510,
+ key.offset: 512,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 514,
+ key.offset: 516,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum2",
key.usr: "c:@E@FooEnum2",
- key.offset: 525,
+ key.offset: 527,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 536,
+ key.offset: 538,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 542,
+ key.offset: 544,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 549,
+ key.offset: 551,
key.length: 8
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Equatable",
key.usr: "s:s9EquatableP",
- key.offset: 560,
+ key.offset: 562,
key.length: 9
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "RawRepresentable",
key.usr: "s:s16RawRepresentableP",
- key.offset: 571,
+ key.offset: 573,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 595,
+ key.offset: 597,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 600,
+ key.offset: 602,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 602,
+ key.offset: 604,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 602,
+ key.offset: 604,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 612,
+ key.offset: 614,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 625,
+ key.offset: 627,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 630,
+ key.offset: 632,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 639,
+ key.offset: 641,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 630,
+ key.offset: 632,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 639,
+ key.offset: 641,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 649,
+ key.offset: 651,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 662,
+ key.offset: 664,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 666,
+ key.offset: 668,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 676,
+ key.offset: 678,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 688,
+ key.offset: 690,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 695,
+ key.offset: 697,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 703,
+ key.offset: 706,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 705,
+ key.offset: 708,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 705,
+ key.offset: 708,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum3",
key.usr: "c:@E@FooEnum3",
- key.offset: 710,
+ key.offset: 713,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 720,
+ key.offset: 723,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 722,
+ key.offset: 725,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 722,
+ key.offset: 725,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum3",
key.usr: "c:@E@FooEnum3",
- key.offset: 727,
+ key.offset: 730,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 740,
+ key.offset: 743,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 747,
+ key.offset: 750,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 751,
+ key.offset: 754,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum3",
key.usr: "c:@E@FooEnum3",
- key.offset: 762,
+ key.offset: 765,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 773,
+ key.offset: 776,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 779,
+ key.offset: 782,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 783,
+ key.offset: 786,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooEnum3",
key.usr: "c:@E@FooEnum3",
- key.offset: 794,
+ key.offset: 797,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 805,
+ key.offset: 808,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 811,
+ key.offset: 814,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 816,
+ key.offset: 819,
key.length: 19
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 838,
+ key.offset: 841,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 849,
+ key.offset: 852,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 854,
+ key.offset: 857,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 876,
+ key.offset: 879,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 881,
+ key.offset: 884,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 898,
+ key.offset: 901,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 903,
+ key.offset: 906,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 926,
+ key.offset: 929,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 933,
+ key.offset: 936,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 941,
+ key.offset: 945,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 943,
+ key.offset: 947,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 943,
+ key.offset: 947,
key.length: 3
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "FooComparisonResult",
key.usr: "c:@E@FooComparisonResult",
- key.offset: 948,
+ key.offset: 952,
key.length: 19
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 969,
+ key.offset: 973,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 971,
+ key.offset: 975,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 971,
+ key.offset: 975,
key.length: 3
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "FooComparisonResult",
key.usr: "c:@E@FooComparisonResult",
- key.offset: 976,
+ key.offset: 980,
key.length: 19
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1000,
+ key.offset: 1004,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1007,
+ key.offset: 1011,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1014,
+ key.offset: 1018,
key.length: 17
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "OptionSet",
key.usr: "s:s9OptionSetP",
- key.offset: 1034,
+ key.offset: 1038,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1051,
+ key.offset: 1055,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1056,
+ key.offset: 1060,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1065,
+ key.offset: 1069,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1056,
+ key.offset: 1060,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1065,
+ key.offset: 1069,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 1075,
+ key.offset: 1079,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1085,
+ key.offset: 1089,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1092,
+ key.offset: 1096,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1096,
+ key.offset: 1100,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1109,
+ key.offset: 1113,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1129,
+ key.offset: 1133,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1140,
+ key.offset: 1144,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1147,
+ key.offset: 1151,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1151,
+ key.offset: 1155,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1165,
+ key.offset: 1169,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1185,
+ key.offset: 1189,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1196,
+ key.offset: 1200,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1203,
+ key.offset: 1207,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1211,
+ key.offset: 1216,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1213,
+ key.offset: 1218,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1213,
+ key.offset: 1218,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1218,
+ key.offset: 1223,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1237,
+ key.offset: 1242,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1239,
+ key.offset: 1244,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1239,
+ key.offset: 1244,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1244,
+ key.offset: 1249,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1266,
+ key.offset: 1271,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 1276,
+ key.offset: 1281,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1288,
+ key.offset: 1293,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1293,
+ key.offset: 1298,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1306,
+ key.offset: 1311,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1293,
+ key.offset: 1298,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1306,
+ key.offset: 1311,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1320,
+ key.offset: 1325,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1345,
+ key.offset: 1350,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1355,
+ key.offset: 1360,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 1380,
+ key.offset: 1385,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1392,
+ key.offset: 1397,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1397,
+ key.offset: 1402,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1400,
+ key.offset: 1405,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1402,
+ key.offset: 1407,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1412,
+ key.offset: 1417,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1415,
+ key.offset: 1420,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1421,
+ key.offset: 1426,
key.length: 1
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Sequence",
key.usr: "s:s8SequenceP",
- key.offset: 1425,
+ key.offset: 1430,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1435,
+ key.offset: 1440,
key.length: 17
},
{
key.kind: source.lang.swift.ref.typealias,
key.name: "Element",
key.usr: "s:SC17FooRuncingOptionsV7Elementa",
- key.offset: 1453,
+ key.offset: 1458,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1464,
+ key.offset: 1469,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1466,
+ key.offset: 1471,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1400,
+ key.offset: 1405,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1402,
+ key.offset: 1407,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 1479,
+ key.offset: 1484,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1488,
+ key.offset: 1493,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1493,
+ key.offset: 1498,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1502,
+ key.offset: 1507,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1504,
+ key.offset: 1509,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1504,
+ key.offset: 1509,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1511,
+ key.offset: 1516,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1535,
+ key.offset: 1540,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1540,
+ key.offset: 1545,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1549,
+ key.offset: 1554,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1552,
+ key.offset: 1557,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1549,
+ key.offset: 1554,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1552,
+ key.offset: 1557,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1559,
+ key.offset: 1564,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1581,
+ key.offset: 1586,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1591,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 1596,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1601,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1607,
+ key.offset: 1612,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1610,
+ key.offset: 1615,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1607,
+ key.offset: 1612,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1610,
+ key.offset: 1615,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1617,
+ key.offset: 1622,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1639,
+ key.offset: 1644,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1649,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 1654,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 1659,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1665,
+ key.offset: 1670,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1670,
+ key.offset: 1675,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1665,
+ key.offset: 1670,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1670,
+ key.offset: 1675,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1677,
+ key.offset: 1682,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1699,
+ key.offset: 1704,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1709,
+ key.offset: 1714,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1714,
+ key.offset: 1719,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1726,
+ key.offset: 1731,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1728,
+ key.offset: 1733,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1728,
+ key.offset: 1733,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1735,
+ key.offset: 1740,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1757,
+ key.offset: 1762,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1780,
+ key.offset: 1785,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1784,
+ key.offset: 1789,
key.length: 7
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1793,
+ key.offset: 1798,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1800,
+ key.offset: 1805,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1811,
+ key.offset: 1816,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1816,
+ key.offset: 1821,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1833,
+ key.offset: 1838,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1836,
+ key.offset: 1841,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1833,
+ key.offset: 1838,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1836,
+ key.offset: 1841,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1843,
+ key.offset: 1848,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1865,
+ key.offset: 1870,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1875,
+ key.offset: 1880,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1880,
+ key.offset: 1885,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1895,
+ key.offset: 1900,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1898,
+ key.offset: 1903,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1895,
+ key.offset: 1900,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1898,
+ key.offset: 1903,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1905,
+ key.offset: 1910,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1927,
+ key.offset: 1932,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1935,
+ key.offset: 1940,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1945,
+ key.offset: 1950,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1970,
+ key.offset: 1975,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1975,
+ key.offset: 1980,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1981,
+ key.offset: 1986,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1983,
+ key.offset: 1988,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1983,
+ key.offset: 1988,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 1990,
+ key.offset: 1995,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2012,
+ key.offset: 2017,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2035,
+ key.offset: 2040,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2040,
+ key.offset: 2045,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2053,
+ key.offset: 2058,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2055,
+ key.offset: 2060,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2055,
+ key.offset: 2060,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2062,
+ key.offset: 2067,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2084,
+ key.offset: 2089,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2107,
+ key.offset: 2112,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2112,
+ key.offset: 2117,
key.length: 19
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2132,
+ key.offset: 2137,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2134,
+ key.offset: 2139,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2134,
+ key.offset: 2139,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2141,
+ key.offset: 2146,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2163,
+ key.offset: 2168,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2184,
+ key.offset: 2189,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2194,
+ key.offset: 2199,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2219,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 2224,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2229,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2233,
+ key.offset: 2238,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2235,
+ key.offset: 2240,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2235,
+ key.offset: 2240,
key.length: 6
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2243,
+ key.offset: 2248,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 2265,
+ key.offset: 2270,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2275,
+ key.offset: 2280,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2284,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 2289,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2294,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2296,
+ key.offset: 2301,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2298,
+ key.offset: 2303,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2298,
+ key.offset: 2303,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2309,
+ key.offset: 2314,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2332,
+ key.offset: 2337,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 2342,
+ key.offset: 2347,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2348,
+ key.offset: 2353,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2367,
+ key.offset: 2372,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2391,
+ key.offset: 2396,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2400,
+ key.offset: 2405,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2405,
+ key.offset: 2410,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2412,
+ key.offset: 2417,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2414,
+ key.offset: 2419,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2414,
+ key.offset: 2419,
key.length: 6
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2422,
+ key.offset: 2427,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2444,
+ key.offset: 2449,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2468,
+ key.offset: 2473,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2477,
+ key.offset: 2482,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2482,
+ key.offset: 2487,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2489,
+ key.offset: 2494,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2494,
+ key.offset: 2499,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2489,
+ key.offset: 2494,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2494,
+ key.offset: 2499,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2505,
+ key.offset: 2510,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2527,
+ key.offset: 2532,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2549,
+ key.offset: 2554,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2559,
+ key.offset: 2564,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2584,
+ key.offset: 2589,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2596,
+ key.offset: 2601,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2608,
+ key.offset: 2613,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2617,
+ key.offset: 2622,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2622,
+ key.offset: 2627,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2632,
+ key.offset: 2637,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2634,
+ key.offset: 2639,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2634,
+ key.offset: 2639,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2641,
+ key.offset: 2646,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2665,
+ key.offset: 2670,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2674,
+ key.offset: 2679,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2679,
+ key.offset: 2684,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2696,
+ key.offset: 2701,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2698,
+ key.offset: 2703,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2698,
+ key.offset: 2703,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2705,
+ key.offset: 2710,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 2729,
+ key.offset: 2734,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2738,
+ key.offset: 2743,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2743,
+ key.offset: 2748,
key.length: 23
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2767,
+ key.offset: 2772,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2769,
+ key.offset: 2774,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2769,
+ key.offset: 2774,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
- key.offset: 2776,
+ key.offset: 2781,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2797,
+ key.offset: 2802,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2804,
+ key.offset: 2809,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2822,
+ key.offset: 2827,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2826,
+ key.offset: 2831,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 2829,
+ key.offset: 2834,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2840,
+ key.offset: 2845,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2844,
+ key.offset: 2849,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 2847,
+ key.offset: 2852,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2859,
+ key.offset: 2864,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2871,
+ key.offset: 2876,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2876,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2878,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2876,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2878,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.ref.struct,
- key.name: "Int32",
- key.usr: "s:s5Int32V",
key.offset: 2881,
- key.length: 5
- },
- {
- key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 2888,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 2890,
+ key.offset: 2883,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2888,
+ key.offset: 2881,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2890,
+ key.offset: 2883,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.struct,
+ key.name: "Int32",
+ key.usr: "s:s5Int32V",
+ key.offset: 2886,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.argument,
+ key.offset: 2893,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.parameter,
+ key.offset: 2895,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2893,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 2895,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 2893,
+ key.offset: 2898,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2903,
+ key.offset: 2908,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2913,
+ key.offset: 2918,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UnsafeMutablePointer",
key.usr: "s:Sp",
- key.offset: 2933,
+ key.offset: 2938,
key.length: 20
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooStruct1",
key.usr: "c:@S@FooStruct1",
- key.offset: 2954,
+ key.offset: 2959,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2966,
+ key.offset: 2971,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2973,
+ key.offset: 2978,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 2991,
+ key.offset: 2996,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 2995,
+ key.offset: 3000,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 2998,
+ key.offset: 3003,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3009,
+ key.offset: 3014,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3013,
+ key.offset: 3018,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 3016,
+ key.offset: 3021,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3028,
+ key.offset: 3033,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3040,
+ key.offset: 3045,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3045,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3047,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3045,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3047,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.ref.struct,
- key.name: "Int32",
- key.usr: "s:s5Int32V",
key.offset: 3050,
- key.length: 5
- },
- {
- key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3057,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3059,
+ key.offset: 3052,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3057,
+ key.offset: 3050,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3059,
+ key.offset: 3052,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.struct,
+ key.name: "Int32",
+ key.usr: "s:s5Int32V",
+ key.offset: 3055,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.argument,
+ key.offset: 3062,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.parameter,
+ key.offset: 3064,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3062,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3064,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 3062,
+ key.offset: 3067,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3072,
+ key.offset: 3077,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3082,
+ key.offset: 3087,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooStruct2",
key.usr: "c:@S@FooStruct2",
- key.offset: 3102,
+ key.offset: 3107,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3113,
+ key.offset: 3118,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3120,
+ key.offset: 3125,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3145,
+ key.offset: 3150,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3149,
+ key.offset: 3154,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3152,
+ key.offset: 3157,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3163,
+ key.offset: 3168,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3167,
+ key.offset: 3172,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 3170,
+ key.offset: 3175,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3182,
+ key.offset: 3187,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3194,
+ key.offset: 3199,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3199,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3201,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3199,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3201,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.ref.struct,
- key.name: "Int32",
- key.usr: "s:s5Int32V",
key.offset: 3204,
- key.length: 5
- },
- {
- key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3211,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3213,
+ key.offset: 3206,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3211,
+ key.offset: 3204,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3213,
+ key.offset: 3206,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.struct,
+ key.name: "Int32",
+ key.usr: "s:s5Int32V",
+ key.offset: 3209,
+ key.length: 5
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.argument,
+ key.offset: 3216,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.parameter,
+ key.offset: 3218,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3216,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3218,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 3216,
+ key.offset: 3221,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3226,
+ key.offset: 3231,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3236,
+ key.offset: 3241,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3250,
+ key.offset: 3255,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3256,
+ key.offset: 3261,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3260,
+ key.offset: 3265,
key.length: 9
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3271,
+ key.offset: 3276,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3277,
+ key.offset: 3282,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3282,
+ key.offset: 3287,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3291,
+ key.offset: 3296,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3293,
+ key.offset: 3298,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3293,
+ key.offset: 3298,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3296,
+ key.offset: 3301,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3306,
+ key.offset: 3311,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3312,
+ key.offset: 3317,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3317,
+ key.offset: 3322,
key.length: 22
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3340,
+ key.offset: 3345,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3342,
+ key.offset: 3347,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3345,
+ key.offset: 3350,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3355,
+ key.offset: 3360,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3361,
+ key.offset: 3366,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3366,
+ key.offset: 3371,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3375,
+ key.offset: 3380,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3377,
+ key.offset: 3382,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3377,
+ key.offset: 3382,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3380,
+ key.offset: 3385,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3387,
+ key.offset: 3392,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3389,
+ key.offset: 3394,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3389,
+ key.offset: 3394,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Float",
key.usr: "s:Sf",
- key.offset: 3392,
+ key.offset: 3397,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3399,
+ key.offset: 3404,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3401,
+ key.offset: 3406,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3401,
+ key.offset: 3406,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Double",
key.usr: "s:Sd",
- key.offset: 3404,
+ key.offset: 3409,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3412,
+ key.offset: 3417,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3414,
+ key.offset: 3419,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3414,
+ key.offset: 3419,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UnsafeMutablePointer",
key.usr: "s:Sp",
- key.offset: 3417,
+ key.offset: 3422,
key.length: 20
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3438,
+ key.offset: 3443,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3450,
+ key.offset: 3455,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3456,
+ key.offset: 3461,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3461,
+ key.offset: 3466,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3478,
+ key.offset: 3483,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3480,
+ key.offset: 3485,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3480,
+ key.offset: 3485,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Float",
key.usr: "s:Sf",
- key.offset: 3487,
+ key.offset: 3492,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3497,
+ key.offset: 3502,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3506,
+ key.offset: 3511,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3511,
+ key.offset: 3516,
key.length: 26
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3538,
+ key.offset: 3543,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3540,
+ key.offset: 3545,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3540,
+ key.offset: 3545,
key.length: 4
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Float",
key.usr: "s:Sf",
- key.offset: 3548,
+ key.offset: 3553,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3558,
+ key.offset: 3563,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3567,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 3572,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3577,
key.length: 16
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "Never",
key.usr: "s:s5NeverO",
- key.offset: 3594,
+ key.offset: 3599,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3600,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 3605,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3610,
key.length: 16
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "Never",
key.usr: "s:s5NeverO",
- key.offset: 3627,
+ key.offset: 3632,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3633,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 3638,
- key.length: 19
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3660,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3643,
+ key.length: 19
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 3665,
- key.length: 19
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3687,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3670,
+ key.length: 19
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 3692,
- key.length: 19
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3714,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3697,
+ key.length: 19
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 3719,
- key.length: 19
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3741,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3724,
+ key.length: 19
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 3746,
- key.length: 19
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3768,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3751,
+ key.length: 19
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 3773,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3778,
key.length: 32
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 3806,
+ key.offset: 3811,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 3808,
+ key.offset: 3813,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3808,
+ key.offset: 3813,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3811,
+ key.offset: 3816,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 3821,
+ key.offset: 3826,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3827,
+ key.offset: 3832,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3836,
+ key.offset: 3841,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3859,
+ key.offset: 3864,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3864,
+ key.offset: 3869,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3884,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 3889,
- key.length: 33
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3930,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3935,
+ key.offset: 3894,
key.length: 33
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3976,
+ key.offset: 3935,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 3940,
+ key.length: 33
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 3981,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 3983,
+ key.offset: 3988,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 3988,
+ key.offset: 3993,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4013,
+ key.offset: 4018,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4017,
+ key.offset: 4022,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4031,
+ key.offset: 4036,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4039,
+ key.offset: 4044,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4043,
+ key.offset: 4048,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4054,
+ key.offset: 4059,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4058,
+ key.offset: 4063,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4072,
+ key.offset: 4077,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4080,
+ key.offset: 4085,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4084,
+ key.offset: 4089,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4095,
+ key.offset: 4100,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4099,
+ key.offset: 4104,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4113,
+ key.offset: 4118,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4121,
+ key.offset: 4126,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4129,
+ key.offset: 4134,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4138,
+ key.offset: 4143,
key.length: 18
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "FooProtocolBase",
key.usr: "c:objc(pl)FooProtocolBase",
- key.offset: 4159,
+ key.offset: 4164,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4179,
+ key.offset: 4184,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4185,
+ key.offset: 4190,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4205,
+ key.offset: 4210,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4210,
+ key.offset: 4215,
key.length: 20
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4238,
+ key.offset: 4243,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4243,
+ key.offset: 4248,
key.length: 20
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 4264,
+ key.offset: 4269,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 4266,
+ key.offset: 4271,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4266,
+ key.offset: 4271,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4276,
+ key.offset: 4281,
key.length: 3
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 4285,
+ key.offset: 4290,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4304,
+ key.offset: 4309,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 4317,
+ key.offset: 4322,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4329,
+ key.offset: 4334,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 4335,
+ key.offset: 4340,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 4341,
+ key.offset: 4346,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4335,
+ key.offset: 4340,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4341,
+ key.offset: 4346,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Float",
key.usr: "s:Sf",
- key.offset: 4344,
+ key.offset: 4349,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4356,
+ key.offset: 4361,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4361,
+ key.offset: 4366,
key.length: 29
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4398,
+ key.offset: 4403,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4404,
+ key.offset: 4409,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4409,
+ key.offset: 4414,
key.length: 17
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4434,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 4439,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4459,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4469,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4444,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 4464,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 4474,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4494,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4504,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4479,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 4499,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 4509,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4514,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4530,
+ key.offset: 4535,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4540,
+ key.offset: 4545,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4545,
+ key.offset: 4550,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4565,
+ key.offset: 4570,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4572,
+ key.offset: 4577,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4578,
+ key.offset: 4583,
key.length: 15
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 4596,
+ key.offset: 4601,
key.length: 12
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "FooProtocolDerived",
key.usr: "c:objc(pl)FooProtocolDerived",
- key.offset: 4610,
+ key.offset: 4615,
key.length: 18
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4636,
+ key.offset: 4641,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4640,
+ key.offset: 4645,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4654,
+ key.offset: 4659,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4665,
+ key.offset: 4670,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4669,
+ key.offset: 4674,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4683,
+ key.offset: 4688,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4694,
+ key.offset: 4699,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4698,
+ key.offset: 4703,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4712,
+ key.offset: 4717,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4720,
+ key.offset: 4725,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4731,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 4736,
- key.length: 16
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4760,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4741,
+ key.length: 16
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 4765,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4770,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 4782,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 4784,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4784,
- key.length: 1
- },
- {
- key.kind: source.lang.swift.ref.struct,
- key.name: "Int32",
- key.usr: "s:s5Int32V",
key.offset: 4787,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.parameter,
+ key.offset: 4789,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4789,
+ key.length: 1
+ },
+ {
+ key.kind: source.lang.swift.ref.struct,
+ key.name: "Int32",
+ key.usr: "s:s5Int32V",
+ key.offset: 4792,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4799,
+ key.offset: 4804,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4804,
+ key.offset: 4809,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 4821,
+ key.offset: 4826,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 4823,
+ key.offset: 4828,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4823,
+ key.offset: 4828,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4826,
+ key.offset: 4831,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 4833,
+ key.offset: 4838,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 4839,
+ key.offset: 4844,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4833,
+ key.offset: 4838,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4839,
+ key.offset: 4844,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 4842,
+ key.offset: 4847,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4854,
+ key.offset: 4859,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4859,
+ key.offset: 4864,
key.length: 29
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4896,
+ key.offset: 4901,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4902,
+ key.offset: 4907,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 4907,
+ key.offset: 4912,
key.length: 13
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4928,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 4933,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4953,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4963,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4938,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 4958,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 4968,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4988,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 4998,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 4973,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 4993,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 5003,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 5008,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5024,
+ key.offset: 5029,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5034,
+ key.offset: 5039,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5039,
+ key.offset: 5044,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5059,
+ key.offset: 5064,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5066,
+ key.offset: 5071,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5076,
+ key.offset: 5081,
key.length: 13
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5092,
+ key.offset: 5097,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5098,
+ key.offset: 5103,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5102,
+ key.offset: 5107,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5115,
+ key.offset: 5120,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5123,
+ key.offset: 5128,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5129,
+ key.offset: 5134,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5133,
+ key.offset: 5138,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5146,
+ key.offset: 5151,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5154,
+ key.offset: 5159,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5160,
+ key.offset: 5165,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5164,
+ key.offset: 5169,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5177,
+ key.offset: 5182,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5185,
+ key.offset: 5190,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5191,
+ key.offset: 5196,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5195,
+ key.offset: 5200,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 5208,
+ key.offset: 5213,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5217,
+ key.offset: 5222,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5223,
+ key.offset: 5228,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5227,
+ key.offset: 5232,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt64",
key.usr: "s:s6UInt64V",
- key.offset: 5240,
+ key.offset: 5245,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5249,
+ key.offset: 5254,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5255,
+ key.offset: 5260,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5259,
+ key.offset: 5264,
key.length: 11
},
{
key.kind: source.lang.swift.ref.typealias,
key.name: "typedef_int_t",
key.usr: "c:Foo.h@T@typedef_int_t",
- key.offset: 5272,
+ key.offset: 5277,
key.length: 13
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5288,
+ key.offset: 5293,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5294,
+ key.offset: 5299,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5298,
+ key.offset: 5303,
key.length: 11
},
{
key.kind: source.lang.swift.ref.typealias,
key.name: "typedef_int_t",
key.usr: "c:Foo.h@T@typedef_int_t",
- key.offset: 5311,
+ key.offset: 5316,
key.length: 13
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5327,
+ key.offset: 5332,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5333,
+ key.offset: 5338,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5337,
+ key.offset: 5342,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int8",
key.usr: "s:s4Int8V",
- key.offset: 5350,
+ key.offset: 5355,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5357,
+ key.offset: 5362,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5363,
+ key.offset: 5368,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5367,
+ key.offset: 5372,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5380,
+ key.offset: 5385,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5388,
+ key.offset: 5393,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5394,
+ key.offset: 5399,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5398,
+ key.offset: 5403,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int16",
key.usr: "s:s5Int16V",
- key.offset: 5412,
+ key.offset: 5417,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5420,
+ key.offset: 5425,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5426,
+ key.offset: 5431,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5430,
+ key.offset: 5435,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 5444,
+ key.offset: 5449,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5450,
+ key.offset: 5455,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5456,
+ key.offset: 5461,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5460,
+ key.offset: 5465,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5474,
+ key.offset: 5479,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5482,
+ key.offset: 5487,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5488,
+ key.offset: 5493,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5492,
+ key.offset: 5497,
key.length: 13
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5507,
+ key.offset: 5512,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5515,
+ key.offset: 5520,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5521,
+ key.offset: 5526,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5525,
+ key.offset: 5530,
key.length: 18
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt64",
key.usr: "s:s6UInt64V",
- key.offset: 5545,
+ key.offset: 5550,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5554,
+ key.offset: 5559,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5560,
+ key.offset: 5565,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5564,
+ key.offset: 5569,
key.length: 16
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 5582,
+ key.offset: 5587,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5591,
+ key.offset: 5596,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5597,
+ key.offset: 5602,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5601,
+ key.offset: 5606,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5620,
+ key.offset: 5625,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5628,
+ key.offset: 5633,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5634,
+ key.offset: 5639,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5638,
+ key.offset: 5643,
key.length: 17
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5657,
+ key.offset: 5662,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5665,
+ key.offset: 5670,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5671,
+ key.offset: 5676,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5676,
+ key.offset: 5681,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5695,
+ key.offset: 5700,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5700,
+ key.offset: 5705,
key.length: 21
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5724,
+ key.offset: 5729,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5731,
+ key.offset: 5736,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5754,
+ key.offset: 5759,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5758,
+ key.offset: 5763,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5761,
+ key.offset: 5766,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5772,
+ key.offset: 5777,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5784,
+ key.offset: 5789,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 5789,
+ key.offset: 5794,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 5791,
+ key.offset: 5796,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5789,
+ key.offset: 5794,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5791,
+ key.offset: 5796,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 5794,
+ key.offset: 5799,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5803,
+ key.offset: 5808,
key.length: 9
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 5813,
+ key.offset: 5818,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5833,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 5838,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 5843,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5858,
+ key.offset: 5863,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5865,
+ key.offset: 5870,
key.length: 9
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 5875,
+ key.offset: 5880,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5895,
+ key.offset: 5900,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5900,
+ key.offset: 5905,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5920,
+ key.offset: 5925,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5930,
+ key.offset: 5935,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5935,
+ key.offset: 5940,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5956,
+ key.offset: 5961,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5963,
+ key.offset: 5968,
key.length: 9
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 5973,
+ key.offset: 5978,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 5993,
+ key.offset: 5998,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 5998,
+ key.offset: 6003,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6018,
+ key.offset: 6023,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6025,
+ key.offset: 6030,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6034,
+ key.offset: 6039,
key.length: 13
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6052,
+ key.offset: 6057,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6058,
+ key.offset: 6063,
key.length: 21
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "_InternalProt",
key.usr: "c:objc(pl)_InternalProt",
- key.offset: 6082,
+ key.offset: 6087,
key.length: 13
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6100,
+ key.offset: 6105,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6106,
+ key.offset: 6111,
key.length: 25
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 6134,
+ key.offset: 6139,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 6154,
+ key.offset: 6159,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6170,
+ key.offset: 6175,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6174,
+ key.offset: 6179,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 6186,
+ key.offset: 6191,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 6202,
+ key.offset: 6207,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6218,
+ key.offset: 6223,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6222,
+ key.offset: 6227,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 6240,
+ key.offset: 6245,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6256,
+ key.offset: 6261,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6260,
+ key.offset: 6265,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6272,
+ key.offset: 6277,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6282,
+ key.offset: 6287,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6286,
+ key.offset: 6291,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6297,
+ key.offset: 6302,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6307,
+ key.offset: 6312,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6311,
+ key.offset: 6316,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6321,
+ key.offset: 6326,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 6331,
+ key.offset: 6336,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6336,
+ key.offset: 6341,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6340,
+ key.offset: 6345,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 6349,
+ key.offset: 6354,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6365,
+ key.offset: 6370,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6369,
+ key.offset: 6374,
key.length: 6
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 6377,
+ key.offset: 6382,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6388,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 6393,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6413,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6423,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6398,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 6418,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 6428,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6448,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6458,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6433,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 6453,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 6463,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6468,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6484,
+ key.offset: 6489,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6494,
+ key.offset: 6499,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6499,
+ key.offset: 6504,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6519,
+ key.offset: 6524,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6526,
+ key.offset: 6531,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6530,
+ key.offset: 6535,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6542,
+ key.offset: 6547,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6548,
+ key.offset: 6553,
key.length: 21
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 6572,
+ key.offset: 6577,
key.length: 12
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 6592,
+ key.offset: 6597,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6604,
+ key.offset: 6609,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 6610,
+ key.offset: 6615,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 6614,
+ key.offset: 6619,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6610,
+ key.offset: 6615,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6614,
+ key.offset: 6619,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 6617,
+ key.offset: 6622,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6629,
+ key.offset: 6634,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6634,
+ key.offset: 6639,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6653,
+ key.offset: 6658,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6658,
+ key.offset: 6663,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6682,
+ key.offset: 6687,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6687,
+ key.offset: 6692,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6705,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 6710,
- key.length: 22
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6740,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6715,
+ key.length: 22
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 6745,
- key.length: 22
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6775,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6750,
+ key.length: 22
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 6780,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6785,
key.length: 21
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6809,
+ key.offset: 6814,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6814,
+ key.offset: 6819,
key.length: 23
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6845,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 6850,
- key.length: 25
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6883,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6855,
+ key.length: 25
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 6888,
- key.length: 25
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6921,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6893,
+ key.length: 25
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 6926,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 6931,
key.length: 24
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6958,
+ key.offset: 6963,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 6963,
+ key.offset: 6968,
key.length: 26
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 6997,
- key.length: 4
- },
- {
- key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 7002,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7022,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7032,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 7007,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 7027,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 7037,
- key.length: 14
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7057,
- key.length: 3
- },
- {
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7067,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 7042,
+ key.length: 14
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
+ key.offset: 7062,
+ key.length: 3
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.keyword,
key.offset: 7072,
+ key.length: 4
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.identifier,
+ key.offset: 7077,
key.length: 15
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7093,
+ key.offset: 7098,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7103,
+ key.offset: 7108,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7108,
+ key.offset: 7113,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7128,
+ key.offset: 7133,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7135,
+ key.offset: 7140,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7141,
+ key.offset: 7146,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7155,
+ key.offset: 7160,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7160,
+ key.offset: 7165,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7177,
+ key.offset: 7182,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7179,
+ key.offset: 7184,
key.length: 1
},
{
key.kind: source.lang.swift.ref.class,
key.name: "FooCFType",
key.usr: "c:Foo.h@T@FooCFTypeRef",
- key.offset: 7182,
+ key.offset: 7187,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7194,
+ key.offset: 7199,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7199,
+ key.offset: 7204,
key.length: 21
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 7223,
+ key.offset: 7228,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7234,
+ key.offset: 7239,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7239,
+ key.offset: 7244,
key.length: 13
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7258,
+ key.offset: 7263,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7263,
+ key.offset: 7268,
key.length: 10
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7279,
+ key.offset: 7284,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7286,
+ key.offset: 7291,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7294,
+ key.offset: 7300,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7296,
+ key.offset: 7302,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7296,
+ key.offset: 7302,
key.length: 3
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "ABAuthorizationStatus",
key.usr: "c:@E@ABAuthorizationStatus",
- key.offset: 7301,
+ key.offset: 7307,
key.length: 21
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7324,
+ key.offset: 7330,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7326,
+ key.offset: 7332,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7326,
+ key.offset: 7332,
key.length: 3
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "ABAuthorizationStatus",
key.usr: "c:@E@ABAuthorizationStatus",
- key.offset: 7331,
+ key.offset: 7337,
key.length: 21
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 7357,
+ key.offset: 7363,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7364,
+ key.offset: 7370,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7369,
+ key.offset: 7375,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7381,
+ key.offset: 7387,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7383,
+ key.offset: 7389,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7383,
+ key.offset: 7389,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 7386,
+ key.offset: 7392,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int32",
key.usr: "s:s5Int32V",
- key.offset: 7396,
+ key.offset: 7402,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7402,
+ key.offset: 7408,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7409,
+ key.offset: 7415,
key.length: 11
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Equatable",
key.usr: "s:s9EquatableP",
- key.offset: 7423,
+ key.offset: 7429,
key.length: 9
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "RawRepresentable",
key.usr: "s:s16RawRepresentableP",
- key.offset: 7434,
+ key.offset: 7440,
key.length: 16
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7458,
+ key.offset: 7464,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7463,
+ key.offset: 7469,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7465,
+ key.offset: 7471,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7465,
+ key.offset: 7471,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 7475,
+ key.offset: 7481,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7488,
+ key.offset: 7494,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7493,
+ key.offset: 7499,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7502,
+ key.offset: 7508,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7493,
+ key.offset: 7499,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7502,
+ key.offset: 7508,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 7512,
+ key.offset: 7518,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7525,
+ key.offset: 7531,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7529,
+ key.offset: 7535,
key.length: 8
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "UInt32",
key.usr: "s:s6UInt32V",
- key.offset: 7539,
+ key.offset: 7545,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7551,
+ key.offset: 7557,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7558,
+ key.offset: 7564,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7566,
+ key.offset: 7573,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7568,
+ key.offset: 7575,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7568,
+ key.offset: 7575,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooSubEnum1",
key.usr: "c:@E@FooSubEnum1",
- key.offset: 7573,
+ key.offset: 7580,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 7586,
+ key.offset: 7593,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 7588,
+ key.offset: 7595,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7588,
+ key.offset: 7595,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooSubEnum1",
key.usr: "c:@E@FooSubEnum1",
- key.offset: 7593,
+ key.offset: 7600,
key.length: 11
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 7609,
+ key.offset: 7616,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7616,
+ key.offset: 7623,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7620,
+ key.offset: 7627,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooSubEnum1",
key.usr: "c:@E@FooSubEnum1",
- key.offset: 7634,
+ key.offset: 7641,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7648,
+ key.offset: 7655,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7654,
+ key.offset: 7661,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7658,
+ key.offset: 7665,
key.length: 12
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "FooSubEnum1",
key.usr: "c:@E@FooSubEnum1",
- key.offset: 7672,
+ key.offset: 7679,
key.length: 11
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7686,
+ key.offset: 7693,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7692,
+ key.offset: 7699,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 7696,
+ key.offset: 7703,
key.length: 25
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 7723,
+ key.offset: 7730,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 7729,
+ key.offset: 7736,
key.length: 3
}
]
@@ -4983,7 +4983,7 @@
key.usr: "c:@E@FooEnum1",
key.doc.full_as_xml: "<Enum file=Foo.h line=\"16\" column=\"6\"><Name>FooEnum1</Name><USR>c:@E@FooEnum1</USR><Declaration>struct FooEnum1 : Equatable, RawRepresentable</Declaration><Abstract><Para> Aaa. FooEnum1. Bbb.</Para></Abstract></Enum>",
key.offset: 36,
- key.length: 204,
+ key.length: 205,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooEnum1</decl.name> : <ref.protocol usr=\"s:s9EquatableP\">Equatable</ref.protocol>, <ref.protocol usr=\"s:s16RawRepresentableP\">RawRepresentable</ref.protocol></decl.struct>",
key.entities: [
{
@@ -5047,23 +5047,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@FooEnum1",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
key.offset: 182,
- key.length: 56,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum1\">FooEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum1\">FooEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.length: 57,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum1\">FooEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum1\">FooEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 204,
+ key.offset: 205,
key.length: 8
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 221,
+ key.offset: 222,
key.length: 8
}
]
@@ -5075,7 +5075,7 @@
key.name: "FooEnum1X",
key.usr: "c:@E@FooEnum1@FooEnum1X",
key.doc.full_as_xml: "<Variable file=Foo.h line=\"18\" column=\"3\"><Name>FooEnum1X</Name><USR>c:@E@FooEnum1@FooEnum1X</USR><Declaration>var FooEnum1X: FooEnum1 { get }</Declaration><Abstract><Para> Aaa. FooEnum1X. Bbb.</Para></Abstract></Variable>",
- key.offset: 241,
+ key.offset: 242,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooEnum1X</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooEnum1\">FooEnum1</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -5083,15 +5083,15 @@
key.kind: source.lang.swift.decl.struct,
key.name: "FooEnum2",
key.usr: "c:@E@FooEnum2",
- key.offset: 273,
- key.length: 204,
+ key.offset: 274,
+ key.length: 205,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooEnum2</decl.name> : <ref.protocol usr=\"s:s9EquatableP\">Equatable</ref.protocol>, <ref.protocol usr=\"s:s16RawRepresentableP\">RawRepresentable</ref.protocol></decl.struct>",
key.entities: [
{
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(_:)",
key.usr: "s:SC8FooEnum2VABs6UInt32Vcfc",
- key.offset: 326,
+ key.offset: 327,
key.length: 24,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>rawValue</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -5099,7 +5099,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rawValue",
- key.offset: 343,
+ key.offset: 344,
key.length: 6
}
]
@@ -5108,7 +5108,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(rawValue:)",
key.usr: "s:SC8FooEnum2VABs6UInt32V8rawValue_tcfc",
- key.offset: 356,
+ key.offset: 357,
key.length: 31,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>rawValue</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.conforms: [
@@ -5123,7 +5123,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "rawValue",
key.name: "rawValue",
- key.offset: 380,
+ key.offset: 381,
key.length: 6
}
]
@@ -5132,7 +5132,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "rawValue",
key.usr: "s:SC8FooEnum2V8rawValues6UInt32Vvp",
- key.offset: 393,
+ key.offset: 394,
key.length: 20,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>rawValue</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.type></decl.var.instance>",
key.conforms: [
@@ -5148,23 +5148,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@FooEnum2",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 419,
- key.length: 56,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum2\">FooEnum2</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum2\">FooEnum2</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 420,
+ key.length: 57,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum2\">FooEnum2</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum2\">FooEnum2</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 441,
+ key.offset: 443,
key.length: 8
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 458,
+ key.offset: 460,
key.length: 8
}
]
@@ -5175,7 +5175,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooEnum2X",
key.usr: "c:@E@FooEnum2@FooEnum2X",
- key.offset: 478,
+ key.offset: 480,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooEnum2X</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooEnum2\">FooEnum2</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -5183,7 +5183,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooEnum2Y",
key.usr: "c:@E@FooEnum2@FooEnum2Y",
- key.offset: 510,
+ key.offset: 512,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooEnum2Y</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooEnum2\">FooEnum2</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -5191,15 +5191,15 @@
key.kind: source.lang.swift.decl.struct,
key.name: "FooEnum3",
key.usr: "c:@E@FooEnum3",
- key.offset: 542,
- key.length: 204,
+ key.offset: 544,
+ key.length: 205,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooEnum3</decl.name> : <ref.protocol usr=\"s:s9EquatableP\">Equatable</ref.protocol>, <ref.protocol usr=\"s:s16RawRepresentableP\">RawRepresentable</ref.protocol></decl.struct>",
key.entities: [
{
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(_:)",
key.usr: "s:SC8FooEnum3VABs6UInt32Vcfc",
- key.offset: 595,
+ key.offset: 597,
key.length: 24,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>rawValue</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -5207,7 +5207,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rawValue",
- key.offset: 612,
+ key.offset: 614,
key.length: 6
}
]
@@ -5216,7 +5216,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(rawValue:)",
key.usr: "s:SC8FooEnum3VABs6UInt32V8rawValue_tcfc",
- key.offset: 625,
+ key.offset: 627,
key.length: 31,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>rawValue</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.conforms: [
@@ -5231,7 +5231,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "rawValue",
key.name: "rawValue",
- key.offset: 649,
+ key.offset: 651,
key.length: 6
}
]
@@ -5240,7 +5240,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "rawValue",
key.usr: "s:SC8FooEnum3V8rawValues6UInt32Vvp",
- key.offset: 662,
+ key.offset: 664,
key.length: 20,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>rawValue</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.type></decl.var.instance>",
key.conforms: [
@@ -5256,23 +5256,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@FooEnum3",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 688,
- key.length: 56,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum3\">FooEnum3</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum3\">FooEnum3</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 690,
+ key.length: 57,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum3\">FooEnum3</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooEnum3\">FooEnum3</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 710,
+ key.offset: 713,
key.length: 8
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 727,
+ key.offset: 730,
key.length: 8
}
]
@@ -5283,7 +5283,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooEnum3X",
key.usr: "c:@E@FooEnum3@FooEnum3X",
- key.offset: 747,
+ key.offset: 750,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooEnum3X</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooEnum3\">FooEnum3</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -5291,7 +5291,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooEnum3Y",
key.usr: "c:@E@FooEnum3@FooEnum3Y",
- key.offset: 779,
+ key.offset: 782,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooEnum3Y</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooEnum3\">FooEnum3</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -5300,8 +5300,8 @@
key.name: "FooComparisonResult",
key.usr: "c:@E@FooComparisonResult",
key.doc.full_as_xml: "<Enum line=\"1\" column=\"1\"><Name>FooComparisonResult</Name><USR>c:@E@FooComparisonResult</USR><Declaration>enum FooComparisonResult : Int</Declaration><Abstract><Para> Aaa. FooComparisonResult. Bbb.</Para></Abstract></Enum>",
- key.offset: 811,
- key.length: 195,
+ key.offset: 814,
+ key.length: 196,
key.fully_annotated_decl: "<decl.enum><syntaxtype.keyword>enum</syntaxtype.keyword> <decl.name>FooComparisonResult</decl.name> : <ref.struct usr=\"s:Si\">Int</ref.struct></decl.enum>",
key.inherits: [
{
@@ -5315,7 +5315,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "orderedAscending",
key.usr: "c:@E@FooComparisonResult@FooOrderedAscending",
- key.offset: 849,
+ key.offset: 852,
key.length: 21,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>orderedAscending</decl.name> = <syntaxtype.number>-1</syntaxtype.number></decl.enumelement>"
},
@@ -5323,7 +5323,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "orderedSame",
key.usr: "c:@E@FooComparisonResult@FooOrderedSame",
- key.offset: 876,
+ key.offset: 879,
key.length: 16,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>orderedSame</decl.name> = <syntaxtype.number>0</syntaxtype.number></decl.enumelement>"
},
@@ -5331,7 +5331,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "orderedDescending",
key.usr: "c:@E@FooComparisonResult@FooOrderedDescending",
- key.offset: 898,
+ key.offset: 901,
key.length: 22,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>orderedDescending</decl.name> = <syntaxtype.number>1</syntaxtype.number></decl.enumelement>"
},
@@ -5340,23 +5340,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@FooComparisonResult",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 926,
- key.length: 78,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@FooComparisonResult\">FooComparisonResult</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@FooComparisonResult\">FooComparisonResult</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 929,
+ key.length: 79,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@FooComparisonResult\">FooComparisonResult</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@FooComparisonResult\">FooComparisonResult</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 948,
+ key.offset: 952,
key.length: 19
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 976,
+ key.offset: 980,
key.length: 19
}
]
@@ -5368,15 +5368,15 @@
key.name: "FooRuncingOptions",
key.usr: "c:@E@FooRuncingOptions",
key.doc.full_as_xml: "<Enum line=\"1\" column=\"1\"><Name>FooRuncingOptions</Name><USR>c:@E@FooRuncingOptions</USR><Declaration>struct FooRuncingOptions : OptionSet</Declaration><Abstract><Para> Aaa. FooRuncingOptions. Bbb.</Para></Abstract></Enum>",
- key.offset: 1007,
- key.length: 336,
+ key.offset: 1011,
+ key.length: 337,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooRuncingOptions</decl.name> : <ref.protocol usr=\"s:s9OptionSetP\">OptionSet</ref.protocol></decl.struct>",
key.entities: [
{
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(rawValue:)",
key.usr: "s:SC17FooRuncingOptionsVABSi8rawValue_tcfc",
- key.offset: 1051,
+ key.offset: 1055,
key.length: 28,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>rawValue</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.conforms: [
@@ -5396,7 +5396,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "rawValue",
key.name: "rawValue",
- key.offset: 1075,
+ key.offset: 1079,
key.length: 3
}
]
@@ -5405,7 +5405,7 @@
key.kind: source.lang.swift.decl.var.static,
key.name: "enableMince",
key.usr: "c:@E@FooRuncingOptions@FooRuncingEnableMince",
- key.offset: 1085,
+ key.offset: 1089,
key.length: 49,
key.fully_annotated_decl: "<decl.var.static><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>enableMince</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.static>"
},
@@ -5413,7 +5413,7 @@
key.kind: source.lang.swift.decl.var.static,
key.name: "enableQuince",
key.usr: "c:@E@FooRuncingOptions@FooRuncingEnableQuince",
- key.offset: 1140,
+ key.offset: 1144,
key.length: 50,
key.fully_annotated_decl: "<decl.var.static><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>enableQuince</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.static>"
},
@@ -5422,23 +5422,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 1196,
- key.length: 74,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 1200,
+ key.length: 75,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 1218,
+ key.offset: 1223,
key.length: 17
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 1244,
+ key.offset: 1249,
key.length: 17
}
]
@@ -5449,7 +5449,7 @@
key.usr: "s:s10SetAlgebraPssAARz7ElementQz012ArrayLiteralC0RtzlExSayAFG05arrayE0d_tcfc::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPssAARz7ElementQz012ArrayLiteralC0RtzlExSayAFG05arrayE0d_tcfc",
key.doc.full_as_xml: "<Function><Name>init(arrayLiteral:)</Name><USR>s:s10SetAlgebraPssAARz7ElementQz012ArrayLiteralC0RtzlExSayAFG05arrayE0d_tcfc</USR><Declaration>convenience init(arrayLiteral: Self.Element...)</Declaration><CommentParts><Abstract><Para>Creates a set containing the elements of the given array literal.</Para></Abstract><Parameters><Parameter><Name>arrayLiteral</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A list of elements of the new set.</Para></Discussion></Parameter></Parameters><Discussion><Para>Do not call this initializer directly. It is used by the compiler when you use an array literal. Instead, create a new set using an array literal as its value by enclosing a comma-separated list of values in square brackets. You can use an array literal anywhere a set is expected by the type context.</Para><Para>Here, a set of strings is created from an array literal holding only strings:</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let ingredients: Set = [\"cocoa beans\", \"sugar\", \"cocoa butter\", \"salt\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[if ingredients.isSuperset(of: [\"sugar\", \"salt\"]) {]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[ print(\"Whatever it is, it's bound to be delicious!\")]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[}]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"Whatever it is, it's bound to be delicious!\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1276,
+ key.offset: 1281,
key.length: 65,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>convenience</syntaxtype.keyword> <syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>arrayLiteral</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type>...</decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -5457,7 +5457,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "arrayLiteral",
key.name: "arrayLiteral",
- key.offset: 1320,
+ key.offset: 1325,
key.length: 17
}
]
@@ -5467,7 +5467,7 @@
{
key.kind: source.lang.swift.decl.extension.struct,
key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions</Declaration><CommentParts><Abstract><Para><codeVoice>SetAlgebra</codeVoice> requirements for which default implementations are supplied.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>SetAlgebra</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></CommentParts></Other>",
- key.offset: 1345,
+ key.offset: 1350,
key.length: 588,
key.extends: {
key.kind: source.lang.swift.ref.struct,
@@ -5494,7 +5494,7 @@
}
],
key.doc.full_as_xml: "<Function><Name>init(_:)</Name><USR>s:s10SetAlgebraPsExqd__cs8SequenceRd__7ElementQyd__ADRtzlufc</USR><Declaration>convenience init<S>(_ sequence: S) where S : Sequence, Self.Element == S.Element</Declaration><CommentParts><Abstract><Para>Creates a new set from a finite sequence of items.</Para></Abstract><Parameters><Parameter><Name>sequence</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>The elements to use as members of the new set.</Para></Discussion></Parameter></Parameters><Discussion><Para>Use this initializer to create a new set from an existing sequence, like an array or a range:</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let validIndices = Set(0..<7).subtracting([2, 4, 5])]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(validIndices)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"[6, 0, 1, 3]\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1380,
+ key.offset: 1385,
key.length: 93,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>convenience</syntaxtype.keyword> <syntaxtype.keyword>init</syntaxtype.keyword><S>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>sequence</decl.var.parameter.name>: <decl.var.parameter.type>S</decl.var.parameter.type></decl.var.parameter>) <syntaxtype.keyword>where</syntaxtype.keyword> <decl.generic_type_requirement>S : <ref.protocol usr=\"s:s8SequenceP\">Sequence</ref.protocol></decl.generic_type_requirement>, <decl.generic_type_requirement><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct>.<ref.typealias usr=\"s:SC17FooRuncingOptionsV7Elementa\">Element</ref.typealias> == S.Element</decl.generic_type_requirement></decl.function.constructor>",
key.entities: [
@@ -5502,7 +5502,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "sequence",
- key.offset: 1412,
+ key.offset: 1417,
key.length: 1
}
]
@@ -5513,7 +5513,7 @@
key.usr: "s:s10SetAlgebraPsE8subtractyxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE8subtractyxF",
key.doc.full_as_xml: "<Function><Name>subtract(_:)</Name><USR>s:s10SetAlgebraPsE8subtractyxF</USR><Declaration>mutating func subtract(_ other: Self)</Declaration><CommentParts><Abstract><Para>Removes the elements of the given set from this set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><Discussion><Para>In the following example, the elements of the <codeVoice>employees</codeVoice> set that are also members of the <codeVoice>neighbors</codeVoice> set are removed. In particular, the names <codeVoice>"Bethany"</codeVoice> and <codeVoice>"Eric"</codeVoice> are removed from <codeVoice>employees</codeVoice>.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[var employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let neighbors: Set = [\"Bethany\", \"Eric\", \"Forlani\", \"Greta\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[employees.subtract(neighbors)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(employees)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"[\"Diana\", \"Chris\", \"Alicia\"]\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1479,
+ key.offset: 1484,
key.length: 50,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>subtract</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -5521,7 +5521,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 1511,
+ key.offset: 1516,
key.length: 17
}
]
@@ -5532,7 +5532,7 @@
key.usr: "s:s10SetAlgebraPsE8isSubsetSbx2of_tF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE8isSubsetSbx2of_tF",
key.doc.full_as_xml: "<Function><Name>isSubset(of:)</Name><USR>s:s10SetAlgebraPsE8isSubsetSbx2of_tF</USR><Declaration>func isSubset(of other: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value that indicates whether the set is a subset of another set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>true</codeVoice> if the set is a subset of <codeVoice>other</codeVoice>; otherwise, <codeVoice>false</codeVoice>.</Para></ResultDiscussion><Discussion><Para>Set <emphasis>A</emphasis> is a subset of another set <emphasis>B</emphasis> if every member of <emphasis>A</emphasis> is also a member of <emphasis>B</emphasis>.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let attendees: Set = [\"Alicia\", \"Bethany\", \"Diana\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(attendees.isSubset(of: employees))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1535,
+ key.offset: 1540,
key.length: 50,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isSubset</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>of</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5540,7 +5540,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "of",
key.name: "other",
- key.offset: 1559,
+ key.offset: 1564,
key.length: 17
}
]
@@ -5551,7 +5551,7 @@
key.usr: "s:s10SetAlgebraPsE10isSupersetSbx2of_tF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE10isSupersetSbx2of_tF",
key.doc.full_as_xml: "<Function><Name>isSuperset(of:)</Name><USR>s:s10SetAlgebraPsE10isSupersetSbx2of_tF</USR><Declaration>func isSuperset(of other: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value that indicates whether the set is a superset of the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>true</codeVoice> if the set is a superset of <codeVoice>other</codeVoice>; otherwise, <codeVoice>false</codeVoice>.</Para></ResultDiscussion><Discussion><Para>Set <emphasis>A</emphasis> is a superset of another set <emphasis>B</emphasis> if every member of <emphasis>B</emphasis> is also a member of <emphasis>A</emphasis>.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let attendees: Set = [\"Alicia\", \"Bethany\", \"Diana\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(employees.isSuperset(of: attendees))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1591,
+ key.offset: 1596,
key.length: 52,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isSuperset</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>of</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5559,7 +5559,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "of",
key.name: "other",
- key.offset: 1617,
+ key.offset: 1622,
key.length: 17
}
]
@@ -5570,7 +5570,7 @@
key.usr: "s:s10SetAlgebraPsE10isDisjointSbx4with_tF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE10isDisjointSbx4with_tF",
key.doc.full_as_xml: "<Function><Name>isDisjoint(with:)</Name><USR>s:s10SetAlgebraPsE10isDisjointSbx4with_tF</USR><Declaration>func isDisjoint(with other: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value that indicates whether the set has no members in common with the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>true</codeVoice> if the set has no elements in common with <codeVoice>other</codeVoice>; otherwise, <codeVoice>false</codeVoice>.</Para></ResultDiscussion><Discussion><Para>In the following example, the <codeVoice>employees</codeVoice> set is disjoint with the <codeVoice>visitors</codeVoice> set because no name appears in both sets.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let visitors: Set = [\"Marcia\", \"Nathaniel\", \"Olivia\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(employees.isDisjoint(with: visitors))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1649,
+ key.offset: 1654,
key.length: 54,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isDisjoint</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>with</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5578,7 +5578,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "with",
key.name: "other",
- key.offset: 1677,
+ key.offset: 1682,
key.length: 17
}
]
@@ -5589,7 +5589,7 @@
key.usr: "s:s10SetAlgebraPsE11subtractingxxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE11subtractingxxF",
key.doc.full_as_xml: "<Function><Name>subtracting(_:)</Name><USR>s:s10SetAlgebraPsE11subtractingxxF</USR><Declaration>func subtracting(_ other: Self) -> Self</Declaration><CommentParts><Abstract><Para>Returns a new set containing the elements of this set that do not occur in the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para>A new set.</Para></ResultDiscussion><Discussion><Para>In the following example, the <codeVoice>nonNeighbors</codeVoice> set is made up of the elements of the <codeVoice>employees</codeVoice> set that are not elements of <codeVoice>neighbors</codeVoice>:</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let neighbors: Set = [\"Bethany\", \"Eric\", \"Forlani\", \"Greta\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let nonNeighbors = employees.subtract(neighbors)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(nonNeighbors)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"[\"Diana\", \"Chris\", \"Alicia\"]\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1709,
+ key.offset: 1714,
key.length: 65,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>subtracting</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5597,7 +5597,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 1735,
+ key.offset: 1740,
key.length: 17
}
]
@@ -5608,7 +5608,7 @@
key.usr: "s:s10SetAlgebraPsE7isEmptySbvp::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE7isEmptySbvp",
key.doc.full_as_xml: "<Other><Name>isEmpty</Name><USR>s:s10SetAlgebraPsE7isEmptySbvp</USR><Declaration>var isEmpty: Bool { get }</Declaration><CommentParts><Abstract><Para>A Boolean value that indicates whether the set has no elements.</Para></Abstract></CommentParts></Other>",
- key.offset: 1780,
+ key.offset: 1785,
key.length: 25,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>isEmpty</decl.name>: <decl.var.type><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -5618,7 +5618,7 @@
key.usr: "s:s10SetAlgebraPsE16isStrictSupersetSbx2of_tF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE16isStrictSupersetSbx2of_tF",
key.doc.full_as_xml: "<Function><Name>isStrictSuperset(of:)</Name><USR>s:s10SetAlgebraPsE16isStrictSupersetSbx2of_tF</USR><Declaration>func isStrictSuperset(of other: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value that indicates whether this set is a strict superset of the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>true</codeVoice> if the set is a strict superset of <codeVoice>other</codeVoice>; otherwise, <codeVoice>false</codeVoice>.</Para></ResultDiscussion><Discussion><Para>Set <emphasis>A</emphasis> is a strict superset of another set <emphasis>B</emphasis> if every member of <emphasis>B</emphasis> is also a member of <emphasis>A</emphasis> and <emphasis>A</emphasis> contains at least one element that is <emphasis>not</emphasis> a member of <emphasis>B</emphasis>.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let attendees: Set = [\"Alicia\", \"Bethany\", \"Diana\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(employees.isStrictSuperset(of: attendees))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// A set is never a strict superset of itself:]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(employees.isStrictSuperset(of: employees))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"false\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1811,
+ key.offset: 1816,
key.length: 58,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isStrictSuperset</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>of</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5626,7 +5626,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "of",
key.name: "other",
- key.offset: 1843,
+ key.offset: 1848,
key.length: 17
}
]
@@ -5637,7 +5637,7 @@
key.usr: "s:s10SetAlgebraPsE14isStrictSubsetSbx2of_tF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s10SetAlgebraPsE14isStrictSubsetSbx2of_tF",
key.doc.full_as_xml: "<Function><Name>isStrictSubset(of:)</Name><USR>s:s10SetAlgebraPsE14isStrictSubsetSbx2of_tF</USR><Declaration>func isStrictSubset(of other: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value that indicates whether this set is a strict subset of the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A set of the same type as the current set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>true</codeVoice> if the set is a strict subset of <codeVoice>other</codeVoice>; otherwise, <codeVoice>false</codeVoice>.</Para></ResultDiscussion><Discussion><Para>Set <emphasis>A</emphasis> is a strict subset of another set <emphasis>B</emphasis> if every member of <emphasis>A</emphasis> is also a member of <emphasis>B</emphasis> and <emphasis>B</emphasis> contains at least one element that is not a member of <emphasis>A</emphasis>.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let employees: Set = [\"Alicia\", \"Bethany\", \"Chris\", \"Diana\", \"Eric\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let attendees: Set = [\"Alicia\", \"Bethany\", \"Diana\"]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(attendees.isStrictSubset(of: employees))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// A set is never a strict subset of itself:]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(attendees.isStrictSubset(of: attendees))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"false\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1875,
+ key.offset: 1880,
key.length: 56,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>isStrictSubset</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>of</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5645,7 +5645,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "of",
key.name: "other",
- key.offset: 1905,
+ key.offset: 1910,
key.length: 17
}
]
@@ -5655,7 +5655,7 @@
{
key.kind: source.lang.swift.decl.extension.struct,
key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions</Declaration><CommentParts><Abstract><Para><codeVoice>OptionSet</codeVoice> requirements for which default implementations are supplied.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>OptionSet</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></CommentParts></Other>",
- key.offset: 1935,
+ key.offset: 1940,
key.length: 247,
key.extends: {
key.kind: source.lang.swift.ref.struct,
@@ -5669,7 +5669,7 @@
key.usr: "s:s9OptionSetPsE5unionxxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPsE5unionxxF",
key.doc.full_as_xml: "<Function><Name>union(_:)</Name><USR>s:s9OptionSetPsE5unionxxF</USR><Declaration>func union(_ other: Self) -> Self</Declaration><CommentParts><Abstract><Para>Returns a new option set of the elements contained in this set, in the given set, or in both.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>An option set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para>A new option set made up of the elements contained in this set, in <codeVoice>other</codeVoice>, or in both.</Para></ResultDiscussion><Discussion><Para>This example uses the <codeVoice>union(_:)</codeVoice> method to add two more shipping options to the default set.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let defaultShipping = ShippingOptions.standard]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let memberShipping = defaultShipping.union([.secondDay, .priority])]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(memberShipping.contains(.priority))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 1970,
+ key.offset: 1975,
key.length: 59,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>union</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5677,7 +5677,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 1990,
+ key.offset: 1995,
key.length: 17
}
]
@@ -5688,7 +5688,7 @@
key.usr: "s:s9OptionSetPsE12intersectionxxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPsE12intersectionxxF",
key.doc.full_as_xml: "<Function><Name>intersection(_:)</Name><USR>s:s9OptionSetPsE12intersectionxxF</USR><Declaration>func intersection(_ other: Self) -> Self</Declaration><CommentParts><Abstract><Para>Returns a new option set with only the elements contained in both this set and the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>An option set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para>A new option set with only the elements contained in both this set and <codeVoice>other</codeVoice>.</Para></ResultDiscussion><Discussion><Para>This example uses the <codeVoice>intersection(_:)</codeVoice> method to limit the available shipping options to what can be used with a PO Box destination.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[// Can only ship standard or priority to PO Boxes]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let poboxShipping: ShippingOptions = [.standard, .priority]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let memberShipping: ShippingOptions =]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[ [.standard, .priority, .secondDay]]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let availableOptions = memberShipping.intersection(poboxShipping)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(availableOptions.contains(.priority))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(availableOptions.contains(.secondDay))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"false\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 2035,
+ key.offset: 2040,
key.length: 66,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>intersection</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5696,7 +5696,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 2062,
+ key.offset: 2067,
key.length: 17
}
]
@@ -5707,7 +5707,7 @@
key.usr: "s:s9OptionSetPsE19symmetricDifferencexxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPsE19symmetricDifferencexxF",
key.doc.full_as_xml: "<Function><Name>symmetricDifference(_:)</Name><USR>s:s9OptionSetPsE19symmetricDifferencexxF</USR><Declaration>func symmetricDifference(_ other: Self) -> Self</Declaration><CommentParts><Abstract><Para>Returns a new option set with the elements contained in this set or in the given set, but not in both.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>An option set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para>A new option set with only the elements contained in either this set or <codeVoice>other</codeVoice>, but not in both.</Para></ResultDiscussion></CommentParts></Function>",
- key.offset: 2107,
+ key.offset: 2112,
key.length: 73,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>symmetricDifference</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5715,7 +5715,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 2141,
+ key.offset: 2146,
key.length: 17
}
]
@@ -5730,7 +5730,7 @@
}
],
key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions where Self == Self.Element</Declaration><CommentParts><Abstract><Para><codeVoice>OptionSet</codeVoice> requirements for which default implementations are supplied when <codeVoice>Element == Self</codeVoice>, which is the default.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>OptionSet</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note></Discussion></CommentParts></Other>",
- key.offset: 2184,
+ key.offset: 2189,
key.length: 363,
key.extends: {
key.kind: source.lang.swift.ref.struct,
@@ -5744,7 +5744,7 @@
key.usr: "s:s9OptionSetPssAARz7ElementQzRszlE8containsSbxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARz7ElementQzRszlE8containsSbxF",
key.doc.full_as_xml: "<Function><Name>contains(_:)</Name><USR>s:s9OptionSetPssAARz7ElementQzRszlE8containsSbxF</USR><Declaration>func contains(_ member: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value that indicates whether a given element is a member of the option set.</Para></Abstract><Parameters><Parameter><Name>member</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>The element to look for in the option set.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>true</codeVoice> if the option set contains <codeVoice>member</codeVoice>; otherwise, <codeVoice>false</codeVoice>.</Para></ResultDiscussion><Discussion><Para>This example uses the <codeVoice>contains(_:)</codeVoice> method to check whether next-day shipping is in the <codeVoice>availableOptions</codeVoice> instance.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let availableOptions = ShippingOptions.express]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[if availableOptions.contains(.nextDay) {]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[ print(\"Next day shipping available\")]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[}]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"Next day shipping available\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 2219,
+ key.offset: 2224,
key.length: 50,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>contains</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>member</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5752,7 +5752,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "member",
- key.offset: 2243,
+ key.offset: 2248,
key.length: 17
}
]
@@ -5763,7 +5763,7 @@
key.usr: "s:s9OptionSetPssAARz7ElementQzRszlE6insertSb8inserted_x17memberAfterInserttxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARz7ElementQzRszlE6insertSb8inserted_x17memberAfterInserttxF",
key.doc.full_as_xml: "<Function><Name>insert(_:)</Name><USR>s:s9OptionSetPssAARz7ElementQzRszlE6insertSb8inserted_x17memberAfterInserttxF</USR><Declaration>mutating func insert(_ newMember: Self.Element) -> (inserted: Bool, memberAfterInsert: Self.Element)</Declaration><CommentParts><Abstract><Para>Adds the given element to the option set if it is not already a member.</Para></Abstract><Parameters><Parameter><Name>newMember</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>The element to insert.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para><codeVoice>(true, newMember)</codeVoice> if <codeVoice>newMember</codeVoice> was not contained in <codeVoice>self</codeVoice>. Otherwise, returns <codeVoice>(false, oldMember)</codeVoice>, where <codeVoice>oldMember</codeVoice> is the member of the set equal to <codeVoice>newMember</codeVoice>.</Para></ResultDiscussion><Discussion><Para>In the following example, the <codeVoice>.secondDay</codeVoice> shipping option is added to the <codeVoice>freeOptions</codeVoice> option set if <codeVoice>purchasePrice</codeVoice> is greater than 50.0. For the <codeVoice>ShippingOptions</codeVoice> declaration, see the <codeVoice>OptionSet</codeVoice> protocol discussion.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let purchasePrice = 87.55]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered><zCodeLineNumbered><![CDATA[var freeOptions: ShippingOptions = [.standard, .priority]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[if purchasePrice > 50 {]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[ freeOptions.insert(.secondDay)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[}]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(freeOptions.contains(.secondDay))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 2275,
+ key.offset: 2280,
key.length: 110,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@discardableResult</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>insert</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>newMember</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><tuple>(<tuple.element><tuple.element.argument_label>inserted</tuple.element.argument_label>: <tuple.element.type><ref.struct usr=\"s:Sb\">Bool</ref.struct></tuple.element.type></tuple.element>, <tuple.element><tuple.element.argument_label>memberAfterInsert</tuple.element.argument_label>: <tuple.element.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></tuple.element.type></tuple.element>)</tuple></decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5771,7 +5771,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "newMember",
- key.offset: 2309,
+ key.offset: 2314,
key.length: 17
}
]
@@ -5782,7 +5782,7 @@
key.usr: "s:s9OptionSetPssAARz7ElementQzRszlE6removexSgxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARz7ElementQzRszlE6removexSgxF",
key.doc.full_as_xml: "<Function><Name>remove(_:)</Name><USR>s:s9OptionSetPssAARz7ElementQzRszlE6removexSgxF</USR><Declaration>mutating func remove(_ member: Self.Element) -> Self.Element?</Declaration><CommentParts><Abstract><Para>Removes the given element and all elements subsumed by it.</Para></Abstract><Parameters><Parameter><Name>member</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>The element of the set to remove.</Para></Discussion></Parameter></Parameters><ResultDiscussion><Para>The intersection of <codeVoice>[member]</codeVoice> and the set, if the intersection was nonempty; otherwise, <codeVoice>nil</codeVoice>.</Para></ResultDiscussion><Discussion><Para>In the following example, the <codeVoice>.priority</codeVoice> shipping option is removed from the <codeVoice>options</codeVoice> option set. Attempting to remove the same shipping option a second time results in <codeVoice>nil</codeVoice>, because <codeVoice>options</codeVoice> no longer contains <codeVoice>.priority</codeVoice> as a member.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[var options: ShippingOptions = [.secondDay, .priority]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let priorityOption = options.remove(.priority)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(priorityOption == .priority)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(options.remove(.priority))]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"nil\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing><Para>In the next example, the <codeVoice>.express</codeVoice> element is passed to <codeVoice>remove(_:)</codeVoice>. Although <codeVoice>.express</codeVoice> is not a member of <codeVoice>options</codeVoice>, <codeVoice>.express</codeVoice> subsumes the remaining <codeVoice>.secondDay</codeVoice> element of the option set. Therefore, <codeVoice>options</codeVoice> is emptied and the intersection between <codeVoice>.express</codeVoice> and <codeVoice>options</codeVoice> is returned.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[let expressOption = options.remove(.express)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(expressOption == .express)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"false\"]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(expressOption == .secondDay)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 2391,
+ key.offset: 2396,
key.length: 71,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@discardableResult</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>remove</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>member</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct>?</decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5790,7 +5790,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "member",
- key.offset: 2422,
+ key.offset: 2427,
key.length: 17
}
]
@@ -5801,7 +5801,7 @@
key.usr: "s:s9OptionSetPssAARz7ElementQzRszlE6updatexSgx4with_tF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARz7ElementQzRszlE6updatexSgx4with_tF",
key.doc.full_as_xml: "<Function><Name>update(with:)</Name><USR>s:s9OptionSetPssAARz7ElementQzRszlE6updatexSgx4with_tF</USR><Declaration>mutating func update(with newMember: Self.Element) -> Self.Element?</Declaration><CommentParts><Abstract><Para>Inserts the given element into the set.</Para></Abstract><ResultDiscussion><Para>The intersection of <codeVoice>[newMember]</codeVoice> and the set if the intersection was nonempty; otherwise, <codeVoice>nil</codeVoice>.</Para></ResultDiscussion><Discussion><Para>If <codeVoice>newMember</codeVoice> is not contained in the set but subsumes current members of the set, the subsumed members are returned.</Para><CodeListing language=\"swift\"><zCodeLineNumbered><![CDATA[var options: ShippingOptions = [.secondDay, .priority]]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[let replaced = options.update(with: .express)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[print(replaced == .secondDay)]]></zCodeLineNumbered><zCodeLineNumbered><![CDATA[// Prints \"true\"]]></zCodeLineNumbered><zCodeLineNumbered></zCodeLineNumbered></CodeListing></Discussion></CommentParts></Function>",
- key.offset: 2468,
+ key.offset: 2473,
key.length: 77,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@discardableResult</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>update</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>with</decl.var.parameter.argument_label> <decl.var.parameter.name>newMember</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct>?</decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -5809,7 +5809,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "with",
key.name: "newMember",
- key.offset: 2505,
+ key.offset: 2510,
key.length: 17
}
]
@@ -5824,7 +5824,7 @@
}
],
key.doc.full_as_xml: "<Other><Name></Name><Declaration>extension FooRuncingOptions where Self.RawValue : FixedWidthInteger</Declaration><CommentParts><Abstract><Para><codeVoice>OptionSet</codeVoice> requirements for which default implementations are supplied when <codeVoice>RawValue</codeVoice> conforms to <codeVoice>FixedWidthInteger</codeVoice>, which is the usual case. Each distinct bit of an option set’s <codeVoice>.rawValue</codeVoice> corresponds to a disjoint value of the <codeVoice>OptionSet</codeVoice>.</Para></Abstract><Discussion><Note><Para>A type conforming to <codeVoice>OptionSet</codeVoice> can implement any of these initializers or methods, and those implementations will be used in lieu of these defaults.</Para></Note><List-Bullet><Item><Para><codeVoice>union</codeVoice> is implemented as a bitwise “or” (<codeVoice>|</codeVoice>) of <codeVoice>rawValue</codeVoice>s</Para></Item><Item><Para><codeVoice>intersection</codeVoice> is implemented as a bitwise “and” (<codeVoice>&</codeVoice>) of <codeVoice>rawValue</codeVoice>s</Para></Item><Item><Para><codeVoice>symmetricDifference</codeVoice> is implemented as a bitwise “exclusive or” (<codeVoice>^</codeVoice>) of <codeVoice>rawValue</codeVoice>s</Para></Item></List-Bullet></Discussion></CommentParts></Other>",
- key.offset: 2549,
+ key.offset: 2554,
key.length: 247,
key.extends: {
key.kind: source.lang.swift.ref.struct,
@@ -5838,7 +5838,7 @@
key.usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlExycfc::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlExycfc",
key.doc.full_as_xml: "<Function><Name>init()</Name><USR>s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlExycfc</USR><Declaration>convenience init()</Declaration><CommentParts><Abstract><Para>Creates an empty option set.</Para></Abstract><Discussion><Para>This initializer creates an option set with a raw value of zero.</Para></Discussion></CommentParts></Function>",
- key.offset: 2584,
+ key.offset: 2589,
key.length: 18,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>convenience</syntaxtype.keyword> <syntaxtype.keyword>init</syntaxtype.keyword>()</decl.function.constructor>"
},
@@ -5848,7 +5848,7 @@
key.usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE9formUnionyxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE9formUnionyxF",
key.doc.full_as_xml: "<Function><Name>formUnion(_:)</Name><USR>s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE9formUnionyxF</USR><Declaration>mutating func formUnion(_ other: Self)</Declaration><CommentParts><Abstract><Para>Inserts the elements of another set into this option set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>An option set.</Para></Discussion></Parameter></Parameters><Discussion><Para>This method is implemented as a <codeVoice>|</codeVoice> (bitwise OR) operation on the two sets’ raw values.</Para></Discussion></CommentParts></Function>",
- key.offset: 2608,
+ key.offset: 2613,
key.length: 51,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>formUnion</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -5856,7 +5856,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 2641,
+ key.offset: 2646,
key.length: 17
}
]
@@ -5867,7 +5867,7 @@
key.usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE16formIntersectionyxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE16formIntersectionyxF",
key.doc.full_as_xml: "<Function><Name>formIntersection(_:)</Name><USR>s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE16formIntersectionyxF</USR><Declaration>mutating func formIntersection(_ other: Self)</Declaration><CommentParts><Abstract><Para>Removes all elements of this option set that are not also present in the given set.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>An option set.</Para></Discussion></Parameter></Parameters><Discussion><Para>This method is implemented as a <codeVoice>&</codeVoice> (bitwise AND) operation on the two sets’ raw values.</Para></Discussion></CommentParts></Function>",
- key.offset: 2665,
+ key.offset: 2670,
key.length: 58,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>formIntersection</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -5875,7 +5875,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 2705,
+ key.offset: 2710,
key.length: 17
}
]
@@ -5886,7 +5886,7 @@
key.usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE23formSymmetricDifferenceyxF::SYNTHESIZED::c:@E@FooRuncingOptions",
key.original_usr: "s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE23formSymmetricDifferenceyxF",
key.doc.full_as_xml: "<Function><Name>formSymmetricDifference(_:)</Name><USR>s:s9OptionSetPssAARzs17FixedWidthInteger8RawValueRpzlE23formSymmetricDifferenceyxF</USR><Declaration>mutating func formSymmetricDifference(_ other: Self)</Declaration><CommentParts><Abstract><Para>Replaces this set with a new set containing all elements contained in either this set or the given set, but not in both.</Para></Abstract><Parameters><Parameter><Name>other</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>An option set.</Para></Discussion></Parameter></Parameters><Discussion><Para>This method is implemented as a <codeVoice>^</codeVoice> (bitwise XOR) operation on the two sets’ raw values.</Para></Discussion></CommentParts></Function>",
- key.offset: 2729,
+ key.offset: 2734,
key.length: 65,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>formSymmetricDifference</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>other</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooRuncingOptions\">FooRuncingOptions</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -5894,7 +5894,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "other",
- key.offset: 2776,
+ key.offset: 2781,
key.length: 17
}
]
@@ -5905,7 +5905,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "FooStruct1",
key.usr: "c:@S@FooStruct1",
- key.offset: 2797,
+ key.offset: 2802,
key.length: 105,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooStruct1</decl.name></decl.struct>",
key.entities: [
@@ -5913,7 +5913,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "x",
key.usr: "c:@S@FooStruct1@FI@x",
- key.offset: 2822,
+ key.offset: 2827,
key.length: 12,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>x</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -5921,7 +5921,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "y",
key.usr: "c:@S@FooStruct1@FI@y",
- key.offset: 2840,
+ key.offset: 2845,
key.length: 13,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>y</decl.name>: <decl.var.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -5929,7 +5929,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init()",
key.usr: "s:SC10FooStruct1VABycfc",
- key.offset: 2859,
+ key.offset: 2864,
key.length: 6,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>()</decl.function.constructor>"
},
@@ -5937,7 +5937,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(x:y:)",
key.usr: "s:SC10FooStruct1VABs5Int32V1x_Sd1ytcfc",
- key.offset: 2871,
+ key.offset: 2876,
key.length: 29,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>y</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -5945,14 +5945,14 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "x",
key.name: "x",
- key.offset: 2881,
+ key.offset: 2886,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "y",
key.name: "y",
- key.offset: 2893,
+ key.offset: 2898,
key.length: 6
}
]
@@ -5963,7 +5963,7 @@
key.kind: source.lang.swift.decl.typealias,
key.name: "FooStruct1Pointer",
key.usr: "c:Foo.h@T@FooStruct1Pointer",
- key.offset: 2903,
+ key.offset: 2908,
key.length: 62,
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>FooStruct1Pointer</decl.name> = <ref.struct usr=\"s:Sp\">UnsafeMutablePointer</ref.struct><<ref.struct usr=\"c:@S@FooStruct1\">FooStruct1</ref.struct>></decl.typealias>",
key.conforms: [
@@ -5988,7 +5988,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "FooStruct2",
key.usr: "c:@S@FooStruct2",
- key.offset: 2966,
+ key.offset: 2971,
key.length: 105,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooStruct2</decl.name></decl.struct>",
key.entities: [
@@ -5996,7 +5996,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "x",
key.usr: "c:@S@FooStruct2@FI@x",
- key.offset: 2991,
+ key.offset: 2996,
key.length: 12,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>x</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -6004,7 +6004,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "y",
key.usr: "c:@S@FooStruct2@FI@y",
- key.offset: 3009,
+ key.offset: 3014,
key.length: 13,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>y</decl.name>: <decl.var.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -6012,7 +6012,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init()",
key.usr: "s:SC10FooStruct2VABycfc",
- key.offset: 3028,
+ key.offset: 3033,
key.length: 6,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>()</decl.function.constructor>"
},
@@ -6020,7 +6020,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(x:y:)",
key.usr: "s:SC10FooStruct2VABs5Int32V1x_Sd1ytcfc",
- key.offset: 3040,
+ key.offset: 3045,
key.length: 29,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>y</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -6028,14 +6028,14 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "x",
key.name: "x",
- key.offset: 3050,
+ key.offset: 3055,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "y",
key.name: "y",
- key.offset: 3062,
+ key.offset: 3067,
key.length: 6
}
]
@@ -6046,7 +6046,7 @@
key.kind: source.lang.swift.decl.typealias,
key.name: "FooStructTypedef1",
key.usr: "c:Foo.h@T@FooStructTypedef1",
- key.offset: 3072,
+ key.offset: 3077,
key.length: 40,
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>FooStructTypedef1</decl.name> = <ref.struct usr=\"c:@S@FooStruct2\">FooStruct2</ref.struct></decl.typealias>"
},
@@ -6054,7 +6054,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "FooStructTypedef2",
key.usr: "c:@SA@FooStructTypedef2",
- key.offset: 3113,
+ key.offset: 3118,
key.length: 112,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooStructTypedef2</decl.name></decl.struct>",
key.entities: [
@@ -6062,7 +6062,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "x",
key.usr: "c:@SA@FooStructTypedef2@FI@x",
- key.offset: 3145,
+ key.offset: 3150,
key.length: 12,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>x</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -6070,7 +6070,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "y",
key.usr: "c:@SA@FooStructTypedef2@FI@y",
- key.offset: 3163,
+ key.offset: 3168,
key.length: 13,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>y</decl.name>: <decl.var.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -6078,7 +6078,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init()",
key.usr: "s:SC17FooStructTypedef2VABycfc",
- key.offset: 3182,
+ key.offset: 3187,
key.length: 6,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>()</decl.function.constructor>"
},
@@ -6086,7 +6086,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(x:y:)",
key.usr: "s:SC17FooStructTypedef2VABs5Int32V1x_Sd1ytcfc",
- key.offset: 3194,
+ key.offset: 3199,
key.length: 29,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>y</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -6094,14 +6094,14 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "x",
key.name: "x",
- key.offset: 3204,
+ key.offset: 3209,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "y",
key.name: "y",
- key.offset: 3216,
+ key.offset: 3221,
key.length: 6
}
]
@@ -6113,7 +6113,7 @@
key.name: "FooTypedef1",
key.usr: "c:Foo.h@T@FooTypedef1",
key.doc.full_as_xml: "<Typedef file=Foo.h line=\"60\" column=\"13\"><Name>FooTypedef1</Name><USR>c:Foo.h@T@FooTypedef1</USR><Declaration>typealias FooTypedef1 = Int32</Declaration><Abstract><Para> Aaa. FooTypedef1. Bbb.</Para></Abstract></Typedef>",
- key.offset: 3226,
+ key.offset: 3231,
key.length: 29,
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>FooTypedef1</decl.name> = <ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.typealias>",
key.conforms: [
@@ -6139,7 +6139,7 @@
key.name: "fooIntVar",
key.usr: "c:@fooIntVar",
key.doc.full_as_xml: "<Variable file=Foo.h line=\"63\" column=\"12\"><Name>fooIntVar</Name><USR>c:@fooIntVar</USR><Declaration>var fooIntVar: Int32</Declaration><Abstract><Para> Aaa. fooIntVar. Bbb.</Para></Abstract></Variable>",
- key.offset: 3256,
+ key.offset: 3261,
key.length: 20,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooIntVar</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type></decl.var.global>"
},
@@ -6148,7 +6148,7 @@
key.name: "fooFunc1(_:)",
key.usr: "c:@F@fooFunc1",
key.doc.full_as_xml: "<Function file=Foo.h line=\"66\" column=\"5\"><Name>fooFunc1</Name><USR>c:@F@fooFunc1</USR><Declaration>func fooFunc1(_ a: Int32) -> Int32</Declaration><Abstract><Para> Aaa. fooFunc1. Bbb.</Para></Abstract></Function>",
- key.offset: 3277,
+ key.offset: 3282,
key.length: 34,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype></decl.function.free>",
key.entities: [
@@ -6156,7 +6156,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "a",
- key.offset: 3296,
+ key.offset: 3301,
key.length: 5
}
]
@@ -6165,14 +6165,14 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooFunc1AnonymousParam(_:)",
key.usr: "c:@F@fooFunc1AnonymousParam",
- key.offset: 3312,
+ key.offset: 3317,
key.length: 48,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFunc1AnonymousParam</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype></decl.function.free>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
- key.offset: 3345,
+ key.offset: 3350,
key.length: 5
}
]
@@ -6181,7 +6181,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooFunc3(_:_:_:_:)",
key.usr: "c:@F@fooFunc3",
- key.offset: 3361,
+ key.offset: 3366,
key.length: 94,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFunc3</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>b</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Sf\">Float</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>c</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Sd\">Double</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>d</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Sp\">UnsafeMutablePointer</ref.struct><<ref.struct usr=\"s:s5Int32V\">Int32</ref.struct>>!</decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype></decl.function.free>",
key.entities: [
@@ -6189,28 +6189,28 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "a",
- key.offset: 3380,
+ key.offset: 3385,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "b",
- key.offset: 3392,
+ key.offset: 3397,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "c",
- key.offset: 3404,
+ key.offset: 3409,
key.length: 6
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "d",
- key.offset: 3417,
+ key.offset: 3422,
key.length: 28
}
]
@@ -6219,7 +6219,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooFuncWithBlock(_:)",
key.usr: "c:@F@fooFuncWithBlock",
- key.offset: 3456,
+ key.offset: 3461,
key.length: 49,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithBlock</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>blk</decl.var.parameter.name>: <decl.var.parameter.type>((<ref.struct usr=\"s:Sf\">Float</ref.struct>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype>)!</decl.var.parameter.type></decl.var.parameter>)</decl.function.free>",
key.entities: [
@@ -6227,7 +6227,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "blk",
- key.offset: 3485,
+ key.offset: 3490,
key.length: 19
}
]
@@ -6236,7 +6236,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooFuncWithFunctionPointer(_:)",
key.usr: "c:@F@fooFuncWithFunctionPointer",
- key.offset: 3506,
+ key.offset: 3511,
key.length: 60,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithFunctionPointer</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>fptr</decl.var.parameter.name>: <decl.var.parameter.type>((<ref.struct usr=\"s:Sf\">Float</ref.struct>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype>)!</decl.var.parameter.type></decl.var.parameter>)</decl.function.free>",
key.entities: [
@@ -6244,7 +6244,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "fptr",
- key.offset: 3546,
+ key.offset: 3551,
key.length: 19
}
]
@@ -6253,7 +6253,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooFuncNoreturn1()",
key.usr: "c:@F@fooFuncNoreturn1",
- key.offset: 3567,
+ key.offset: 3572,
key.length: 32,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncNoreturn1</decl.name>() -> <decl.function.returntype><ref.enum usr=\"s:s5NeverO\">Never</ref.enum></decl.function.returntype></decl.function.free>"
},
@@ -6261,7 +6261,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooFuncNoreturn2()",
key.usr: "c:@F@fooFuncNoreturn2",
- key.offset: 3600,
+ key.offset: 3605,
key.length: 32,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncNoreturn2</decl.name>() -> <decl.function.returntype><ref.enum usr=\"s:s5NeverO\">Never</ref.enum></decl.function.returntype></decl.function.free>"
},
@@ -6270,7 +6270,7 @@
key.name: "fooFuncWithComment1()",
key.usr: "c:@F@fooFuncWithComment1",
key.doc.full_as_xml: "<Function file=Foo.h line=\"89\" column=\"6\"><Name>fooFuncWithComment1</Name><USR>c:@F@fooFuncWithComment1</USR><Declaration>func fooFuncWithComment1()</Declaration><Abstract><Para> Aaa. fooFuncWithComment1. Bbb. Ccc.</Para></Abstract><Discussion><Para> Ddd.</Para></Discussion></Function>",
- key.offset: 3633,
+ key.offset: 3638,
key.length: 26,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithComment1</decl.name>()</decl.function.free>"
},
@@ -6279,7 +6279,7 @@
key.name: "fooFuncWithComment2()",
key.usr: "c:@F@fooFuncWithComment2",
key.doc.full_as_xml: "<Function file=Foo.h line=\"94\" column=\"6\"><Name>fooFuncWithComment2</Name><USR>c:@F@fooFuncWithComment2</USR><Declaration>func fooFuncWithComment2()</Declaration><Abstract><Para> Aaa. fooFuncWithComment2. Bbb.</Para></Abstract></Function>",
- key.offset: 3660,
+ key.offset: 3665,
key.length: 26,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithComment2</decl.name>()</decl.function.free>"
},
@@ -6288,7 +6288,7 @@
key.name: "fooFuncWithComment3()",
key.usr: "c:@F@fooFuncWithComment3",
key.doc.full_as_xml: "<Function file=Foo.h line=\"102\" column=\"6\"><Name>fooFuncWithComment3</Name><USR>c:@F@fooFuncWithComment3</USR><Declaration>func fooFuncWithComment3()</Declaration><Abstract><Para> Aaa. fooFuncWithComment3. Bbb.</Para></Abstract><Discussion><Para> Ccc.</Para></Discussion></Function>",
- key.offset: 3687,
+ key.offset: 3692,
key.length: 26,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithComment3</decl.name>()</decl.function.free>"
},
@@ -6297,7 +6297,7 @@
key.name: "fooFuncWithComment4()",
key.usr: "c:@F@fooFuncWithComment4",
key.doc.full_as_xml: "<Function file=Foo.h line=\"108\" column=\"6\"><Name>fooFuncWithComment4</Name><USR>c:@F@fooFuncWithComment4</USR><Declaration>func fooFuncWithComment4()</Declaration><Abstract><Para> Aaa. fooFuncWithComment4. Bbb.</Para></Abstract><Discussion><Para> Ddd.</Para></Discussion></Function>",
- key.offset: 3714,
+ key.offset: 3719,
key.length: 26,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithComment4</decl.name>()</decl.function.free>"
},
@@ -6306,7 +6306,7 @@
key.name: "fooFuncWithComment5()",
key.usr: "c:@F@fooFuncWithComment5",
key.doc.full_as_xml: "<Function file=Foo.h line=\"114\" column=\"6\"><Name>fooFuncWithComment5</Name><USR>c:@F@fooFuncWithComment5</USR><Declaration>func fooFuncWithComment5()</Declaration><Abstract><Para> Aaa. fooFuncWithComment5. Bbb. Ccc.</Para></Abstract><Discussion><Para> Ddd.</Para></Discussion></Function>",
- key.offset: 3741,
+ key.offset: 3746,
key.length: 26,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooFuncWithComment5</decl.name>()</decl.function.free>"
},
@@ -6315,7 +6315,7 @@
key.name: "redeclaredInMultipleModulesFunc1(_:)",
key.usr: "c:@F@redeclaredInMultipleModulesFunc1",
key.doc.full_as_xml: "<Function file=Foo.h line=\"118\" column=\"5\"><Name>redeclaredInMultipleModulesFunc1</Name><USR>c:@F@redeclaredInMultipleModulesFunc1</USR><Declaration>func redeclaredInMultipleModulesFunc1(_ a: Int32) -> Int32</Declaration><Abstract><Para> Aaa. redeclaredInMultipleModulesFunc1. Bbb.</Para></Abstract></Function>",
- key.offset: 3768,
+ key.offset: 3773,
key.length: 58,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>redeclaredInMultipleModulesFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype></decl.function.free>",
key.entities: [
@@ -6323,7 +6323,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "a",
- key.offset: 3811,
+ key.offset: 3816,
key.length: 5
}
]
@@ -6333,7 +6333,7 @@
key.name: "FooProtocolBase",
key.usr: "c:objc(pl)FooProtocolBase",
key.doc.full_as_xml: "<Other file=Foo.h line=\"121\" column=\"11\"><Name>FooProtocolBase</Name><USR>c:objc(pl)FooProtocolBase</USR><Declaration>protocol FooProtocolBase</Declaration><Abstract><Para> Aaa. FooProtocolBase. Bbb.</Para></Abstract></Other>",
- key.offset: 3827,
+ key.offset: 3832,
key.length: 301,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>FooProtocolBase</decl.name></decl.protocol>",
key.entities: [
@@ -6342,7 +6342,7 @@
key.name: "fooProtoFunc()",
key.usr: "c:objc(pl)FooProtocolBase(im)fooProtoFunc",
key.doc.full_as_xml: "<Function isInstanceMethod=\"1\" file=Foo.h line=\"125\" column=\"1\"><Name>fooProtoFunc</Name><USR>c:objc(pl)FooProtocolBase(im)fooProtoFunc</USR><Declaration>func fooProtoFunc()</Declaration><Abstract><Para> Aaa. fooProtoFunc. Bbb. Ccc.</Para></Abstract></Function>",
- key.offset: 3859,
+ key.offset: 3864,
key.length: 19,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooProtoFunc</decl.name>()</decl.function.method.instance>"
},
@@ -6351,7 +6351,7 @@
key.name: "fooProtoFuncWithExtraIndentation1()",
key.usr: "c:objc(pl)FooProtocolBase(im)fooProtoFuncWithExtraIndentation1",
key.doc.full_as_xml: "<Function isInstanceMethod=\"1\" file=Foo.h line=\"129\" column=\"3\"><Name>fooProtoFuncWithExtraIndentation1</Name><USR>c:objc(pl)FooProtocolBase(im)fooProtoFuncWithExtraIndentation1</USR><Declaration>func fooProtoFuncWithExtraIndentation1()</Declaration><Abstract><Para> Aaa. fooProtoFuncWithExtraIndentation1. Bbb. Ccc.</Para></Abstract></Function>",
- key.offset: 3884,
+ key.offset: 3889,
key.length: 40,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooProtoFuncWithExtraIndentation1</decl.name>()</decl.function.method.instance>"
},
@@ -6360,7 +6360,7 @@
key.name: "fooProtoFuncWithExtraIndentation2()",
key.usr: "c:objc(pl)FooProtocolBase(im)fooProtoFuncWithExtraIndentation2",
key.doc.full_as_xml: "<Function isInstanceMethod=\"1\" file=Foo.h line=\"135\" column=\"3\"><Name>fooProtoFuncWithExtraIndentation2</Name><USR>c:objc(pl)FooProtocolBase(im)fooProtoFuncWithExtraIndentation2</USR><Declaration>func fooProtoFuncWithExtraIndentation2()</Declaration><Abstract><Para> Aaa. fooProtoFuncWithExtraIndentation2. Bbb. Ccc.</Para></Abstract></Function>",
- key.offset: 3930,
+ key.offset: 3935,
key.length: 40,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooProtoFuncWithExtraIndentation2</decl.name>()</decl.function.method.instance>"
},
@@ -6368,7 +6368,7 @@
key.kind: source.lang.swift.decl.function.method.static,
key.name: "fooProtoClassFunc()",
key.usr: "c:objc(pl)FooProtocolBase(cm)fooProtoClassFunc",
- key.offset: 3976,
+ key.offset: 3981,
key.length: 31,
key.fully_annotated_decl: "<decl.function.method.static><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooProtoClassFunc</decl.name>()</decl.function.method.static>"
},
@@ -6376,7 +6376,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "fooProperty1",
key.usr: "c:objc(pl)FooProtocolBase(py)fooProperty1",
- key.offset: 4013,
+ key.offset: 4018,
key.length: 35,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooProperty1</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -6384,7 +6384,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "fooProperty2",
key.usr: "c:objc(pl)FooProtocolBase(py)fooProperty2",
- key.offset: 4054,
+ key.offset: 4059,
key.length: 35,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooProperty2</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -6392,7 +6392,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "fooProperty3",
key.usr: "c:objc(pl)FooProtocolBase(py)fooProperty3",
- key.offset: 4095,
+ key.offset: 4100,
key.length: 31,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooProperty3</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.instance>"
}
@@ -6402,7 +6402,7 @@
key.kind: source.lang.swift.decl.protocol,
key.name: "FooProtocolDerived",
key.usr: "c:objc(pl)FooProtocolDerived",
- key.offset: 4129,
+ key.offset: 4134,
key.length: 49,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>FooProtocolDerived</decl.name> : <ref.protocol usr=\"c:objc(pl)FooProtocolBase\">FooProtocolBase</ref.protocol></decl.protocol>",
key.conforms: [
@@ -6417,7 +6417,7 @@
key.kind: source.lang.swift.decl.class,
key.name: "FooClassBase",
key.usr: "c:objc(cs)FooClassBase",
- key.offset: 4179,
+ key.offset: 4184,
key.length: 392,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>FooClassBase</decl.name></decl.class>",
key.entities: [
@@ -6425,7 +6425,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooBaseInstanceFunc0()",
key.usr: "c:objc(cs)FooClassBase(im)fooBaseInstanceFunc0",
- key.offset: 4205,
+ key.offset: 4210,
key.length: 27,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooBaseInstanceFunc0</decl.name>()</decl.function.method.instance>"
},
@@ -6433,7 +6433,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooBaseInstanceFunc1(_:)",
key.usr: "c:objc(cs)FooClassBase(im)fooBaseInstanceFunc1:",
- key.offset: 4238,
+ key.offset: 4243,
key.length: 60,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooBaseInstanceFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>anObject</decl.var.parameter.name>: <decl.var.parameter.type>Any!</decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.class usr=\"c:objc(cs)FooClassBase\">FooClassBase</ref.class>!</decl.function.returntype></decl.function.method.instance>",
key.entities: [
@@ -6441,7 +6441,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "anObject",
- key.offset: 4276,
+ key.offset: 4281,
key.length: 4
}
]
@@ -6450,7 +6450,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init()",
key.usr: "c:objc(cs)FooClassBase(im)init",
- key.offset: 4304,
+ key.offset: 4309,
key.length: 7,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>!()</decl.function.constructor>"
},
@@ -6458,7 +6458,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(float:)",
key.usr: "c:objc(cs)FooClassBase(im)initWithFloat:",
- key.offset: 4317,
+ key.offset: 4322,
key.length: 33,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>convenience</syntaxtype.keyword> <syntaxtype.keyword>init</syntaxtype.keyword>!(<decl.var.parameter><decl.var.parameter.argument_label>float</decl.var.parameter.argument_label> <decl.var.parameter.name>f</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Sf\">Float</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -6466,7 +6466,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "float",
key.name: "f",
- key.offset: 4344,
+ key.offset: 4349,
key.length: 5
}
]
@@ -6475,7 +6475,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooBaseInstanceFuncOverridden()",
key.usr: "c:objc(cs)FooClassBase(im)fooBaseInstanceFuncOverridden",
- key.offset: 4356,
+ key.offset: 4361,
key.length: 36,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooBaseInstanceFuncOverridden</decl.name>()</decl.function.method.instance>"
},
@@ -6483,7 +6483,7 @@
key.kind: source.lang.swift.decl.function.method.class,
key.name: "fooBaseClassFunc0()",
key.usr: "c:objc(cs)FooClassBase(cm)fooBaseClassFunc0",
- key.offset: 4398,
+ key.offset: 4403,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.class><syntaxtype.keyword>class</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooBaseClassFunc0</decl.name>()</decl.function.method.class>"
},
@@ -6491,7 +6491,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "_internalMeth1()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth1",
- key.offset: 4434,
+ key.offset: 4439,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth1</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6499,7 +6499,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "_internalMeth2()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth2",
- key.offset: 4469,
+ key.offset: 4474,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth2</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6507,7 +6507,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "nonInternalMeth()",
key.usr: "c:objc(cs)FooClassBase(im)nonInternalMeth",
- key.offset: 4504,
+ key.offset: 4509,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>nonInternalMeth</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6515,7 +6515,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "_internalMeth3()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth3",
- key.offset: 4540,
+ key.offset: 4545,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth3</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -6526,7 +6526,7 @@
key.name: "FooClassDerived",
key.usr: "c:objc(cs)FooClassDerived",
key.doc.full_as_xml: "<Other file=Foo.h line=\"158\" column=\"12\"><Name>FooClassDerived</Name><USR>c:objc(cs)FooClassDerived</USR><Declaration>class FooClassDerived : FooClassBase, FooProtocolDerived</Declaration><Abstract><Para> Aaa. FooClassDerived. Bbb.</Para></Abstract></Other>",
- key.offset: 4572,
+ key.offset: 4577,
key.length: 493,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>FooClassDerived</decl.name> : <ref.class usr=\"c:objc(cs)FooClassBase\">FooClassBase</ref.class>, <ref.protocol usr=\"c:objc(pl)FooProtocolDerived\">FooProtocolDerived</ref.protocol></decl.class>",
key.inherits: [
@@ -6548,7 +6548,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "fooProperty1",
key.usr: "c:objc(cs)FooClassDerived(py)fooProperty1",
- key.offset: 4636,
+ key.offset: 4641,
key.length: 23,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooProperty1</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -6556,7 +6556,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "fooProperty2",
key.usr: "c:objc(cs)FooClassDerived(py)fooProperty2",
- key.offset: 4665,
+ key.offset: 4670,
key.length: 23,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooProperty2</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -6564,7 +6564,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "fooProperty3",
key.usr: "c:objc(cs)FooClassDerived(py)fooProperty3",
- key.offset: 4694,
+ key.offset: 4699,
key.length: 31,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>fooProperty3</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -6572,7 +6572,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooInstanceFunc0()",
key.usr: "c:objc(cs)FooClassDerived(im)fooInstanceFunc0",
- key.offset: 4731,
+ key.offset: 4736,
key.length: 23,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooInstanceFunc0</decl.name>()</decl.function.method.instance>"
},
@@ -6580,7 +6580,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooInstanceFunc1(_:)",
key.usr: "c:objc(cs)FooClassDerived(im)fooInstanceFunc1:",
- key.offset: 4760,
+ key.offset: 4765,
key.length: 33,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooInstanceFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -6588,7 +6588,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "a",
- key.offset: 4787,
+ key.offset: 4792,
key.length: 5
}
]
@@ -6597,7 +6597,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooInstanceFunc2(_:withB:)",
key.usr: "c:objc(cs)FooClassDerived(im)fooInstanceFunc2:withB:",
- key.offset: 4799,
+ key.offset: 4804,
key.length: 49,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooInstanceFunc2</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>withB</decl.var.parameter.argument_label> <decl.var.parameter.name>b</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -6605,14 +6605,14 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "a",
- key.offset: 4826,
+ key.offset: 4831,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "withB",
key.name: "b",
- key.offset: 4842,
+ key.offset: 4847,
key.length: 5
}
]
@@ -6621,7 +6621,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "fooBaseInstanceFuncOverridden()",
key.usr: "c:objc(cs)FooClassDerived(im)fooBaseInstanceFuncOverridden",
- key.offset: 4854,
+ key.offset: 4859,
key.length: 36,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooBaseInstanceFuncOverridden</decl.name>()</decl.function.method.instance>",
key.inherits: [
@@ -6636,7 +6636,7 @@
key.kind: source.lang.swift.decl.function.method.class,
key.name: "fooClassFunc0()",
key.usr: "c:objc(cs)FooClassDerived(cm)fooClassFunc0",
- key.offset: 4896,
+ key.offset: 4901,
key.length: 26,
key.fully_annotated_decl: "<decl.function.method.class><syntaxtype.keyword>class</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooClassFunc0</decl.name>()</decl.function.method.class>"
},
@@ -6645,7 +6645,7 @@
key.name: "_internalMeth1()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth1::SYNTHESIZED::c:objc(cs)FooClassDerived",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth1",
- key.offset: 4928,
+ key.offset: 4933,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth1</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6654,7 +6654,7 @@
key.name: "_internalMeth2()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth2::SYNTHESIZED::c:objc(cs)FooClassDerived",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth2",
- key.offset: 4963,
+ key.offset: 4968,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth2</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6663,7 +6663,7 @@
key.name: "nonInternalMeth()",
key.usr: "c:objc(cs)FooClassBase(im)nonInternalMeth::SYNTHESIZED::c:objc(cs)FooClassDerived",
key.original_usr: "c:objc(cs)FooClassBase(im)nonInternalMeth",
- key.offset: 4998,
+ key.offset: 5003,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>nonInternalMeth</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6672,7 +6672,7 @@
key.name: "_internalMeth3()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth3::SYNTHESIZED::c:objc(cs)FooClassDerived",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth3",
- key.offset: 5034,
+ key.offset: 5039,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth3</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -6682,7 +6682,7 @@
key.kind: source.lang.swift.decl.typealias,
key.name: "typedef_int_t",
key.usr: "c:Foo.h@T@typedef_int_t",
- key.offset: 5066,
+ key.offset: 5071,
key.length: 31,
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <decl.name>typedef_int_t</decl.name> = <ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.typealias>",
key.conforms: [
@@ -6707,7 +6707,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_1",
key.usr: "c:Foo.h@3720@macro@FOO_MACRO_1",
- key.offset: 5098,
+ key.offset: 5103,
key.length: 30,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_1</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6715,7 +6715,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_2",
key.usr: "c:Foo.h@3742@macro@FOO_MACRO_2",
- key.offset: 5129,
+ key.offset: 5134,
key.length: 30,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_2</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6723,7 +6723,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_3",
key.usr: "c:Foo.h@3764@macro@FOO_MACRO_3",
- key.offset: 5160,
+ key.offset: 5165,
key.length: 30,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_3</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6731,7 +6731,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_4",
key.usr: "c:Foo.h@3828@macro@FOO_MACRO_4",
- key.offset: 5191,
+ key.offset: 5196,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_4</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6739,7 +6739,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_5",
key.usr: "c:Foo.h@3860@macro@FOO_MACRO_5",
- key.offset: 5223,
+ key.offset: 5228,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_5</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt64V\">UInt64</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6747,7 +6747,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_6",
key.usr: "c:Foo.h@3902@macro@FOO_MACRO_6",
- key.offset: 5255,
+ key.offset: 5260,
key.length: 38,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_6</decl.name>: <decl.var.type><ref.typealias usr=\"c:Foo.h@T@typedef_int_t\">typedef_int_t</ref.typealias></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6755,7 +6755,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_7",
key.usr: "c:Foo.h@3943@macro@FOO_MACRO_7",
- key.offset: 5294,
+ key.offset: 5299,
key.length: 38,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_7</decl.name>: <decl.var.type><ref.typealias usr=\"c:Foo.h@T@typedef_int_t\">typedef_int_t</ref.typealias></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6763,7 +6763,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_8",
key.usr: "c:Foo.h@3984@macro@FOO_MACRO_8",
- key.offset: 5333,
+ key.offset: 5338,
key.length: 29,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_8</decl.name>: <decl.var.type><ref.struct usr=\"s:s4Int8V\">Int8</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6771,7 +6771,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_9",
key.usr: "c:Foo.h@4015@macro@FOO_MACRO_9",
- key.offset: 5363,
+ key.offset: 5368,
key.length: 30,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_9</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6779,7 +6779,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_10",
key.usr: "c:Foo.h@4045@macro@FOO_MACRO_10",
- key.offset: 5394,
+ key.offset: 5399,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_10</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int16V\">Int16</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6787,7 +6787,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_11",
key.usr: "c:Foo.h@4079@macro@FOO_MACRO_11",
- key.offset: 5426,
+ key.offset: 5431,
key.length: 29,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_11</decl.name>: <decl.var.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6795,7 +6795,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_OR",
key.usr: "c:Foo.h@4112@macro@FOO_MACRO_OR",
- key.offset: 5456,
+ key.offset: 5461,
key.length: 31,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_OR</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6803,7 +6803,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_AND",
key.usr: "c:Foo.h@4161@macro@FOO_MACRO_AND",
- key.offset: 5488,
+ key.offset: 5493,
key.length: 32,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_AND</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6811,7 +6811,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_BITWIDTH",
key.usr: "c:Foo.h@4211@macro@FOO_MACRO_BITWIDTH",
- key.offset: 5521,
+ key.offset: 5526,
key.length: 38,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_BITWIDTH</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt64V\">UInt64</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6819,7 +6819,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_SIGNED",
key.usr: "c:Foo.h@4266@macro@FOO_MACRO_SIGNED",
- key.offset: 5560,
+ key.offset: 5565,
key.length: 36,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_SIGNED</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6827,7 +6827,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_REDEF_1",
key.usr: "c:Foo.h@4477@macro@FOO_MACRO_REDEF_1",
- key.offset: 5597,
+ key.offset: 5602,
key.length: 36,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_REDEF_1</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6835,7 +6835,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_MACRO_REDEF_2",
key.usr: "c:Foo.h@4534@macro@FOO_MACRO_REDEF_2",
- key.offset: 5634,
+ key.offset: 5639,
key.length: 36,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_MACRO_REDEF_2</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>"
},
@@ -6843,7 +6843,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "theLastDeclInFoo()",
key.usr: "c:@F@theLastDeclInFoo",
- key.offset: 5671,
+ key.offset: 5676,
key.length: 23,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>theLastDeclInFoo</decl.name>()</decl.function.free>"
},
@@ -6851,7 +6851,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "_internalTopLevelFunc()",
key.usr: "c:@F@_internalTopLevelFunc",
- key.offset: 5695,
+ key.offset: 5700,
key.length: 28,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalTopLevelFunc</decl.name>()</decl.function.free>"
},
@@ -6859,7 +6859,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "_InternalStruct",
key.usr: "c:@S@_InternalStruct",
- key.offset: 5724,
+ key.offset: 5729,
key.length: 78,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>_InternalStruct</decl.name></decl.struct>",
key.entities: [
@@ -6867,7 +6867,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "x",
key.usr: "c:@S@_InternalStruct@FI@x",
- key.offset: 5754,
+ key.offset: 5759,
key.length: 12,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>x</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type></decl.var.instance>"
},
@@ -6875,7 +6875,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init()",
key.usr: "s:SC15_InternalStructVABycfc",
- key.offset: 5772,
+ key.offset: 5777,
key.length: 6,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>()</decl.function.constructor>"
},
@@ -6883,7 +6883,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(x:)",
key.usr: "s:SC15_InternalStructVABs5Int32V1x_tcfc",
- key.offset: 5784,
+ key.offset: 5789,
key.length: 16,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -6891,7 +6891,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "x",
key.name: "x",
- key.offset: 5794,
+ key.offset: 5799,
key.length: 5
}
]
@@ -6900,7 +6900,7 @@
},
{
key.kind: source.lang.swift.decl.extension.class,
- key.offset: 5803,
+ key.offset: 5808,
key.length: 61,
key.extends: {
key.kind: source.lang.swift.ref.class,
@@ -6912,7 +6912,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "_internalMeth1()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth1",
- key.offset: 5833,
+ key.offset: 5838,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth1</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -6920,7 +6920,7 @@
},
{
key.kind: source.lang.swift.decl.extension.class,
- key.offset: 5865,
+ key.offset: 5870,
key.length: 97,
key.extends: {
key.kind: source.lang.swift.ref.class,
@@ -6932,7 +6932,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "_internalMeth2()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth2",
- key.offset: 5895,
+ key.offset: 5900,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth2</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -6940,7 +6940,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "nonInternalMeth()",
key.usr: "c:objc(cs)FooClassBase(im)nonInternalMeth",
- key.offset: 5930,
+ key.offset: 5935,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>nonInternalMeth</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -6948,7 +6948,7 @@
},
{
key.kind: source.lang.swift.decl.extension.class,
- key.offset: 5963,
+ key.offset: 5968,
key.length: 61,
key.extends: {
key.kind: source.lang.swift.ref.class,
@@ -6960,7 +6960,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "_internalMeth3()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth3",
- key.offset: 5993,
+ key.offset: 5998,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth3</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -6970,7 +6970,7 @@
key.kind: source.lang.swift.decl.protocol,
key.name: "_InternalProt",
key.usr: "c:objc(pl)_InternalProt",
- key.offset: 6025,
+ key.offset: 6030,
key.length: 26,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>_InternalProt</decl.name></decl.protocol>"
},
@@ -6978,7 +6978,7 @@
key.kind: source.lang.swift.decl.class,
key.name: "ClassWithInternalProt",
key.usr: "c:objc(cs)ClassWithInternalProt",
- key.offset: 6052,
+ key.offset: 6057,
key.length: 47,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>ClassWithInternalProt</decl.name> : <ref.protocol usr=\"c:objc(pl)_InternalProt\">_InternalProt</ref.protocol></decl.class>",
key.conforms: [
@@ -6993,7 +6993,7 @@
key.kind: source.lang.swift.decl.class,
key.name: "FooClassPropertyOwnership",
key.usr: "c:objc(cs)FooClassPropertyOwnership",
- key.offset: 6100,
+ key.offset: 6105,
key.length: 425,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>FooClassPropertyOwnership</decl.name> : <ref.class usr=\"c:objc(cs)FooClassBase\">FooClassBase</ref.class></decl.class>",
key.inherits: [
@@ -7008,7 +7008,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "assignable",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)assignable",
- key.offset: 6154,
+ key.offset: 6159,
key.length: 42,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>unowned(unsafe)</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>assignable</decl.name>: <decl.var.type>AnyObject!</decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7016,7 +7016,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "unsafeAssignable",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)unsafeAssignable",
- key.offset: 6202,
+ key.offset: 6207,
key.length: 48,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>unowned(unsafe)</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>unsafeAssignable</decl.name>: <decl.var.type>AnyObject!</decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7024,7 +7024,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "retainable",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)retainable",
- key.offset: 6256,
+ key.offset: 6261,
key.length: 20,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>retainable</decl.name>: <decl.var.type>Any!</decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7032,7 +7032,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "strongRef",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)strongRef",
- key.offset: 6282,
+ key.offset: 6287,
key.length: 19,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>strongRef</decl.name>: <decl.var.type>Any!</decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7040,7 +7040,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "copyable",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)copyable",
- key.offset: 6307,
+ key.offset: 6312,
key.length: 18,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>copyable</decl.name>: <decl.var.type>Any!</decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7048,7 +7048,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "weakRef",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)weakRef",
- key.offset: 6331,
+ key.offset: 6336,
key.length: 28,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>weak</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>weakRef</decl.name>: <decl.var.type>AnyObject!</decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7056,7 +7056,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "scalar",
key.usr: "c:objc(cs)FooClassPropertyOwnership(py)scalar",
- key.offset: 6365,
+ key.offset: 6370,
key.length: 17,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>scalar</decl.name>: <decl.var.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> <syntaxtype.keyword>set</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -7065,7 +7065,7 @@
key.name: "_internalMeth1()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth1::SYNTHESIZED::c:objc(cs)FooClassPropertyOwnership",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth1",
- key.offset: 6388,
+ key.offset: 6393,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth1</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -7074,7 +7074,7 @@
key.name: "_internalMeth2()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth2::SYNTHESIZED::c:objc(cs)FooClassPropertyOwnership",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth2",
- key.offset: 6423,
+ key.offset: 6428,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth2</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -7083,7 +7083,7 @@
key.name: "nonInternalMeth()",
key.usr: "c:objc(cs)FooClassBase(im)nonInternalMeth::SYNTHESIZED::c:objc(cs)FooClassPropertyOwnership",
key.original_usr: "c:objc(cs)FooClassBase(im)nonInternalMeth",
- key.offset: 6458,
+ key.offset: 6463,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>nonInternalMeth</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -7092,7 +7092,7 @@
key.name: "_internalMeth3()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth3::SYNTHESIZED::c:objc(cs)FooClassPropertyOwnership",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth3",
- key.offset: 6494,
+ key.offset: 6499,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth3</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -7102,7 +7102,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FOO_NIL",
key.usr: "c:Foo.h@5323@macro@FOO_NIL",
- key.offset: 6526,
+ key.offset: 6531,
key.length: 15,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FOO_NIL</decl.name>: <decl.var.type><tuple>()</tuple></decl.var.type></decl.var.global>",
key.attributes: [
@@ -7118,7 +7118,7 @@
key.kind: source.lang.swift.decl.class,
key.name: "FooUnavailableMembers",
key.usr: "c:objc(cs)FooUnavailableMembers",
- key.offset: 6542,
+ key.offset: 6547,
key.length: 592,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>FooUnavailableMembers</decl.name> : <ref.class usr=\"c:objc(cs)FooClassBase\">FooClassBase</ref.class></decl.class>",
key.inherits: [
@@ -7133,7 +7133,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(int:)",
key.usr: "c:objc(cs)FooUnavailableMembers(cm)unavailableMembersWithInt:",
- key.offset: 6592,
+ key.offset: 6597,
key.length: 31,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>convenience</syntaxtype.keyword> <syntaxtype.keyword>init</syntaxtype.keyword>!(<decl.var.parameter><decl.var.parameter.argument_label>int</decl.var.parameter.argument_label> <decl.var.parameter.name>i</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -7141,7 +7141,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "int",
key.name: "i",
- key.offset: 6617,
+ key.offset: 6622,
key.length: 5
}
]
@@ -7150,7 +7150,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "unavailable()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)unavailable",
- key.offset: 6629,
+ key.offset: 6634,
key.length: 18,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>unavailable</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7166,7 +7166,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "swiftUnavailable()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)swiftUnavailable",
- key.offset: 6653,
+ key.offset: 6658,
key.length: 23,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>swiftUnavailable</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7181,7 +7181,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "deprecated()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)deprecated",
- key.offset: 6682,
+ key.offset: 6687,
key.length: 17,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>deprecated</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7197,7 +7197,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityIntroduced()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityIntroduced",
- key.offset: 6705,
+ key.offset: 6710,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityIntroduced</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7212,7 +7212,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityDeprecated()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityDeprecated",
- key.offset: 6740,
+ key.offset: 6745,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityDeprecated</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7231,7 +7231,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityObsoleted()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityObsoleted",
- key.offset: 6775,
+ key.offset: 6780,
key.length: 28,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityObsoleted</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7247,7 +7247,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityUnavailable()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityUnavailable",
- key.offset: 6809,
+ key.offset: 6814,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityUnavailable</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7263,7 +7263,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityIntroducedMsg()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityIntroducedMsg",
- key.offset: 6845,
+ key.offset: 6850,
key.length: 32,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityIntroducedMsg</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7279,7 +7279,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityDeprecatedMsg()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityDeprecatedMsg",
- key.offset: 6883,
+ key.offset: 6888,
key.length: 32,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityDeprecatedMsg</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7298,7 +7298,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityObsoletedMsg()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityObsoletedMsg",
- key.offset: 6921,
+ key.offset: 6926,
key.length: 31,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityObsoletedMsg</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7315,7 +7315,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "availabilityUnavailableMsg()",
key.usr: "c:objc(cs)FooUnavailableMembers(im)availabilityUnavailableMsg",
- key.offset: 6958,
+ key.offset: 6963,
key.length: 33,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityUnavailableMsg</decl.name>()</decl.function.method.instance>",
key.attributes: [
@@ -7333,7 +7333,7 @@
key.name: "_internalMeth1()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth1::SYNTHESIZED::c:objc(cs)FooUnavailableMembers",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth1",
- key.offset: 6997,
+ key.offset: 7002,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth1</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -7342,7 +7342,7 @@
key.name: "_internalMeth2()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth2::SYNTHESIZED::c:objc(cs)FooUnavailableMembers",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth2",
- key.offset: 7032,
+ key.offset: 7037,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth2</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -7351,7 +7351,7 @@
key.name: "nonInternalMeth()",
key.usr: "c:objc(cs)FooClassBase(im)nonInternalMeth::SYNTHESIZED::c:objc(cs)FooUnavailableMembers",
key.original_usr: "c:objc(cs)FooClassBase(im)nonInternalMeth",
- key.offset: 7067,
+ key.offset: 7072,
key.length: 30,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>nonInternalMeth</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
},
@@ -7360,7 +7360,7 @@
key.name: "_internalMeth3()",
key.usr: "c:objc(cs)FooClassBase(im)_internalMeth3::SYNTHESIZED::c:objc(cs)FooUnavailableMembers",
key.original_usr: "c:objc(cs)FooClassBase(im)_internalMeth3",
- key.offset: 7103,
+ key.offset: 7108,
key.length: 29,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>_internalMeth3</decl.name>() -> <decl.function.returntype>Any!</decl.function.returntype></decl.function.method.instance>"
}
@@ -7370,7 +7370,7 @@
key.kind: source.lang.swift.decl.class,
key.name: "FooCFType",
key.usr: "c:Foo.h@T@FooCFTypeRef",
- key.offset: 7135,
+ key.offset: 7140,
key.length: 19,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>FooCFType</decl.name></decl.class>"
},
@@ -7378,14 +7378,14 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "FooCFTypeRelease(_:)",
key.usr: "c:@F@FooCFTypeRelease",
- key.offset: 7155,
+ key.offset: 7160,
key.length: 38,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>FooCFTypeRelease</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.class usr=\"c:Foo.h@T@FooCFTypeRef\">FooCFType</ref.class>!</decl.var.parameter.type></decl.var.parameter>)</decl.function.free>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
- key.offset: 7182,
+ key.offset: 7187,
key.length: 10
}
],
@@ -7402,8 +7402,8 @@
key.kind: source.lang.swift.decl.enum,
key.name: "ABAuthorizationStatus",
key.usr: "c:@E@ABAuthorizationStatus",
- key.offset: 7194,
- key.length: 169,
+ key.offset: 7199,
+ key.length: 170,
key.fully_annotated_decl: "<decl.enum><syntaxtype.keyword>enum</syntaxtype.keyword> <decl.name>ABAuthorizationStatus</decl.name> : <ref.struct usr=\"s:Si\">Int</ref.struct></decl.enum>",
key.inherits: [
{
@@ -7417,7 +7417,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "notDetermined",
key.usr: "c:@E@ABAuthorizationStatus@kABAuthorizationStatusNotDetermined",
- key.offset: 7234,
+ key.offset: 7239,
key.length: 18,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>notDetermined</decl.name> = <syntaxtype.number>0</syntaxtype.number></decl.enumelement>",
key.attributes: [
@@ -7432,7 +7432,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "restricted",
key.usr: "c:@E@ABAuthorizationStatus@kABAuthorizationStatusRestricted",
- key.offset: 7258,
+ key.offset: 7263,
key.length: 15,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>restricted</decl.name> = <syntaxtype.number>1</syntaxtype.number></decl.enumelement>",
key.attributes: [
@@ -7448,23 +7448,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@ABAuthorizationStatus",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 7279,
- key.length: 82,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@ABAuthorizationStatus\">ABAuthorizationStatus</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@ABAuthorizationStatus\">ABAuthorizationStatus</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 7284,
+ key.length: 83,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@ABAuthorizationStatus\">ABAuthorizationStatus</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"c:@E@ABAuthorizationStatus\">ABAuthorizationStatus</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 7301,
+ key.offset: 7307,
key.length: 21
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 7331,
+ key.offset: 7337,
key.length: 21
}
]
@@ -7483,7 +7483,7 @@
key.kind: source.lang.swift.decl.function.free,
key.name: "fooSubFunc1(_:)",
key.usr: "c:@F@fooSubFunc1",
- key.offset: 7364,
+ key.offset: 7370,
key.length: 37,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>fooSubFunc1</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:s5Int32V\">Int32</ref.struct></decl.function.returntype></decl.function.free>",
key.entities: [
@@ -7491,7 +7491,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "a",
- key.offset: 7386,
+ key.offset: 7392,
key.length: 5
}
],
@@ -7501,15 +7501,15 @@
key.kind: source.lang.swift.decl.struct,
key.name: "FooSubEnum1",
key.usr: "c:@E@FooSubEnum1",
- key.offset: 7402,
- key.length: 213,
+ key.offset: 7408,
+ key.length: 214,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>FooSubEnum1</decl.name> : <ref.protocol usr=\"s:s9EquatableP\">Equatable</ref.protocol>, <ref.protocol usr=\"s:s16RawRepresentableP\">RawRepresentable</ref.protocol></decl.struct>",
key.entities: [
{
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(_:)",
key.usr: "s:SC11FooSubEnum1VABs6UInt32Vcfc",
- key.offset: 7458,
+ key.offset: 7464,
key.length: 24,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>_</decl.var.parameter.argument_label> <decl.var.parameter.name>rawValue</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.entities: [
@@ -7517,7 +7517,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rawValue",
- key.offset: 7475,
+ key.offset: 7481,
key.length: 6
}
]
@@ -7526,7 +7526,7 @@
key.kind: source.lang.swift.decl.function.constructor,
key.name: "init(rawValue:)",
key.usr: "s:SC11FooSubEnum1VABs6UInt32V8rawValue_tcfc",
- key.offset: 7488,
+ key.offset: 7494,
key.length: 31,
key.fully_annotated_decl: "<decl.function.constructor><syntaxtype.keyword>init</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.argument_label>rawValue</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.parameter.type></decl.var.parameter>)</decl.function.constructor>",
key.conforms: [
@@ -7541,7 +7541,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "rawValue",
key.name: "rawValue",
- key.offset: 7512,
+ key.offset: 7518,
key.length: 6
}
]
@@ -7550,7 +7550,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "rawValue",
key.usr: "s:SC11FooSubEnum1V8rawValues6UInt32Vvp",
- key.offset: 7525,
+ key.offset: 7531,
key.length: 20,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>rawValue</decl.name>: <decl.var.type><ref.struct usr=\"s:s6UInt32V\">UInt32</ref.struct></decl.var.type></decl.var.instance>",
key.conforms: [
@@ -7566,23 +7566,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::c:@E@FooSubEnum1",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 7551,
- key.length: 62,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 7557,
+ key.length: 63,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 7573,
+ key.offset: 7580,
key.length: 11
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 7593,
+ key.offset: 7600,
key.length: 11
}
]
@@ -7594,7 +7594,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooSubEnum1X",
key.usr: "c:@E@FooSubEnum1@FooSubEnum1X",
- key.offset: 7616,
+ key.offset: 7623,
key.length: 37,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooSubEnum1X</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>",
key.modulename: "Foo.FooSub"
@@ -7603,7 +7603,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooSubEnum1Y",
key.usr: "c:@E@FooSubEnum1@FooSubEnum1Y",
- key.offset: 7654,
+ key.offset: 7661,
key.length: 37,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooSubEnum1Y</decl.name>: <decl.var.type><ref.struct usr=\"c:@E@FooSubEnum1\">FooSubEnum1</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>",
key.modulename: "Foo.FooSub"
@@ -7612,7 +7612,7 @@
key.kind: source.lang.swift.decl.var.global,
key.name: "FooSubUnnamedEnumeratorA1",
key.usr: "c:@Ea@FooSubUnnamedEnumeratorA1@FooSubUnnamedEnumeratorA1",
- key.offset: 7692,
+ key.offset: 7699,
key.length: 42,
key.fully_annotated_decl: "<decl.var.global><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>FooSubUnnamedEnumeratorA1</decl.name>: <decl.var.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.global>",
key.modulename: "Foo.FooSub"
diff --git a/test/SourceKit/DocSupport/doc_source_file.swift.response b/test/SourceKit/DocSupport/doc_source_file.swift.response
index 91a55ec..4d01a6e 100644
--- a/test/SourceKit/DocSupport/doc_source_file.swift.response
+++ b/test/SourceKit/DocSupport/doc_source_file.swift.response
@@ -1977,7 +1977,7 @@
key.usr: "s:8__main__1poiAA2CCCAD_AA3CC0CtF",
key.offset: 288,
key.length: 42,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>+</decl.name>(<decl.var.parameter><decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:8__main__2CCC\">CC</ref.class></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>b</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:8__main__3CC0C\">CC0</ref.class></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.class usr=\"s:8__main__2CCC\">CC</ref.class></decl.function.returntype></decl.function.operator.infix>",
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>+ </decl.name>(<decl.var.parameter><decl.var.parameter.name>a</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:8__main__2CCC\">CC</ref.class></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>b</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:8__main__3CC0C\">CC0</ref.class></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.class usr=\"s:8__main__2CCC\">CC</ref.class></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
@@ -2661,7 +2661,7 @@
key.usr: "s:8__main__5Prot3P1poiyx_xtFZ",
key.offset: 1973,
key.length: 30,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>+</decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.generic_type_param usr=\"s:8__main__5Prot3P4Selfxmfp\">Self</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>y</decl.var.parameter.name>: <decl.var.parameter.type><ref.generic_type_param usr=\"s:8__main__5Prot3P4Selfxmfp\">Self</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>)</decl.function.operator.infix>",
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>+ </decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.generic_type_param usr=\"s:8__main__5Prot3P4Selfxmfp\">Self</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>y</decl.var.parameter.name>: <decl.var.parameter.type><ref.generic_type_param usr=\"s:8__main__5Prot3P4Selfxmfp\">Self</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>)</decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
diff --git a/test/SourceKit/DocSupport/doc_swift_module.swift.response b/test/SourceKit/DocSupport/doc_swift_module.swift.response
index d6eba0a..77a345d 100644
--- a/test/SourceKit/DocSupport/doc_swift_module.swift.response
+++ b/test/SourceKit/DocSupport/doc_swift_module.swift.response
@@ -36,7 +36,7 @@
extension C1Cases {
- static func !=(_ lhs: C1.C1Cases, _ rhs: C1.C1Cases) -> Bool
+ static func != (_ lhs: C1.C1Cases, _ rhs: C1.C1Cases) -> Bool
}
class C2 : cake.C1 {
@@ -69,7 +69,7 @@
case Blah
- static func !=(_ lhs: MyEnum, _ rhs: MyEnum) -> Bool
+ static func != (_ lhs: MyEnum, _ rhs: MyEnum) -> Bool
}
@objc protocol P2 {
@@ -129,7 +129,7 @@
extension SE {
- static func !=(_ lhs: S1.SE, _ rhs: S1.SE) -> Bool
+ static func != (_ lhs: S1.SE, _ rhs: S1.SE) -> Bool
}
struct S2 : P3 {
@@ -481,929 +481,929 @@
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 467,
+ key.offset: 468,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 469,
+ key.offset: 470,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 469,
+ key.offset: 470,
key.length: 3
},
{
key.kind: source.lang.swift.ref.class,
key.name: "C1",
key.usr: "s:4cake2C1C",
- key.offset: 474,
+ key.offset: 475,
key.length: 2
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "C1Cases",
key.usr: "s:4cake2C1C0B5CasesO",
- key.offset: 477,
+ key.offset: 478,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 486,
+ key.offset: 487,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 488,
+ key.offset: 489,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 488,
+ key.offset: 489,
key.length: 3
},
{
key.kind: source.lang.swift.ref.class,
key.name: "C1",
key.usr: "s:4cake2C1C",
- key.offset: 493,
+ key.offset: 494,
key.length: 2
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "C1Cases",
key.usr: "s:4cake2C1C0B5CasesO",
- key.offset: 496,
+ key.offset: 497,
key.length: 7
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 508,
+ key.offset: 509,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 516,
+ key.offset: 517,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 522,
+ key.offset: 523,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 527,
+ key.offset: 528,
key.length: 4
},
{
key.kind: source.lang.swift.ref.class,
key.name: "C1",
key.usr: "s:4cake2C1C",
- key.offset: 532,
+ key.offset: 533,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 542,
+ key.offset: 543,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 547,
+ key.offset: 548,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 560,
+ key.offset: 561,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 565,
+ key.offset: 566,
key.length: 7
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 575,
+ key.offset: 576,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 590,
+ key.offset: 591,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 595,
+ key.offset: 596,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 612,
+ key.offset: 613,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 617,
+ key.offset: 618,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 631,
+ key.offset: 632,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 636,
+ key.offset: 637,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 648,
+ key.offset: 649,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 658,
+ key.offset: 659,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 660,
+ key.offset: 661,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 660,
+ key.offset: 661,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 667,
+ key.offset: 668,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 675,
+ key.offset: 676,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 681,
+ key.offset: 682,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 690,
+ key.offset: 691,
key.length: 9
},
{
key.kind: source.lang.swift.ref.class,
key.name: "C2",
key.usr: "s:4cake2C2C",
- key.offset: 700,
+ key.offset: 701,
key.length: 2
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "P4",
key.usr: "s:4cake2P4P",
- key.offset: 705,
+ key.offset: 706,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 715,
+ key.offset: 716,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 720,
+ key.offset: 721,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 733,
+ key.offset: 734,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 740,
+ key.offset: 741,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 756,
+ key.offset: 757,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 761,
+ key.offset: 762,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 769,
+ key.offset: 770,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 771,
+ key.offset: 772,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 769,
+ key.offset: 770,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 771,
+ key.offset: 772,
key.length: 1
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "P4",
key.usr: "s:4cake2P4P",
- key.offset: 774,
+ key.offset: 775,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 787,
+ key.offset: 788,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 792,
+ key.offset: 793,
key.length: 6
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 801,
+ key.offset: 802,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 812,
+ key.offset: 813,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 817,
+ key.offset: 818,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 827,
+ key.offset: 828,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 834,
+ key.offset: 835,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 842,
+ key.offset: 844,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 844,
+ key.offset: 846,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 844,
+ key.offset: 846,
key.length: 3
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "MyEnum",
key.usr: "s:4cake6MyEnumO",
- key.offset: 849,
+ key.offset: 851,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 857,
+ key.offset: 859,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 859,
+ key.offset: 861,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 859,
+ key.offset: 861,
key.length: 3
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "MyEnum",
key.usr: "s:4cake6MyEnumO",
- key.offset: 864,
+ key.offset: 866,
key.length: 6
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 875,
+ key.offset: 877,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 883,
+ key.offset: 885,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 889,
+ key.offset: 891,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 898,
+ key.offset: 900,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 908,
+ key.offset: 910,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.attribute.builtin,
- key.offset: 914,
+ key.offset: 916,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 923,
+ key.offset: 925,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 928,
+ key.offset: 930,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 938,
+ key.offset: 940,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 947,
+ key.offset: 949,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 957,
+ key.offset: 959,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 972,
+ key.offset: 974,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 977,
+ key.offset: 979,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 986,
+ key.offset: 988,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 994,
+ key.offset: 996,
key.length: 8
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1003,
+ key.offset: 1005,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1015,
+ key.offset: 1017,
key.length: 14
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1030,
+ key.offset: 1032,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1043,
+ key.offset: 1045,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1047,
+ key.offset: 1049,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 1050,
+ key.offset: 1052,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1056,
+ key.offset: 1058,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1067,
+ key.offset: 1069,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1072,
+ key.offset: 1074,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1083,
+ key.offset: 1085,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1088,
+ key.offset: 1090,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1098,
+ key.offset: 1100,
key.length: 9
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Prot",
key.usr: "s:4cake4ProtP",
- key.offset: 1108,
+ key.offset: 1110,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1120,
+ key.offset: 1122,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1125,
+ key.offset: 1127,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1137,
+ key.offset: 1139,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1147,
+ key.offset: 1149,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1149,
+ key.offset: 1151,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1149,
+ key.offset: 1151,
key.length: 5
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 1156,
+ key.offset: 1158,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 1164,
+ key.offset: 1166,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1170,
+ key.offset: 1172,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1179,
+ key.offset: 1181,
key.length: 9
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Prot",
key.usr: "s:4cake4ProtP",
- key.offset: 1189,
+ key.offset: 1191,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1194,
+ key.offset: 1196,
key.length: 5
},
{
key.kind: source.lang.swift.ref.generic_type_param,
key.name: "Self",
key.usr: "s:4cake4ProtPA2aBRzSi7ElementRtzlE4Selfxmfp",
- key.offset: 1200,
+ key.offset: 1202,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1205,
+ key.offset: 1207,
key.length: 7
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 1216,
+ key.offset: 1218,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1227,
+ key.offset: 1229,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1232,
+ key.offset: 1234,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1244,
+ key.offset: 1246,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1251,
+ key.offset: 1253,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1261,
+ key.offset: 1263,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1266,
+ key.offset: 1268,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1280,
+ key.offset: 1282,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1285,
+ key.offset: 1287,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1296,
+ key.offset: 1298,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1301,
+ key.offset: 1303,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1312,
+ key.offset: 1314,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1317,
+ key.offset: 1319,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1330,
+ key.offset: 1332,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1335,
+ key.offset: 1337,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1347,
+ key.offset: 1349,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1354,
+ key.offset: 1356,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1368,
+ key.offset: 1370,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1372,
+ key.offset: 1374,
key.length: 1
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
- key.offset: 1375,
+ key.offset: 1377,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1388,
+ key.offset: 1390,
key.length: 9
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "SE",
key.usr: "s:4cake2S1V2SEO",
- key.offset: 1398,
+ key.offset: 1400,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1408,
+ key.offset: 1410,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1415,
+ key.offset: 1417,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1423,
+ key.offset: 1426,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1425,
+ key.offset: 1428,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1425,
+ key.offset: 1428,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "S1",
key.usr: "s:4cake2S1V",
- key.offset: 1430,
- key.length: 2
- },
- {
- key.kind: source.lang.swift.ref.enum,
- key.name: "SE",
- key.usr: "s:4cake2S1V2SEO",
key.offset: 1433,
key.length: 2
},
{
+ key.kind: source.lang.swift.ref.enum,
+ key.name: "SE",
+ key.usr: "s:4cake2S1V2SEO",
+ key.offset: 1436,
+ key.length: 2
+ },
+ {
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1437,
+ key.offset: 1440,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1439,
+ key.offset: 1442,
key.length: 3
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1439,
+ key.offset: 1442,
key.length: 3
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "S1",
key.usr: "s:4cake2S1V",
- key.offset: 1444,
+ key.offset: 1447,
key.length: 2
},
{
key.kind: source.lang.swift.ref.enum,
key.name: "SE",
key.usr: "s:4cake2S1V2SEO",
- key.offset: 1447,
+ key.offset: 1450,
key.length: 2
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bool",
key.usr: "s:Sb",
- key.offset: 1454,
+ key.offset: 1457,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1462,
+ key.offset: 1465,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1469,
+ key.offset: 1472,
key.length: 2
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "P3",
key.usr: "s:4cake2P3P",
- key.offset: 1474,
+ key.offset: 1477,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1484,
+ key.offset: 1487,
key.length: 9
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1494,
+ key.offset: 1497,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1498,
+ key.offset: 1501,
key.length: 4
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "S2",
key.usr: "s:4cake2S2V",
- key.offset: 1503,
+ key.offset: 1506,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1509,
+ key.offset: 1512,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1514,
+ key.offset: 1517,
key.length: 6
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1521,
+ key.offset: 1524,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1525,
+ key.offset: 1528,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1529,
+ key.offset: 1532,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1531,
+ key.offset: 1534,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1535,
+ key.offset: 1538,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1539,
+ key.offset: 1542,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1541,
+ key.offset: 1544,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.identifier,
- key.offset: 1545,
+ key.offset: 1548,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 1549,
+ key.offset: 1552,
key.length: 5
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1555,
+ key.offset: 1558,
key.length: 2
},
{
key.kind: source.lang.swift.ref.protocol,
key.name: "Prot",
key.usr: "s:4cake4ProtP",
- key.offset: 1560,
+ key.offset: 1563,
key.length: 4
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1566,
+ key.offset: 1569,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1571,
+ key.offset: 1574,
key.length: 4
},
{
key.kind: source.lang.swift.ref.class,
key.name: "C1",
key.usr: "s:4cake2C1C",
- key.offset: 1576,
- key.length: 2
- },
- {
- key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1580,
+ key.offset: 1579,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
key.offset: 1583,
+ key.length: 2
+ },
+ {
+ key.kind: source.lang.swift.syntaxtype.typeidentifier,
+ key.offset: 1586,
key.length: 7
},
{
key.kind: source.lang.swift.syntaxtype.typeidentifier,
- key.offset: 1594,
+ key.offset: 1597,
key.length: 4
},
{
key.kind: source.lang.swift.ref.class,
key.name: "C1",
key.usr: "s:4cake2C1C",
- key.offset: 1599,
+ key.offset: 1602,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1529,
+ key.offset: 1532,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1531,
+ key.offset: 1534,
key.length: 2
},
{
key.kind: source.lang.swift.syntaxtype.argument,
- key.offset: 1539,
+ key.offset: 1542,
key.length: 1
},
{
key.kind: source.lang.swift.syntaxtype.parameter,
- key.offset: 1541,
+ key.offset: 1544,
key.length: 2
},
{
key.kind: source.lang.swift.ref.typealias,
key.name: "Element",
key.usr: "s:4cake2C1C7Elementa",
- key.offset: 1602,
+ key.offset: 1605,
key.length: 7
}
]
@@ -1632,7 +1632,7 @@
{
key.kind: source.lang.swift.decl.extension.enum,
key.offset: 427,
- key.length: 87,
+ key.length: 88,
key.extends: {
key.kind: source.lang.swift.ref.enum,
key.name: "C1Cases",
@@ -1644,23 +1644,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::s:4cake2C1C0B5CasesO",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
key.offset: 452,
- key.length: 60,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:4cake2C1C\">C1</ref.class>.<ref.enum usr=\"s:4cake2C1C0B5CasesO\">C1Cases</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:4cake2C1C\">C1</ref.class>.<ref.enum usr=\"s:4cake2C1C0B5CasesO\">C1Cases</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.length: 61,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:4cake2C1C\">C1</ref.class>.<ref.enum usr=\"s:4cake2C1C0B5CasesO\">C1Cases</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr=\"s:4cake2C1C\">C1</ref.class>.<ref.enum usr=\"s:4cake2C1C0B5CasesO\">C1Cases</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 474,
+ key.offset: 475,
key.length: 10
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 493,
+ key.offset: 494,
key.length: 10
}
]
@@ -1671,7 +1671,7 @@
key.kind: source.lang.swift.decl.class,
key.name: "C2",
key.usr: "s:4cake2C2C",
- key.offset: 516,
+ key.offset: 517,
key.length: 172,
key.fully_annotated_decl: "<decl.class><syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>C2</decl.name> : <ref.class usr=\"s:4cake2C1C\">C1</ref.class></decl.class>",
key.inherits: [
@@ -1686,7 +1686,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "C2foo()",
key.usr: "s:4cake2C2C5C2fooyyF",
- key.offset: 542,
+ key.offset: 543,
key.length: 12,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>C2foo</decl.name>()</decl.function.method.instance>"
},
@@ -1695,7 +1695,7 @@
key.name: "C1Cases",
key.usr: "s:4cake2C1C0B5CasesO::SYNTHESIZED::s:4cake2C2C",
key.original_usr: "s:4cake2C1C0B5CasesO",
- key.offset: 560,
+ key.offset: 561,
key.length: 46,
key.fully_annotated_decl: "<decl.enum><syntaxtype.keyword>enum</syntaxtype.keyword> <decl.name>C1Cases</decl.name> : <ref.struct usr=\"s:Si\">Int</ref.struct></decl.enum>",
key.inherits: [
@@ -1710,7 +1710,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "case1",
key.usr: "s:4cake2C1C0B5CasesO5case1A2EmF",
- key.offset: 590,
+ key.offset: 591,
key.length: 10,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>case1</decl.name></decl.enumelement>"
}
@@ -1721,7 +1721,7 @@
key.name: "extfoo()",
key.usr: "s:4cake4ProtPA2aBRzSi7ElementRtzlE6extfooyyF::SYNTHESIZED::s:4cake2C2C",
key.original_usr: "s:4cake4ProtPA2aBRzSi7ElementRtzlE6extfooyyF",
- key.offset: 612,
+ key.offset: 613,
key.length: 13,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>extfoo</decl.name>()</decl.function.method.instance>"
},
@@ -1730,7 +1730,7 @@
key.name: "foo1()",
key.usr: "s:4cake4ProtPAAE4foo1yyF::SYNTHESIZED::s:4cake2C2C",
key.original_usr: "s:4cake4ProtPAAE4foo1yyF",
- key.offset: 631,
+ key.offset: 632,
key.length: 11,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo1</decl.name>()</decl.function.method.instance>"
},
@@ -1739,7 +1739,7 @@
key.name: "subscript(_:)",
key.usr: "s:4cake4ProtPAAES2icip::SYNTHESIZED::s:4cake2C2C",
key.original_usr: "s:4cake4ProtPAAES2icip",
- key.offset: 648,
+ key.offset: 649,
key.length: 38,
key.fully_annotated_decl: "<decl.function.subscript><syntaxtype.keyword>subscript</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.name>index</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Si\">Int</ref.struct></decl.function.returntype> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.function.subscript>",
key.entities: [
@@ -1747,7 +1747,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "index",
- key.offset: 667,
+ key.offset: 668,
key.length: 3
}
]
@@ -1756,7 +1756,7 @@
},
{
key.kind: source.lang.swift.decl.extension.class,
- key.offset: 690,
+ key.offset: 691,
key.length: 95,
key.conforms: [
{
@@ -1776,7 +1776,7 @@
key.name: "C1foo()",
key.usr: "s:4cake2C1C5C1fooyyF::SYNTHESIZED::s:4cake2C2C",
key.original_usr: "s:4cake2C1C5C1fooyyF",
- key.offset: 715,
+ key.offset: 716,
key.length: 12,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>C1foo</decl.name>()</decl.function.method.instance>"
},
@@ -1785,7 +1785,7 @@
key.name: "C1S1",
key.usr: "s:4cake2C1C0B2S1V::SYNTHESIZED::s:4cake2C2C",
key.original_usr: "s:4cake2C1C0B2S1V",
- key.offset: 733,
+ key.offset: 734,
key.length: 50,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>C1S1</decl.name></decl.struct>",
key.entities: [
@@ -1793,7 +1793,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "C1S1foo(a:)",
key.usr: "s:4cake2C1C0B2S1V0B5S1fooyAA2P4_p1a_tF",
- key.offset: 756,
+ key.offset: 757,
key.length: 21,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>C1S1foo</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>a</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.protocol usr=\"s:4cake2P4P\">P4</ref.protocol></decl.var.parameter.type></decl.var.parameter>)</decl.function.method.instance>",
key.entities: [
@@ -1801,7 +1801,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "a",
key.name: "a",
- key.offset: 774,
+ key.offset: 775,
key.length: 2
}
]
@@ -1814,8 +1814,8 @@
key.kind: source.lang.swift.decl.enum,
key.name: "MyEnum",
key.usr: "s:4cake6MyEnumO",
- key.offset: 787,
- key.length: 94,
+ key.offset: 788,
+ key.length: 95,
key.fully_annotated_decl: "<decl.enum><syntaxtype.keyword>enum</syntaxtype.keyword> <decl.name>MyEnum</decl.name> : <ref.struct usr=\"s:Si\">Int</ref.struct></decl.enum>",
key.inherits: [
{
@@ -1829,7 +1829,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "Blah",
key.usr: "s:4cake6MyEnumO4BlahA2CmF",
- key.offset: 812,
+ key.offset: 813,
key.length: 9,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>Blah</decl.name></decl.enumelement>"
},
@@ -1838,23 +1838,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::s:4cake6MyEnumO",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 827,
- key.length: 52,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"s:4cake6MyEnumO\">MyEnum</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"s:4cake6MyEnumO\">MyEnum</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 828,
+ key.length: 53,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"s:4cake6MyEnumO\">MyEnum</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.enum usr=\"s:4cake6MyEnumO\">MyEnum</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 849,
+ key.offset: 851,
key.length: 6
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 864,
+ key.offset: 866,
key.length: 6
}
]
@@ -1865,7 +1865,7 @@
key.kind: source.lang.swift.decl.protocol,
key.name: "P2",
key.usr: "c:@M@cake@objc(pl)P2",
- key.offset: 883,
+ key.offset: 885,
key.length: 53,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@objc</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>P2</decl.name></decl.protocol>",
key.entities: [
@@ -1873,7 +1873,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo1()",
key.usr: "c:@M@cake@objc(pl)P2(im)foo1",
- key.offset: 908,
+ key.offset: 910,
key.length: 26,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@objc</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>optional</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo1</decl.name>()</decl.function.method.instance>",
key.is_optional: 1
@@ -1884,7 +1884,7 @@
key.kind: source.lang.swift.decl.protocol,
key.name: "P3",
key.usr: "s:4cake2P3P",
- key.offset: 938,
+ key.offset: 940,
key.length: 37,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>P3</decl.name></decl.protocol>",
key.entities: [
@@ -1892,7 +1892,7 @@
key.kind: source.lang.swift.decl.associatedtype,
key.name: "T",
key.usr: "s:4cake2P3P1T",
- key.offset: 957,
+ key.offset: 959,
key.length: 16,
key.fully_annotated_decl: "<decl.associatedtype><syntaxtype.keyword>associatedtype</syntaxtype.keyword> <decl.name>T</decl.name></decl.associatedtype>"
}
@@ -1902,7 +1902,7 @@
key.kind: source.lang.swift.decl.protocol,
key.name: "P4",
key.usr: "s:4cake2P4P",
- key.offset: 977,
+ key.offset: 979,
key.length: 15,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>P4</decl.name></decl.protocol>"
},
@@ -1910,7 +1910,7 @@
key.kind: source.lang.swift.decl.protocol,
key.name: "Prot",
key.usr: "s:4cake4ProtP",
- key.offset: 994,
+ key.offset: 996,
key.length: 102,
key.fully_annotated_decl: "<decl.protocol><syntaxtype.keyword>protocol</syntaxtype.keyword> <decl.name>Prot</decl.name></decl.protocol>",
key.entities: [
@@ -1918,7 +1918,7 @@
key.kind: source.lang.swift.decl.associatedtype,
key.name: "Element",
key.usr: "s:4cake4ProtP7Element",
- key.offset: 1015,
+ key.offset: 1017,
key.length: 22,
key.fully_annotated_decl: "<decl.associatedtype><syntaxtype.keyword>associatedtype</syntaxtype.keyword> <decl.name>Element</decl.name></decl.associatedtype>"
},
@@ -1926,7 +1926,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "p",
key.usr: "s:4cake4ProtP1pSivp",
- key.offset: 1043,
+ key.offset: 1045,
key.length: 18,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>p</decl.name>: <decl.var.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.instance>"
},
@@ -1934,7 +1934,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo()",
key.usr: "s:4cake4ProtP3fooyyF",
- key.offset: 1067,
+ key.offset: 1069,
key.length: 10,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo</decl.name>()</decl.function.method.instance>"
},
@@ -1942,7 +1942,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo1()",
key.usr: "s:4cake4ProtP4foo1yyF",
- key.offset: 1083,
+ key.offset: 1085,
key.length: 11,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo1</decl.name>()</decl.function.method.instance>"
}
@@ -1950,7 +1950,7 @@
},
{
key.kind: source.lang.swift.decl.extension.protocol,
- key.offset: 1098,
+ key.offset: 1100,
key.length: 79,
key.extends: {
key.kind: source.lang.swift.ref.protocol,
@@ -1963,7 +1963,7 @@
key.name: "foo1()",
key.usr: "s:4cake4ProtPAAE4foo1yyF",
key.default_implementation_of: "s:4cake4ProtP4foo1yyF",
- key.offset: 1120,
+ key.offset: 1122,
key.length: 11,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo1</decl.name>()</decl.function.method.instance>"
},
@@ -1971,7 +1971,7 @@
key.kind: source.lang.swift.decl.function.subscript,
key.name: "subscript(_:)",
key.usr: "s:4cake4ProtPAAES2icip",
- key.offset: 1137,
+ key.offset: 1139,
key.length: 38,
key.fully_annotated_decl: "<decl.function.subscript><syntaxtype.keyword>subscript</syntaxtype.keyword>(<decl.var.parameter><decl.var.parameter.name>index</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Si\">Int</ref.struct></decl.function.returntype> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.function.subscript>",
key.entities: [
@@ -1979,7 +1979,7 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "index",
- key.offset: 1156,
+ key.offset: 1158,
key.length: 3
}
]
@@ -1993,7 +1993,7 @@
key.description: "Self.Element == Int"
}
],
- key.offset: 1179,
+ key.offset: 1181,
key.length: 63,
key.extends: {
key.kind: source.lang.swift.ref.protocol,
@@ -2005,7 +2005,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "extfoo()",
key.usr: "s:4cake4ProtPA2aBRzSi7ElementRtzlE6extfooyyF",
- key.offset: 1227,
+ key.offset: 1229,
key.length: 13,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>extfoo</decl.name>()</decl.function.method.instance>"
}
@@ -2015,7 +2015,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "S1",
key.usr: "s:4cake2S1V",
- key.offset: 1244,
+ key.offset: 1246,
key.length: 142,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>S1</decl.name></decl.struct>",
key.entities: [
@@ -2023,7 +2023,7 @@
key.kind: source.lang.swift.decl.enum,
key.name: "SE",
key.usr: "s:4cake2S1V2SEO",
- key.offset: 1261,
+ key.offset: 1263,
key.length: 63,
key.fully_annotated_decl: "<decl.enum><syntaxtype.keyword>enum</syntaxtype.keyword> <ref.struct usr=\"s:4cake2S1V\">S1</ref.struct>.<decl.name>SE</decl.name></decl.enum>",
key.entities: [
@@ -2031,7 +2031,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "a",
key.usr: "s:4cake2S1V2SEO1aA2EmF",
- key.offset: 1280,
+ key.offset: 1282,
key.length: 6,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>a</decl.name></decl.enumelement>"
},
@@ -2039,7 +2039,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "b",
key.usr: "s:4cake2S1V2SEO1bA2EmF",
- key.offset: 1296,
+ key.offset: 1298,
key.length: 6,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>b</decl.name></decl.enumelement>"
},
@@ -2047,7 +2047,7 @@
key.kind: source.lang.swift.decl.enumelement,
key.name: "c",
key.usr: "s:4cake2S1V2SEO1cA2EmF",
- key.offset: 1312,
+ key.offset: 1314,
key.length: 6,
key.fully_annotated_decl: "<decl.enumelement><syntaxtype.keyword>case</syntaxtype.keyword> <decl.name>c</decl.name></decl.enumelement>"
}
@@ -2057,7 +2057,7 @@
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "foo1()",
key.usr: "s:4cake2S1V4foo1yyF",
- key.offset: 1330,
+ key.offset: 1332,
key.length: 11,
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>foo1</decl.name>()</decl.function.method.instance>"
},
@@ -2065,7 +2065,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "S2",
key.usr: "s:4cake2S1V2S2V",
- key.offset: 1347,
+ key.offset: 1349,
key.length: 37,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>S2</decl.name></decl.struct>",
key.entities: [
@@ -2073,7 +2073,7 @@
key.kind: source.lang.swift.decl.var.instance,
key.name: "b",
key.usr: "s:4cake2S1V2S2V1bSivp",
- key.offset: 1368,
+ key.offset: 1370,
key.length: 10,
key.fully_annotated_decl: "<decl.var.instance><syntaxtype.keyword>let</syntaxtype.keyword> <decl.name>b</decl.name>: <decl.var.type><ref.struct usr=\"s:Si\">Int</ref.struct></decl.var.type></decl.var.instance>"
}
@@ -2083,8 +2083,8 @@
},
{
key.kind: source.lang.swift.decl.extension.enum,
- key.offset: 1388,
- key.length: 72,
+ key.offset: 1390,
+ key.length: 73,
key.extends: {
key.kind: source.lang.swift.ref.enum,
key.name: "SE",
@@ -2096,23 +2096,23 @@
key.name: "!=(_:_:)",
key.usr: "s:s9EquatablePsE2neoiSbx_xtFZ::SYNTHESIZED::s:4cake2S1V2SEO",
key.original_usr: "s:s9EquatablePsE2neoiSbx_xtFZ",
- key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func !=(lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
- key.offset: 1408,
- key.length: 50,
- key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!=</decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:4cake2S1V\">S1</ref.struct>.<ref.enum usr=\"s:4cake2S1V2SEO\">SE</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:4cake2S1V\">S1</ref.struct>.<ref.enum usr=\"s:4cake2S1V2SEO\">SE</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
+ key.doc.full_as_xml: "<Function><Name>!=(_:_:)</Name><USR>s:s9EquatablePsE2neoiSbx_xtFZ</USR><Declaration>static func != (lhs: Self, rhs: Self) -> Bool</Declaration><CommentParts><Abstract><Para>Returns a Boolean value indicating whether two values are not equal.</Para></Abstract><Parameters><Parameter><Name>lhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>A value to compare.</Para></Discussion></Parameter><Parameter><Name>rhs</Name><Direction isExplicit=\"0\">in</Direction><Discussion><Para>Another value to compare.</Para></Discussion></Parameter></Parameters><Discussion><Para>Inequality is the inverse of equality. For any values <codeVoice>a</codeVoice> and <codeVoice>b</codeVoice>, <codeVoice>a != b</codeVoice> implies that <codeVoice>a == b</codeVoice> is <codeVoice>false</codeVoice>.</Para><Para>This is the default implementation of the not-equal-to operator (<codeVoice>!=</codeVoice>) for any type that conforms to <codeVoice>Equatable</codeVoice>.</Para></Discussion></CommentParts></Function>",
+ key.offset: 1410,
+ key.length: 51,
+ key.fully_annotated_decl: "<decl.function.operator.infix><syntaxtype.keyword>static</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>!= </decl.name>(<decl.var.parameter><decl.var.parameter.name>lhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:4cake2S1V\">S1</ref.struct>.<ref.enum usr=\"s:4cake2S1V2SEO\">SE</ref.enum></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>rhs</decl.var.parameter.name>: <decl.var.parameter.type><ref.struct usr=\"s:4cake2S1V\">S1</ref.struct>.<ref.enum usr=\"s:4cake2S1V2SEO\">SE</ref.enum></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.struct usr=\"s:Sb\">Bool</ref.struct></decl.function.returntype></decl.function.operator.infix>",
key.entities: [
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "lhs",
- key.offset: 1430,
+ key.offset: 1433,
key.length: 5
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "_",
key.name: "rhs",
- key.offset: 1444,
+ key.offset: 1447,
key.length: 5
}
]
@@ -2123,7 +2123,7 @@
key.kind: source.lang.swift.decl.struct,
key.name: "S2",
key.usr: "s:4cake2S2V",
- key.offset: 1462,
+ key.offset: 1465,
key.length: 45,
key.fully_annotated_decl: "<decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>S2</decl.name> : <ref.protocol usr=\"s:4cake2P3P\">P3</ref.protocol></decl.struct>",
key.conforms: [
@@ -2138,7 +2138,7 @@
key.kind: source.lang.swift.decl.typealias,
key.name: "T",
key.usr: "s:4cake2S2V1Ta",
- key.offset: 1484,
+ key.offset: 1487,
key.length: 21,
key.fully_annotated_decl: "<decl.typealias><syntaxtype.keyword>typealias</syntaxtype.keyword> <ref.struct usr=\"s:4cake2S2V\">S2</ref.struct>.<decl.name>T</decl.name> = <ref.struct usr=\"s:4cake2S2V\">S2</ref.struct></decl.typealias>",
key.conforms: [
@@ -2174,7 +2174,7 @@
key.description: "T1.Element == C1.Element"
}
],
- key.offset: 1509,
+ key.offset: 1512,
key.length: 100,
key.fully_annotated_decl: "<decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>genfoo</decl.name><<decl.generic_type_param usr=\"s:4cake6genfooyx1x_q_1ytAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T1L_xmfp\"><decl.generic_type_param.name>T1</decl.generic_type_param.name></decl.generic_type_param>, <decl.generic_type_param usr=\"s:4cake6genfooyx1x_q_1ytAA4ProtRzAA2C1CRb_Si7ElementRtzr0_lF2T2L_q_mfp\"><decl.generic_type_param.name>T2</decl.generic_type_param.name></decl.generic_type_param>>(<decl.var.parameter><decl.var.parameter.argument_label>x</decl.var.parameter.argument_label> <decl.var.parameter.name>ix</decl.var.parameter.name>: <decl.var.parameter.type>T1</decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.argument_label>y</decl.var.parameter.argument_label> <decl.var.parameter.name>iy</decl.var.parameter.name>: <decl.var.parameter.type>T2</decl.var.parameter.type></decl.var.parameter>) <syntaxtype.keyword>where</syntaxtype.keyword> <decl.generic_type_requirement>T1 : <ref.protocol usr=\"s:4cake4ProtP\">Prot</ref.protocol></decl.generic_type_requirement>, <decl.generic_type_requirement>T2 : <ref.class usr=\"s:4cake2C1C\">C1</ref.class></decl.generic_type_requirement>, <decl.generic_type_requirement>T1.Element == <ref.class usr=\"s:4cake2C1C\">C1</ref.class>.<ref.typealias usr=\"s:4cake2C1C7Elementa\">Element</ref.typealias></decl.generic_type_requirement></decl.function.free>",
key.entities: [
@@ -2182,14 +2182,14 @@
key.kind: source.lang.swift.decl.var.local,
key.keyword: "x",
key.name: "ix",
- key.offset: 1535,
+ key.offset: 1538,
key.length: 2
},
{
key.kind: source.lang.swift.decl.var.local,
key.keyword: "y",
key.name: "iy",
- key.offset: 1545,
+ key.offset: 1548,
key.length: 2
}
]
diff --git a/test/SourceKit/DocumentStructure/mark_edit.swift.response b/test/SourceKit/DocumentStructure/mark_edit.swift.response
index 62e0e85..de19dc3 100644
--- a/test/SourceKit/DocumentStructure/mark_edit.swift.response
+++ b/test/SourceKit/DocumentStructure/mark_edit.swift.response
@@ -13,8 +13,6 @@
]
}
{
- key.offset: 0,
- key.length: 3,
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
key.substructure: [
{
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-block-comment.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-block-comment.swift
new file mode 100644
index 0000000..d3fe128
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-block-comment.swift
@@ -0,0 +1,5 @@
+
+let x = /*
+
+*/ 2
+func foo() {}
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-chained-comment.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-chained-comment.swift
new file mode 100644
index 0000000..42a1b54
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-chained-comment.swift
@@ -0,0 +1,5 @@
+let y = /*
+
+*// /*
+
+*/ 2
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-disjoint-effect.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-disjoint-effect.swift
new file mode 100644
index 0000000..b6e9f63
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-disjoint-effect.swift
@@ -0,0 +1,6 @@
+func getIt
+struct MyStruct {
+ func getChildStruct() -> String {
+ return ""
+ }
+}
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-multiline-string.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-multiline-string.swift
new file mode 100644
index 0000000..85143bd
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-multiline-string.swift
@@ -0,0 +1,12 @@
+let a = "value"
+let x = """
+
+\(
+a
+)
+
+
+
+func foo () -> String {
+ return "foo"
+}
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-nested-token.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-nested-token.swift
new file mode 100644
index 0000000..69c1432
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-nested-token.swift
@@ -0,0 +1,19 @@
+/// This function does stuff
+///
+/// - parameter first: The first parameter
+///
+/// - returns: The return value
+func foo(first: Int) -> String {
+ return ""
+}
+
+let x = "Changing this string should only affect this line"
+
+/// This function does other stuff
+///
+/// - parameter first: The first parameter
+///
+/// - returns: The return value
+func bar(first: Int) -> String {
+ return ""
+}
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-remove.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-remove.swift
new file mode 100644
index 0000000..b4ac2a5
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-edit-remove.swift
@@ -0,0 +1,4 @@
+let l = 2
+l
+\( 56
+)
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-multiple-edits.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-multiple-edits.swift
new file mode 100644
index 0000000..6c18bdc
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-multiple-edits.swift
@@ -0,0 +1,14 @@
+
+/// A comment
+/// - Note: important things
+let x = 42
+
+struct Point {
+ let x: Int = x
+ let y: Int = x
+
+ func mag2() {
+ return x*x + y*y;
+ }
+}
+
diff --git a/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-partial-delete.swift b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-partial-delete.swift
new file mode 100644
index 0000000..def3663
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/Inputs/syntaxmap-partial-delete.swift
@@ -0,0 +1,2 @@
+
+let x = 421
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-block-comment.swift b/test/SourceKit/SyntaxMapData/syntaxmap-edit-block-comment.swift
new file mode 100644
index 0000000..2304819
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-block-comment.swift
@@ -0,0 +1,98 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-edit-block-comment.swift == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-block-comment.swift -pos=4:2 -replace=" " -length=1 == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-block-comment.swift -pos=4:2 -replace="/" -length=1 == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-block-comment.swift -pos=1:1 -replace="//" -length=2 | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Initial state
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 34,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 3,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 7,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 11,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 18,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 20,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 25,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After removing the '/' from the comment close
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 11,
+// CHECK-NEXT: key.length: 23,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 11,
+// CHECK-NEXT: key.length: 23
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After adding the '/' back to the comment close
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 11,
+// CHECK-NEXT: key.length: 23,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 11,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 18,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 20,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 25,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// after adding a single-line comment on the line above
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 3,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-chained-comment.swift b/test/SourceKit/SyntaxMapData/syntaxmap-edit-chained-comment.swift
new file mode 100644
index 0000000..2718461
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-chained-comment.swift
@@ -0,0 +1,70 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-edit-chained-comment.swift == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-chained-comment.swift -pos=1:9 -replace=" " -length=1 == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-chained-comment.swift -pos=1:9 -replace="/" -length=1 | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Initial state
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 25,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 4,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 8,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 16,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 23,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+
+// After replacing the '/' from the comment open with ' '
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 8,
+// CHECK-NEXT: key.length: 14,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 13,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After adding the '/' back to the comment open
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 8,
+// CHECK-NEXT: key.length: 14,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 8,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.comment,
+// CHECK-NEXT: key.offset: 16,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response b/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response
index bc86f00..d0497be 100644
--- a/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response
@@ -29,7 +29,7 @@
}
{
key.offset: 1,
- key.length: 36,
+ key.length: 33,
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
key.syntaxmap: [
{
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response2 b/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response2
index ae9b915..4d92f16 100644
--- a/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response2
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-del.swift.response2
@@ -28,8 +28,6 @@
]
}
{
- key.offset: 36,
- key.length: 0,
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
key.syntaxmap: [
]
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-disjoint-effect.swift b/test/SourceKit/SyntaxMapData/syntaxmap-edit-disjoint-effect.swift
new file mode 100644
index 0000000..5eccc0e
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-disjoint-effect.swift
@@ -0,0 +1,70 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-edit-disjoint-effect.swift == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-disjoint-effect.swift -pos=1:11 -replace='(' -length=1 | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Original contents
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 86,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 5,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 12,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 19,
+// CHECK-NEXT: key.length: 8
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 32,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 37,
+// CHECK-NEXT: key.length: 14
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 57,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 70,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 77,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After opening the parameter list (without closing it)
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 12,
+// CHECK-NEXT: key.length: 51,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 12,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: }
+
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-multiline-string.swift b/test/SourceKit/SyntaxMapData/syntaxmap-edit-multiline-string.swift
new file mode 100644
index 0000000..e75fb30
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-multiline-string.swift
@@ -0,0 +1,137 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-edit-multiline-string.swift == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-multiline-string.swift -pos=8:1 -replace='"""' -length=3 == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-multiline-string.swift -pos=6:2 -replace=')' -length=1 == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-multiline-string.swift -pos=2:10 -replace=' ' -length=1 | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Original file contents
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 84,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 4,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 8,
+// CHECK-NEXT: key.length: 7
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 16,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 20,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 24,
+// CHECK-NEXT: key.length: 60
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After terminating the multiline string
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 24,
+// CHECK-NEXT: key.length: 60,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 24,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string_interpolation_anchor,
+// CHECK-NEXT: key.offset: 30,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 32,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string_interpolation_anchor,
+// CHECK-NEXT: key.offset: 34,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 35,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 43,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 48,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 58,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 69,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 76,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After adding a character after the interpolation
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 35,
+// CHECK-NEXT: key.length: 6,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 35,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After replacing the middle opening quote with a space
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 24,
+// CHECK-NEXT: key.length: 60,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 24,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 32,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 38,
+// CHECK-NEXT: key.length: 46
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-nested-token.swift b/test/SourceKit/SyntaxMapData/syntaxmap-edit-nested-token.swift
new file mode 100644
index 0000000..f266bff
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-nested-token.swift
@@ -0,0 +1,200 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-edit-nested-token.swift == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-nested-token.swift -pos=10:43 -replace='impact' -length=6 | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Original file contents
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 386,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 29
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 29,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 33,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment.field,
+// CHECK-NEXT: key.offset: 39,
+// CHECK-NEXT: key.length: 9
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 48,
+// CHECK-NEXT: key.length: 28
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 76,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 80,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment.field,
+// CHECK-NEXT: key.offset: 86,
+// CHECK-NEXT: key.length: 7
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 93,
+// CHECK-NEXT: key.length: 19
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 112,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 117,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 121,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 128,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 136,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 147,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 154,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 160,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 164,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 168,
+// CHECK-NEXT: key.length: 51
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 221,
+// CHECK-NEXT: key.length: 35
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 256,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 260,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment.field,
+// CHECK-NEXT: key.offset: 266,
+// CHECK-NEXT: key.length: 9
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 275,
+// CHECK-NEXT: key.length: 28
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 303,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 307,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment.field,
+// CHECK-NEXT: key.offset: 313,
+// CHECK-NEXT: key.length: 7
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 320,
+// CHECK-NEXT: key.length: 19
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 339,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 344,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 348,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 355,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 363,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 374,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 381,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After editing a string in between nested comments
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 168,
+// CHECK-NEXT: key.length: 51,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.string,
+// CHECK-NEXT: key.offset: 168,
+// CHECK-NEXT: key.length: 51
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit-remove.swift b/test/SourceKit/SyntaxMapData/syntaxmap-edit-remove.swift
new file mode 100644
index 0000000..b6314c2
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit-remove.swift
@@ -0,0 +1,57 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-edit-remove.swift == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-remove.swift -pos=3:3 -length=1 -replace='' == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-remove.swift -pos=2:1 -replace='' -length=1 == -req=edit -print-raw-response %S/Inputs/syntaxmap-edit-remove.swift -pos=1:9 -length=1 -replace='' | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Initial state
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 20,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 4,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 8,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 10,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 15,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After removing the space before the '56'
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: ],
+
+// After deleting the identifier 'l'
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: ],
+
+// After deleting the last token on the first line
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: ],
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-edit.swift.response b/test/SourceKit/SyntaxMapData/syntaxmap-edit.swift.response
index 39c0de8..0f55ca4 100644
--- a/test/SourceKit/SyntaxMapData/syntaxmap-edit.swift.response
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-edit.swift.response
@@ -41,16 +41,11 @@
]
}
{
- key.offset: 81,
- key.length: 15,
+ key.offset: 87,
+ key.length: 6,
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
key.syntaxmap: [
{
- key.kind: source.lang.swift.syntaxtype.keyword,
- key.offset: 81,
- key.length: 5
- },
- {
key.kind: source.lang.swift.syntaxtype.identifier,
key.offset: 87,
key.length: 6
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-multiple-edits.swift b/test/SourceKit/SyntaxMapData/syntaxmap-multiple-edits.swift
new file mode 100644
index 0000000..cf14f45
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-multiple-edits.swift
@@ -0,0 +1,251 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-multiple-edits.swift == -req=edit -print-raw-response -pos=6:13 -length=1 -replace=" " %S/Inputs/syntaxmap-multiple-edits.swift == -req="edit" -pos=14:1 -length=0 -replace="let y = 2" -print-raw-response %S/Inputs/syntaxmap-multiple-edits.swift == -req="edit" -pos=8:10 -length=7 -replace='Int64 = 3; let z = 2' -print-raw-response %S/Inputs/syntaxmap-multiple-edits.swift == -req="edit" -pos=4:9 -length=2 -replace='50 * 95 - 100' -print-raw-response %S/Inputs/syntaxmap-multiple-edits.swift == -req="edit" -pos=1:1 -length=0 -replace='func firstFunc(x: Int) {}' -print-raw-response %S/Inputs/syntaxmap-multiple-edits.swift | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// Initial syntax map
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 152,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 2,
+// CHECK-NEXT: key.length: 14
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 16,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment.field,
+// CHECK-NEXT: key.offset: 22,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.doccomment,
+// CHECK-NEXT: key.offset: 26,
+// CHECK-NEXT: key.length: 19
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 45,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 49,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 53,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 57,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 64,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 74,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 78,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 81,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 87,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 91,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 95,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 98,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 104,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 109,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 114,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 127,
+// CHECK-NEXT: key.length: 6
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 134,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 136,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 140,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 142,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After replacing a space with a space
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: ],
+
+// After adding code at the end of the file
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 151,
+// CHECK-NEXT: key.length: 9,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 151,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 155,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 159,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+
+// After inserting more than we removed
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 98,
+// CHECK-NEXT: key.length: 20,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 98,
+// CHECK-NEXT: key.length: 5
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 106,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 109,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 113,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 117,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After inserting less than we removed
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 53,
+// CHECK-NEXT: key.length: 13,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 53,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 58,
+// CHECK-NEXT: key.length: 2
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 63,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+// After adding code at the start of the file
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 21,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 4
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 5,
+// CHECK-NEXT: key.length: 9
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 15,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.typeidentifier,
+// CHECK-NEXT: key.offset: 18,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
diff --git a/test/SourceKit/SyntaxMapData/syntaxmap-partial-delete.swift b/test/SourceKit/SyntaxMapData/syntaxmap-partial-delete.swift
new file mode 100644
index 0000000..3f065ea
--- /dev/null
+++ b/test/SourceKit/SyntaxMapData/syntaxmap-partial-delete.swift
@@ -0,0 +1,39 @@
+// RUN: %sourcekitd-test -req=open -print-raw-response %S/Inputs/syntaxmap-partial-delete.swift == -req=edit -print-raw-response -pos=2:10 -length=2 -replace='' %S/Inputs/syntaxmap-partial-delete.swift | %sed_clean > %t.response
+// RUN: %FileCheck -input-file=%t.response %s
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 0,
+// CHECK-NEXT: key.length: 13,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.keyword,
+// CHECK-NEXT: key.offset: 1,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.identifier,
+// CHECK-NEXT: key.offset: 5,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 9,
+// CHECK-NEXT: key.length: 3
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
+
+
+// After removing 2 chars from number literal
+
+// CHECK: {{^}}{
+// CHECK-NEXT: key.offset: 9,
+// CHECK-NEXT: key.length: 1,
+// CHECK-NEXT: key.diagnostic_stage: source.diagnostic.stage.swift.parse,
+// CHECK-NEXT: key.syntaxmap: [
+// CHECK-NEXT: {
+// CHECK-NEXT: key.kind: source.lang.swift.syntaxtype.number,
+// CHECK-NEXT: key.offset: 9,
+// CHECK-NEXT: key.length: 1
+// CHECK-NEXT: }
+// CHECK-NEXT: ],
diff --git a/test/attr/accessibility_print.swift b/test/attr/accessibility_print.swift
index b4eb3a1..2785b7e 100644
--- a/test/attr/accessibility_print.swift
+++ b/test/attr/accessibility_print.swift
@@ -94,7 +94,7 @@
case Foo, Bar
// CHECK: internal init()
init() { self = .Foo }
- // CHECK: internal var hashValue
+ // CHECK: private var hashValue
} // CHECK: {{^[}]}}
// CHECK-LABEL: internal{{(\*/)?}} enum DB_InternalEnum {
diff --git a/test/attr/attr_inlineable.swift b/test/attr/attr_inlineable.swift
index fbfa2aa..d675917 100644
--- a/test/attr/attr_inlineable.swift
+++ b/test/attr/attr_inlineable.swift
@@ -182,3 +182,22 @@
let _: VersionedEnum = .orange
_ = VersionedEnum.persimmon
}
+
+// Inherited initializers - <rdar://problem/34398148>
+@_versioned
+class Base {
+ @_versioned
+ init(x: Int) {}
+}
+
+@_versioned
+class Middle : Base {}
+
+@_versioned
+class Derived : Middle {
+ @_versioned
+ @_inlineable
+ init(y: Int) {
+ super.init(x: y)
+ }
+}
diff --git a/test/attr/attr_objc.swift b/test/attr/attr_objc.swift
index 74a3124..7fe75bd 100644
--- a/test/attr/attr_objc.swift
+++ b/test/attr/attr_objc.swift
@@ -2182,11 +2182,11 @@
// CHECK-LABEL: @objc class OperatorInClass
@objc class OperatorInClass {
- // CHECK: {{^}} static func ==(lhs: OperatorInClass, rhs: OperatorInClass) -> Bool
+ // CHECK: {{^}} static func == (lhs: OperatorInClass, rhs: OperatorInClass) -> Bool
static func ==(lhs: OperatorInClass, rhs: OperatorInClass) -> Bool {
return true
}
- // CHECK: {{^}} @objc static func +(lhs: OperatorInClass, rhs: OperatorInClass) -> OperatorInClass
+ // CHECK: {{^}} @objc static func + (lhs: OperatorInClass, rhs: OperatorInClass) -> OperatorInClass
@objc static func +(lhs: OperatorInClass, rhs: OperatorInClass) -> OperatorInClass { // expected-error {{operator methods cannot be declared @objc}}
return lhs
}
diff --git a/test/attr/attr_versioned.swift b/test/attr/attr_versioned.swift
index 1a5682e..3a6fe43 100644
--- a/test/attr/attr_versioned.swift
+++ b/test/attr/attr_versioned.swift
@@ -45,3 +45,23 @@
@_versioned func versionedRequirement() -> T
// expected-error@-1 {{'@_versioned' attribute cannot be used in protocols}}
}
+
+// Derived conformances had issues with @_versioned - rdar://problem/34342955
+@_versioned
+internal enum EqEnum {
+ case foo
+}
+
+@_versioned
+internal enum RawEnum : Int {
+ case foo = 0
+}
+
+@_inlineable
+public func usesEqEnum() -> Bool {
+ _ = (EqEnum.foo == .foo)
+ _ = EqEnum.foo.hashValue
+
+ _ = RawEnum.foo.rawValue
+ _ = RawEnum(rawValue: 0)
+}
diff --git a/test/decl/protocol/recursive_requirement_ok.swift b/test/decl/protocol/recursive_requirement_ok.swift
index 2266500..63851eb 100644
--- a/test/decl/protocol/recursive_requirement_ok.swift
+++ b/test/decl/protocol/recursive_requirement_ok.swift
@@ -84,3 +84,11 @@
// CHECK: Generic signature: <Self, T where Self : P11, T : P11, Self.Q == T.Q>
func map<T>(_: T.Type) where T : P11, Q == T.Q
}
+
+// Redundances within a requirement signature.
+protocol P12 { }
+
+protocol P13 {
+ associatedtype AT1 : P12
+ associatedtype AT2: P13 where AT2.AT1 == AT1
+}
diff --git a/test/decl/var/properties.swift b/test/decl/var/properties.swift
index a0b1f07..a9cc4a6 100644
--- a/test/decl/var/properties.swift
+++ b/test/decl/var/properties.swift
@@ -469,7 +469,7 @@
}
extension ProtocolWithExtension1 {
var fooExt: Int // expected-error{{extensions may not contain stored properties}}
- static var fooExtStatic = 4 // expected-error{{static stored properties not supported in generic types}}
+ static var fooExtStatic = 4 // expected-error{{static stored properties not supported in protocol extensions}}
}
func getS() -> S {
diff --git a/test/expr/postfix/dot/dot_keywords.swift b/test/expr/postfix/dot/dot_keywords.swift
index 705ca21..ba2821f 100644
--- a/test/expr/postfix/dot/dot_keywords.swift
+++ b/test/expr/postfix/dot/dot_keywords.swift
@@ -1,4 +1,4 @@
-// RUN: %target-typecheck-verify-swift
+// RUN: %target-typecheck-verify-swift -swift-version 4
let x: Int = 1
let y: Int = x.self
@@ -77,3 +77,31 @@
let instanceWithDeinitMember = ClassWithDeinitMember()
_ = instanceWithDeinitMember.deinit
+
+
+// SR-5715 : Fix variable name in nested static value
+struct SR5715 {
+ struct A {
+ struct B {}
+ }
+}
+
+extension SR5715.A.B {
+ private static let x: Int = 5
+
+ func f() -> Int {
+ return x // expected-error {{static member 'x' cannot be used on instance of type 'SR5715.A.B'}} {{12-12=SR5715.A.B.}}
+ }
+}
+
+// Static function in protocol should have `Self.` instead of its protocol name
+protocol P {}
+
+extension P {
+ static func f() {}
+
+ func g() {
+ f() // expected-error {{static member 'f' cannot be used on instance of type 'Self'}} {{5-5=Self.}}
+ }
+}
+
diff --git a/test/expr/unary/keypath/keypath-unimplemented.swift b/test/expr/unary/keypath/keypath-unimplemented.swift
index b4fdaa3..4791e87 100644
--- a/test/expr/unary/keypath/keypath-unimplemented.swift
+++ b/test/expr/unary/keypath/keypath-unimplemented.swift
@@ -9,10 +9,6 @@
var i = 0
}
-func unsupportedComponents() {
- _ = \A.[0] // expected-error{{key path support for subscript components is not implemented}}
-}
-
// rdar://problem/32209039 - Improve diagnostic when unsupported tuple element references are used in key path literals
let _ = \(Int, String).0 // expected-error {{key path cannot reference tuple elements}}
let _ = \(a: Int, b: String).b // expected-error {{key path cannot reference tuple elements}}
diff --git a/test/expr/unary/keypath/keypath.swift b/test/expr/unary/keypath/keypath.swift
index fdbb755..3b7f36c 100644
--- a/test/expr/unary/keypath/keypath.swift
+++ b/test/expr/unary/keypath/keypath.swift
@@ -1,10 +1,21 @@
-// RUN: %target-swift-frontend -typecheck -parse-as-library -enable-experimental-keypath-components %s -verify
+// RUN: %target-swift-frontend -typecheck -parse-as-library %s -verify
-struct Sub {}
-struct OptSub {}
+struct Sub: Hashable {
+ static func ==(_: Sub, _: Sub) -> Bool { return true }
+ var hashValue: Int { return 0 }
+}
+struct OptSub: Hashable {
+ static func ==(_: OptSub, _: OptSub) -> Bool { return true }
+ var hashValue: Int { return 0 }
+}
+struct NonHashableSub {}
+
struct Prop {
subscript(sub: Sub) -> A { get { return A() } set { } }
subscript(optSub: OptSub) -> A? { get { return A() } set { } }
+ subscript(nonHashableSub: NonHashableSub) -> A { get { return A() } set { } }
+ subscript(a: Sub, b: Sub) -> A { get { return A() } set { } }
+ subscript(a: Sub, b: NonHashableSub) -> A { get { return A() } set { } }
var nonMutatingProperty: B {
get { fatalError() }
@@ -27,19 +38,25 @@
struct B {}
struct C<T> {
var value: T
+ subscript() -> T { get { return value } }
subscript(sub: Sub) -> T { get { return value } set { } }
- subscript<U>(sub: U) -> U { get { return sub } set { } }
+ subscript<U: Hashable>(sub: U) -> U { get { return sub } set { } }
+ subscript<X>(noHashableConstraint sub: X) -> X { get { return sub } set { } }
}
extension Array where Element == A {
var property: Prop { fatalError() }
}
+protocol P { var member: String { get } }
+extension B : P { var member : String { return "Member Value" } }
+
struct Exactly<T> {}
func expect<T>(_ x: inout T, toHaveType _: Exactly<T>.Type) {}
-func testKeyPath(sub: Sub, optSub: OptSub, x: Int) {
+func testKeyPath(sub: Sub, optSub: OptSub,
+ nonHashableSub: NonHashableSub, x: Int) {
var a = \A.property
expect(&a, toHaveType: Exactly<WritableKeyPath<A, Prop>>.self)
@@ -152,6 +169,21 @@
let _: AnyKeyPath = \.property // expected-error{{ambiguous}}
let _: AnyKeyPath = \C.value // expected-error{{cannot convert}} (need to improve diagnostic)
let _: AnyKeyPath = \.value // expected-error{{ambiguous}}
+
+ let _ = \Prop.[nonHashableSub] // expected-error{{subscript index of type 'NonHashableSub' in a key path must be Hashable}}
+ let _ = \Prop.[sub, sub]
+ let _ = \Prop.[sub, nonHashableSub] // expected-error{{subscript index of type 'NonHashableSub' in a key path must be Hashable}}
+
+ let _ = \C<Int>.[]
+ let _ = \C<Int>.[sub]
+ let _ = \C<Int>.[noHashableConstraint: sub]
+ let _ = \C<Int>.[noHashableConstraint: nonHashableSub] // expected-error{{subscript index of type 'NonHashableSub' in a key path must be Hashable}}
+}
+
+func testKeyPathInGenericContext<H: Hashable, X>(hashable: H, anything: X) {
+ let _ = \C<Int>.[hashable]
+ let _ = \C<Int>.[noHashableConstraint: hashable]
+ let _ = \C<Int>.[noHashableConstraint: anything] // expected-error{{subscript index of type 'X' in a key path must be Hashable}}
}
func testDisembodiedStringInterpolation(x: Int) {
@@ -326,6 +358,11 @@
_ = base[keyPath: kp]
}
+func testKeyPathSubscriptExistentialBase(base: B, kp: KeyPath<P, String>) {
+ _ = base[keyPath: kp]
+}
+
+
struct AA {
subscript(x: Int) -> Int { return x }
subscript(labeled x: Int) -> Int { return x }
diff --git a/test/lit.cfg b/test/lit.cfg
index 1dbaefc..12a5315 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -908,17 +908,24 @@
source_compiler_rt_libs(os.path.join(test_resource_dir, 'clang', 'lib',
platform.system().lower()))
-def check_runtime_feature(name):
+def check_runtime_libs(features_to_check):
for lib in config.compiler_rt_libs:
- if lib.startswith('libclang_rt.' + name + '_'):
- config.available_features.add(name + '_runtime')
- return
+ for (libname, feature) in features_to_check:
+ if lib.startswith("libclang_rt." + libname + "_"):
+ config.available_features.add(feature)
-check_runtime_feature('profile')
-check_runtime_feature('asan')
-check_runtime_feature('ubsan')
-check_runtime_feature('tsan')
-check_runtime_feature('safestack')
+runtime_libs = [
+ ('profile', 'profile_runtime'),
+ ('asan', 'asan_runtime'),
+ ('ubsan', 'ubsan_runtime'),
+ ('tsan', 'tsan_runtime'),
+ ('safestack', 'safestack_runtime')
+]
+
+if run_ptrsize != "32":
+ runtime_libs.append(('tsan', 'tsan_runtime'))
+
+check_runtime_libs(runtime_libs)
if not getattr(config, 'target_run_simple_swift', None):
config.target_run_simple_swift = (
diff --git a/test/multifile/imported-conformance/option-set/library.swift b/test/multifile/imported-conformance/option-set/library.swift
new file mode 100644
index 0000000..d0894c2
--- /dev/null
+++ b/test/multifile/imported-conformance/option-set/library.swift
@@ -0,0 +1,8 @@
+// RUN: true
+
+import Foundation
+
+@inline(__always)
+public func replace(rgx: NSRegularExpression, in: String, with: String, x: NSRange) -> String {
+ return rgx.stringByReplacingMatches(in: `in`, options: [], range: x, withTemplate: with)
+}
diff --git a/test/multifile/imported-conformance/option-set/main.swift b/test/multifile/imported-conformance/option-set/main.swift
new file mode 100644
index 0000000..fa06202
--- /dev/null
+++ b/test/multifile/imported-conformance/option-set/main.swift
@@ -0,0 +1,15 @@
+// RUN: %empty-directory(%t)
+
+// RUN: %empty-directory(%t/linker)
+// RUN: %target-build-swift -emit-module -emit-library %S/library.swift -o %t/linker/liblibrary.%target-dylib-extension -emit-module-path %t/linker/library.swiftmodule -module-name library
+// RUN: %target-build-swift %S/main.swift -I %t/linker/ -L %t/linker/ -llibrary -o %t/linker/main
+
+// REQUIRES: executable_test
+// REQUIRES: objc_interop
+
+import Foundation
+import library
+
+public func rreplace(rgx: NSRegularExpression, in: String, with: String, x: NSRange) -> String {
+ return replace(rgx: rgx, in: `in`, with: with, x: x)
+}
diff --git a/test/refactoring/CollapseNestedIf/Outputs/basic/L15-3.swift.expected b/test/refactoring/CollapseNestedIf/Outputs/basic/L15-3.swift.expected
new file mode 100644
index 0000000..7b6ac3e
--- /dev/null
+++ b/test/refactoring/CollapseNestedIf/Outputs/basic/L15-3.swift.expected
@@ -0,0 +1,22 @@
+func testCollapseNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ }
+}
+func testMultiConditionalNestedIf() {
+ let a = 3
+ if a > 2, a != 4 {
+ if a < 10, a != 5 {}
+ }
+}
+func testLetNestedIf() {
+ let a: Int? = 3
+ if let b = a, b != 5 {}
+}
+func testCaseLetNestedIf() {
+ let a: Int? = 3
+ if case .some(let b) = a {
+ if b != 5 {}
+ }
+}
diff --git a/test/refactoring/CollapseNestedIf/Outputs/basic/L21-3.swift.expected b/test/refactoring/CollapseNestedIf/Outputs/basic/L21-3.swift.expected
new file mode 100644
index 0000000..4a7870c
--- /dev/null
+++ b/test/refactoring/CollapseNestedIf/Outputs/basic/L21-3.swift.expected
@@ -0,0 +1,22 @@
+func testCollapseNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ }
+}
+func testMultiConditionalNestedIf() {
+ let a = 3
+ if a > 2, a != 4 {
+ if a < 10, a != 5 {}
+ }
+}
+func testLetNestedIf() {
+ let a: Int? = 3
+ if let b = a {
+ if b != 5 {}
+ }
+}
+func testCaseLetNestedIf() {
+ let a: Int? = 3
+ if case .some(let b) = a, b != 5 {}
+}
diff --git a/test/refactoring/CollapseNestedIf/Outputs/basic/L3-3.swift.expected b/test/refactoring/CollapseNestedIf/Outputs/basic/L3-3.swift.expected
new file mode 100644
index 0000000..6d06314
--- /dev/null
+++ b/test/refactoring/CollapseNestedIf/Outputs/basic/L3-3.swift.expected
@@ -0,0 +1,22 @@
+func testCollapseNestedIf() {
+ let a = 3
+ if a > 2, a < 10 {}
+}
+func testMultiConditionalNestedIf() {
+ let a = 3
+ if a > 2, a != 4 {
+ if a < 10, a != 5 {}
+ }
+}
+func testLetNestedIf() {
+ let a: Int? = 3
+ if let b = a {
+ if b != 5 {}
+ }
+}
+func testCaseLetNestedIf() {
+ let a: Int? = 3
+ if case .some(let b) = a {
+ if b != 5 {}
+ }
+}
diff --git a/test/refactoring/CollapseNestedIf/Outputs/basic/L9-3.swift.expected b/test/refactoring/CollapseNestedIf/Outputs/basic/L9-3.swift.expected
new file mode 100644
index 0000000..9d0c817
--- /dev/null
+++ b/test/refactoring/CollapseNestedIf/Outputs/basic/L9-3.swift.expected
@@ -0,0 +1,22 @@
+func testCollapseNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ }
+}
+func testMultiConditionalNestedIf() {
+ let a = 3
+ if a > 2, a != 4, a < 10, a != 5 {}
+}
+func testLetNestedIf() {
+ let a: Int? = 3
+ if let b = a {
+ if b != 5 {}
+ }
+}
+func testCaseLetNestedIf() {
+ let a: Int? = 3
+ if case .some(let b) = a {
+ if b != 5 {}
+ }
+}
diff --git a/test/refactoring/CollapseNestedIf/basic.swift b/test/refactoring/CollapseNestedIf/basic.swift
new file mode 100644
index 0000000..cbc728d
--- /dev/null
+++ b/test/refactoring/CollapseNestedIf/basic.swift
@@ -0,0 +1,33 @@
+func testCollapseNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ }
+}
+func testMultiConditionalNestedIf() {
+ let a = 3
+ if a > 2, a != 4 {
+ if a < 10, a != 5 {}
+ }
+}
+func testLetNestedIf() {
+ let a: Int? = 3
+ if let b = a {
+ if b != 5 {}
+ }
+}
+func testCaseLetNestedIf() {
+ let a: Int? = 3
+ if case .some(let b) = a {
+ if b != 5 {}
+ }
+}
+// RUN: rm -rf %t.result && mkdir -p %t.result
+// RUN: %refactor -collapse-nested-if -source-filename %s -pos=3:3 > %t.result/L3-3.swift
+// RUN: diff -u %S/Outputs/basic/L3-3.swift.expected %t.result/L3-3.swift
+// RUN: %refactor -collapse-nested-if -source-filename %s -pos=9:3 > %t.result/L9-3.swift
+// RUN: diff -u %S/Outputs/basic/L9-3.swift.expected %t.result/L9-3.swift
+// RUN: %refactor -collapse-nested-if -source-filename %s -pos=15:3 > %t.result/L15-3.swift
+// RUN: diff -u %S/Outputs/basic/L15-3.swift.expected %t.result/L15-3.swift
+// RUN: %refactor -collapse-nested-if -source-filename %s -pos=21:3 > %t.result/L21-3.swift
+// RUN: diff -u %S/Outputs/basic/L21-3.swift.expected %t.result/L21-3.swift
diff --git a/test/refactoring/RefactoringKind/basic.swift b/test/refactoring/RefactoringKind/basic.swift
index 0e1276c..ba3135a 100644
--- a/test/refactoring/RefactoringKind/basic.swift
+++ b/test/refactoring/RefactoringKind/basic.swift
@@ -174,6 +174,35 @@
return "abc"
}
+func testCollapseNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ }
+}
+
+func testMultiConditionalNestedIf() {
+ let a = 3
+ if a > 2, a != 4 {
+ if a < 10 {}
+ }
+}
+
+func testExtraDeclNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ let b = 0
+ }
+}
+
+func testExtraIfNestedIf() {
+ let a = 3
+ if a > 2 {
+ if a < 10 {}
+ let b = 0
+ }
+}
// RUN: %refactor -source-filename %s -pos=2:1 -end-pos=5:13 | %FileCheck %s -check-prefix=CHECK1
// RUN: %refactor -source-filename %s -pos=3:1 -end-pos=5:13 | %FileCheck %s -check-prefix=CHECK1
// RUN: %refactor -source-filename %s -pos=4:1 -end-pos=5:13 | %FileCheck %s -check-prefix=CHECK1
@@ -245,6 +274,11 @@
// RUN: %refactor -source-filename %s -pos=173:3 -end-pos=173:27| %FileCheck %s -check-prefix=CHECK-EXTRCT-METHOD
+// RUN: %refactor -source-filename %s -pos=179:3 | %FileCheck %s -check-prefix=CHECK-COLLAPSE-NESTED-IF-EXPRESSION
+// RUN: %refactor -source-filename %s -pos=186:3 | %FileCheck %s -check-prefix=CHECK-COLLAPSE-NESTED-IF-EXPRESSION
+// RUN: %refactor -source-filename %s -pos=193:3 | %FileCheck %s -check-prefix=CHECK-NONE
+// RUN: %refactor -source-filename %s -pos=201:3 | %FileCheck %s -check-prefix=CHECK-NONE
+
// CHECK1: Action begins
// CHECK1-NEXT: Extract Method
// CHECK1-NEXT: Action ends
@@ -279,3 +313,5 @@
// CHECK-EXTRCT-METHOD-NEXT: Action ends
// CHECK-LOCALIZE-STRING: Localize String
+
+// CHECK-COLLAPSE-NESTED-IF-EXPRESSION: Collapse Nested If Expression
diff --git a/test/stdlib/CharacterTraps.swift b/test/stdlib/CharacterTraps.swift
index 3bddb57..823bb35 100644
--- a/test/stdlib/CharacterTraps.swift
+++ b/test/stdlib/CharacterTraps.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/DictionaryTraps.swift b/test/stdlib/DictionaryTraps.swift
index ac0bb18..e03f10e 100644
--- a/test/stdlib/DictionaryTraps.swift
+++ b/test/stdlib/DictionaryTraps.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/IntervalTraps.swift b/test/stdlib/IntervalTraps.swift
index 9b8c2df..0e530c8 100644
--- a/test/stdlib/IntervalTraps.swift
+++ b/test/stdlib/IntervalTraps.swift
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/KeyPath.swift b/test/stdlib/KeyPath.swift
index fcfc008..478116e 100644
--- a/test/stdlib/KeyPath.swift
+++ b/test/stdlib/KeyPath.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -Xfrontend -enable-sil-ownership -Xfrontend -enable-experimental-keypath-components -o %t/a.out
+// RUN: %target-build-swift %s -Xfrontend -enable-sil-ownership -Xfrontend -g -o %t/a.out
// RUN: %target-run %t/a.out
// REQUIRES: executable_test
@@ -546,4 +546,125 @@
expectEqual(kp1.hashValue, kp2.hashValue)
}
+struct SubscriptResult<T: Hashable, U: Hashable> {
+ var canary = LifetimeTracked(3333)
+ var left: T
+ var right: U
+
+ init(left: T, right: U) {
+ self.left = left
+ self.right = right
+ }
+
+ subscript(left: T) -> Bool {
+ return self.left == left
+ }
+ subscript(right: U) -> Bool {
+ return self.right == right
+ }
+}
+
+struct Subscripts<T: Hashable> {
+ var canary = LifetimeTracked(4444)
+
+ subscript<U: Hashable>(x: T, y: U) -> SubscriptResult<T, U> {
+ return SubscriptResult(left: x, right: y)
+ }
+
+ subscript(x: Int, y: Int) -> Int {
+ return x + y
+ }
+}
+
+struct KeyA: Hashable {
+ var canary = LifetimeTracked(1111)
+ var value: String
+
+ init(value: String) { self.value = value }
+
+ static func ==(a: KeyA, b: KeyA) -> Bool { return a.value == b.value }
+ var hashValue: Int { return value.hashValue }
+}
+struct KeyB: Hashable {
+ var canary = LifetimeTracked(2222)
+
+ var value: Int
+
+ init(value: Int) { self.value = value }
+
+ static func ==(a: KeyB, b: KeyB) -> Bool { return a.value == b.value }
+ var hashValue: Int { return value.hashValue }
+}
+
+func fullGenericContext<T: Hashable, U: Hashable>(x: T, y: U) -> KeyPath<Subscripts<T>, SubscriptResult<T, U>> {
+ return \Subscripts<T>.[x, y]
+}
+
+func halfGenericContext<U: Hashable>(x: KeyA, y: U) -> KeyPath<Subscripts<KeyA>, SubscriptResult<KeyA, U>> {
+ return \Subscripts<KeyA>.[x, y]
+}
+
+func nonGenericContext(x: KeyA, y: KeyB) -> KeyPath<Subscripts<KeyA>, SubscriptResult<KeyA, KeyB>> {
+ return \Subscripts<KeyA>.[x, y]
+}
+
+keyPath.test("subscripts") {
+ let a = fullGenericContext(x: KeyA(value: "hey"), y: KeyB(value: 1738))
+ let b = halfGenericContext(x: KeyA(value: "hey"), y: KeyB(value: 1738))
+ let c = nonGenericContext(x: KeyA(value: "hey"), y: KeyB(value: 1738))
+
+ expectEqual(a, b)
+ expectEqual(a, c)
+ expectEqual(b, a)
+ expectEqual(b, c)
+ expectEqual(c, a)
+ expectEqual(c, b)
+ expectEqual(a.hashValue, b.hashValue)
+ expectEqual(a.hashValue, c.hashValue)
+ expectEqual(b.hashValue, a.hashValue)
+ expectEqual(b.hashValue, c.hashValue)
+ expectEqual(c.hashValue, a.hashValue)
+ expectEqual(c.hashValue, b.hashValue)
+
+ let base = Subscripts<KeyA>()
+
+ let kp2 = \SubscriptResult<KeyA, KeyB>.[KeyA(value: "hey")]
+
+ for kp in [a, b, c] {
+ let projected = base[keyPath: kp]
+ expectEqual(projected.left.value, "hey")
+ expectEqual(projected.right.value, 1738)
+
+ expectEqual(projected[keyPath: kp2], true)
+
+ let kp12 =
+ \Subscripts<KeyA>.[KeyA(value: "hey"), KeyB(value: 1738)][KeyA(value: "hey")]
+
+ let kp12a = kp.appending(path: kp2)
+
+ expectEqual(kp12, kp12a)
+ expectEqual(kp12a, kp12)
+ expectEqual(kp12.hashValue, kp12a.hashValue)
+ }
+
+ let ints = \Subscripts<KeyA>.[17, 38]
+ let ints2 = \Subscripts<KeyA>.[17, 38]
+ let ints3 = \Subscripts<KeyA>.[38, 17]
+ expectEqual(base[keyPath: ints], 17 + 38)
+
+ expectEqual(ints, ints2)
+ expectEqual(ints2, ints)
+ expectNotEqual(ints, ints3)
+ expectNotEqual(ints2, ints3)
+ expectNotEqual(ints3, ints)
+ expectNotEqual(ints3, ints2)
+
+ expectEqual(ints.hashValue, ints2.hashValue)
+
+ let ints_be = ints.appending(path: \Int.bigEndian)
+
+ expectEqual(base[keyPath: ints_be], (17 + 38).bigEndian)
+}
+
runAllTests()
+
diff --git a/test/stdlib/KeyPathImplementation.swift b/test/stdlib/KeyPathImplementation.swift
index 7d166e2..8ccde01 100644
--- a/test/stdlib/KeyPathImplementation.swift
+++ b/test/stdlib/KeyPathImplementation.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -g -Xfrontend -enable-experimental-keypath-components -o %t/a.out
+// RUN: %target-build-swift %s -g -o %t/a.out
// RUN: %target-run %t/a.out
// REQUIRES: executable_test
diff --git a/test/stdlib/KeyPathObjC.swift b/test/stdlib/KeyPathObjC.swift
index aface86..787b325 100644
--- a/test/stdlib/KeyPathObjC.swift
+++ b/test/stdlib/KeyPathObjC.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -Xfrontend -enable-experimental-keypath-components -o %t/a.out
+// RUN: %target-build-swift %s -o %t/a.out
// RUN: %target-run %t/a.out
// REQUIRES: executable_test
// REQUIRES: objc_interop
diff --git a/test/stdlib/MediaPlayer.swift b/test/stdlib/MediaPlayer.swift
index 597cd03..2265d94 100644
--- a/test/stdlib/MediaPlayer.swift
+++ b/test/stdlib/MediaPlayer.swift
@@ -2,6 +2,7 @@
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: OS=ios
+// REQUIRES: rdar34462543
import MediaPlayer
import StdlibUnittest
diff --git a/test/stdlib/RangeTraps.swift b/test/stdlib/RangeTraps.swift
index ce8b07c..865f940 100644
--- a/test/stdlib/RangeTraps.swift
+++ b/test/stdlib/RangeTraps.swift
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/SetTraps.swift b/test/stdlib/SetTraps.swift
index 2e06b8b..a1c3a77 100644
--- a/test/stdlib/SetTraps.swift
+++ b/test/stdlib/SetTraps.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/SetTrapsObjC.swift b/test/stdlib/SetTrapsObjC.swift
index da7f065..4c19c76 100644
--- a/test/stdlib/SetTrapsObjC.swift
+++ b/test/stdlib/SetTrapsObjC.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/StringTraps.swift b/test/stdlib/StringTraps.swift
index 92be21b..2a8ce0f 100644
--- a/test/stdlib/StringTraps.swift
+++ b/test/stdlib/StringTraps.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/test/stdlib/TestData.swift b/test/stdlib/TestData.swift
index f8482e3..0322aa9 100644
--- a/test/stdlib/TestData.swift
+++ b/test/stdlib/TestData.swift
@@ -31,7 +31,71 @@
class TestData : TestDataSuper {
- // This is a type of Data that starts off as a storage of all 0x01s, but it only creates that buffer when needed. When mutated it converts into a more traditional data storage backed by a buffer.
+ class AllOnesImmutableData : NSData {
+ private var _length : Int
+ var _pointer : UnsafeMutableBufferPointer<UInt8>? {
+ willSet {
+ if let p = _pointer { free(p.baseAddress) }
+ }
+ }
+
+ init(length : Int) {
+ _length = length
+ super.init()
+ }
+
+ required init?(coder aDecoder: NSCoder) {
+ // Not tested
+ fatalError()
+ }
+
+ deinit {
+ if let p = _pointer {
+ free(p.baseAddress)
+ }
+ }
+
+ override var length : Int {
+ get {
+ return _length
+ }
+ }
+
+ override var bytes : UnsafeRawPointer {
+ if let d = _pointer {
+ return UnsafeRawPointer(d.baseAddress!)
+ } else {
+ // Need to allocate the buffer now.
+ // It doesn't matter if the buffer is uniquely referenced or not here.
+ let buffer = malloc(length)
+ memset(buffer, 1, length)
+ let bytePtr = buffer!.bindMemory(to: UInt8.self, capacity: length)
+ let result = UnsafeMutableBufferPointer(start: bytePtr, count: length)
+ _pointer = result
+ return UnsafeRawPointer(result.baseAddress!)
+ }
+ }
+
+ override func getBytes(_ buffer: UnsafeMutableRawPointer, length: Int) {
+ if let d = _pointer {
+ // Get the real data from the buffer
+ memmove(buffer, d.baseAddress, length)
+ } else {
+ // A more efficient implementation of getBytes in the case where no one has asked for our backing bytes
+ memset(buffer, 1, length)
+ }
+ }
+
+ override func copy(with zone: NSZone? = nil) -> Any {
+ return self
+ }
+
+ override func mutableCopy(with zone: NSZone? = nil) -> Any {
+ return AllOnesData(length: _length)
+ }
+ }
+
+
class AllOnesData : NSMutableData {
private var _length : Int
@@ -73,9 +137,8 @@
}
let bytePtr = newBuffer.bindMemory(to: UInt8.self, capacity: newValue)
_pointer = UnsafeMutableBufferPointer(start: bytePtr, count: newValue)
- } else {
- _length = newValue
}
+ _length = newValue
}
}
@@ -122,6 +185,15 @@
}
}
+ var heldData: Data?
+
+ // this holds a reference while applying the function which forces the internal ref type to become non-uniquely referenced
+ func holdReference(_ data: Data, apply: () -> Void) {
+ heldData = data
+ apply()
+ heldData = nil
+ }
+
// MARK: -
// String of course has its own way to get data, but this way tests our own data struct
@@ -1215,6 +1287,2382 @@
data.replaceSubrange(4 ..< 4, with: Data(bytes: []))
expectEqual(expected, data.count)
}
+
+ func test_validateMutation_withUnsafeMutableBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 0xFF, 6, 7, 8, 9]))
+ }
+
+ func test_validateMutation_appendBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0x5)
+ }
+
+ func test_validateMutation_appendData() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let other = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.append(other)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0)
+ }
+
+ func test_validateMutation_appendBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0)
+ }
+
+ func test_validateMutation_appendSequence() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let seq = repeatElement(UInt8(1), count: 10)
+ data.append(contentsOf: seq)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 1)
+ }
+
+ func test_validateMutation_appendContentsOf() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ data.append(contentsOf: bytes)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0)
+ }
+
+ func test_validateMutation_resetBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 0, 0, 0, 8, 9]))
+ }
+
+ func test_validateMutation_replaceSubrange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_replaceSubrangeCountableRange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_replaceSubrangeWithBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer {
+ data.replaceSubrange(range, with: $0)
+ }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_replaceSubrangeWithCollection() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_replaceSubrangeWithBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_slice_withUnsafeMutableBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 6, 7, 8]))
+ }
+
+ func test_validateMutation_slice_appendBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_appendData() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let other = Data(bytes: [0xFF, 0xFF])
+ data.append(other)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_appendBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_appendSequence() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let seq = repeatElement(UInt8(0xFF), count: 2)
+ data.append(contentsOf: seq)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_appendContentsOf() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_resetBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [4, 0, 0, 0, 8]))
+ }
+
+ func test_validateMutation_slice_replaceSubrange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_replaceSubrangeCountableRange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_replaceSubrangeWithBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer {
+ data.replaceSubrange(range, with: $0)
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_replaceSubrangeWithCollection() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_replaceSubrangeWithBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_cow_withUnsafeMutableBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 0xFF, 6, 7, 8, 9]))
+ }
+ }
+
+ func test_validateMutation_cow_appendBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 0x9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x68)
+ }
+ }
+
+ func test_validateMutation_cow_appendData() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let other = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.append(other)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_appendBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_appendSequence() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let seq = repeatElement(UInt8(1), count: 10)
+ data.append(contentsOf: seq)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 1)
+ }
+ }
+
+ func test_validateMutation_cow_appendContentsOf() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ data.append(contentsOf: bytes)
+ expectEqual(data[data.startIndex.advanced(by: 9)], 9)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_resetBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 0, 0, 0, 8, 9]))
+ }
+ }
+
+ func test_validateMutation_cow_replaceSubrange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+ }
+
+ func test_validateMutation_cow_replaceSubrangeCountableRange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+ }
+
+ func test_validateMutation_cow_replaceSubrangeWithBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer {
+ data.replaceSubrange(range, with: $0)
+ }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+ }
+
+ func test_validateMutation_cow_replaceSubrangeWithCollection() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+ }
+
+ func test_validateMutation_cow_replaceSubrangeWithBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 0xFF, 0xFF, 9]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_withUnsafeMutableBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 6, 7, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_appendBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 4)], 0x8)
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0x68)
+ }
+ }
+
+ func test_validateMutation_slice_cow_appendData() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let other = Data(bytes: [0xFF, 0xFF])
+ data.append(other)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_appendBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_appendSequence() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let seq = repeatElement(UInt8(0xFF), count: 2)
+ data.append(contentsOf: seq)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_appendContentsOf() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_resetBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [4, 0, 0, 0, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_replaceSubrange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_replaceSubrangeCountableRange() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_replaceSubrangeWithBuffer() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer {
+ data.replaceSubrange(range, with: $0)
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_replaceSubrangeWithCollection() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_replaceSubrangeWithBytes() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_immutableBacking_withUnsafeMutableBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+
+ func test_validateMutation_immutableBacking_appendBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0x68)
+ }
+
+ func test_validateMutation_immutableBacking_appendData() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let other = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.append(other)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0)
+ }
+
+ func test_validateMutation_immutableBacking_appendBuffer() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0)
+ }
+
+ func test_validateMutation_immutableBacking_appendSequence() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let seq = repeatElement(UInt8(1), count: 10)
+ data.append(contentsOf: seq)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 1)
+ }
+
+ func test_validateMutation_immutableBacking_appendContentsOf() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ data.append(contentsOf: bytes)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0)
+ }
+
+ func test_validateMutation_immutableBacking_resetBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00, 0x72, 0x6c, 0x64]))
+ }
+
+ func test_validateMutation_immutableBacking_replaceSubrange() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xFF, 0xFF, 0x6c, 0x64]))
+ }
+
+ func test_validateMutation_immutableBacking_replaceSubrangeCountableRange() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xFF, 0xFF, 0x6c, 0x64]))
+ }
+
+ func test_validateMutation_immutableBacking_replaceSubrangeWithBuffer() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer {
+ data.replaceSubrange(range, with: $0)
+ }
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xFF, 0xFF, 0x6c, 0x64]))
+ }
+
+ func test_validateMutation_immutableBacking_replaceSubrangeWithCollection() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xFF, 0xFF, 0x6c, 0x64]))
+ }
+
+ func test_validateMutation_immutableBacking_replaceSubrangeWithBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xFF, 0xFF, 0x6c, 0x64]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_withUnsafeMutableBytes() {
+ var data = (NSData(bytes: "hello world", length: 11) as Data)[4..<9]
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+
+ func test_validateMutation_slice_immutableBacking_appendBytes() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_appendData() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_appendBuffer() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_appendSequence() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_appendContentsOf() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_resetBytes() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [4, 0, 0, 0, 8]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_replaceSubrange() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_replaceSubrangeCountableRange() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_replaceSubrangeWithBuffer() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ replacement.withUnsafeBufferPointer { (buffer: UnsafeBufferPointer<UInt8>) in
+ data.replaceSubrange(range, with: buffer)
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_replaceSubrangeWithCollection() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with:replacement)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_slice_immutableBacking_replaceSubrangeWithBytes() {
+ let base: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = base.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ replacement.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+
+ func test_validateMutation_cow_immutableBacking_withUnsafeMutableBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_appendBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0x68)
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_appendData() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let other = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.append(other)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_appendBuffer() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let bytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_appendSequence() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let seq = repeatElement(UInt8(1), count: 10)
+ data.append(contentsOf: seq)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 1)
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_appendContentsOf() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let bytes: [UInt8] = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ data.append(contentsOf: bytes)
+ expectEqual(data[data.startIndex.advanced(by: 10)], 0x64)
+ expectEqual(data[data.startIndex.advanced(by: 11)], 1)
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_resetBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00, 0x72, 0x6c, 0x64]))
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_replaceSubrange() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64]))
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_replaceSubrangeCountableRange() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64]))
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_replaceSubrangeWithBuffer() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ replacement.withUnsafeBufferPointer { (buffer: UnsafeBufferPointer<UInt8>) in
+ data.replaceSubrange(range, with: buffer)
+ }
+ expectEqual(data, Data(bytes: [0x68, 0xff, 0xff, 0x64]))
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_replaceSubrangeWithCollection() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0xff, 0xff, 0x64]))
+ }
+ }
+
+ func test_validateMutation_cow_immutableBacking_replaceSubrangeWithBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ holdReference(data) {
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ replacement.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [0x68, 0xff, 0xff, 0x64]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_withUnsafeMutableBytes() {
+ var data = (NSData(bytes: "hello world", length: 11) as Data)[4..<9]
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_appendBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_appendData() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_appendBuffer() {
+ var data = (NSData(bytes: "hello world", length: 11) as Data)[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer{ data.append($0) }
+ expectEqual(data, Data(bytes: [0x6f, 0x20, 0x77, 0x6f, 0x72, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_appendSequence() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let bytes = repeatElement(UInt8(0xFF), count: 2)
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_appendContentsOf() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_resetBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [4, 0, 0, 0, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_replaceSubrange() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_replaceSubrangeCountableRange() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithBuffer() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithCollection() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return (NSData(bytes: $0.baseAddress!, length: $0.count) as Data)[4..<9]
+ }
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes { data.replaceSubrange(range, with: $0.baseAddress!, count: 2) }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_mutableBacking_withUnsafeMutableBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+
+ func test_validateMutation_mutableBacking_appendBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_mutableBacking_appendData() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_mutableBacking_appendBuffer() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_mutableBacking_appendSequence() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_mutableBacking_appendContentsOf() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_mutableBacking_resetBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [0, 1, 2, 3, 4, 0, 0, 0, 8, 9]))
+ }
+
+ func test_validateMutation_mutableBacking_replaceSubrange() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_mutableBacking_replaceSubrangeCountableRange() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_mutableBacking_replaceSubrangeWithBuffer() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer {
+ data.replaceSubrange(range, with: $0)
+ }
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_mutableBacking_replaceSubrangeWithCollection() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_mutableBacking_replaceSubrangeWithBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var data = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ data.append(contentsOf: [7, 8, 9])
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count)
+ }
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 9]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_withUnsafeMutableBytes() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+
+ func test_validateMutation_slice_mutableBacking_appendBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_appendData() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_appendBuffer() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let bytes: [UInt8] = [1, 2, 3]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [0x6f, 0x20, 0x77, 0x6f, 0x72, 0x1, 0x2, 0x3]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_appendSequence() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let seq = repeatElement(UInt8(1), count: 3)
+ data.append(contentsOf: seq)
+ expectEqual(data, Data(bytes: [0x6f, 0x20, 0x77, 0x6f, 0x72, 0x1, 0x1, 0x1]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_appendContentsOf() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let bytes: [UInt8] = [1, 2, 3]
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [0x6f, 0x20, 0x77, 0x6f, 0x72, 0x1, 0x2, 0x3]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_resetBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [4, 0, 0, 0, 8]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_replaceSubrange() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0x6f, 0xFF, 0xFF, 0x72]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_replaceSubrangeCountableRange() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0x6f, 0xFF, 0xFF, 0x72]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_replaceSubrangeWithBuffer() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ replacement.withUnsafeBufferPointer { (buffer: UnsafeBufferPointer<UInt8>) in
+ data.replaceSubrange(range, with: buffer)
+ }
+ expectEqual(data, Data(bytes: [0x6f, 0xFF, 0xFF, 0x72]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_replaceSubrangeWithCollection() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with:replacement)
+ expectEqual(data, Data(bytes: [0x6f, 0xFF, 0xFF, 0x72]))
+ }
+
+ func test_validateMutation_slice_mutableBacking_replaceSubrangeWithBytes() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ replacement.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [0x6f, 0xFF, 0xFF, 0x72]))
+ }
+
+ func test_validateMutation_cow_mutableBacking_withUnsafeMutableBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_appendBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 16)], 6)
+ expectEqual(data[data.startIndex.advanced(by: 17)], 0x68)
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_appendData() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ data.append("hello", count: 5)
+ expectEqual(data[data.startIndex.advanced(by: 16)], 6)
+ expectEqual(data[data.startIndex.advanced(by: 17)], 0x68)
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_appendBuffer() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let other = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+ data.append(other)
+ expectEqual(data[data.startIndex.advanced(by: 16)], 6)
+ expectEqual(data[data.startIndex.advanced(by: 17)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_appendSequence() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let seq = repeatElement(UInt8(1), count: 10)
+ data.append(contentsOf: seq)
+ expectEqual(data[data.startIndex.advanced(by: 16)], 6)
+ expectEqual(data[data.startIndex.advanced(by: 17)], 1)
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_appendContentsOf() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let bytes: [UInt8] = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ data.append(contentsOf: bytes)
+ expectEqual(data[data.startIndex.advanced(by: 16)], 6)
+ expectEqual(data[data.startIndex.advanced(by: 17)], 1)
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_resetBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x00, 0x72, 0x6c, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06]))
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_replaceSubrange() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06]))
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_replaceSubrangeCountableRange() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement = Data(bytes: [0xFF, 0xFF])
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06]))
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_replaceSubrangeWithBuffer() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ replacement.withUnsafeBufferPointer { (buffer: UnsafeBufferPointer<UInt8>) in
+ data.replaceSubrange(range, with: buffer)
+ }
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06]))
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_replaceSubrangeWithCollection() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ data.replaceSubrange(range, with: replacement)
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06]))
+ }
+ }
+
+ func test_validateMutation_cow_mutableBacking_replaceSubrangeWithBytes() {
+ var data = NSData(bytes: "hello world", length: 11) as Data
+ data.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ holdReference(data) {
+ let replacement: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 4)..<data.startIndex.advanced(by: 9)
+ replacement.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [0x68, 0x65, 0x6c, 0x6c, 0xff, 0xff, 0x6c, 0x64, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_withUnsafeMutableBytes() {
+ var base = NSData(bytes: "hello world", length: 11) as Data
+ base.append(contentsOf: [1, 2, 3, 4, 5, 6])
+ var data = base[4..<9]
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_appendBytes() {
+ let bytes: [UInt8] = [0, 1, 2]
+ var base = bytes.withUnsafeBytes { (ptr) in
+ return NSData(bytes: ptr.baseAddress!, length: ptr.count) as Data
+ }
+ base.append(contentsOf: [3, 4, 5])
+ var data = base[1..<4]
+ holdReference(data) {
+ let bytesToAppend: [UInt8] = [6, 7, 8]
+ bytesToAppend.withUnsafeBytes { (ptr) in
+ data.append(ptr.baseAddress!.assumingMemoryBound(to: UInt8.self), count: ptr.count)
+ }
+ expectEqual(data, Data(bytes: [1, 2, 3, 6, 7, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_appendData() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_appendBuffer() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer{ data.append($0) }
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_appendSequence() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let bytes = repeatElement(UInt8(0xFF), count: 2)
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_appendContentsOf() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.append(contentsOf: bytes)
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 8, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_resetBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [4, 0, 0, 0, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_replaceSubrange() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_replaceSubrangeCountableRange() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: CountableRange<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithBuffer() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithCollection() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ data.replaceSubrange(range, with: bytes)
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithBytes() {
+ let baseBytes: [UInt8] = [0, 1, 2, 3, 4, 5, 6]
+ var base = baseBytes.withUnsafeBufferPointer {
+ return NSData(bytes: $0.baseAddress!, length: $0.count) as Data
+ }
+ base.append(contentsOf: [7, 8, 9])
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Data.Index> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes { data.replaceSubrange(range, with: $0.baseAddress!, count: 2) }
+ expectEqual(data, Data(bytes: [4, 0xFF, 0xFF, 8]))
+ }
+ }
+
+ func test_validateMutation_customBacking_withUnsafeMutableBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 1, 1, 1, 1]))
+ }
+
+ func test_validateMutation_customBacking_appendBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customBacking_appendData() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customBacking_appendBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.append(buffer)
+ }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+
+ }
+
+ func test_validateMutation_customBacking_appendSequence() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customBacking_appendContentsOf() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customBacking_resetBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0, 0, 0, 1, 1]))
+ }
+
+ func test_validateMutation_customBacking_replaceSubrange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let range: Range<Int> = 1..<4
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1, 1, 1, 1, 1, 1]))
+ }
+
+ func test_validateMutation_customBacking_replaceSubrangeCountableRange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let range: CountableRange<Int> = 1..<4
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1, 1, 1, 1, 1, 1]))
+ }
+
+ func test_validateMutation_customBacking_replaceSubrangeWithBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Int> = 1..<4
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.replaceSubrange(range, with: buffer)
+ }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1, 1, 1, 1, 1, 1]))
+ }
+
+ func test_validateMutation_customBacking_replaceSubrangeWithCollection() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let range: Range<Int> = 1..<4
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1, 1, 1, 1, 1, 1]))
+ }
+
+ func test_validateMutation_customBacking_replaceSubrangeWithBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Int> = 1..<5
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.replaceSubrange(range, with: buffer.baseAddress!, count: buffer.count)
+ }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1, 1, 1, 1, 1]))
+ }
+
+ func test_validateMutation_slice_customBacking_withUnsafeMutableBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+
+ func test_validateMutation_slice_customBacking_appendBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes { ptr in
+ data.append(ptr.baseAddress!.assumingMemoryBound(to: UInt8.self), count: ptr.count)
+ }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customBacking_appendData() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customBacking_appendBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.append(buffer)
+ }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customBacking_appendSequence() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let seq = repeatElement(UInt8(0xFF), count: 2)
+ data.append(contentsOf: seq)
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customBacking_appendContentsOf() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customBacking_resetBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 1]))
+ }
+
+ func test_validateMutation_slice_customBacking_replaceSubrange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+
+ func test_validateMutation_slice_customBacking_replaceSubrangeCountableRange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+
+ func test_validateMutation_slice_customBacking_replaceSubrangeWithBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.replaceSubrange(range, with: buffer)
+ }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+
+ func test_validateMutation_slice_customBacking_replaceSubrangeWithCollection() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+
+ func test_validateMutation_slice_customBacking_replaceSubrangeWithBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes { buffer in
+ data.replaceSubrange(range, with: buffer.baseAddress!, count: 2)
+ }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+
+ func test_validateMutation_cow_customBacking_withUnsafeMutableBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_appendBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.append(buffer.baseAddress!, count: buffer.count)
+ }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_appendData() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_appendBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_appendSequence() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_appendContentsOf() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_resetBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0, 0, 0, 1, 1]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_replaceSubrange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_replaceSubrangeCountableRange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_replaceSubrangeWithBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_replaceSubrangeWithCollection() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_cow_customBacking_replaceSubrangeWithBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count)
+ }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_withUnsafeMutableBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_appendBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { (buffer) in
+ data.append(buffer.baseAddress!, count: buffer.count)
+ }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_appendData() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_appendBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_appendSequence() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_appendContentsOf() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 1, 1, 1, 1, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_resetBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 1]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_replaceSubrange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_replaceSubrangeCountableRange() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_replaceSubrangeWithBuffer() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_replaceSubrangeWithCollection() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customBacking_replaceSubrangeWithBytes() {
+ var data = Data(referencing: AllOnesImmutableData(length: 10))[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBytes {
+ data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count)
+ }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 1]))
+ }
+ }
+
+ func test_validateMutation_customMutableBacking_withUnsafeMutableBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+
+ func test_validateMutation_customMutableBacking_appendBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customMutableBacking_appendData() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customMutableBacking_appendBuffer() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customMutableBacking_appendSequence() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customMutableBacking_appendContentsOf() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_customMutableBacking_resetBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ data.resetBytes(in: 5..<8)
+ expectEqual(data.count, 10)
+ expectEqual(data[data.startIndex.advanced(by: 0)], 1)
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 6)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 7)], 0)
+ }
+
+ func test_validateMutation_customMutableBacking_replaceSubrange() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_customMutableBacking_replaceSubrangeCountableRange() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_customMutableBacking_replaceSubrangeWithBuffer() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_customMutableBacking_replaceSubrangeWithCollection() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_customMutableBacking_replaceSubrangeWithBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+
+ func test_validateMutation_slice_customMutableBacking_appendBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_appendData() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_appendBuffer() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_appendSequence() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_appendContentsOf() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_resetBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ data.resetBytes(in: 5..<8)
+
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 2)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 3)], 0)
+ }
+
+ func test_validateMutation_slice_customMutableBacking_replaceSubrange() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_replaceSubrangeCountableRange() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_replaceSubrangeWithBuffer() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_replaceSubrangeWithCollection() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_slice_customMutableBacking_replaceSubrangeWithBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+
+ func test_validateMutation_cow_customMutableBacking_withUnsafeMutableBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 5).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_appendBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_appendData() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_appendBuffer() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_appendSequence() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_appendContentsOf() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_resetBytes() {
+ var data = Data(referencing: AllOnesData(length: 10))
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data.count, 10)
+ expectEqual(data[data.startIndex.advanced(by: 0)], 1)
+ expectEqual(data[data.startIndex.advanced(by: 5)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 6)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 7)], 0)
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_replaceSubrange() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_replaceSubrangeCountableRange() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_replaceSubrangeWithBuffer() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_replaceSubrangeWithCollection() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_cow_customMutableBacking_replaceSubrangeWithBytes() {
+ var data = Data(referencing: AllOnesData(length: 1))
+ data.count = 10
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [1, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_withUnsafeMutableBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
+ ptr.advanced(by: 1).pointee = 0xFF
+ }
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0xFF)
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_appendBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_appendData() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ data.append(Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_appendBuffer() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.append($0) }
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_appendSequence() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ data.append(contentsOf: repeatElement(UInt8(0xFF), count: 2))
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_appendContentsOf() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ data.append(contentsOf: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [0, 0, 0, 0, 0, 0xFF, 0xFF]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_resetBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ data.resetBytes(in: 5..<8)
+ expectEqual(data[data.startIndex.advanced(by: 1)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 2)], 0)
+ expectEqual(data[data.startIndex.advanced(by: 3)], 0)
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_replaceSubrange() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeCountableRange() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: CountableRange<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: Data(bytes: [0xFF, 0xFF]))
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBuffer() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0) }
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithCollection() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ data.replaceSubrange(range, with: [0xFF, 0xFF])
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBytes() {
+ var base = Data(referencing: AllOnesData(length: 1))
+ base.count = 10
+ var data = base[4..<9]
+ holdReference(data) {
+ let range: Range<Int> = data.startIndex.advanced(by: 1)..<data.endIndex.advanced(by: -1)
+ let bytes: [UInt8] = [0xFF, 0xFF]
+ bytes.withUnsafeBufferPointer { data.replaceSubrange(range, with: $0.baseAddress!, count: $0.count) }
+ expectEqual(data, Data(bytes: [0, 0xFF, 0xFF, 0]))
+ }
+ }
+
+ func test_sliceHash() {
+ let base1 = Data(bytes: [0, 0xFF, 0xFF, 0])
+ let base2 = Data(bytes: [0, 0xFF, 0xFF, 0])
+ let base3 = Data(bytes: [0xFF, 0xFF, 0xFF, 0])
+ let sliceEmulation = Data(bytes: [0xFF, 0xFF])
+ expectEqual(base1.hashValue, base2.hashValue)
+ let slice1 = base1[base1.startIndex.advanced(by: 1)..<base1.endIndex.advanced(by: -1)]
+ let slice2 = base2[base2.startIndex.advanced(by: 1)..<base2.endIndex.advanced(by: -1)]
+ let slice3 = base3[base3.startIndex.advanced(by: 1)..<base3.endIndex.advanced(by: -1)]
+ expectEqual(slice1.hashValue, sliceEmulation.hashValue)
+ expectEqual(slice1.hashValue, slice2.hashValue)
+ expectEqual(slice2.hashValue, slice3.hashValue)
+ }
+
+ func test_slice_resize_growth() {
+ var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<9]
+ data.resetBytes(in: data.endIndex.advanced(by: -1)..<data.endIndex.advanced(by: 1))
+ expectEqual(data, Data(bytes: [4, 5, 6, 7, 0, 0]))
+ }
+
+ func test_sliceEnumeration() {
+ var base = DispatchData.empty
+ let bytes: [UInt8] = [0, 1, 2, 3, 4]
+ base.append(bytes.withUnsafeBytes { DispatchData(bytes: $0) })
+ base.append(bytes.withUnsafeBytes { DispatchData(bytes: $0) })
+ base.append(bytes.withUnsafeBytes { DispatchData(bytes: $0) })
+ let data = ((base as AnyObject) as! Data)[3..<11]
+ var regionRanges: [Range<Int>] = []
+ var regionData: [Data] = []
+ data.enumerateBytes { (buffer, index, _) in
+ regionData.append(Data(bytes: buffer.baseAddress!, count: buffer.count))
+ regionRanges.append(index..<index + buffer.count)
+ }
+ expectEqual(regionRanges.count, 3)
+ expectEqual(Range<Data.Index>(3..<5), regionRanges[0])
+ expectEqual(Range<Data.Index>(5..<10), regionRanges[1])
+ expectEqual(Range<Data.Index>(10..<11), regionRanges[2])
+ expectEqual(Data(bytes: [3, 4]), regionData[0]) //fails
+ expectEqual(Data(bytes: [0, 1, 2, 3, 4]), regionData[1]) //passes
+ expectEqual(Data(bytes: [0]), regionData[2]) //fails
+ }
}
#if !FOUNDATION_XCTEST
@@ -1282,6 +3730,249 @@
DataTests.test("test_replaceSubrangeReferencingMutable") { TestData().test_replaceSubrangeReferencingMutable() }
DataTests.test("test_replaceSubrangeReferencingImmutable") { TestData().test_replaceSubrangeReferencingImmutable() }
DataTests.test("test_replaceSubrangeFromBridged") { TestData().test_replaceSubrangeFromBridged() }
+DataTests.test("test_validateMutation_withUnsafeMutableBytes") { TestData().test_validateMutation_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_appendBytes") { TestData().test_validateMutation_appendBytes() }
+DataTests.test("test_validateMutation_appendData") { TestData().test_validateMutation_appendData() }
+DataTests.test("test_validateMutation_appendBuffer") { TestData().test_validateMutation_appendBuffer() }
+DataTests.test("test_validateMutation_appendSequence") { TestData().test_validateMutation_appendSequence() }
+DataTests.test("test_validateMutation_appendContentsOf") { TestData().test_validateMutation_appendContentsOf() }
+DataTests.test("test_validateMutation_resetBytes") { TestData().test_validateMutation_resetBytes() }
+DataTests.test("test_validateMutation_replaceSubrange") { TestData().test_validateMutation_replaceSubrange() }
+DataTests.test("test_validateMutation_replaceSubrangeCountableRange") { TestData().test_validateMutation_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_replaceSubrangeWithBuffer") { TestData().test_validateMutation_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_replaceSubrangeWithCollection") { TestData().test_validateMutation_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_replaceSubrangeWithBytes") { TestData().test_validateMutation_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_appendBytes") { TestData().test_validateMutation_slice_appendBytes() }
+DataTests.test("test_validateMutation_slice_appendData") { TestData().test_validateMutation_slice_appendData() }
+DataTests.test("test_validateMutation_slice_appendBuffer") { TestData().test_validateMutation_slice_appendBuffer() }
+DataTests.test("test_validateMutation_slice_appendSequence") { TestData().test_validateMutation_slice_appendSequence() }
+DataTests.test("test_validateMutation_slice_appendContentsOf") { TestData().test_validateMutation_slice_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_resetBytes") { TestData().test_validateMutation_slice_resetBytes() }
+DataTests.test("test_validateMutation_slice_replaceSubrange") { TestData().test_validateMutation_slice_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_cow_withUnsafeMutableBytes") { TestData().test_validateMutation_cow_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_cow_appendBytes") { TestData().test_validateMutation_cow_appendBytes() }
+DataTests.test("test_validateMutation_cow_appendData") { TestData().test_validateMutation_cow_appendData() }
+DataTests.test("test_validateMutation_cow_appendBuffer") { TestData().test_validateMutation_cow_appendBuffer() }
+DataTests.test("test_validateMutation_cow_appendSequence") { TestData().test_validateMutation_cow_appendSequence() }
+DataTests.test("test_validateMutation_cow_appendContentsOf") { TestData().test_validateMutation_cow_appendContentsOf() }
+DataTests.test("test_validateMutation_cow_resetBytes") { TestData().test_validateMutation_cow_resetBytes() }
+DataTests.test("test_validateMutation_cow_replaceSubrange") { TestData().test_validateMutation_cow_replaceSubrange() }
+DataTests.test("test_validateMutation_cow_replaceSubrangeCountableRange") { TestData().test_validateMutation_cow_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_cow_replaceSubrangeWithBuffer") { TestData().test_validateMutation_cow_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_cow_replaceSubrangeWithCollection") { TestData().test_validateMutation_cow_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_cow_replaceSubrangeWithBytes") { TestData().test_validateMutation_cow_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_cow_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_cow_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_cow_appendBytes") { TestData().test_validateMutation_slice_cow_appendBytes() }
+DataTests.test("test_validateMutation_slice_cow_appendData") { TestData().test_validateMutation_slice_cow_appendData() }
+DataTests.test("test_validateMutation_slice_cow_appendBuffer") { TestData().test_validateMutation_slice_cow_appendBuffer() }
+DataTests.test("test_validateMutation_slice_cow_appendSequence") { TestData().test_validateMutation_slice_cow_appendSequence() }
+DataTests.test("test_validateMutation_slice_cow_appendContentsOf") { TestData().test_validateMutation_slice_cow_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_cow_resetBytes") { TestData().test_validateMutation_slice_cow_resetBytes() }
+DataTests.test("test_validateMutation_slice_cow_replaceSubrange") { TestData().test_validateMutation_slice_cow_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_cow_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_cow_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_cow_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_cow_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_cow_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_cow_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_cow_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_cow_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_immutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_immutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_immutableBacking_appendBytes") { TestData().test_validateMutation_immutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_immutableBacking_appendData") { TestData().test_validateMutation_immutableBacking_appendData() }
+DataTests.test("test_validateMutation_immutableBacking_appendBuffer") { TestData().test_validateMutation_immutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_immutableBacking_appendSequence") { TestData().test_validateMutation_immutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_immutableBacking_appendContentsOf") { TestData().test_validateMutation_immutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_immutableBacking_resetBytes") { TestData().test_validateMutation_immutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_immutableBacking_replaceSubrange") { TestData().test_validateMutation_immutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_immutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_immutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_immutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_immutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_immutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_immutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_immutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_immutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_immutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_immutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_immutableBacking_appendBytes") { TestData().test_validateMutation_slice_immutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_immutableBacking_appendData") { TestData().test_validateMutation_slice_immutableBacking_appendData() }
+DataTests.test("test_validateMutation_slice_immutableBacking_appendBuffer") { TestData().test_validateMutation_slice_immutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_immutableBacking_appendSequence") { TestData().test_validateMutation_slice_immutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_immutableBacking_appendContentsOf") { TestData().test_validateMutation_slice_immutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_immutableBacking_resetBytes") { TestData().test_validateMutation_slice_immutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_immutableBacking_replaceSubrange") { TestData().test_validateMutation_slice_immutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_immutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_immutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_immutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_immutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_immutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_immutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_immutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_immutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_cow_immutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_cow_immutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_cow_immutableBacking_appendBytes") { TestData().test_validateMutation_cow_immutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_cow_immutableBacking_appendData") { TestData().test_validateMutation_cow_immutableBacking_appendData() }
+DataTests.test("test_validateMutation_cow_immutableBacking_appendBuffer") { TestData().test_validateMutation_cow_immutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_cow_immutableBacking_appendSequence") { TestData().test_validateMutation_cow_immutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_cow_immutableBacking_appendContentsOf") { TestData().test_validateMutation_cow_immutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_cow_immutableBacking_resetBytes") { TestData().test_validateMutation_cow_immutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_cow_immutableBacking_replaceSubrange") { TestData().test_validateMutation_cow_immutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_cow_immutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_cow_immutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_cow_immutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_cow_immutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_cow_immutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_cow_immutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_cow_immutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_cow_immutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_cow_immutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_appendBytes") { TestData().test_validateMutation_slice_cow_immutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_appendData") { TestData().test_validateMutation_slice_cow_immutableBacking_appendData() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_appendBuffer") { TestData().test_validateMutation_slice_cow_immutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_appendSequence") { TestData().test_validateMutation_slice_cow_immutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_appendContentsOf") { TestData().test_validateMutation_slice_cow_immutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_resetBytes") { TestData().test_validateMutation_slice_cow_immutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_replaceSubrange") { TestData().test_validateMutation_slice_cow_immutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_cow_immutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_cow_immutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_mutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_mutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_mutableBacking_appendBytes") { TestData().test_validateMutation_mutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_mutableBacking_appendData") { TestData().test_validateMutation_mutableBacking_appendData() }
+DataTests.test("test_validateMutation_mutableBacking_appendBuffer") { TestData().test_validateMutation_mutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_mutableBacking_appendSequence") { TestData().test_validateMutation_mutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_mutableBacking_appendContentsOf") { TestData().test_validateMutation_mutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_mutableBacking_resetBytes") { TestData().test_validateMutation_mutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_mutableBacking_replaceSubrange") { TestData().test_validateMutation_mutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_mutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_mutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_mutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_mutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_mutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_mutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_mutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_mutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_mutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_mutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_mutableBacking_appendBytes") { TestData().test_validateMutation_slice_mutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_mutableBacking_appendData") { TestData().test_validateMutation_slice_mutableBacking_appendData() }
+DataTests.test("test_validateMutation_slice_mutableBacking_appendBuffer") { TestData().test_validateMutation_slice_mutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_mutableBacking_appendSequence") { TestData().test_validateMutation_slice_mutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_mutableBacking_appendContentsOf") { TestData().test_validateMutation_slice_mutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_mutableBacking_resetBytes") { TestData().test_validateMutation_slice_mutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_mutableBacking_replaceSubrange") { TestData().test_validateMutation_slice_mutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_mutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_mutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_mutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_mutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_mutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_mutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_mutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_mutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_cow_mutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_cow_mutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_cow_mutableBacking_appendBytes") { TestData().test_validateMutation_cow_mutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_cow_mutableBacking_appendData") { TestData().test_validateMutation_cow_mutableBacking_appendData() }
+DataTests.test("test_validateMutation_cow_mutableBacking_appendBuffer") { TestData().test_validateMutation_cow_mutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_cow_mutableBacking_appendSequence") { TestData().test_validateMutation_cow_mutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_cow_mutableBacking_appendContentsOf") { TestData().test_validateMutation_cow_mutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_cow_mutableBacking_resetBytes") { TestData().test_validateMutation_cow_mutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_cow_mutableBacking_replaceSubrange") { TestData().test_validateMutation_cow_mutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_cow_mutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_cow_mutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_cow_mutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_cow_mutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_cow_mutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_cow_mutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_cow_mutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_cow_mutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_cow_mutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_appendBytes") { TestData().test_validateMutation_slice_cow_mutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_appendData") { TestData().test_validateMutation_slice_cow_mutableBacking_appendData() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_appendBuffer") { TestData().test_validateMutation_slice_cow_mutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_appendSequence") { TestData().test_validateMutation_slice_cow_mutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_appendContentsOf") { TestData().test_validateMutation_slice_cow_mutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_resetBytes") { TestData().test_validateMutation_slice_cow_mutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_replaceSubrange") { TestData().test_validateMutation_slice_cow_mutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_cow_mutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_cow_mutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_customBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_customBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_customBacking_appendBytes") { TestData().test_validateMutation_customBacking_appendBytes() }
+DataTests.test("test_validateMutation_customBacking_appendData") { TestData().test_validateMutation_customBacking_appendData() }
+DataTests.test("test_validateMutation_customBacking_appendBuffer") { TestData().test_validateMutation_customBacking_appendBuffer() }
+DataTests.test("test_validateMutation_customBacking_appendSequence") { TestData().test_validateMutation_customBacking_appendSequence() }
+DataTests.test("test_validateMutation_customBacking_appendContentsOf") { TestData().test_validateMutation_customBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_customBacking_resetBytes") { TestData().test_validateMutation_customBacking_resetBytes() }
+DataTests.test("test_validateMutation_customBacking_replaceSubrange") { TestData().test_validateMutation_customBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_customBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_customBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_customBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_customBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_customBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_customBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_customBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_customBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_customBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_customBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_customBacking_appendBytes") { TestData().test_validateMutation_slice_customBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_customBacking_appendData") { TestData().test_validateMutation_slice_customBacking_appendData() }
+DataTests.test("test_validateMutation_slice_customBacking_appendBuffer") { TestData().test_validateMutation_slice_customBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_customBacking_appendSequence") { TestData().test_validateMutation_slice_customBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_customBacking_appendContentsOf") { TestData().test_validateMutation_slice_customBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_customBacking_resetBytes") { TestData().test_validateMutation_slice_customBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_customBacking_replaceSubrange") { TestData().test_validateMutation_slice_customBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_customBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_customBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_customBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_customBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_customBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_customBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_customBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_customBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_cow_customBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_cow_customBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_cow_customBacking_appendBytes") { TestData().test_validateMutation_cow_customBacking_appendBytes() }
+DataTests.test("test_validateMutation_cow_customBacking_appendData") { TestData().test_validateMutation_cow_customBacking_appendData() }
+DataTests.test("test_validateMutation_cow_customBacking_appendBuffer") { TestData().test_validateMutation_cow_customBacking_appendBuffer() }
+DataTests.test("test_validateMutation_cow_customBacking_appendSequence") { TestData().test_validateMutation_cow_customBacking_appendSequence() }
+DataTests.test("test_validateMutation_cow_customBacking_appendContentsOf") { TestData().test_validateMutation_cow_customBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_cow_customBacking_resetBytes") { TestData().test_validateMutation_cow_customBacking_resetBytes() }
+DataTests.test("test_validateMutation_cow_customBacking_replaceSubrange") { TestData().test_validateMutation_cow_customBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_cow_customBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_cow_customBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_cow_customBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_cow_customBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_cow_customBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_cow_customBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_cow_customBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_cow_customBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_cow_customBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_appendBytes") { TestData().test_validateMutation_slice_cow_customBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_appendData") { TestData().test_validateMutation_slice_cow_customBacking_appendData() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_appendBuffer") { TestData().test_validateMutation_slice_cow_customBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_appendSequence") { TestData().test_validateMutation_slice_cow_customBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_appendContentsOf") { TestData().test_validateMutation_slice_cow_customBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_resetBytes") { TestData().test_validateMutation_slice_cow_customBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_replaceSubrange") { TestData().test_validateMutation_slice_cow_customBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_cow_customBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_cow_customBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_cow_customBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_cow_customBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_cow_customBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_customMutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_customMutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_customMutableBacking_appendBytes") { TestData().test_validateMutation_customMutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_customMutableBacking_appendData") { TestData().test_validateMutation_customMutableBacking_appendData() }
+DataTests.test("test_validateMutation_customMutableBacking_appendBuffer") { TestData().test_validateMutation_customMutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_customMutableBacking_appendSequence") { TestData().test_validateMutation_customMutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_customMutableBacking_appendContentsOf") { TestData().test_validateMutation_customMutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_customMutableBacking_resetBytes") { TestData().test_validateMutation_customMutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_customMutableBacking_replaceSubrange") { TestData().test_validateMutation_customMutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_customMutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_customMutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_customMutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_customMutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_customMutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_customMutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_customMutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_customMutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_appendBytes") { TestData().test_validateMutation_slice_customMutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_appendData") { TestData().test_validateMutation_slice_customMutableBacking_appendData() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_appendBuffer") { TestData().test_validateMutation_slice_customMutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_appendSequence") { TestData().test_validateMutation_slice_customMutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_appendContentsOf") { TestData().test_validateMutation_slice_customMutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_resetBytes") { TestData().test_validateMutation_slice_customMutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_replaceSubrange") { TestData().test_validateMutation_slice_customMutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_customMutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_customMutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_customMutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_customMutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_customMutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_cow_customMutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_appendBytes") { TestData().test_validateMutation_cow_customMutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_appendData") { TestData().test_validateMutation_cow_customMutableBacking_appendData() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_appendBuffer") { TestData().test_validateMutation_cow_customMutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_appendSequence") { TestData().test_validateMutation_cow_customMutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_appendContentsOf") { TestData().test_validateMutation_cow_customMutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_resetBytes") { TestData().test_validateMutation_cow_customMutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_replaceSubrange") { TestData().test_validateMutation_cow_customMutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_cow_customMutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_cow_customMutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_cow_customMutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_cow_customMutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_cow_customMutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_withUnsafeMutableBytes") { TestData().test_validateMutation_slice_cow_customMutableBacking_withUnsafeMutableBytes() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_appendBytes") { TestData().test_validateMutation_slice_cow_customMutableBacking_appendBytes() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_appendData") { TestData().test_validateMutation_slice_cow_customMutableBacking_appendData() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_appendBuffer") { TestData().test_validateMutation_slice_cow_customMutableBacking_appendBuffer() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_appendSequence") { TestData().test_validateMutation_slice_cow_customMutableBacking_appendSequence() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_appendContentsOf") { TestData().test_validateMutation_slice_cow_customMutableBacking_appendContentsOf() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_resetBytes") { TestData().test_validateMutation_slice_cow_customMutableBacking_resetBytes() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_replaceSubrange") { TestData().test_validateMutation_slice_cow_customMutableBacking_replaceSubrange() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeCountableRange") { TestData().test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeCountableRange() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBuffer") { TestData().test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBuffer() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithCollection") { TestData().test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithCollection() }
+DataTests.test("test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBytes") { TestData().test_validateMutation_slice_cow_customMutableBacking_replaceSubrangeWithBytes() }
+DataTests.test("test_sliceHash") { TestData().test_sliceHash() }
+DataTests.test("test_slice_resize_growth") { TestData().test_slice_resize_growth() }
+DataTests.test("test_sliceEnumeration") { TestData().test_sliceEnumeration() }
// XCTest does not have a crash detection, whereas lit does
DataTests.test("bounding failure subdata") {
diff --git a/test/stdlib/TestJSONEncoder.swift b/test/stdlib/TestJSONEncoder.swift
index 96a1cd7..5ed50b8 100644
--- a/test/stdlib/TestJSONEncoder.swift
+++ b/test/stdlib/TestJSONEncoder.swift
@@ -449,6 +449,34 @@
// Optional URLs should encode the same way.
_testRoundTrip(of: OptionalTopLevelWrapper(url), expectedJSON: expectedJSON)
}
+
+ // MARK: - Type coercion
+ func testTypeCoercion() {
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int8].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int16].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int32].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int64].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt8].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt16].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt32].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt64].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Float].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Double].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int8], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int16], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int32], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int64], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt8], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt16], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt32], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt64], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0.0, 1.0] as [Float], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0.0, 1.0] as [Double], as: [Bool].self)
+ }
// MARK: - Helper Functions
private var _jsonEmptyDictionary: Data {
@@ -498,6 +526,14 @@
expectUnreachable("Failed to decode \(T.self) from JSON: \(error)")
}
}
+
+ private func _testRoundTripTypeCoercionFailure<T,U>(of value: T, as type: U.Type) where T : Codable, U : Codable {
+ do {
+ let data = try JSONEncoder().encode(value)
+ let _ = try JSONDecoder().decode(U.self, from: data)
+ expectUnreachable("Coercion from \(T.self) to \(U.self) was expected to fail.")
+ } catch {}
+ }
}
// MARK: - Helper Global Functions
@@ -1067,5 +1103,6 @@
JSONEncoderTests.test("testSuperEncoderCodingPaths") { TestJSONEncoder().testSuperEncoderCodingPaths() }
JSONEncoderTests.test("testInterceptDecimal") { TestJSONEncoder().testInterceptDecimal() }
JSONEncoderTests.test("testInterceptURL") { TestJSONEncoder().testInterceptURL() }
+JSONEncoderTests.test("testTypeCoercion") { TestJSONEncoder().testTypeCoercion() }
runAllTests()
#endif
diff --git a/test/stdlib/TestPlistEncoder.swift b/test/stdlib/TestPlistEncoder.swift
index d62b7a5..d7b037b 100644
--- a/test/stdlib/TestPlistEncoder.swift
+++ b/test/stdlib/TestPlistEncoder.swift
@@ -170,6 +170,34 @@
_testRoundTrip(of: topLevel, in: .xml, expectedPlist: try! PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0))
}
+ // MARK: - Type coercion
+ func testTypeCoercion() {
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int8].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int16].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int32].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Int64].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt8].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt16].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt32].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [UInt64].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Float].self)
+ _testRoundTripTypeCoercionFailure(of: [false, true], as: [Double].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int8], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int16], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int32], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [Int64], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt8], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt16], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt32], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0, 1] as [UInt64], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0.0, 1.0] as [Float], as: [Bool].self)
+ _testRoundTripTypeCoercionFailure(of: [0.0, 1.0] as [Double], as: [Bool].self)
+ }
+
// MARK: - Helper Functions
private var _plistEmptyDictionaryBinary: Data {
return Data(base64Encoded: "YnBsaXN0MDDQCAAAAAAAAAEBAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAJ")!
@@ -211,6 +239,14 @@
expectUnreachable("Failed to decode \(T.self) from plist: \(error)")
}
}
+
+ private func _testRoundTripTypeCoercionFailure<T,U>(of value: T, as type: U.Type) where T : Codable, U : Codable {
+ do {
+ let data = try PropertyListEncoder().encode(value)
+ let _ = try PropertyListDecoder().decode(U.self, from: data)
+ expectUnreachable("Coercion from \(T.self) to \(U.self) was expected to fail.")
+ } catch {}
+ }
}
// MARK: - Helper Global Functions
@@ -694,5 +730,6 @@
PropertyListEncoderTests.test("testEncodingTopLevelData") { TestPropertyListEncoder().testEncodingTopLevelData() }
PropertyListEncoderTests.test("testInterceptData") { TestPropertyListEncoder().testInterceptData() }
PropertyListEncoderTests.test("testInterceptDate") { TestPropertyListEncoder().testInterceptDate() }
+PropertyListEncoderTests.test("testTypeCoercion") { TestPropertyListEncoder().testTypeCoercion() }
runAllTests()
#endif
diff --git a/test/stdlib/test_runtime_function_counters.swift b/test/stdlib/test_runtime_function_counters.swift
new file mode 100644
index 0000000..90676fb
--- /dev/null
+++ b/test/stdlib/test_runtime_function_counters.swift
@@ -0,0 +1,264 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-build-swift %s -o %t/test_runtime_function_counters
+// RUN: %target-run %t/test_runtime_function_counters 2>&1 | %FileCheck %s
+// REQUIRES: swift_stdlib_asserts
+// REQUIRES: executable_test
+
+/// Test functionality related to the runtime function counters.
+
+class C {
+ var next: C? = nil
+ func test(_ c: C) {
+ }
+}
+
+struct MyStruct {
+ var ref1: AnyObject? = C()
+ var ref2: AnyObject = C()
+ var str: String = ""
+}
+
+public final class List<T> {
+ var value: T
+ var next: List<T>?
+
+ init(_ value: T) {
+ self.value = value
+ self.next = nil
+ }
+
+ init(_ value: T, _ tail: List<T>) {
+ self.value = value
+ self.next = tail
+ }
+}
+
+public func length<T>(_ l: List<T>) -> Int {
+ var ll: List<T>? = l
+ var len = 0
+ while ll != nil {
+ len = len + 1
+ ll = ll?.next
+ }
+ return len
+}
+
+/// CHECK-LABEL: TEST: Collect references inside objects
+/// Constant strings do not have an owner, thus no references.
+/// CHECK: Constant string: []
+/// An array has one reference
+/// CHECK: Array<Int>: [{{[0-9a-fA-Fx]+}}]
+/// MyStruct has two references
+/// CHECK: MyStruct: [{{[0-9a-fA-Fx]+}}, {{[0-9a-fA-Fx]+}}]
+/// Dictionary has once reference
+/// CHECK: Dictionary<Int, Int>: [{{[0-9a-fA-Fx]+}}]
+/// Set has once reference
+/// CHECK: Set<Int>: [{{[0-9a-fA-Fx]+}}]
+/// Test collection of references inside different types of objects.
+@inline(never)
+func testCollectReferencesInsideObject() {
+ print("TEST: Collect references inside objects")
+ let s = "MyString"
+ let aint = [1,2,3,4]
+ let dint = [1:1, 2:2]
+ let sint: Set<Int> = [1,2,3,4]
+
+ print("Constant string: \(_collectReferencesInsideObject(s))")
+ print("Array<Int>: \(_collectReferencesInsideObject(aint))")
+ print("MyStruct: \(_collectReferencesInsideObject(MyStruct()))")
+ print("Dictionary<Int, Int>: \(_collectReferencesInsideObject(dint))")
+ print("Set<Int>: \(_collectReferencesInsideObject(sint))")
+
+ var mystring = "MyString"
+ mystring.append("End")
+ testString(mystring)
+ testDict(dint)
+ testObjectCycle()
+}
+
+
+/// CHECK-LABEL: TEST: APIs from _RuntimeFunctionCounters
+/// CHECK: Number of runtime function pointers:
+/// Test some APIs from _RuntimeFunctionCounters
+func testRuntimeCounters() {
+ print("TEST: APIs from _RuntimeFunctionCounters")
+ let numRuntimeFunctionPointer =
+ _RuntimeFunctionCounters.getNumRuntimeFunctionCounters()
+
+ print("Number of runtime function pointers: \(numRuntimeFunctionPointer)")
+
+ let names = _RuntimeFunctionCounters.getRuntimeFunctionNames()
+ let offsets = _RuntimeFunctionCounters.getRuntimeFunctionCountersOffsets()
+
+ for i in 0..<numRuntimeFunctionPointer {
+ print("Runtime function \(i) : \(names[i]) at offset: \(offsets[i])")
+ }
+
+ var d: [Int : Int] = [:]
+ let globalCounters1 = _GlobalRuntimeFunctionCountersState()
+
+ for i in 0..<50 {
+ let k = i
+ let v = i*i
+ d[k] = v
+ }
+
+ let globalCounters2 = _GlobalRuntimeFunctionCountersState()
+
+ globalCounters1.dumpDiff(globalCounters2, skipUnchanged: true)
+}
+
+/// Test finding references inside a String object.
+@inline(never)
+func testString(_ s: String) {
+ print("TEST: Collect references for strings")
+ let refs = _collectReferencesInsideObject(s)
+ print("References are: \(refs)")
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ let _ = [String](repeating: s, count: 4)
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test finding references inside a Dictionary object.
+@inline(never)
+func testDict(_ _dint: [Int : Int]) {
+ print("TEST: Collect references for dictionaries")
+ var dint = _dint
+ dint[3] = 3
+ let refs = _collectReferencesInsideObject(dint)
+ print("References are: \(refs)")
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ dint[222] = 222
+ dint[2222] = 2222
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test finding references inside an object graph with a cycle.
+/// It should not result in a stack overflow.
+@inline(never)
+func testObjectCycle() {
+ print("TEST: Collect references on object graph with cycles")
+ print("testObjectCycle")
+ let c1 = C()
+ let c2 = C()
+ c1.next = c1
+ c2.next = c1
+ let refs = _collectReferencesInsideObject(c1)
+ print("References are: \(refs)")
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ c1.next = nil
+ c2.next = nil
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test runtime function counters for a List object.
+@inline(never)
+func testLists() {
+ print("TEST: Runtime function counters for Lists")
+ print("testLists")
+ let globalCounters1 = _GlobalRuntimeFunctionCountersState()
+ var l: List<Int>? = List(1, List(2, List(3, List(4, List(5)))))
+ let refs = _collectReferencesInsideObject(l!)
+ let globalCounters11 = _GlobalRuntimeFunctionCountersState()
+ let _ = _collectReferencesInsideObject(l!)
+ let globalCounters111 = _GlobalRuntimeFunctionCountersState()
+
+ print("Global counters diff for 11")
+ globalCounters1.dumpDiff(globalCounters11, skipUnchanged: true)
+ print("Global counters diff for 111")
+ globalCounters1.dumpDiff(globalCounters111, skipUnchanged: true)
+
+ let len = length(l!)
+ let globalCounters2 = _GlobalRuntimeFunctionCountersState()
+ print("Length of the list is \(len)")
+ print("Global counters diff after constructing a list and computing its length")
+ globalCounters1.dumpDiff(globalCounters2, skipUnchanged: true)
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ l = nil
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ print("List head counters after list becomes unreferenced")
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test the _measureRuntimeFunctionCountersDiffs API.
+@inline(never)
+func testMeasureRuntimeFunctionCountersDiffs() {
+ print("TEST: Measure runtime function counters diff")
+ let l: List<Int>? = List(1, List(2, List(3, List(4, List(5)))))
+ let refs = _collectReferencesInsideObject(l!)
+ var len = 0
+ let (globalCounters, objectsCountersDiffs) =
+ _measureRuntimeFunctionCountersDiffs(objects: [refs[0]]) {
+ len = length(l!)
+ }
+ print("List length is: \(len)")
+ print("Global counters changes")
+ globalCounters.dump(skipUnchanged: true)
+ print("Objects counters changes")
+ for (i, objectCounters) in objectsCountersDiffs.enumerated() {
+ print("Object counters diff for \(refs[i])")
+ objectCounters.dump(skipUnchanged: true)
+ }
+}
+
+/// This is a handler that is invoked on each runtime functions counters update.
+@inline(never)
+func updatesHandler(object: UnsafeRawPointer, functionId: Int64) {
+ let savedMode = _RuntimeFunctionCounters.disableRuntimeFunctionCountersUpdates()
+ print("Start handler")
+ let functionName = _RuntimeFunctionCounters.runtimeFunctionNames[Int(functionId)]
+ print("Function \(functionName) was invoked on object \(object)")
+ print("End handler")
+ _RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates(mode: savedMode)
+}
+
+/// Check that it is possible to set your own runtime functions counters
+/// updates handler and this handler is invoked at runtime.
+/// CHECK-LABEL: TEST: Provide runtime function counters update handler
+/// CHECK: Start handler
+/// Check that allocations and deallocations are intercepted too.
+/// CHECK: swift_allocObject
+/// CHECK: swift_deallocObject
+/// CHECK: End handler
+/// Test that you can provide custom handlers for runtime functions counters
+/// updates.
+var globalC: C? = nil
+@inline(never)
+func testFunctionRuntimeCountersUpdateHandler() {
+ print("TEST: Provide runtime function counters update handler")
+ let l: List<Int>? = List(1, List(2, List(3, List(4, List(5)))))
+ let oldHandler =
+ _RuntimeFunctionCounters.setGlobalRuntimeFunctionCountersUpdateHandler(
+ handler: updatesHandler)
+ globalC = C()
+ globalC = nil
+ let len = length(l!)
+ _ = _RuntimeFunctionCounters.setGlobalRuntimeFunctionCountersUpdateHandler(
+ handler: oldHandler)
+ print("Restored old handler")
+ print(len)
+}
+
+/// Enable runtime function counters stats collection.
+_RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates()
+
+/// Test collection of references inside different types of objects.
+testCollectReferencesInsideObject()
+
+/// Test some APIs from _RuntimeFunctionCounters.
+testRuntimeCounters()
+
+/// Test dumping of counters for all objects.
+_RuntimeFunctionCounters.dumpObjectsRuntimeFunctionPointers()
+
+/// Test runtime function counters for a List object.
+testLists()
+
+/// Test the _measureRuntimeFunctionCountersDiffs API.
+testMeasureRuntimeFunctionCountersDiffs()
+
+/// Test that you can provide custom handlers for runtime functions counters updates.
+testFunctionRuntimeCountersUpdateHandler()
diff --git a/test/stdlib/test_runtime_function_counters_with_disabled_assertions.swift b/test/stdlib/test_runtime_function_counters_with_disabled_assertions.swift
new file mode 100644
index 0000000..6a517a9
--- /dev/null
+++ b/test/stdlib/test_runtime_function_counters_with_disabled_assertions.swift
@@ -0,0 +1,258 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-build-swift %s -o %t/test_runtime_function_counters
+// RUN: %target-run %t/test_runtime_function_counters 2>&1 | %FileCheck %s
+// REQUIRES: executable_test
+
+/// Test functionality related to the runtime function counters.
+
+class C {
+ var next: C? = nil
+ func test(_ c: C) {
+ }
+}
+
+struct MyStruct {
+ var ref1: AnyObject? = C()
+ var ref2: AnyObject = C()
+ var str: String = ""
+}
+
+public final class List<T> {
+ var value: T
+ var next: List<T>?
+
+ init(_ value: T) {
+ self.value = value
+ self.next = nil
+ }
+
+ init(_ value: T, _ tail: List<T>) {
+ self.value = value
+ self.next = tail
+ }
+}
+
+public func length<T>(_ l: List<T>) -> Int {
+ var ll: List<T>? = l
+ var len = 0
+ while ll != nil {
+ len = len + 1
+ ll = ll?.next
+ }
+ return len
+}
+
+/// CHECK-LABEL: TEST: Collect references inside objects
+/// Constant strings do not have an owner, thus no references.
+/// CHECK: Constant string: []
+/// An array has one reference
+/// CHECK: Array<Int>: [{{[0-9a-fA-Fx]+}}]
+/// MyStruct has two references
+/// CHECK: MyStruct: [{{[0-9a-fA-Fx]+}}, {{[0-9a-fA-Fx]+}}]
+/// Dictionary has once reference
+/// CHECK: Dictionary<Int, Int>: [{{[0-9a-fA-Fx]+}}]
+/// Set has once reference
+/// CHECK: Set<Int>: [{{[0-9a-fA-Fx]+}}]
+/// Test collection of references inside different types of objects.
+@inline(never)
+func testCollectReferencesInsideObject() {
+ print("TEST: Collect references inside objects")
+ let s = "MyString"
+ let aint = [1,2,3,4]
+ let dint = [1:1, 2:2]
+ let sint: Set<Int> = [1,2,3,4]
+
+ print("Constant string: \(_collectReferencesInsideObject(s))")
+ print("Array<Int>: \(_collectReferencesInsideObject(aint))")
+ print("MyStruct: \(_collectReferencesInsideObject(MyStruct()))")
+ print("Dictionary<Int, Int>: \(_collectReferencesInsideObject(dint))")
+ print("Set<Int>: \(_collectReferencesInsideObject(sint))")
+
+ var mystring = "MyString"
+ mystring.append("End")
+ testString(mystring)
+ testDict(dint)
+ testObjectCycle()
+}
+
+
+/// CHECK-LABEL: TEST: APIs from _RuntimeFunctionCounters
+/// CHECK: Number of runtime function pointers:
+/// Test some APIs from _RuntimeFunctionCounters
+func testRuntimeCounters() {
+ print("TEST: APIs from _RuntimeFunctionCounters")
+ let numRuntimeFunctionPointer =
+ _RuntimeFunctionCounters.getNumRuntimeFunctionCounters()
+
+ print("Number of runtime function pointers: \(numRuntimeFunctionPointer)")
+
+ let names = _RuntimeFunctionCounters.getRuntimeFunctionNames()
+ let offsets = _RuntimeFunctionCounters.getRuntimeFunctionCountersOffsets()
+
+ for i in 0..<numRuntimeFunctionPointer {
+ print("Runtime function \(i) : \(names[i]) at offset: \(offsets[i])")
+ }
+
+ var d: [Int : Int] = [:]
+ let globalCounters1 = _GlobalRuntimeFunctionCountersState()
+
+ for i in 0..<50 {
+ let k = i
+ let v = i*i
+ d[k] = v
+ }
+
+ let globalCounters2 = _GlobalRuntimeFunctionCountersState()
+
+ globalCounters1.dumpDiff(globalCounters2, skipUnchanged: true)
+}
+
+/// Test finding references inside a String object.
+@inline(never)
+func testString(_ s: String) {
+ print("TEST: Collect references for strings")
+ let refs = _collectReferencesInsideObject(s)
+ print("References are: \(refs)")
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ let _ = [String](repeating: s, count: 4)
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test finding references inside a Dictionary object.
+@inline(never)
+func testDict(_ _dint: [Int : Int]) {
+ print("TEST: Collect references for dictionaries")
+ var dint = _dint
+ dint[3] = 3
+ let refs = _collectReferencesInsideObject(dint)
+ print("References are: \(refs)")
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ dint[222] = 222
+ dint[2222] = 2222
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test finding references inside an object graph with a cycle.
+/// It should not result in a stack overflow.
+@inline(never)
+func testObjectCycle() {
+ print("TEST: Collect references on object graph with cycles")
+ print("testObjectCycle")
+ let c1 = C()
+ let c2 = C()
+ c1.next = c1
+ c2.next = c1
+ let refs = _collectReferencesInsideObject(c1)
+ print("References are: \(refs)")
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ c1.next = nil
+ c2.next = nil
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test runtime function counters for a List object.
+@inline(never)
+func testLists() {
+ print("TEST: Runtime function counters for Lists")
+ print("testLists")
+ let globalCounters1 = _GlobalRuntimeFunctionCountersState()
+ var l: List<Int>? = List(1, List(2, List(3, List(4, List(5)))))
+ let refs = _collectReferencesInsideObject(l!)
+ let globalCounters11 = _GlobalRuntimeFunctionCountersState()
+ let _ = _collectReferencesInsideObject(l!)
+ let globalCounters111 = _GlobalRuntimeFunctionCountersState()
+
+ print("Global counters diff for 11")
+ globalCounters1.dumpDiff(globalCounters11, skipUnchanged: true)
+ print("Global counters diff for 111")
+ globalCounters1.dumpDiff(globalCounters111, skipUnchanged: true)
+
+ let len = length(l!)
+ let globalCounters2 = _GlobalRuntimeFunctionCountersState()
+ print("Length of the list is \(len)")
+ print("Global counters diff after constructing a list and computing its length")
+ globalCounters1.dumpDiff(globalCounters2, skipUnchanged: true)
+ let objectCounters1 = _ObjectRuntimeFunctionCountersState(refs[0])
+ l = nil
+ let objectCounters2 = _ObjectRuntimeFunctionCountersState(refs[0])
+ print("List head counters after list becomes unreferenced")
+ objectCounters1.dumpDiff(objectCounters2, skipUnchanged: true)
+}
+
+/// Test the _measureRuntimeFunctionCountersDiffs API.
+@inline(never)
+func testMeasureRuntimeFunctionCountersDiffs() {
+ print("TEST: Measure runtime function counters diff")
+ let l: List<Int>? = List(1, List(2, List(3, List(4, List(5)))))
+ let refs = _collectReferencesInsideObject(l!)
+ var len = 0
+ let (globalCounters, objectsCountersDiffs) =
+ _measureRuntimeFunctionCountersDiffs(objects: [refs[0]]) {
+ len = length(l!)
+ }
+ print("List length is: \(len)")
+ print("Global counters changes")
+ globalCounters.dump(skipUnchanged: true)
+ print("Objects counters changes")
+ for (i, objectCounters) in objectsCountersDiffs.enumerated() {
+ print("Object counters diff for \(refs[i])")
+ objectCounters.dump(skipUnchanged: true)
+ }
+}
+
+/// This is a handler that is invoked on each runtime functions counters update.
+@inline(never)
+func updatesHandler(object: UnsafeRawPointer, functionId: Int64) {
+ let savedMode = _RuntimeFunctionCounters.disableRuntimeFunctionCountersUpdates()
+ print("Start handler")
+ let functionName = _RuntimeFunctionCounters.runtimeFunctionNames[Int(functionId)]
+ print("Function \(functionName) was invoked on object \(object)")
+ print("End handler")
+ _RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates(mode: savedMode)
+}
+
+/// Check that it is possible to set your own runtime functions counters
+/// updates handler and this handler is invoked at runtime.
+/// CHECK-LABEL: TEST: Provide runtime function counters update handler
+/// Test that you can provide custom handlers for runtime functions counters
+/// updates.
+var globalC: C? = nil
+@inline(never)
+func testFunctionRuntimeCountersUpdateHandler() {
+ print("TEST: Provide runtime function counters update handler")
+ let l: List<Int>? = List(1, List(2, List(3, List(4, List(5)))))
+ let oldHandler =
+ _RuntimeFunctionCounters.setGlobalRuntimeFunctionCountersUpdateHandler(
+ handler: updatesHandler)
+ globalC = C()
+ globalC = nil
+ let len = length(l!)
+ _ = _RuntimeFunctionCounters.setGlobalRuntimeFunctionCountersUpdateHandler(
+ handler: oldHandler)
+ print("Restored old handler")
+ print(len)
+}
+
+/// Enable runtime function counters stats collection.
+_RuntimeFunctionCounters.enableRuntimeFunctionCountersUpdates()
+
+/// Test collection of references inside different types of objects.
+testCollectReferencesInsideObject()
+
+/// Test some APIs from _RuntimeFunctionCounters.
+testRuntimeCounters()
+
+/// Test dumping of counters for all objects.
+_RuntimeFunctionCounters.dumpObjectsRuntimeFunctionPointers()
+
+/// Test runtime function counters for a List object.
+testLists()
+
+/// Test the _measureRuntimeFunctionCountersDiffs API.
+testMeasureRuntimeFunctionCountersDiffs()
+
+/// Test that you can provide custom handlers for runtime functions counters updates.
+testFunctionRuntimeCountersUpdateHandler()
diff --git a/tools/SourceKit/CMakeLists.txt b/tools/SourceKit/CMakeLists.txt
index 03787e2..0ba6c2a 100644
--- a/tools/SourceKit/CMakeLists.txt
+++ b/tools/SourceKit/CMakeLists.txt
@@ -518,28 +518,30 @@
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
if(SWIFT_BUILD_SOURCEKIT)
- add_custom_command(
- OUTPUT "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so"
- COMMAND autoreconf -fvi
- COMMAND /usr/bin/env "CC=${PATH_TO_CLANG_BUILD}/bin/clang" "CXX=${PATH_TO_CLANG_BUILD}/bin/clang++" "OBJC=${PATH_TO_CLANG_BUILD}/bin/clang" ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/configure --prefix="${CMAKE_INSTALL_PREFIX}"
- COMMAND /usr/bin/make
- COMMAND /bin/mkdir -p ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/
- COMMAND /bin/cp ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/.libs/libdispatch.so ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so
- COMMAND /usr/bin/make distclean
- WORKING_DIRECTORY ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}
- COMMENT "Generating libdispatch.so"
- USES_TERMINAL
- )
- add_custom_target(needs-libdispatch
- DEPENDS "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so"
- )
+ include(ExternalProject)
+ ExternalProject_Add(libdispatch
+ SOURCE_DIR
+ "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}"
+ BINARY_DIR
+ "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}"
+ CMAKE_ARGS
+ -DCMAKE_C_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang
+ -DCMAKE_CXX_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang++
+ -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+ BUILD_BYPRODUCTS
+ ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/${CMAKE_SHARED_LIBRARY_PREFIX}dispatch${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+ include_directories(AFTER
+ ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime)
+ link_directories(${SWIFT_PATH_TO_LIBDISPATCH_BUILD})
endif()
include_directories(AFTER ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
- add_library(dispatch SHARED IMPORTED)
- set_target_properties(dispatch PROPERTIES
- IMPORTED_LOCATION ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/.libs/libdispatch.so)
+ add_library(dispatch UNKNOWN IMPORTED)
+ set_target_properties(dispatch
+ PROPERTIES
+ IMPORTED_LOCATION ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/${CMAKE_SHARED_LIBRARY_PREFIX}dispatch${CMAKE_SHARED_LIBRARY_SUFFIX})
add_library(swiftCore SHARED IMPORTED)
set_target_properties(swiftCore PROPERTIES
diff --git a/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def b/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
index a768f27..8f019c7 100644
--- a/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
+++ b/tools/SourceKit/include/SourceKit/Core/ProtocolUIDs.def
@@ -310,10 +310,9 @@
KIND(DiagWarning, "source.diagnostic.severity.warning")
KIND(DiagError, "source.diagnostic.severity.error")
-KIND(CodeCompletionKeyword, "source.codecompletion.keyword")
KIND(CodeCompletionEverything, "source.codecompletion.everything")
KIND(CodeCompletionModule, "source.codecompletion.module")
-KIND(CodeCompletionCodeCompleteKeyword, "source.codecompletion.keyword")
+KIND(CodeCompletionKeyword, "source.codecompletion.keyword")
KIND(CodeCompletionLiteral, "source.codecompletion.literal")
KIND(CodeCompletionCustom, "source.codecompletion.custom")
KIND(CodeCompletionIdentifier, "source.codecompletion.identifier")
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp b/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
index 48aef12..67abda9 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
@@ -258,110 +258,261 @@
}
}
-
struct SwiftSyntaxToken {
- unsigned Column;
+ unsigned Offset;
unsigned Length:24;
SyntaxNodeKind Kind:8;
- SwiftSyntaxToken(unsigned Column, unsigned Length,
- SyntaxNodeKind Kind)
- :Column(Column), Length(Length), Kind(Kind) { }
+ static SwiftSyntaxToken createInvalid() {
+ return {0, 0, SyntaxNodeKind::AttributeBuiltin};
+ }
+
+ SwiftSyntaxToken(unsigned Offset, unsigned Length, SyntaxNodeKind Kind)
+ : Offset(Offset), Length(Length), Kind(Kind) {}
+
+ unsigned endOffset() const { return Offset + Length; }
+
+ bool isInvalid() const { return Length == 0; }
+
+ bool operator==(const SwiftSyntaxToken &Other) const {
+ return Offset == Other.Offset && Length == Other.Length &&
+ Kind == Other.Kind;
+ }
+
+ bool operator!=(const SwiftSyntaxToken &Other) const {
+ return Offset != Other.Offset || Length != Other.Length ||
+ Kind != Other.Kind;
+ }
};
-class SwiftSyntaxMap {
- typedef std::vector<SwiftSyntaxToken> SwiftSyntaxLineMap;
- std::vector<SwiftSyntaxLineMap> Lines;
+struct SwiftEditorCharRange {
+ unsigned Offset;
+ unsigned EndOffset;
-public:
- bool matchesFirstTokenOnLine(unsigned Line,
- const SwiftSyntaxToken &Token) const {
- assert(Line > 0);
- if (Lines.size() < Line)
+ SwiftEditorCharRange(unsigned Offset, unsigned EndOffset) :
+ Offset(Offset), EndOffset(EndOffset) {}
+
+ SwiftEditorCharRange(SwiftSyntaxToken Token) :
+ Offset(Token.Offset), EndOffset(Token.endOffset()) {}
+
+ size_t length() const { return EndOffset - Offset; }
+ bool isEmpty() const { return Offset == EndOffset; }
+ bool intersects(const SwiftSyntaxToken &Token) const {
+ return this->Offset < (Token.endOffset()) && this->EndOffset > Token.Offset;
+ }
+ void extendToInclude(const SwiftEditorCharRange &Range) {
+ if (Range.Offset < Offset)
+ Offset = Range.Offset;
+ if (Range.EndOffset > EndOffset)
+ EndOffset = Range.EndOffset;
+ }
+ void extendToInclude(unsigned OtherOffset) {
+ extendToInclude({OtherOffset, OtherOffset});
+ }
+};
+
+/// Finds and represents the first mismatching tokens in two syntax maps,
+/// ignoring invalidated tokens.
+template <class Iter>
+struct TokenMismatch {
+ /// The begin and end iterators of the previous syntax map
+ Iter PrevTok, PrevEnd;
+ /// The begin and end iterators of the current syntax map
+ Iter CurrTok, CurrEnd;
+
+ TokenMismatch(Iter CurrTok, Iter CurrEnd, Iter PrevTok, Iter PrevEnd) :
+ PrevTok(PrevTok), PrevEnd(PrevEnd), CurrTok(CurrTok), CurrEnd(CurrEnd) {
+ skipInvalid();
+ while(advance());
+ }
+
+ /// Returns true if a mismatch was found
+ bool foundMismatch() const {
+ return CurrTok != CurrEnd || PrevTok != PrevEnd;
+ }
+
+ /// Returns the smallest start offset of the mismatched token ranges
+ unsigned mismatchStart() const {
+ assert(foundMismatch());
+ if (CurrTok != CurrEnd) {
+ if (PrevTok != PrevEnd)
+ return std::min(CurrTok->Offset, PrevTok->Offset);
+ return CurrTok->Offset;
+ }
+ return PrevTok->Offset;
+ }
+
+ /// Returns the largest end offset of the mismatched token ranges
+ unsigned mismatchEnd() const {
+ assert(foundMismatch());
+ if (CurrTok != CurrEnd) {
+ if (PrevTok != PrevEnd)
+ return std::max(CurrTok->endOffset(), PrevTok->endOffset());
+ return CurrTok->endOffset();
+ }
+ return PrevTok->endOffset();
+ }
+
+private:
+ void skipInvalid() {
+ while (PrevTok != PrevEnd && PrevTok->isInvalid())
+ ++PrevTok;
+ }
+
+ bool advance() {
+ if (CurrTok == CurrEnd || PrevTok == PrevEnd || *CurrTok != *PrevTok)
return false;
+ ++CurrTok;
+ ++PrevTok;
+ skipInvalid();
+ return true;
+ }
+};
- unsigned LineOffset = Line - 1;
- const SwiftSyntaxLineMap &LineMap = Lines[LineOffset];
- if (LineMap.empty())
- return false;
+/// Represents a the syntax highlighted token ranges in a source file
+struct SwiftSyntaxMap {
+ std::vector<SwiftSyntaxToken> Tokens;
- const SwiftSyntaxToken &Tok = LineMap.front();
- if (Tok.Column == Token.Column && Tok.Length == Token.Length
- && Tok.Kind == Token.Kind) {
- return true;
- }
-
- return false;
+ explicit SwiftSyntaxMap(unsigned Capacity = 0) {
+ if (Capacity)
+ Tokens.reserve(Capacity);
}
- void addTokenForLine(unsigned Line, const SwiftSyntaxToken &Token) {
- assert(Line > 0);
- if (Lines.size() < Line) {
- Lines.resize(Line);
- }
- unsigned LineOffset = Line - 1;
- SwiftSyntaxLineMap &LineMap = Lines[LineOffset];
- // FIXME: Assert this token is after the last one
- LineMap.push_back(Token);
+ void addToken(const SwiftSyntaxToken &Token) {
+ assert(Tokens.empty() || Token.Offset >= Tokens.back().Offset);
+ Tokens.push_back(Token);
}
- void mergeTokenForLine(unsigned Line, const SwiftSyntaxToken &Token) {
- assert(Line > 0);
- if (Lines.size() < Line) {
- Lines.resize(Line);
+ /// Merge this nested token into the last token that was added
+ void mergeToken(const SwiftSyntaxToken &Token) {
+ if (Tokens.empty()) {
+ Tokens.push_back(Token);
+ return;
}
- unsigned LineOffset = Line - 1;
- SwiftSyntaxLineMap &LineMap = Lines[LineOffset];
- if (!LineMap.empty()) {
- auto &LastTok = LineMap.back();
- mergeSplitRanges(LastTok.Column, LastTok.Length,
- Token.Column, Token.Length,
- [&](unsigned BeforeOff, unsigned BeforeLen,
- unsigned AfterOff, unsigned AfterLen) {
- auto LastKind = LastTok.Kind;
- LineMap.pop_back();
- if (BeforeLen)
- LineMap.emplace_back(BeforeOff, BeforeLen, LastKind);
- LineMap.push_back(Token);
- if (AfterLen)
- LineMap.emplace_back(AfterOff, AfterLen, LastKind);
- });
+ auto &LastTok = Tokens.back();
+ assert(LastTok.Offset <= Token.Offset);
+ mergeSplitRanges(LastTok.Offset, LastTok.Length, Token.Offset, Token.Length,
+ [&](unsigned BeforeOff, unsigned BeforeLen,
+ unsigned AfterOff, unsigned AfterLen) {
+ auto LastKind = LastTok.Kind;
+ Tokens.pop_back();
+ if (BeforeLen)
+ Tokens.emplace_back(BeforeOff, BeforeLen, LastKind);
+ Tokens.push_back(Token);
+ if (AfterLen)
+ Tokens.emplace_back(AfterOff, AfterLen, LastKind);
+ });
+ }
+
+ /// Adjusts the token offsets and lengths in this syntax map to account for
+ /// replacing \p Len bytes at the given \p Offset with \p NewLen bytes. Tokens
+ /// before the replacement stay the same, tokens after it are shifted, and
+ /// tokens that intersect it are 'removed' (really just marked invalid).
+ /// Clients are expected to match this behavior.
+ ///
+ /// Returns the union of the replaced range and the token ranges it
+ /// intersected, or nothing if no tokens were intersected.
+ llvm::Optional<SwiftEditorCharRange>
+ adjustForReplacement(unsigned Offset, unsigned Len, unsigned NewLen) {
+ unsigned ReplacedStart = Offset;
+ unsigned ReplacedEnd = Offset + Len;
+ bool TokenIntersected = false;
+ SwiftEditorCharRange Affected = { /*Offset=*/ReplacedStart,
+ /*EndOffset=*/ReplacedEnd};
+ // Adjust the tokens
+ auto Token = Tokens.begin();
+ while (Token != Tokens.end() && Token->endOffset() <= ReplacedStart) {
+ // Completely before the replaced range – no change needed
+ ++Token;
}
- else {
- // Not overlapping, just add the new token to the end
- LineMap.push_back(Token);
+
+ while (Token != Tokens.end() && Token->Offset < ReplacedEnd) {
+ // Intersecting the replaced range – extend Affected and invalidate
+ TokenIntersected = true;
+ Affected.extendToInclude(*Token);
+ *Token = SwiftSyntaxToken::createInvalid();
+ ++Token;
+ }
+
+ while (Token != Tokens.end()) {
+ // Completely after the replaced range - shift to account for NewLen
+ if (NewLen >= Len)
+ Token->Offset += NewLen - Len;
+ else
+ Token->Offset -= Len - NewLen;
+ ++Token;
+ }
+
+ // If the replaced range didn't intersect with any existing tokens, there's
+ // no need to report an affected range
+ if (!TokenIntersected)
+ return None;
+
+ // Update the end of the affected range to account for NewLen
+ if (NewLen >= Len) {
+ Affected.EndOffset += NewLen - Len;
+ } else {
+ Affected.EndOffset -= Len - NewLen;
+ }
+
+ return Affected;
+ }
+
+ /// Passes each token in this SwiftSyntaxMap to the given \p Consumer
+ void forEach(EditorConsumer &Consumer) {
+ for (auto &Token: Tokens) {
+ auto Kind = SwiftLangSupport::getUIDForSyntaxNodeKind(Token.Kind);
+ Consumer.handleSyntaxMap(Token.Offset, Token.Length, Kind);
}
}
- void clearLineRange(unsigned StartLine, unsigned Length) {
- assert(StartLine > 0);
- unsigned LineOffset = StartLine - 1;
- for (unsigned Line = LineOffset; Line < LineOffset + Length
- && Line < Lines.size(); ++Line) {
- Lines[Line].clear();
+ /// Finds the delta between the given SwiftSyntaxMap, \p Prev, and this one.
+ /// It passes each token not in \p Prev to the given \p Consumer and, if
+ /// needed, also expands or sets the given \p Affected range to cover all
+ /// non-matching tokens in the two lists.
+ ///
+ /// Returns true if this SwiftSyntaxMap is different to \p Prev.
+ bool forEachChanged(const SwiftSyntaxMap &Prev,
+ llvm::Optional<SwiftEditorCharRange> &Affected,
+ EditorConsumer &Consumer) const {
+ typedef std::vector<SwiftSyntaxToken>::const_iterator ForwardIt;
+ typedef std::vector<SwiftSyntaxToken>::const_reverse_iterator ReverseIt;
+
+ // Find the first pair of tokens that don't match
+ TokenMismatch<ForwardIt>
+ Forward(Tokens.begin(), Tokens.end(), Prev.Tokens.begin(), Prev.Tokens.end());
+
+ // Exit early if there was no mismatch
+ if (!Forward.foundMismatch())
+ return Affected && !Affected->isEmpty();
+
+ // Find the last pair of tokens that don't match
+ TokenMismatch<ReverseIt>
+ Backward(Tokens.rbegin(), Tokens.rend(), Prev.Tokens.rbegin(), Prev.Tokens.rend());
+ assert(Backward.foundMismatch());
+
+ // Set or extend the affected range to include the mismatched range
+ SwiftEditorCharRange
+ MismatchRange = {Forward.mismatchStart(),Backward.mismatchEnd()};
+ if (!Affected) {
+ Affected = MismatchRange;
+ } else {
+ Affected->extendToInclude(MismatchRange);
}
- }
- void removeLineRange(unsigned StartLine, unsigned Length) {
- assert(StartLine > 0 && Length > 0);
-
- if (StartLine < Lines.size()) {
- unsigned EndLine = StartLine + Length - 1;
- // Delete all syntax map data from start line through end line
- Lines.erase(Lines.begin() + StartLine - 1,
- EndLine >= Lines.size() ? Lines.end()
- : Lines.begin() + EndLine);
+ // Report all tokens in the affected range to the EditorConsumer
+ auto From = Forward.CurrTok;
+ auto To = Backward.CurrTok;
+ while (From != Tokens.begin() && (From-1)->Offset >= Affected->Offset)
+ --From;
+ while (To != Tokens.rbegin() && (To-1)->endOffset() <= Affected->EndOffset)
+ --To;
+ for (; From < To.base(); ++From) {
+ auto Kind = SwiftLangSupport::getUIDForSyntaxNodeKind(From->Kind);
+ Consumer.handleSyntaxMap(From->Offset, From->Length, Kind);
}
- }
- void insertLineRange(unsigned StartLine, unsigned Length) {
- Lines.insert(StartLine <= Lines.size() ? Lines.begin() + StartLine - 1
- : Lines.end(),
- Length, SwiftSyntaxLineMap());
- }
-
- void reset() {
- Lines.clear();
+ return true;
}
};
@@ -373,8 +524,6 @@
:Offset(Offset), Length(Length), Kind(Kind) { }
};
-typedef std::pair<unsigned, unsigned> SwiftEditorCharRange;
-
struct SwiftSemanticToken {
unsigned ByteOffset;
unsigned Length : 24;
@@ -849,9 +998,12 @@
const std::string FilePath;
EditableTextBufferRef EditableBuffer;
+ /// The list of syntax highlighted token offsets and ranges in the document
SwiftSyntaxMap SyntaxMap;
- LineRange EditedLineRange;
- SwiftEditorCharRange AffectedRange;
+ /// The minimal range of syntax highlighted tokens affected by the last edit
+ llvm::Optional<SwiftEditorCharRange> AffectedRange;
+ /// Whether the last operation was an edit rather than a document open
+ bool Edited;
std::vector<DiagnosticEntryInfo> ParserDiagnostics;
RefPtr<SwiftDocumentSemanticInfo> SemanticInfo;
@@ -1180,121 +1332,39 @@
}
};
+/// Walks the syntax model to populate a given SwiftSyntaxMap with the token
+/// ranges to highlight and pass document structure information to the given
+/// EditorConsumer.
class SwiftEditorSyntaxWalker: public ide::SyntaxModelWalker {
+ /// The syntax map to populate
SwiftSyntaxMap &SyntaxMap;
- LineRange EditedLineRange;
- SwiftEditorCharRange &AffectedRange;
SourceManager &SrcManager;
- EditorConsumer &Consumer;
unsigned BufferID;
SwiftDocumentStructureWalker DocStructureWalker;
- std::vector<EditorConsumerSyntaxMapEntry> ConsumerSyntaxMap;
+ /// The current token nesting level (e.g. for a field in a doc comment)
unsigned NestingLevel = 0;
public:
SwiftEditorSyntaxWalker(SwiftSyntaxMap &SyntaxMap,
- LineRange EditedLineRange,
- SwiftEditorCharRange &AffectedRange,
SourceManager &SrcManager, EditorConsumer &Consumer,
unsigned BufferID)
- : SyntaxMap(SyntaxMap), EditedLineRange(EditedLineRange),
- AffectedRange(AffectedRange), SrcManager(SrcManager), Consumer(Consumer),
- BufferID(BufferID),
+ : SyntaxMap(SyntaxMap), SrcManager(SrcManager), BufferID(BufferID),
DocStructureWalker(SrcManager, BufferID, Consumer) { }
bool walkToNodePre(SyntaxNode Node) override {
if (Node.Kind == SyntaxNodeKind::CommentMarker)
return DocStructureWalker.walkToNodePre(Node);
-
++NestingLevel;
- SourceLoc StartLoc = Node.Range.getStart();
- auto StartLineAndColumn = SrcManager.getLineAndColumn(StartLoc);
- auto EndLineAndColumn = SrcManager.getLineAndColumn(Node.Range.getEnd());
- unsigned StartLine = StartLineAndColumn.first;
- unsigned EndLine = EndLineAndColumn.second > 1 ? EndLineAndColumn.first
- : EndLineAndColumn.first - 1;
- unsigned Offset = SrcManager.getByteDistance(
- SrcManager.getLocForBufferStart(BufferID), StartLoc);
- // Note that the length can span multiple lines.
- unsigned Length = Node.Range.getByteLength();
- SwiftSyntaxToken Token(StartLineAndColumn.second, Length,
- Node.Kind);
- if (EditedLineRange.isValid()) {
- if (StartLine < EditedLineRange.startLine()) {
- if (EndLine < EditedLineRange.startLine()) {
- // We're entirely before the edited range, no update needed.
- return true;
- }
+ auto End = SrcManager.getLocOffsetInBuffer(Node.Range.getEnd(), BufferID),
+ Start = SrcManager.getLocOffsetInBuffer(Node.Range.getStart(), BufferID);
- // This token starts before the edited range, but doesn't end before it,
- // we need to adjust edited line range and clear the affected syntax map
- // line range.
- unsigned AdjLineCount = EditedLineRange.startLine() - StartLine;
- EditedLineRange.setRange(StartLine, AdjLineCount
- + EditedLineRange.lineCount());
- SyntaxMap.clearLineRange(StartLine, AdjLineCount);
-
- // Also adjust the affected char range accordingly.
- unsigned AdjCharCount = AffectedRange.first - Offset;
- AffectedRange.first -= AdjCharCount;
- AffectedRange.second += AdjCharCount;
- }
- else if (Offset > AffectedRange.first + AffectedRange.second) {
- // We're passed the affected range and already synced up, just return.
- return true;
- }
- else if (StartLine > EditedLineRange.endLine()) {
- // We're after the edited line range, let's test if we're synced up.
- if (SyntaxMap.matchesFirstTokenOnLine(StartLine, Token)) {
- // We're synced up, mark the affected range and return.
- AffectedRange.second =
- Offset - (StartLineAndColumn.second - 1) - AffectedRange.first;
- return true;
- }
-
- // We're not synced up, continue replacing syntax map data on this line.
- SyntaxMap.clearLineRange(StartLine, 1);
- EditedLineRange.extendToIncludeLine(StartLine);
- }
-
- if (EndLine > StartLine) {
- // The token spans multiple lines, make sure to replace syntax map data
- // for affected lines.
- EditedLineRange.extendToIncludeLine(EndLine);
-
- unsigned LineCount = EndLine - StartLine + 1;
- SyntaxMap.clearLineRange(StartLine, LineCount);
- }
-
- }
-
- // Add the syntax map token.
- if (NestingLevel > 1)
- SyntaxMap.mergeTokenForLine(StartLine, Token);
- else
- SyntaxMap.addTokenForLine(StartLine, Token);
-
- // Add consumer entry.
- unsigned ByteOffset = SrcManager.getLocOffsetInBuffer(Node.Range.getStart(),
- BufferID);
- UIdent Kind = SwiftLangSupport::getUIDForSyntaxNodeKind(Node.Kind);
if (NestingLevel > 1) {
- assert(!ConsumerSyntaxMap.empty());
- auto &Last = ConsumerSyntaxMap.back();
- mergeSplitRanges(Last.Offset, Last.Length, ByteOffset, Length,
- [&](unsigned BeforeOff, unsigned BeforeLen,
- unsigned AfterOff, unsigned AfterLen) {
- auto LastKind = Last.Kind;
- ConsumerSyntaxMap.pop_back();
- if (BeforeLen)
- ConsumerSyntaxMap.emplace_back(BeforeOff, BeforeLen, LastKind);
- ConsumerSyntaxMap.emplace_back(ByteOffset, Length, Kind);
- if (AfterLen)
- ConsumerSyntaxMap.emplace_back(AfterOff, AfterLen, LastKind);
- });
+ // We're nested inside the previously reported token - merge
+ SyntaxMap.mergeToken({Start, End - Start, Node.Kind});
+ } else {
+ // We're a top-level token, add it after the previous one
+ SyntaxMap.addToken({Start, End - Start, Node.Kind});
}
- else
- ConsumerSyntaxMap.emplace_back(ByteOffset, Length, Kind);
return true;
}
@@ -1302,14 +1372,7 @@
bool walkToNodePost(SyntaxNode Node) override {
if (Node.Kind == SyntaxNodeKind::CommentMarker)
return DocStructureWalker.walkToNodePost(Node);
-
- if (--NestingLevel == 0) {
- // We've unwound to the top level, so inform the consumer and drain
- // the consumer syntax map queue.
- for (auto &Entry: ConsumerSyntaxMap)
- Consumer.handleSyntaxMap(Entry.Offset, Entry.Length, Entry.Kind);
- ConsumerSyntaxMap.clear();
- }
+ --NestingLevel;
return true;
}
@@ -1590,11 +1653,14 @@
llvm::sys::ScopedLock L(Impl.AccessMtx);
+ Impl.Edited = false;
Impl.EditableBuffer =
new EditableTextBuffer(Impl.FilePath, Buf->getBuffer());
- Impl.SyntaxMap.reset();
- Impl.EditedLineRange.setRange(0,0);
- Impl.AffectedRange = std::make_pair(0, Buf->getBufferSize());
+
+ // Reset the syntax map data and affected range
+ Impl.SyntaxMap.Tokens.clear();
+ Impl.AffectedRange = {0, static_cast<unsigned>(Buf->getBufferSize())};
+
Impl.SemanticInfo =
new SwiftDocumentSemanticInfo(Impl.FilePath, Impl.LangSupport);
Impl.SemanticInfo->setCompilerArgs(Args);
@@ -1607,7 +1673,10 @@
llvm::sys::ScopedLock L(Impl.AccessMtx);
+ Impl.Edited = true;
llvm::StringRef Str = Buf->getBuffer();
+
+ // Update the buffer itself
ImmutableTextSnapshotRef Snapshot =
Impl.EditableBuffer->replace(Offset, Length, Str);
@@ -1633,37 +1702,12 @@
}
}
- SourceManager &SrcManager = Impl.SyntaxInfo->getSourceManager();
- unsigned BufID = Impl.SyntaxInfo->getBufferID();
- SourceLoc StartLoc = SrcManager.getLocForBufferStart(BufID).getAdvancedLoc(
- Offset);
- unsigned StartLine = SrcManager.getLineAndColumn(StartLoc).first;
- unsigned EndLine = SrcManager.getLineAndColumn(
- StartLoc.getAdvancedLoc(Length)).first;
-
- // Delete all syntax map data from start line through end line.
- unsigned OldLineCount = EndLine - StartLine + 1;
- Impl.SyntaxMap.removeLineRange(StartLine, OldLineCount);
-
- // Insert empty syntax map data for replaced lines.
- unsigned NewLineCount = Str.count('\n') + 1;
- Impl.SyntaxMap.insertLineRange(StartLine, NewLineCount);
-
- // Update the edited line range.
- Impl.EditedLineRange.setRange(StartLine, NewLineCount);
-
- ImmutableTextBufferRef ImmBuf = Snapshot->getBuffer();
-
- // The affected range starts from the previous newline.
- if (Offset > 0) {
- auto AffectedRangeOffset = ImmBuf->getText().rfind('\n', Offset);
- Impl.AffectedRange.first =
- AffectedRangeOffset != StringRef::npos ? AffectedRangeOffset + 1 : 0;
- }
- else
- Impl.AffectedRange.first = 0;
-
- Impl.AffectedRange.second = ImmBuf->getText().size() - Impl.AffectedRange.first;
+ // Update the old syntax map offsets to account for the replaced range.
+ // Also set the initial AffectedRange to cover any tokens that
+ // the replaced range intersected. This allows for clients that split
+ // multi-line tokens at line boundaries, and ensure all parts of these tokens
+ // will be cleared.
+ Impl.AffectedRange = Impl.SyntaxMap.adjustForReplacement(Offset, Length, Str.size());
return Snapshot;
}
@@ -1716,17 +1760,34 @@
ide::SyntaxModelContext ModelContext(Impl.SyntaxInfo->getSourceFile());
- SwiftEditorSyntaxWalker SyntaxWalker(Impl.SyntaxMap,
- Impl.EditedLineRange,
- Impl.AffectedRange,
+ SwiftSyntaxMap NewMap = SwiftSyntaxMap(Impl.SyntaxMap.Tokens.size() + 16);
+
+ SwiftEditorSyntaxWalker SyntaxWalker(NewMap,
Impl.SyntaxInfo->getSourceManager(),
Consumer,
Impl.SyntaxInfo->getBufferID());
-
ModelContext.walk(SyntaxWalker);
- Consumer.recordAffectedRange(Impl.AffectedRange.first,
- Impl.AffectedRange.second);
+ bool SawChanges = true;
+ if (Impl.Edited) {
+ // We're ansering an edit request. Report all highlighted token ranges not
+ // in the previous syntax map to the Consumer and extend the AffectedRange
+ // to contain all added/removed token ranges.
+ SawChanges = NewMap.forEachChanged(Impl.SyntaxMap, Impl.AffectedRange,
+ Consumer);
+ } else {
+ // The is an open/initialise. Report all highlighted token ranges to the
+ // Consumer.
+ NewMap.forEach(Consumer);
+ }
+ Impl.SyntaxMap = std::move(NewMap);
+
+ // Recording an affected length of 0 still results in the client updating its
+ // copy of the syntax map (by clearning all tokens on the line of the affected
+ // offset). We need to not record it at all to signal a no-op.
+ if (SawChanges)
+ Consumer.recordAffectedRange(Impl.AffectedRange->Offset,
+ Impl.AffectedRange->length());
}
void SwiftEditorDocument::readSemanticInfo(ImmutableTextSnapshotRef Snapshot,
diff --git a/tools/driver/swift_format_main.cpp b/tools/driver/swift_format_main.cpp
index 89f41d5..eaa5920 100644
--- a/tools/driver/swift_format_main.cpp
+++ b/tools/driver/swift_format_main.cpp
@@ -96,9 +96,8 @@
}
public:
- void setMainExecutablePath(const std::string &Path) {
- MainExecutablePath = Path;
- }
+ SwiftFormatInvocation(const std::string &ExecPath)
+ : MainExecutablePath(ExecPath) {}
const std::string &getOutputFilename() { return OutputFilename; }
@@ -241,10 +240,8 @@
PrintingDiagnosticConsumer PDC;
Instance.addDiagnosticConsumer(&PDC);
- SwiftFormatInvocation Invocation;
- std::string MainExecutablePath =
- llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
- Invocation.setMainExecutablePath(MainExecutablePath);
+ SwiftFormatInvocation Invocation(
+ llvm::sys::fs::getMainExecutable(Argv0, MainAddr));
DiagnosticEngine &Diags = Instance.getDiags();
if (Invocation.parseArgs(Args, Diags) != 0)
diff --git a/tools/swift-refactor/swift-refactor.cpp b/tools/swift-refactor/swift-refactor.cpp
index 78e550c..3a2b3c2 100644
--- a/tools/swift-refactor/swift-refactor.cpp
+++ b/tools/swift-refactor/swift-refactor.cpp
@@ -38,6 +38,8 @@
"expand-default", "Perform expand default statement refactoring"),
clEnumValN(RefactoringKind::LocalizeString,
"localize-string", "Perform string localization refactoring"),
+ clEnumValN(RefactoringKind::CollapseNestedIfExpr,
+ "collapse-nested-if", "Perform collapse nested if statements"),
clEnumValN(RefactoringKind::SimplifyNumberLiteral,
"simplify-long-number", "Perform simplify long number literal refactoring"),
clEnumValN(RefactoringKind::ExtractFunction,
diff --git a/unittests/runtime/weak.mm b/unittests/runtime/weak.mm
index 2e11a3a..faf19d2 100644
--- a/unittests/runtime/weak.mm
+++ b/unittests/runtime/weak.mm
@@ -277,7 +277,8 @@
DestroyedObjCCount = 0;
WeakReference ref1;
- swift_unknownWeakInit(&ref1, o1);
+ auto res = swift_unknownWeakInit(&ref1, o1);
+ ASSERT_EQ(&ref1, res);
void *tmp = swift_unknownWeakLoadStrong(&ref1);
ASSERT_EQ(tmp, o1);
@@ -435,7 +436,8 @@
ASSERT_EQ(nullptr, result);
// ref2 = ref1 (nil -> nil)
- swift_unknownUnownedCopyInit(&ref2, &ref1);
+ auto res = swift_unknownUnownedCopyInit(&ref2, &ref1);
+ ASSERT_EQ(&ref2, res);
result = swift_unknownUnownedLoadStrong(&ref1);
ASSERT_EQ(nullptr, result);
result = swift_unknownUnownedLoadStrong(&ref2);
@@ -535,7 +537,8 @@
ASSERT_EQ(nullptr, result);
// ref2 = ref1 (nil -> nil)
- swift_unknownUnownedTakeInit(&ref2, &ref1);
+ auto res = swift_unknownUnownedTakeInit(&ref2, &ref1);
+ ASSERT_EQ(&ref2, res);
result = swift_unknownUnownedLoadStrong(&ref2);
ASSERT_EQ(nullptr, result);
swift_unknownUnownedDestroy(&ref2);
@@ -638,7 +641,8 @@
swift_unknownRelease(result);
// ref1 = ref2 (objc self transition)
- swift_unknownUnownedCopyAssign(&ref1, &ref2);
+ auto res = swift_unknownUnownedCopyAssign(&ref1, &ref2);
+ ASSERT_EQ(&ref1, res);
result = swift_unknownUnownedLoadStrong(&ref1);
ASSERT_EQ(objc1, result);
swift_unknownRelease(result);
@@ -766,7 +770,8 @@
void *result;
// ref1 = objc1
- swift_unknownUnownedInit(&ref1, objc1);
+ auto res = swift_unknownUnownedInit(&ref1, objc1);
+ ASSERT_EQ(&ref1, res);
result = swift_unknownUnownedLoadStrong(&ref1);
ASSERT_EQ(objc1, result);
swift_unknownRelease(result);
@@ -778,7 +783,8 @@
swift_unknownRelease(result);
// ref1 = ref2 (objc self transition)
- swift_unknownUnownedTakeAssign(&ref1, &ref2);
+ res = swift_unknownUnownedTakeAssign(&ref1, &ref2);
+ ASSERT_EQ(&ref1, res);
result = swift_unknownUnownedLoadStrong(&ref1);
ASSERT_EQ(objc1, result);
swift_unknownRelease(result);
@@ -928,3 +934,34 @@
swift_unownedDestroy(&ref1);
swift_unknownUnownedDestroy(&ref2);
}
+
+TEST(WeakTest, unknownWeak) {
+ void *objc1 = make_objc_object();
+ HeapObject *swift1 = make_swift_object();
+
+ WeakReference ref1;
+ auto res = swift_unknownWeakInit(&ref1, objc1);
+ ASSERT_EQ(&ref1, res);
+
+ WeakReference ref2;
+ res = swift_unknownWeakCopyInit(&ref2, &ref1);
+ ASSERT_EQ(&ref2, res);
+
+ WeakReference ref3; // ref2 dead.
+ res = swift_unknownWeakTakeInit(&ref3, &ref2);
+ ASSERT_EQ(&ref3, res);
+
+ res = swift_unknownWeakAssign(&ref3, swift1);
+ ASSERT_EQ(&ref3, res);
+
+ res = swift_unknownWeakCopyAssign(&ref3, &ref1);
+ ASSERT_EQ(&ref3, res);
+
+ res = swift_unknownWeakTakeAssign(&ref3, &ref1);
+ ASSERT_EQ(&ref3, res);
+
+ swift_unknownWeakDestroy(&ref3);
+
+ swift_release(swift1);
+ swift_unknownRelease(objc1);
+}
diff --git a/utils/build-script b/utils/build-script
index bcf13e0..b4ba44d 100755
--- a/utils/build-script
+++ b/utils/build-script
@@ -245,8 +245,6 @@
@staticmethod
def apply_default_arguments(toolchain, args):
- driver_arguments.apply_default_arguments(args)
-
# infer if ninja is required
ninja_required = (
args.cmake_generator == 'Ninja' or args.build_foundation)
@@ -270,80 +268,80 @@
# iterate over all supported platforms.
self.platforms_to_skip_build = set()
- if args.skip_build_linux:
+ if not args.build_linux:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.Linux)
- if args.skip_build_freebsd:
+ if not args.build_freebsd:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.FreeBSD)
- if args.skip_build_cygwin:
+ if not args.build_cygwin:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.Cygwin)
- if args.skip_build_osx:
+ if not args.build_osx:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.OSX)
- if args.skip_build_ios_device:
+ if not args.build_ios_device:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.iOS)
- if args.skip_build_ios_simulator:
+ if not args.build_ios_simulator:
self.platforms_to_skip_build.add(
StdlibDeploymentTarget.iOSSimulator)
- if args.skip_build_tvos_device:
+ if not args.build_tvos_device:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.AppleTV)
- if args.skip_build_tvos_simulator:
+ if not args.build_tvos_simulator:
self.platforms_to_skip_build.add(
StdlibDeploymentTarget.AppleTVSimulator)
- if args.skip_build_watchos_device:
+ if not args.build_watchos_device:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.AppleWatch)
- if args.skip_build_watchos_simulator:
+ if not args.build_watchos_simulator:
self.platforms_to_skip_build.add(
StdlibDeploymentTarget.AppleWatchSimulator)
- if args.skip_build_android:
+ if not args.build_android:
self.platforms_to_skip_build.add(StdlibDeploymentTarget.Android)
self.platforms_to_skip_test = set()
self.platforms_archs_to_skip_test = set()
- if args.skip_test_linux:
+ if not args.test_linux:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.Linux)
- if args.skip_test_freebsd:
+ if not args.test_freebsd:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.FreeBSD)
- if args.skip_test_cygwin:
+ if not args.test_cygwin:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.Cygwin)
- if args.skip_test_osx:
+ if not args.test_osx:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.OSX)
- if args.skip_test_ios_host:
+ if not args.test_ios_device:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.iOS)
else:
exit_rejecting_arguments("error: iOS device tests are not " +
"supported in open-source Swift.")
- if args.skip_test_ios_simulator:
+ if not args.test_ios_simulator:
self.platforms_to_skip_test.add(
StdlibDeploymentTarget.iOSSimulator)
- if args.skip_test_ios_32bit_simulator:
+ if not args.test_ios_32bit_simulator:
self.platforms_archs_to_skip_test.add(
StdlibDeploymentTarget.iOSSimulator.i386)
- if args.skip_test_tvos_host:
+ if not args.test_tvos_device:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.AppleTV)
else:
exit_rejecting_arguments("error: tvOS device tests are not " +
"supported in open-source Swift.")
- if args.skip_test_tvos_simulator:
+ if not args.test_tvos_simulator:
self.platforms_to_skip_test.add(
StdlibDeploymentTarget.AppleTVSimulator)
- if args.skip_test_watchos_host:
+ if not args.test_watchos_device:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.AppleWatch)
else:
exit_rejecting_arguments("error: watchOS device tests are not " +
"supported in open-source Swift.")
- if args.skip_test_watchos_simulator:
+ if not args.test_watchos_simulator:
self.platforms_to_skip_test.add(
StdlibDeploymentTarget.AppleWatchSimulator)
- if args.skip_test_android_host:
+ if not args.test_android_device:
self.platforms_to_skip_test.add(StdlibDeploymentTarget.Android)
self.platforms_to_skip_test_host = set()
- if args.skip_test_ios_host:
+ if not args.test_ios_device:
self.platforms_to_skip_test_host.add(StdlibDeploymentTarget.iOS)
- if args.skip_test_tvos_host:
+ if not args.test_tvos_device:
self.platforms_to_skip_test_host.add(
StdlibDeploymentTarget.AppleTV)
- if args.skip_test_watchos_host:
+ if not args.test_watchos_device:
self.platforms_to_skip_test_host.add(
StdlibDeploymentTarget.AppleWatch)
@@ -503,7 +501,7 @@
impl_args += ["--skip-build-cmark",
"--skip-build-llvm",
"--skip-build-swift"]
- if args.skip_build_benchmarks:
+ if not args.build_benchmarks:
impl_args += ["--skip-build-benchmarks"]
if not args.build_foundation:
impl_args += ["--skip-build-foundation"]
@@ -534,27 +532,27 @@
if args.build_swift_static_sdk_overlay:
impl_args += ["--build-swift-static-sdk-overlay"]
- if args.skip_build_linux:
+ if not args.build_linux:
impl_args += ["--skip-build-linux"]
- if args.skip_build_freebsd:
+ if not args.build_freebsd:
impl_args += ["--skip-build-freebsd"]
- if args.skip_build_cygwin:
+ if not args.build_cygwin:
impl_args += ["--skip-build-cygwin"]
- if args.skip_build_osx:
+ if not args.build_osx:
impl_args += ["--skip-build-osx"]
- if args.skip_build_ios_device:
+ if not args.build_ios_device:
impl_args += ["--skip-build-ios-device"]
- if args.skip_build_ios_simulator:
+ if not args.build_ios_simulator:
impl_args += ["--skip-build-ios-simulator"]
- if args.skip_build_tvos_device:
+ if not args.build_tvos_device:
impl_args += ["--skip-build-tvos-device"]
- if args.skip_build_tvos_simulator:
+ if not args.build_tvos_simulator:
impl_args += ["--skip-build-tvos-simulator"]
- if args.skip_build_watchos_device:
+ if not args.build_watchos_device:
impl_args += ["--skip-build-watchos-device"]
- if args.skip_build_watchos_simulator:
+ if not args.build_watchos_simulator:
impl_args += ["--skip-build-watchos-simulator"]
- if args.skip_build_android:
+ if not args.build_android:
impl_args += ["--skip-build-android"]
if not args.test and not args.long_test:
@@ -570,29 +568,29 @@
"--skip-test-libicu",
"--skip-test-playgroundlogger",
"--skip-test-playgroundsupport"]
- if args.skip_test_linux:
+ if not args.test_linux:
impl_args += ["--skip-test-linux"]
- if args.skip_test_freebsd:
+ if not args.test_freebsd:
impl_args += ["--skip-test-freebsd"]
- if args.skip_test_cygwin:
+ if not args.test_cygwin:
impl_args += ["--skip-test-cygwin"]
- if args.skip_test_osx:
+ if not args.test_osx:
impl_args += ["--skip-test-osx"]
- if args.skip_test_ios_host:
+ if not args.test_ios_device:
impl_args += ["--skip-test-ios-host"]
- if args.skip_test_ios_simulator:
+ if not args.test_ios_simulator:
impl_args += ["--skip-test-ios-simulator"]
- if args.skip_test_ios_32bit_simulator:
+ if not args.test_ios_32bit_simulator:
impl_args += ["--skip-test-ios-32bit-simulator"]
- if args.skip_test_tvos_host:
+ if not args.test_tvos_device:
impl_args += ["--skip-test-tvos-host"]
- if args.skip_test_tvos_simulator:
+ if not args.test_tvos_simulator:
impl_args += ["--skip-test-tvos-simulator"]
- if args.skip_test_watchos_host:
+ if not args.test_watchos_device:
impl_args += ["--skip-test-watchos-host"]
- if args.skip_test_watchos_simulator:
+ if not args.test_watchos_simulator:
impl_args += ["--skip-test-watchos-simulator"]
- if args.skip_test_android_host:
+ if not args.test_android_device:
impl_args += ["--skip-test-android-host"]
if args.build_runtime_with_host_compiler:
impl_args += ["--build-runtime-with-host-compiler"]
diff --git a/utils/build-script-impl b/utils/build-script-impl
index d1b0d0c..14773fc 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
@@ -1698,6 +1698,7 @@
echo "--config ${FOUNDATION_BUILD_TYPE}"
;;
libdispatch)
+ echo "--config ${LIBDISPATCH_BUILD_TYPE}"
;;
libicu)
;;
@@ -2447,41 +2448,61 @@
SWIFTC_BIN="$(build_directory_bin ${LOCAL_HOST} swift)/swiftc"
LLVM_BIN="$(build_directory_bin ${LOCAL_HOST} llvm)"
- if [[ "${RECONFIGURE}" || ! -f "${LIBDISPATCH_BUILD_DIR}"/config.status ]]; then
- echo "Reconfiguring libdispatch"
- # First time building; need to run autotools and configure
- if [[ "$LIBDISPATCH_BUILD_TYPE" == "Release" ]] ; then
- dispatch_build_variant_arg="release"
- elif [[ "$LIBDISPATCH_BUILD_TYPE" == "RelWithDebInfo" ]]; then
- dispatch_build_variant_arg="releasedebuginfo"
- else
- dispatch_build_variant_arg="debug"
- fi
+ case "${host}" in
+ macosx-*)
+ if [[ "${RECONFIGURE}" || ! -f "${LIBDISPATCH_BUILD_DIR}"/config.status ]]; then
+ echo "Reconfiguring libdispatch"
+ # First time building; need to run autotools and configure
+ if [[ "$LIBDISPATCH_BUILD_TYPE" == "Release" ]] ; then
+ dispatch_build_variant_arg="release"
+ elif [[ "$LIBDISPATCH_BUILD_TYPE" == "RelWithDebInfo" ]]; then
+ dispatch_build_variant_arg="releasedebuginfo"
+ else
+ dispatch_build_variant_arg="debug"
+ fi
- if [ $(true_false "${BUILD_SWIFT_STATIC_STDLIB}") == "TRUE" ]; then
- libdispatch_enable_static="--enable-static=yes"
- else
- libdispatch_enable_static=""
- fi
+ if [ $(true_false "${BUILD_SWIFT_STATIC_STDLIB}") == "TRUE" ]; then
+ libdispatch_enable_static="--enable-static=yes"
+ else
+ libdispatch_enable_static=""
+ fi
- call mkdir -p "${LIBDISPATCH_BUILD_DIR}"
- with_pushd "${LIBDISPATCH_SOURCE_DIR}" \
- call autoreconf -fvi
- with_pushd "${LIBDISPATCH_BUILD_DIR}" \
- call env CC="${LLVM_BIN}/clang" CXX="${LLVM_BIN}/clang++" SWIFTC="${SWIFTC_BIN}" \
- "${LIBDISPATCH_SOURCE_DIR}"/configure --with-swift-toolchain="${SWIFT_BUILD_PATH}" \
- --with-build-variant=$dispatch_build_variant_arg \
- --prefix="$(get_host_install_destdir ${host})$(get_host_install_prefix ${host})" ${libdispatch_enable_static}
- else
- echo "Skipping reconfiguration of libdispatch"
- fi
- with_pushd "${LIBDISPATCH_BUILD_DIR}" \
- call make
- with_pushd "${LIBDISPATCH_BUILD_DIR}/tests" \
- call make build-tests
+ call mkdir -p "${LIBDISPATCH_BUILD_DIR}"
+ with_pushd "${LIBDISPATCH_SOURCE_DIR}" \
+ call autoreconf -fvi
+ with_pushd "${LIBDISPATCH_BUILD_DIR}" \
+ call env CC="${LLVM_BIN}/clang" CXX="${LLVM_BIN}/clang++" SWIFTC="${SWIFTC_BIN}" \
+ "${LIBDISPATCH_SOURCE_DIR}"/configure --with-swift-toolchain="${SWIFT_BUILD_PATH}" \
+ --with-build-variant=$dispatch_build_variant_arg \
+ --prefix="$(get_host_install_destdir ${host})$(get_host_install_prefix ${host})" ${libdispatch_enable_static}
+ else
+ echo "Skipping reconfiguration of libdispatch"
+ fi
+ with_pushd "${LIBDISPATCH_BUILD_DIR}" \
+ call make
+ with_pushd "${LIBDISPATCH_BUILD_DIR}/tests" \
+ call make build-tests
- # libdispatch builds itself and doesn't use cmake
- continue
+ # libdispatch builds itself and doesn't use cmake
+ continue
+ ;;
+ *)
+ cmake_options=(
+ ${cmake_options[@]}
+ -DCMAKE_BUILD_TYPE:STRING="${LIBDISPATCH_BUILD_TYPE}"
+ -DCMAKE_C_COMPILER:PATH="${LLVM_BIN}/clang"
+ -DCMAKE_CXX_COMPILER:PATH="${LLVM_BIN}/clang++"
+ -DCMAKE_SWIFT_COMPILER:PATH="${SWIFTC_BIN}"
+ -DCMAKE_INSTALL_PREFIX:PATH="$(get_host_install_destdir ${host})$(get_host_install_prefix ${host})"
+
+ -DENABLE_SWIFT=YES
+ -DSWIFT_RUNTIME_LIBDIR:PATH="${SWIFT_BUILD_PATH}/lib/swift/${SWIFT_HOST_VARIANT}/${SWIFT_HOST_VARIANT_ARCH}"
+
+ -DENABLE_TESTING=YES
+ )
+ ;;
+ esac
+
;;
libicu)
SWIFT_BUILD_PATH=$(build_directory ${host} swift)
@@ -2849,12 +2870,21 @@
if [[ "${SKIP_TEST_LIBDISPATCH}" ]]; then
continue
fi
- LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
- echo "--- Running tests for ${product} ---"
- with_pushd "${LIBDISPATCH_BUILD_DIR}" \
- call env VERBOSE=1 make check
- echo "--- Finished tests for ${product} ---"
- continue
+
+ case "${host}" in
+ macosx-*)
+ LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
+ echo "--- Running tests for ${product} ---"
+ with_pushd "${LIBDISPATCH_BUILD_DIR}" \
+ call env VERBOSE=1 make check
+ echo "--- Finished tests for ${product} ---"
+ continue
+ ;;
+ *)
+ results_targets=( "test" )
+ executable_target=""
+ ;;
+ esac
;;
libicu)
if [[ "${SKIP_TEST_LIBICU}" ]]; then
@@ -3101,22 +3131,29 @@
if [[ -z "${INSTALL_LIBDISPATCH}" ]] ; then
continue
fi
- if [[ -z "${INSTALL_DESTDIR}" ]] ; then
- echo "--install-destdir is required to install products."
- exit 1
- fi
- echo "--- Installing ${product} ---"
- LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
- with_pushd "${LIBDISPATCH_BUILD_DIR}" \
- call make install
- DISPATCH_LIBDIR="${host_install_destdir}${host_install_prefix}/lib/swift/${SWIFT_HOST_VARIANT}"
- DISPATCH_LIBDIR_STATIC="${host_install_destdir}${host_install_prefix}/lib/swift_static/${SWIFT_HOST_VARIANT}"
- if [ -f "$DISPATCH_LIBDIR/libdispatch.a" ]; then
- mv "$DISPATCH_LIBDIR/libdispatch.a" "$DISPATCH_LIBDIR_STATIC"
- fi
- # As libdispatch installation is self-contained, we break early here.
- continue
+ case "${host}" in
+ macosx-*)
+ if [[ -z "${INSTALL_DESTDIR}" ]] ; then
+ echo "--install-destdir is required to install products."
+ exit 1
+ fi
+ echo "--- Installing ${product} ---"
+ LIBDISPATCH_BUILD_DIR=$(build_directory ${host} ${product})
+ with_pushd "${LIBDISPATCH_BUILD_DIR}" \
+ call make install
+ DISPATCH_LIBDIR="${host_install_destdir}${host_install_prefix}/lib/swift/${SWIFT_HOST_VARIANT}"
+ DISPATCH_LIBDIR_STATIC="${host_install_destdir}${host_install_prefix}/lib/swift_static/${SWIFT_HOST_VARIANT}"
+ if [ -f "$DISPATCH_LIBDIR/libdispatch.a" ]; then
+ mv "$DISPATCH_LIBDIR/libdispatch.a" "$DISPATCH_LIBDIR_STATIC"
+ fi
+
+ # As libdispatch installation is self-contained, we break early here.
+ continue
+ ;;
+ *)
+ ;;
+ esac
;;
libicu)
if [[ -z "${INSTALL_LIBICU}" ]]; then
diff --git a/utils/build_swift/README.md b/utils/build_swift/README.md
new file mode 100644
index 0000000..1141a39
--- /dev/null
+++ b/utils/build_swift/README.md
@@ -0,0 +1,12 @@
+# build_swift
+
+The `build_swift` module contains data-structures and functions used by
+the Swift build-script.
+
+## Unit Tests
+
+You may run the unit test suite using the command:
+
+```sh
+$ python -m unittest discover -s utils/build_swift
+```
diff --git a/utils/build_swift/driver_arguments.py b/utils/build_swift/driver_arguments.py
index e9c6388..c902c00 100644
--- a/utils/build_swift/driver_arguments.py
+++ b/utils/build_swift/driver_arguments.py
@@ -24,13 +24,31 @@
__all__ = [
- 'apply_default_arguments',
'create_argument_parser',
]
-def apply_default_arguments(args):
- """Preprocess argument namespace to apply default behaviors."""
+class _ApplyDefaultsArgumentParser(argparse.ArgumentParser):
+ """Wrapper class around the default ArgumentParser that allows for
+ post-processing the parsed argument namespace to apply default argument
+ transformations.
+ """
+
+ def __init__(self, apply_defaults=None, *args, **kwargs):
+ self._apply_defaults = apply_defaults
+ super(_ApplyDefaultsArgumentParser, self).__init__(*args, **kwargs)
+
+ def parse_known_args(self, args=None, namespace=None):
+ args, argv = super(_ApplyDefaultsArgumentParser, self)\
+ .parse_known_args(args, namespace)
+
+ self._apply_defaults(args)
+ return args, argv
+
+
+def _apply_default_arguments(args):
+ """Preprocess argument namespace to apply default behaviors.
+ """
# Build cmark if any cmark-related options were specified.
if (args.cmark_build_variant is not None):
@@ -126,15 +144,15 @@
# Propagate global --skip-build
if args.skip_build:
- args.skip_build_linux = True
- args.skip_build_freebsd = True
- args.skip_build_cygwin = True
- args.skip_build_osx = True
- args.skip_build_ios = True
- args.skip_build_tvos = True
- args.skip_build_watchos = True
- args.skip_build_android = True
- args.skip_build_benchmarks = True
+ args.build_linux = False
+ args.build_freebsd = False
+ args.build_cygwin = False
+ args.build_osx = False
+ args.build_ios = False
+ args.build_tvos = False
+ args.build_watchos = False
+ args.build_android = False
+ args.build_benchmarks = False
args.build_lldb = False
args.build_llbuild = False
args.build_swiftpm = False
@@ -147,20 +165,20 @@
# --skip-{ios,tvos,watchos} or --skip-build-{ios,tvos,watchos} are
# merely shorthands for --skip-build-{**os}-{device,simulator}
- if not args.ios or args.skip_build_ios:
- args.skip_build_ios_device = True
- args.skip_build_ios_simulator = True
+ if not args.ios or not args.build_ios:
+ args.build_ios_device = False
+ args.build_ios_simulator = False
- if not args.tvos or args.skip_build_tvos:
- args.skip_build_tvos_device = True
- args.skip_build_tvos_simulator = True
+ if not args.tvos or not args.build_tvos:
+ args.build_tvos_device = False
+ args.build_tvos_simulator = False
- if not args.watchos or args.skip_build_watchos:
- args.skip_build_watchos_device = True
- args.skip_build_watchos_simulator = True
+ if not args.watchos or not args.build_watchos:
+ args.build_watchos_device = False
+ args.build_watchos_simulator = False
- if not args.android or args.skip_build_android:
- args.skip_build_android = True
+ if not args.android or not args.build_android:
+ args.build_android = False
# --validation-test implies --test.
if args.validation_test:
@@ -176,53 +194,53 @@
# If none of tests specified skip swift stdlib test on all platforms
if not args.test and not args.validation_test and not args.long_test:
- args.skip_test_linux = True
- args.skip_test_freebsd = True
- args.skip_test_cygwin = True
- args.skip_test_osx = True
- args.skip_test_ios = True
- args.skip_test_tvos = True
- args.skip_test_watchos = True
+ args.test_linux = False
+ args.test_freebsd = False
+ args.test_cygwin = False
+ args.test_osx = False
+ args.test_ios = False
+ args.test_tvos = False
+ args.test_watchos = False
# --skip-test-ios is merely a shorthand for host and simulator tests.
- if args.skip_test_ios:
- args.skip_test_ios_host = True
- args.skip_test_ios_simulator = True
+ if not args.test_ios:
+ args.test_ios_device = False
+ args.test_ios_simulator = False
# --skip-test-tvos is merely a shorthand for host and simulator tests.
- if args.skip_test_tvos:
- args.skip_test_tvos_host = True
- args.skip_test_tvos_simulator = True
+ if not args.test_tvos:
+ args.test_tvos_device = False
+ args.test_tvos_simulator = False
# --skip-test-watchos is merely a shorthand for host and simulator
# --tests.
- if args.skip_test_watchos:
- args.skip_test_watchos_host = True
- args.skip_test_watchos_simulator = True
+ if not args.test_watchos:
+ args.test_watchos_device = False
+ args.test_watchos_simulator = False
# --skip-build-{ios,tvos,watchos}-{device,simulator} implies
# --skip-test-{ios,tvos,watchos}-{host,simulator}
- if args.skip_build_ios_device:
- args.skip_test_ios_host = True
- if args.skip_build_ios_simulator:
- args.skip_test_ios_simulator = True
+ if not args.build_ios_device:
+ args.test_ios_device = False
+ if not args.build_ios_simulator:
+ args.test_ios_simulator = False
- if args.skip_build_tvos_device:
- args.skip_test_tvos_host = True
- if args.skip_build_tvos_simulator:
- args.skip_test_tvos_simulator = True
+ if not args.build_tvos_device:
+ args.test_tvos_device = False
+ if not args.build_tvos_simulator:
+ args.test_tvos_simulator = False
- if args.skip_build_watchos_device:
- args.skip_test_watchos_host = True
- if args.skip_build_watchos_simulator:
- args.skip_test_watchos_simulator = True
+ if not args.build_watchos_device:
+ args.test_watchos_device = False
+ if not args.build_watchos_simulator:
+ args.test_watchos_simulator = False
- if args.skip_build_android:
- args.skip_test_android_host = True
+ if not args.build_android:
+ args.test_android_device = False
if not args.host_test:
- args.skip_test_ios_host = True
- args.skip_test_tvos_host = True
- args.skip_test_watchos_host = True
- args.skip_test_android_host = True
+ args.test_ios_device = False
+ args.test_tvos_device = False
+ args.test_watchos_device = False
+ args.test_android_device = False
if args.build_subdir is None:
args.build_subdir = \
@@ -241,11 +259,14 @@
if StdlibDeploymentTarget.Android.contains(tgt)]
if not args.android and len(android_tgts) > 0:
args.android = True
- args.skip_build_android = True
+ args.build_android = False
def create_argument_parser():
- parser = argparse.ArgumentParser(
+ """Return a configured argument parser."""
+
+ parser = _ApplyDefaultsArgumentParser(
+ apply_defaults=_apply_default_arguments,
formatter_class=argparse.RawDescriptionHelpFormatter,
usage=USAGE,
description=DESCRIPTION,
@@ -595,20 +616,24 @@
iterations with -Onone", metavar='N', type=int, default=3)
run_tests_group.add_argument(
"--skip-test-osx",
- help="skip testing Swift stdlibs for Mac OS X",
- action=arguments.action.optional_bool)
+ dest='test_osx',
+ action=arguments.action.optional_false,
+ help="skip testing Swift stdlibs for Mac OS X")
run_tests_group.add_argument(
"--skip-test-linux",
- help="skip testing Swift stdlibs for Linux",
- action=arguments.action.optional_bool)
+ dest='test_linux',
+ action=arguments.action.optional_false,
+ help="skip testing Swift stdlibs for Linux")
run_tests_group.add_argument(
"--skip-test-freebsd",
- help="skip testing Swift stdlibs for FreeBSD",
- action=arguments.action.optional_bool)
+ dest='test_freebsd',
+ action=arguments.action.optional_false,
+ help="skip testing Swift stdlibs for FreeBSD")
run_tests_group.add_argument(
"--skip-test-cygwin",
- help="skip testing Swift stdlibs for Cygwin",
- action=arguments.action.optional_bool)
+ dest='test_cygwin',
+ action=arguments.action.optional_false,
+ help="skip testing Swift stdlibs for Cygwin")
parser.add_argument(
"--build-runtime-with-host-compiler",
help="Use the host compiler, not the self-built one to compile the "
@@ -645,130 +670,155 @@
action="store_true")
run_build_group.add_argument(
"--skip-build-linux",
- help="skip building Swift stdlibs for Linux",
- action=arguments.action.optional_bool)
+ dest='build_linux',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for Linux")
run_build_group.add_argument(
"--skip-build-freebsd",
- help="skip building Swift stdlibs for FreeBSD",
- action=arguments.action.optional_bool)
+ dest='build_freebsd',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for FreeBSD")
run_build_group.add_argument(
"--skip-build-cygwin",
- help="skip building Swift stdlibs for Cygwin",
- action=arguments.action.optional_bool)
+ dest='build_cygwin',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for Cygwin")
run_build_group.add_argument(
"--skip-build-osx",
- help="skip building Swift stdlibs for MacOSX",
- action=arguments.action.optional_bool)
+ dest='build_osx',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for MacOSX")
run_build_group.add_argument(
"--skip-build-ios",
- help="skip building Swift stdlibs for iOS",
- action=arguments.action.optional_bool)
+ dest='build_ios',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for iOS")
run_build_group.add_argument(
"--skip-build-ios-device",
+ dest='build_ios_device',
+ action=arguments.action.optional_false,
help="skip building Swift stdlibs for iOS devices "
- "(i.e. build simulators only)",
- action=arguments.action.optional_bool)
+ "(i.e. build simulators only)")
run_build_group.add_argument(
"--skip-build-ios-simulator",
+ dest='build_ios_simulator',
+ action=arguments.action.optional_false,
help="skip building Swift stdlibs for iOS simulator "
- "(i.e. build devices only)",
- action=arguments.action.optional_bool)
+ "(i.e. build devices only)")
run_build_group.add_argument(
"--skip-build-tvos",
- help="skip building Swift stdlibs for tvOS",
- action=arguments.action.optional_bool)
+ dest='build_tvos',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for tvOS")
run_build_group.add_argument(
"--skip-build-tvos-device",
+ dest='build_tvos_device',
+ action=arguments.action.optional_false,
help="skip building Swift stdlibs for tvOS devices "
- "(i.e. build simulators only)",
- action=arguments.action.optional_bool)
+ "(i.e. build simulators only)")
run_build_group.add_argument(
"--skip-build-tvos-simulator",
+ dest='build_tvos_simulator',
+ action=arguments.action.optional_false,
help="skip building Swift stdlibs for tvOS simulator "
- "(i.e. build devices only)",
- action=arguments.action.optional_bool)
+ "(i.e. build devices only)")
run_build_group.add_argument(
"--skip-build-watchos",
- help="skip building Swift stdlibs for watchOS",
- action=arguments.action.optional_bool)
+ dest='build_watchos',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for watchOS")
run_build_group.add_argument(
"--skip-build-watchos-device",
+ dest='build_watchos_device',
+ action=arguments.action.optional_false,
help="skip building Swift stdlibs for watchOS devices "
- "(i.e. build simulators only)",
- action=arguments.action.optional_bool)
+ "(i.e. build simulators only)")
run_build_group.add_argument(
"--skip-build-watchos-simulator",
+ dest='build_watchos_simulator',
+ action=arguments.action.optional_false,
help="skip building Swift stdlibs for watchOS simulator "
- "(i.e. build devices only)",
- action=arguments.action.optional_bool)
+ "(i.e. build devices only)")
run_build_group.add_argument(
"--skip-build-android",
- help="skip building Swift stdlibs for Android",
- action=arguments.action.optional_bool)
+ dest='build_android',
+ action=arguments.action.optional_false,
+ help="skip building Swift stdlibs for Android")
run_build_group.add_argument(
"--skip-build-benchmarks",
- help="skip building Swift Benchmark Suite",
- action=arguments.action.optional_bool)
+ dest='build_benchmarks',
+ action=arguments.action.optional_false,
+ help="skip building Swift Benchmark Suite")
skip_test_group = parser.add_argument_group(
title="Skip testing specified targets")
skip_test_group.add_argument(
"--skip-test-ios",
+ dest='test_ios',
+ action=arguments.action.optional_false,
help="skip testing all iOS targets. Equivalent to specifying both "
- "--skip-test-ios-simulator and --skip-test-ios-host",
- action=arguments.action.optional_bool)
+ "--skip-test-ios-simulator and --skip-test-ios-host")
skip_test_group.add_argument(
"--skip-test-ios-simulator",
- help="skip testing iOS simulator targets",
- action=arguments.action.optional_bool)
+ dest='test_ios_simulator',
+ action=arguments.action.optional_false,
+ help="skip testing iOS simulator targets")
skip_test_group.add_argument(
"--skip-test-ios-32bit-simulator",
- help="skip testing iOS 32 bit simulator targets",
- action=arguments.action.optional_bool,
- default=False)
+ dest='test_ios_32bit_simulator',
+ action=arguments.action.optional_false,
+ help="skip testing iOS 32 bit simulator targets")
skip_test_group.add_argument(
"--skip-test-ios-host",
+ dest='test_ios_device',
+ action=arguments.action.optional_false,
help="skip testing iOS device targets on the host machine (the phone "
- "itself)",
- action=arguments.action.optional_bool)
+ "itself)")
skip_test_group.add_argument(
"--skip-test-tvos",
+ dest='test_tvos',
+ action=arguments.action.optional_false,
help="skip testing all tvOS targets. Equivalent to specifying both "
- "--skip-test-tvos-simulator and --skip-test-tvos-host",
- action=arguments.action.optional_bool)
+ "--skip-test-tvos-simulator and --skip-test-tvos-host")
skip_test_group.add_argument(
"--skip-test-tvos-simulator",
- help="skip testing tvOS simulator targets",
- action=arguments.action.optional_bool)
+ dest='test_tvos_simulator',
+ action=arguments.action.optional_false,
+ help="skip testing tvOS simulator targets")
skip_test_group.add_argument(
"--skip-test-tvos-host",
+ dest='test_tvos_device',
+ action=arguments.action.optional_false,
help="skip testing tvOS device targets on the host machine (the TV "
- "itself)",
- action=arguments.action.optional_bool)
+ "itself)")
skip_test_group.add_argument(
"--skip-test-watchos",
+ dest='test_watchos',
+ action=arguments.action.optional_false,
help="skip testing all tvOS targets. Equivalent to specifying both "
- "--skip-test-watchos-simulator and --skip-test-watchos-host",
- action=arguments.action.optional_bool)
+ "--skip-test-watchos-simulator and --skip-test-watchos-host")
skip_test_group.add_argument(
"--skip-test-watchos-simulator",
- help="skip testing watchOS simulator targets",
- action=arguments.action.optional_bool)
+ dest='test_watchos_simulator',
+ action=arguments.action.optional_false,
+ help="skip testing watchOS simulator targets")
skip_test_group.add_argument(
"--skip-test-watchos-host",
+ dest='test_watchos_device',
+ action=arguments.action.optional_false,
help="skip testing watchOS device targets on the host machine (the "
- "watch itself)",
- action=arguments.action.optional_bool)
+ "watch itself)")
skip_test_group.add_argument(
"--skip-test-android-host",
+ dest='test_android_device',
+ action=arguments.action.optional_false,
help="skip testing Android device targets on the host machine (the "
- "phone itself)",
- action=arguments.action.optional_bool)
+ "phone itself)")
parser.add_argument(
"-i", "--ios",
@@ -1111,6 +1161,8 @@
return parser
+# ----------------------------------------------------------------------------
+
USAGE = """
%(prog)s [-h | --help] [OPTION ...]
%(prog)s --preset=NAME [SUBSTITUTION ...]
diff --git a/utils/build_swift/tests/__init__.py b/utils/build_swift/tests/__init__.py
new file mode 100644
index 0000000..fa71f9f
--- /dev/null
+++ b/utils/build_swift/tests/__init__.py
@@ -0,0 +1,7 @@
+# This source file is part of the Swift.org open source project
+#
+# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+# Licensed under Apache License v2.0 with Runtime Library Exception
+#
+# See https://swift.org/LICENSE.txt for license information
+# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py
new file mode 100644
index 0000000..58b6c2e
--- /dev/null
+++ b/utils/build_swift/tests/expected_options.py
@@ -0,0 +1,511 @@
+# This source file is part of the Swift.org open source project
+#
+# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+# Licensed under Apache License v2.0 with Runtime Library Exception
+#
+# See https://swift.org/LICENSE.txt for license information
+# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+
+import argparse
+
+
+__all__ = [
+ 'Option',
+ 'AppendOption',
+ 'ChoicesOption',
+ 'HelpOption',
+ 'IgnoreOption',
+ 'IntOption',
+ 'PathOption',
+ 'StrOption',
+ 'ToggleOption',
+ 'UnsupportedOption',
+ 'EXPECTED_OPTIONS',
+ 'EXPECTED_DEFAULTS',
+]
+
+
+# -----------------------------------------------------------------------------
+
+EXPECTED_DEFAULTS = {
+ 'android': False,
+ 'android_api_level': '21',
+ 'android_deploy_device_path': '/data/local/tmp',
+ 'android_icu_i18n': None,
+ 'android_icu_i18n_include': None,
+ 'android_icu_uc': None,
+ 'android_icu_uc_include': None,
+ 'android_ndk': None,
+ 'android_ndk_gcc_version': '4.9',
+ 'assertions': True,
+ 'benchmark': False,
+ 'benchmark_num_o_iterations': 3,
+ 'benchmark_num_onone_iterations': 3,
+ 'build_android': False,
+ 'build_args': [],
+ 'build_benchmarks': True,
+ 'build_cygwin': True,
+ 'build_foundation': False,
+ 'build_freebsd': True,
+ 'build_ios': True,
+ 'build_ios_device': False,
+ 'build_ios_simulator': False,
+ 'build_jobs': 4,
+ 'build_libdispatch': False,
+ 'build_libicu': False,
+ 'build_linux': True,
+ 'build_llbuild': False,
+ 'build_lldb': False,
+ 'build_ninja': False,
+ 'build_osx': True,
+ 'build_playgroundlogger': False,
+ 'build_playgroundsupport': False,
+ 'build_runtime_with_host_compiler': False,
+ 'build_stdlib_deployment_targets': ['all'],
+ 'build_subdir': 'Ninja-DebugAssert',
+ 'build_swift_dynamic_sdk_overlay': True,
+ 'build_swift_dynamic_stdlib': True,
+ 'build_swift_static_sdk_overlay': False,
+ 'build_swift_static_stdlib': False,
+ 'build_swift_stdlib_unittest_extra': False,
+ 'build_swiftpm': False,
+ 'build_tvos': True,
+ 'build_tvos_device': False,
+ 'build_tvos_simulator': False,
+ 'build_variant': 'Debug',
+ 'build_watchos': True,
+ 'build_watchos_device': False,
+ 'build_watchos_simulator': False,
+ 'build_xctest': False,
+ 'clang_compiler_version': None,
+ 'clang_profile_instr_use': None,
+ 'clang_user_visible_version': '5.0.0',
+ 'clean': False,
+ 'cmake': None,
+ 'cmake_generator': 'Ninja',
+ 'cmark_assertions': True,
+ 'cmark_build_variant': 'Debug',
+ 'compiler_vendor': 'none',
+ 'coverage_db': None,
+ 'cross_compile_hosts': [],
+ 'darwin_deployment_version_ios': '7.0',
+ 'darwin_deployment_version_osx': '10.9',
+ 'darwin_deployment_version_tvos': '9.0',
+ 'darwin_deployment_version_watchos': '2.0',
+ 'darwin_xcrun_toolchain': 'default',
+ 'distcc': False,
+ 'dry_run': False,
+ 'enable_asan': False,
+ 'enable_lsan': False,
+ 'enable_sil_ownership': False,
+ 'enable_tsan': False,
+ 'enable_tsan_runtime': None,
+ 'enable_ubsan': False,
+ 'export_compile_commands': False,
+ 'extra_cmake_options': [],
+ 'extra_swift_args': [],
+ 'force_optimized_typechecker': False,
+ 'foundation_build_variant': 'Debug',
+ 'host_cc': None,
+ 'host_cxx': None,
+ 'host_libtool': None,
+ 'host_lipo': None,
+ 'host_target': 'macosx-x86_64',
+ 'host_test': False,
+ 'install_prefix': '/Applications/Xcode.app/Contents/Developer/Toolchains/'
+ 'XcodeDefault.xctoolchain/usr',
+ 'install_symroot': None,
+ 'ios': False,
+ 'ios_all': False,
+ 'legacy_impl': True,
+ 'libdispatch_build_variant': 'Debug',
+ 'libicu_build_variant': 'Debug',
+ 'lit_args': '-sv',
+ 'lldb_assertions': None,
+ 'lldb_build_variant': 'Debug',
+ 'llvm_assertions': True,
+ 'llvm_build_variant': 'Debug',
+ 'llvm_max_parallel_lto_link_jobs': 0,
+ 'llvm_targets_to_build': 'X86;ARM;AArch64;PowerPC;SystemZ;Mips',
+ 'long_test': False,
+ 'lto_type': None,
+ 'show_sdks': False,
+ 'skip_build': False,
+ 'stdlib_deployment_targets': [
+ 'macosx-x86_64',
+ 'iphonesimulator-i386',
+ 'iphonesimulator-x86_64',
+ 'appletvsimulator-x86_64',
+ 'watchsimulator-i386',
+ 'iphoneos-armv7',
+ 'iphoneos-armv7s',
+ 'iphoneos-arm64',
+ 'appletvos-arm64',
+ 'watchos-armv7k'
+ ],
+ 'swift_analyze_code_coverage': 'false',
+ 'swift_assertions': True,
+ 'swift_build_variant': 'Debug',
+ 'swift_compiler_version': None,
+ 'swift_stdlib_assertions': True,
+ 'swift_stdlib_build_variant': 'Debug',
+ 'swift_tools_max_parallel_lto_link_jobs': 0,
+ 'swift_user_visible_version': '4.1',
+ 'symbols_package': None,
+ 'test': None,
+ 'test_android_device': False,
+ 'test_cygwin': False,
+ 'test_freebsd': False,
+ 'test_ios': False,
+ 'test_ios_32bit_simulator': True,
+ 'test_ios_device': False,
+ 'test_ios_simulator': False,
+ 'test_linux': False,
+ 'test_optimize_for_size': None,
+ 'test_optimized': None,
+ 'test_osx': False,
+ 'test_tvos': False,
+ 'test_tvos_device': False,
+ 'test_tvos_simulator': False,
+ 'test_watchos': False,
+ 'test_watchos_device': False,
+ 'test_watchos_simulator': False,
+ 'tvos': False,
+ 'tvos_all': False,
+ 'validation_test': None,
+ 'verbose_build': False,
+ 'watchos': False,
+ 'watchos_all': False
+}
+
+
+# -----------------------------------------------------------------------------
+
+class _BaseOption(object):
+
+ def __init__(self, option_string, dest, default=None):
+ self.option_string = option_string
+ self.dest = dest
+
+ if default is None:
+ default = EXPECTED_DEFAULTS.get(dest, None)
+
+ self.default = default
+
+ def sanitized_str(self):
+ if self.option_string.startswith('--'):
+ return self.option_string[2:].replace('-', '_')
+
+ if len(self.option_string) == 2 and self.option_string[0] == '-':
+ return self.option_string[1]
+
+ raise ValueError('invalid option_string format: ' + self.option_string)
+
+
+class Option(_BaseOption):
+ """Option that accepts no arguments."""
+
+ def __init__(self, *args, **kwargs):
+ self.value = kwargs.pop('value', None)
+ super(Option, self).__init__(*args, **kwargs)
+
+
+class HelpOption(_BaseOption):
+ """Option that prints the help message and exits."""
+
+ pass
+
+
+class ToggleOption(_BaseOption):
+ """Option that accepts no argument or an optional bool argument."""
+
+ pass
+
+
+class ChoicesOption(_BaseOption):
+ """Option that accepts an argument from a predifined list of choices."""
+
+ def __init__(self, *args, **kwargs):
+ self.choices = kwargs.pop('choices', None)
+ super(ChoicesOption, self).__init__(*args, **kwargs)
+
+
+class IntOption(_BaseOption):
+ """Option that accepts an int argument."""
+
+ pass
+
+
+class StrOption(_BaseOption):
+ """Option that accepts a str argument."""
+
+ pass
+
+
+class PathOption(_BaseOption):
+ """Option that accepts a path argument."""
+
+ pass
+
+
+class AppendOption(_BaseOption):
+ """Option that can be called more than once to append argument to internal
+ list.
+ """
+
+ pass
+
+
+class UnsupportedOption(_BaseOption):
+ """Option that is not supported."""
+
+ def __init__(self, *args, **kwargs):
+ kwargs['dest'] = kwargs.pop('dest', None)
+ super(UnsupportedOption, self).__init__(*args, **kwargs)
+
+
+class IgnoreOption(_BaseOption):
+ """Option that should be ignored when generating tests. Instead a test
+ should be written manually as the behavior cannot or should not be auto-
+ generated.
+ """
+
+ pass
+
+
+# -----------------------------------------------------------------------------
+
+EXPECTED_OPTIONS = [
+ # Ignore the help options since they always call sys.exit(0)
+ HelpOption('-h', dest='help', default=argparse.SUPPRESS),
+ HelpOption('--help', dest='help', default=argparse.SUPPRESS),
+
+ Option('--assertions', dest='assertions', value=True),
+ Option('--benchmark', dest='benchmark', value=True),
+ Option('--clean', dest='clean', value=True),
+ Option('--cmark-assertions', dest='cmark_assertions', value=True),
+ Option('--debug', dest='build_variant', value='Debug'),
+ Option('--debug-cmark', dest='cmark_build_variant', value='Debug'),
+ Option('--debug-foundation',
+ dest='foundation_build_variant', value='Debug'),
+ Option('--debug-libdispatch',
+ dest='libdispatch_build_variant', value='Debug'),
+ Option('--debug-libicu', dest='libicu_build_variant', value='Debug'),
+ Option('--debug-lldb', dest='lldb_build_variant', value='Debug'),
+ Option('--debug-llvm', dest='llvm_build_variant', value='Debug'),
+ Option('--debug-swift', dest='swift_build_variant', value='Debug'),
+ Option('--debug-swift-stdlib',
+ dest='swift_stdlib_build_variant', value='Debug'),
+ Option('--dry-run', dest='dry_run', value=True),
+ Option('--eclipse', dest='cmake_generator', value='Eclipse CDT4 - Ninja'),
+ Option('--enable-sil-ownership', dest='enable_sil_ownership', value=True),
+ Option('--force-optimized-typechecker',
+ dest='force_optimized_typechecker', value=True),
+ Option('--ios', dest='ios', value=True),
+ Option('--llbuild', dest='build_llbuild', value=True),
+ Option('--lldb', dest='build_lldb', value=True),
+ Option('--lldb-assertions', dest='lldb_assertions', value=True),
+ Option('--llvm-assertions', dest='llvm_assertions', value=True),
+ Option('--make', dest='cmake_generator', value='Unix Makefiles'),
+ Option('--no-assertions', dest='assertions', value=False),
+ Option('--no-legacy-impl', dest='legacy_impl', value=False),
+ Option('--no-lldb-assertions', dest='lldb_assertions', value=False),
+ Option('--no-llvm-assertions', dest='llvm_assertions', value=False),
+ Option('--no-swift-assertions', dest='swift_assertions', value=False),
+ Option('--no-swift-stdlib-assertions',
+ dest='swift_stdlib_assertions', value=False),
+ Option('--playgroundlogger', dest='build_playgroundlogger', value=True),
+ Option('--playgroundsupport', dest='build_playgroundsupport', value=True),
+ Option('--release', dest='build_variant', value='Release'),
+ Option('--release-debuginfo',
+ dest='build_variant', value='RelWithDebInfo'),
+ Option('--skip-build', dest='skip_build', value=True),
+ Option('--skip-ios', dest='ios', value=False),
+ Option('--skip-tvos', dest='tvos', value=False),
+ Option('--skip-watchos', dest='watchos', value=False),
+ Option('--swift-assertions', dest='swift_assertions', value=True),
+ Option('--swift-stdlib-assertions',
+ dest='swift_stdlib_assertions', value=True),
+ Option('--swiftpm', dest='build_swiftpm', value=True),
+ Option('--xcode', dest='cmake_generator', value='Xcode'),
+ Option('-B', dest='benchmark', value=True),
+ Option('-R', dest='build_variant', value='Release'),
+ Option('-S', dest='skip_build', value=True),
+ Option('-T', dest='validation_test', value=True),
+ Option('-b', dest='build_llbuild', value=True),
+ Option('-c', dest='clean', value=True),
+ Option('-d', dest='build_variant', value='Debug'),
+ Option('-e', dest='cmake_generator', value='Eclipse CDT4 - Ninja'),
+ Option('-i', dest='ios', value=True),
+ Option('-l', dest='build_lldb', value=True),
+ Option('-m', dest='cmake_generator', value='Unix Makefiles'),
+ Option('-n', dest='dry_run', value=True),
+ Option('-o', dest='test_optimized', value=True),
+ Option('-p', dest='build_swiftpm', value=True),
+ Option('-r', dest='build_variant', value='RelWithDebInfo'),
+ Option('-s', dest='test_optimize_for_size', value=True),
+ Option('-t', dest='test', value=True),
+ Option('-x', dest='cmake_generator', value='Xcode'),
+
+ ToggleOption('--android', dest='android'),
+ ToggleOption('--build-ninja', dest='build_ninja'),
+ ToggleOption('--build-runtime-with-host-compiler',
+ dest='build_runtime_with_host_compiler'),
+ ToggleOption('--build-swift-dynamic-sdk-overlay',
+ dest='build_swift_dynamic_sdk_overlay'),
+ ToggleOption('--build-swift-dynamic-stdlib',
+ dest='build_swift_dynamic_stdlib'),
+ ToggleOption('--build-swift-static-sdk-overlay',
+ dest='build_swift_static_sdk_overlay'),
+ ToggleOption('--build-swift-static-stdlib',
+ dest='build_swift_static_stdlib'),
+ ToggleOption('--build-swift-stdlib-unittest-extra',
+ dest='build_swift_stdlib_unittest_extra'),
+ ToggleOption('--distcc', dest='distcc'),
+ ToggleOption('--enable-asan', dest='enable_asan'),
+ ToggleOption('--enable-lsan', dest='enable_lsan'),
+ ToggleOption('--enable-tsan', dest='enable_tsan'),
+ ToggleOption('--enable-ubsan', dest='enable_ubsan'),
+ ToggleOption('--export-compile-commands', dest='export_compile_commands'),
+ ToggleOption('--foundation', dest='build_foundation'),
+ ToggleOption('--host-test', dest='host_test'),
+ ToggleOption('--libdispatch', dest='build_libdispatch'),
+ ToggleOption('--libicu', dest='build_libicu'),
+ ToggleOption('--long-test', dest='long_test'),
+ ToggleOption('--show-sdks', dest='show_sdks'),
+ ToggleOption('--skip-build-android', dest='build_android'),
+ ToggleOption('--skip-build-benchmarks', dest='build_benchmarks'),
+ ToggleOption('--skip-build-cygwin', dest='build_cygwin'),
+ ToggleOption('--skip-build-freebsd', dest='build_freebsd'),
+ ToggleOption('--skip-build-ios', dest='build_ios'),
+ ToggleOption('--skip-build-ios-device', dest='build_ios_device'),
+ ToggleOption('--skip-build-ios-simulator',
+ dest='build_ios_simulator'),
+ ToggleOption('--skip-build-linux', dest='build_linux'),
+ ToggleOption('--skip-build-osx', dest='build_osx'),
+ ToggleOption('--skip-build-tvos', dest='build_tvos'),
+ ToggleOption('--skip-build-tvos-device', dest='build_tvos_device'),
+ ToggleOption('--skip-build-tvos-simulator',
+ dest='build_tvos_simulator'),
+ ToggleOption('--skip-build-watchos', dest='build_watchos'),
+ ToggleOption('--skip-build-watchos-device',
+ dest='build_watchos_device'),
+ ToggleOption('--skip-build-watchos-simulator',
+ dest='build_watchos_simulator'),
+ ToggleOption('--skip-test-android-host', dest='test_android_device'),
+ ToggleOption('--skip-test-cygwin', dest='test_cygwin'),
+ ToggleOption('--skip-test-freebsd', dest='test_freebsd'),
+ ToggleOption('--skip-test-ios', dest='test_ios'),
+ ToggleOption('--skip-test-ios-32bit-simulator',
+ dest='test_ios_32bit_simulator'),
+ ToggleOption('--skip-test-ios-host', dest='test_ios_device'),
+ ToggleOption('--skip-test-ios-simulator', dest='test_ios_simulator'),
+ ToggleOption('--skip-test-linux', dest='test_linux'),
+ ToggleOption('--skip-test-osx', dest='test_osx'),
+ ToggleOption('--skip-test-tvos', dest='test_tvos'),
+ ToggleOption('--skip-test-tvos-host', dest='test_tvos_device'),
+ ToggleOption('--skip-test-tvos-simulator',
+ dest='test_tvos_simulator'),
+ ToggleOption('--skip-test-watchos', dest='test_watchos'),
+ ToggleOption('--skip-test-watchos-host', dest='test_watchos_device'),
+ ToggleOption('--skip-test-watchos-simulator',
+ dest='test_watchos_simulator'),
+ ToggleOption('--test', dest='test'),
+ ToggleOption('--test-optimize-for-size', dest='test_optimize_for_size'),
+ ToggleOption('--test-optimized', dest='test_optimized'),
+ ToggleOption('--tvos', dest='tvos'),
+ ToggleOption('--validation-test', dest='validation_test'),
+ ToggleOption('--verbose-build', dest='verbose_build'),
+ ToggleOption('--watchos', dest='watchos'),
+ ToggleOption('--xctest', dest='build_xctest'),
+
+ ChoicesOption('--android-ndk-gcc-version',
+ dest='android_ndk_gcc_version',
+ choices=['4.8', '4.9']),
+ ChoicesOption('--compiler-vendor',
+ dest='compiler_vendor',
+ choices=['none', 'apple']),
+ ChoicesOption('--swift-analyze-code-coverage',
+ dest='swift_analyze_code_coverage',
+ choices=['false', 'not-merged', 'merged']),
+
+ StrOption('--android-api-level', dest='android_api_level'),
+ StrOption('--build-args', dest='build_args'),
+ StrOption('--build-stdlib-deployment-targets',
+ dest='build_stdlib_deployment_targets'),
+ StrOption('--darwin-deployment-version-ios',
+ dest='darwin_deployment_version_ios'),
+ StrOption('--darwin-deployment-version-osx',
+ dest='darwin_deployment_version_osx'),
+ StrOption('--darwin-deployment-version-tvos',
+ dest='darwin_deployment_version_tvos'),
+ StrOption('--darwin-deployment-version-watchos',
+ dest='darwin_deployment_version_watchos'),
+ StrOption('--darwin-xcrun-toolchain', dest='darwin_xcrun_toolchain'),
+ StrOption('--enable-tsan-runtime', dest='enable_tsan_runtime'),
+ StrOption('--host-target', dest='host_target'),
+ StrOption('--lit-args', dest='lit_args'),
+ StrOption('--llvm-targets-to-build', dest='llvm_targets_to_build'),
+
+ PathOption('--android-deploy-device-path',
+ dest='android_deploy_device_path'),
+ PathOption('--android-icu-i18n', dest='android_icu_i18n'),
+ PathOption('--android-icu-i18n-include', dest='android_icu_i18n_include'),
+ PathOption('--android-icu-uc', dest='android_icu_uc'),
+ PathOption('--android-icu-uc-include', dest='android_icu_uc_include'),
+ PathOption('--android-ndk', dest='android_ndk'),
+ PathOption('--build-subdir', dest='build_subdir'),
+ PathOption('--clang-profile-instr-use', dest='clang_profile_instr_use'),
+ PathOption('--cmake', dest='cmake'),
+ PathOption('--coverage-db', dest='coverage_db'),
+ PathOption('--host-cc', dest='host_cc'),
+ PathOption('--host-cxx', dest='host_cxx'),
+ PathOption('--host-libtool', dest='host_libtool'),
+ PathOption('--host-lipo', dest='host_lipo'),
+ PathOption('--install-prefix', dest='install_prefix'),
+ PathOption('--install-symroot', dest='install_symroot'),
+ PathOption('--symbols-package', dest='symbols_package'),
+
+ IntOption('--benchmark-num-o-iterations',
+ dest='benchmark_num_o_iterations'),
+ IntOption('--benchmark-num-onone-iterations',
+ dest='benchmark_num_onone_iterations'),
+ IntOption('--jobs', dest='build_jobs'),
+ IntOption('--llvm-max-parallel-lto-link-jobs',
+ dest='llvm_max_parallel_lto_link_jobs'),
+ IntOption('--swift-tools-max-parallel-lto-link-jobs',
+ dest='swift_tools_max_parallel_lto_link_jobs'),
+ IntOption('-j', dest='build_jobs'),
+
+ AppendOption('--cross-compile-hosts', dest='cross_compile_hosts'),
+ AppendOption('--extra-cmake-options', dest='extra_cmake_options'),
+ AppendOption('--extra-swift-args', dest='extra_swift_args'),
+ AppendOption('--stdlib-deployment-targets',
+ dest='stdlib_deployment_targets'),
+
+ UnsupportedOption('--build-jobs'),
+ UnsupportedOption('--common-cmake-options'),
+ UnsupportedOption('--ios-all'),
+ UnsupportedOption('--only-execute'),
+ UnsupportedOption('--skip-test-optimize-for-size'),
+ UnsupportedOption('--skip-test-optimized'),
+ UnsupportedOption('--tvos-all'),
+ UnsupportedOption('--watchos-all'),
+ UnsupportedOption('-I'),
+
+ # NOTE: LTO flag is a special case that acts both as an option and has
+ # valid choices
+ Option('--lto', dest='lto_type'),
+ ChoicesOption('--lto', dest='lto_type', choices=['thin', 'full']),
+
+ # NOTE: We'll need to manually test the behavior of these since they
+ # validate compiler version strings.
+ IgnoreOption('--clang-compiler-version',
+ dest='clang_compiler_version'),
+ IgnoreOption('--clang-user-visible-version',
+ dest='clang_user_visible_version'),
+ IgnoreOption('--swift-compiler-version',
+ dest='swift_compiler_version'),
+ IgnoreOption('--swift-user-visible-version',
+ dest='swift_user_visible_version'),
+]
diff --git a/utils/build_swift/tests/test_driver_arguments.py b/utils/build_swift/tests/test_driver_arguments.py
new file mode 100644
index 0000000..f5c9b94
--- /dev/null
+++ b/utils/build_swift/tests/test_driver_arguments.py
@@ -0,0 +1,540 @@
+# This source file is part of the Swift.org open source project
+#
+# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+# Licensed under Apache License v2.0 with Runtime Library Exception
+#
+# See https://swift.org/LICENSE.txt for license information
+# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+
+from __future__ import print_function
+
+import os
+import sys
+import unittest
+
+from contextlib import contextmanager
+from io import StringIO
+
+from build_swift import driver_arguments
+from build_swift.tests import expected_options
+
+from swift_build_support.swift_build_support import migration
+from swift_build_support.swift_build_support.SwiftBuildSupport import (
+ get_all_preset_names,
+ get_preset_options,
+)
+
+FILE_PATH = os.path.abspath(__file__)
+TESTS_PATH = os.path.abspath(os.path.join(FILE_PATH, os.pardir))
+BUILD_SWIFT_PATH = os.path.abspath(os.path.join(TESTS_PATH, os.pardir))
+UTILS_PATH = os.path.abspath(os.path.join(BUILD_SWIFT_PATH, os.pardir))
+
+BUILD_SCRIPT_IMPL = os.path.join(UTILS_PATH, 'build-script-impl')
+
+PRESETS_FILES = [
+ os.path.join(UTILS_PATH, 'build-presets.ini'),
+]
+
+
+class ParserError(Exception):
+ pass
+
+
+@contextmanager
+def redirect_stderr(stream=None):
+ stream = stream or StringIO()
+ old_stderr, sys.stderr = sys.stderr, stream
+ try:
+ yield stream
+ finally:
+ sys.stderr = old_stderr
+
+
+@contextmanager
+def redirect_stdout(stream=None):
+ stream = stream or StringIO()
+ old_stdout, sys.stdout = sys.stdout, stream
+ try:
+ yield stream
+ finally:
+ sys.stdout = old_stdout
+
+
+def _load_all_presets(presets_files):
+ preset_names = get_all_preset_names(presets_files)
+
+ # Hack to filter out mixins which are not expected to be valid presets
+ preset_names = [n for n in preset_names if not n.startswith('mixin')]
+
+ substitutions = {
+ 'install_destdir': '/tmp/install',
+ 'install_symroot': '/tmp/symroot',
+ 'installable_package': '/tmp/xcode-xyz-root.tar.gz',
+ }
+
+ presets = dict()
+ for name in preset_names:
+ try:
+ # Attempt to parse preset
+ presets[name] = get_preset_options(substitutions,
+ presets_files, name)
+ except SystemExit:
+ continue
+
+ return presets
+
+
+class TestDriverArgumentParserMeta(type):
+ """Metaclass used to dynamically generate test methods for each of the
+ individual options accepted by the parser and methods to validate all of
+ the presets.
+ """
+
+ def __new__(cls, name, bases, attrs):
+ # Generate tests for each default value
+ for dest, value in expected_options.EXPECTED_DEFAULTS.items():
+ test_name = 'test_default_value_' + dest
+ attrs[test_name] = cls.generate_default_value_test(dest, value)
+
+ # Generate tests for each expected option
+ for option in expected_options.EXPECTED_OPTIONS:
+ test_name = 'test_option_' + option.sanitized_str()
+ attrs[test_name] = cls.generate_option_test(option)
+
+ # Generate tests for each preset
+ presets = _load_all_presets(PRESETS_FILES)
+
+ for name, args in presets.items():
+ test_name = 'test_preset_' + name
+ attrs[test_name] = cls.generate_preset_test(name, args)
+
+ return super(TestDriverArgumentParserMeta, cls).__new__(
+ cls, name, bases, attrs)
+
+ @classmethod
+ def generate_default_value_test(cls, dest, default_value):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ parsed_values = self.parse_args([])
+
+ parsed_value = getattr(parsed_values, dest)
+ if default_value.__class__ is str:
+ parsed_value = str(parsed_value)
+
+ self.assertEqual(default_value, parsed_value,
+ 'Invalid default value for "{}": {} != {}'
+ .format(dest, default_value, parsed_value))
+
+ return test
+
+ @classmethod
+ def _generate_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args([option.option_string])
+ self.assertEqual(getattr(args, option.dest), option.value)
+
+ with self.assertRaises(ParserError):
+ self.parse_args([option.option_string, 'foo'])
+
+ return test
+
+ @classmethod
+ def _generate_append_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ # Range size is arbitrary, just needs to be more than once
+ for i in range(1, 4):
+ args = self.parse_args([option.option_string, 'ARG'] * i)
+ self.assertEqual(getattr(args, option.dest), ['ARG'] * i)
+
+ return test
+
+ @classmethod
+ def _generate_choices_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ for choice in option.choices:
+ args = self.parse_args([option.option_string, str(choice)])
+ self.assertEqual(getattr(args, option.dest), choice)
+
+ with self.assertRaises(ParserError):
+ self.parse_args([option.option_string, 'INVALID'])
+
+ return test
+
+ @classmethod
+ def _generate_help_option_test(cls, option):
+ def test(self):
+ with redirect_stdout() as output, self.assertRaises(ParserError):
+ self.parse_args([option.option_string])
+ self.assertNotEmpty(output)
+
+ return test
+
+ @classmethod
+ def _generate_int_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ for i in [0, 1, 42]:
+ args = self.parse_args([option.option_string, str(i)])
+ self.assertEqual(int(getattr(args, option.dest)), i)
+
+ # FIXME: int-type options should not accept non-int strings
+ # with self.assertRaises(ParserError):
+ # self.parse_args([option.option_string, str(0.0)])
+ # self.parse_args([option.option_string, str(1.0)])
+ # self.parse_args([option.option_string, str(3.14)])
+ # self.parse_args([option.option_string, 'NaN'])
+
+ return test
+
+ @classmethod
+ def _generate_path_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ self.parse_args([option.option_string, sys.executable])
+
+ # FIXME: path-type options should not accept non-path inputs
+ # with self.assertRaises(ParserError):
+ # self.parse_args([option.option_string, 'foo'])
+
+ return test
+
+ @classmethod
+ def _generate_str_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ self.parse_args([option.option_string, 'foo'])
+
+ return test
+
+ @classmethod
+ def _generate_toggle_option_test(cls, option):
+ def test(self):
+ with self.assertNotRaises(ParserError):
+ # Standalone argument
+ self.parse_args([option.option_string])
+
+ # True values
+ # self.parse_args([option.option_string, True])
+ # self.parse_args([option.option_string, 1])
+ self.parse_args([option.option_string, '1'])
+ self.parse_args([option.option_string, 'true'])
+ self.parse_args([option.option_string, 'True'])
+ # self.parse_args([option.option_string, 'TRUE'])
+
+ # False values
+ # self.parse_args([option.option_string, False])
+ # self.parse_args([option.option_string, 0])
+ self.parse_args([option.option_string, '0'])
+ self.parse_args([option.option_string, 'false'])
+ self.parse_args([option.option_string, 'False'])
+ # self.parse_args([option.option_string, 'FALSE'])
+
+ return test
+
+ @classmethod
+ def _generate_unsupported_option_test(cls, option):
+ def test(self):
+ with self.assertRaises(ParserError):
+ self.parse_args([option.option_string])
+
+ return test
+
+ @classmethod
+ def generate_option_test(cls, option):
+ if option.__class__ is expected_options.Option:
+ return cls._generate_option_test(option)
+ elif option.__class__ is expected_options.AppendOption:
+ return cls._generate_append_option_test(option)
+ elif option.__class__ is expected_options.ChoicesOption:
+ return cls._generate_choices_option_test(option)
+ elif option.__class__ is expected_options.HelpOption:
+ return cls._generate_help_option_test(option)
+ elif option.__class__ is expected_options.IntOption:
+ return cls._generate_int_option_test(option)
+ elif option.__class__ is expected_options.PathOption:
+ return cls._generate_path_option_test(option)
+ elif option.__class__ is expected_options.StrOption:
+ return cls._generate_str_option_test(option)
+ elif option.__class__ is expected_options.ToggleOption:
+ return cls._generate_toggle_option_test(option)
+ elif option.__class__ is expected_options.UnsupportedOption:
+ return cls._generate_unsupported_option_test(option)
+
+ # Ignore all IgnoreOption tests since they should be manually tested
+ elif option.__class__ is expected_options.IgnoreOption:
+ return lambda self: None
+
+ # Catch-all meaningless test
+ return lambda self: \
+ self.fail('Unexpected option "{}"'.format(option.option_string))
+
+ @classmethod
+ def generate_preset_test(cls, preset_name, preset_args):
+ def test(self):
+ try:
+ self.parse_args(preset_args, check_impl_args=True)
+ except ParserError as e:
+ self.fail('Failed to parse preset "{}": {}'.format(
+ preset_name, e))
+
+ return test
+
+
+class TestDriverArgumentParser(unittest.TestCase):
+
+ __metaclass__ = TestDriverArgumentParserMeta
+
+ def parse_args(self, args, error_message=None, check_impl_args=False):
+ if error_message is None:
+ error_message = 'failed to parse arguments: ' + str(args)
+
+ with open(os.devnull, 'w') as devnull:
+ try:
+ with redirect_stderr(devnull), redirect_stdout(devnull):
+ namespace = migration.parse_args(self.parser, args)
+ except (SystemExit, ValueError) as e:
+ raise ParserError(error_message, e)
+
+ if not namespace.build_script_impl_args and not check_impl_args:
+ return namespace
+
+ try:
+ with redirect_stderr(devnull), redirect_stdout(devnull):
+ migration.check_impl_args(BUILD_SCRIPT_IMPL,
+ namespace.build_script_impl_args)
+ except (SystemExit, ValueError) as e:
+ raise ParserError(error_message, e)
+
+ return namespace
+
+ @contextmanager
+ def assertNotRaises(self, exception):
+ assert issubclass(exception, BaseException)
+
+ try:
+ yield
+ except exception as e:
+ self.fail(str(e))
+
+ def setUp(self):
+ self.parser = driver_arguments.create_argument_parser()
+
+ # -------------------------------------------------------------------------
+ # Manual option tests
+
+ def test_option_clang_compiler_version(self):
+ option_string = '--clang-compiler-version'
+
+ with self.assertNotRaises(ParserError):
+ self.parse_args([option_string, '5.0.0'])
+ self.parse_args([option_string, '5.0.1'])
+ self.parse_args([option_string, '5.0.0.1'])
+
+ with self.assertRaises(ParserError):
+ self.parse_args([option_string, '1'])
+ self.parse_args([option_string, '1.2'])
+ self.parse_args([option_string, '0.0.0.0.1'])
+
+ def test_option_clang_user_visible_version(self):
+ option_string = '--clang-user-visible-version'
+
+ with self.assertNotRaises(ParserError):
+ self.parse_args([option_string, '5.0.0'])
+ self.parse_args([option_string, '5.0.1'])
+ self.parse_args([option_string, '5.0.0.1'])
+
+ with self.assertRaises(ParserError):
+ self.parse_args([option_string, '1'])
+ self.parse_args([option_string, '1.2'])
+ self.parse_args([option_string, '0.0.0.0.1'])
+
+ def test_option_swift_compiler_version(self):
+ option_string = '--swift-compiler-version'
+
+ with self.assertNotRaises(ParserError):
+ self.parse_args([option_string, '4.1'])
+ self.parse_args([option_string, '4.0.1'])
+ self.parse_args([option_string, '200.99.1'])
+
+ with self.assertRaises(ParserError):
+ self.parse_args([option_string, '1'])
+ self.parse_args([option_string, '0.0.0.1'])
+
+ def test_option_swift_user_visible_version(self):
+ option_string = '--swift-user-visible-version'
+
+ with self.assertNotRaises(ParserError):
+ self.parse_args([option_string, '4.1'])
+ self.parse_args([option_string, '4.0.1'])
+ self.parse_args([option_string, '200.99.1'])
+
+ with self.assertRaises(ParserError):
+ self.parse_args([option_string, '1'])
+ self.parse_args([option_string, '0.0.0.1'])
+
+ # -------------------------------------------------------------------------
+ # Implied defaults tests
+
+ def test_implied_defaults_assertions(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--assertions'])
+
+ self.assertTrue(args.cmark_assertions)
+ self.assertTrue(args.llvm_assertions)
+ self.assertTrue(args.swift_assertions)
+ self.assertTrue(args.swift_stdlib_assertions)
+
+ def test_implied_defaults_cmark_build_variant(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--debug-cmark'])
+ self.assertTrue(args.build_cmark)
+
+ def test_implied_defaults_lldb_build_variant(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--debug-lldb'])
+ self.assertTrue(args.build_lldb)
+
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--lldb-assertions'])
+ self.assertTrue(args.build_lldb)
+
+ def test_implied_defaults_build_variant(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--debug'])
+
+ self.assertEquals(args.cmark_build_variant, 'Debug')
+ self.assertEquals(args.foundation_build_variant, 'Debug')
+ self.assertEquals(args.libdispatch_build_variant, 'Debug')
+ self.assertEquals(args.libicu_build_variant, 'Debug')
+ self.assertEquals(args.lldb_build_variant, 'Debug')
+ self.assertEquals(args.llvm_build_variant, 'Debug')
+ self.assertEquals(args.swift_build_variant, 'Debug')
+ self.assertEquals(args.swift_stdlib_build_variant, 'Debug')
+
+ def test_implied_defaults_skip_build(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-build'])
+
+ self.assertFalse(args.build_benchmarks)
+
+ self.assertFalse(args.build_linux)
+ self.assertFalse(args.build_android)
+ self.assertFalse(args.build_freebsd)
+ self.assertFalse(args.build_cygwin)
+ self.assertFalse(args.build_osx)
+ self.assertFalse(args.build_ios)
+ self.assertFalse(args.build_tvos)
+ self.assertFalse(args.build_watchos)
+
+ self.assertFalse(args.build_foundation)
+ self.assertFalse(args.build_libdispatch)
+ self.assertFalse(args.build_libicu)
+ self.assertFalse(args.build_lldb)
+ self.assertFalse(args.build_llbuild)
+ self.assertFalse(args.build_playgroundlogger)
+ self.assertFalse(args.build_playgroundsupport)
+ self.assertFalse(args.build_swiftpm)
+ self.assertFalse(args.build_xctest)
+
+ def test_implied_defaults_skip_build_ios(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-build-ios'])
+ self.assertFalse(args.build_ios_device)
+ self.assertFalse(args.build_ios_simulator)
+
+ # Also implies that the tests should be skipped
+ self.assertFalse(args.test_ios_device)
+ self.assertFalse(args.test_ios_simulator)
+
+ def test_implied_defaults_skip_build_tvos(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-build-tvos'])
+ self.assertFalse(args.build_tvos_device)
+ self.assertFalse(args.build_tvos_simulator)
+
+ # Also implies that the tests should be skipped
+ self.assertFalse(args.test_tvos_device)
+ self.assertFalse(args.test_tvos_simulator)
+
+ def test_implied_defaults_skip_build_watchos(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-build-watchos'])
+ self.assertFalse(args.build_watchos_device)
+ self.assertFalse(args.build_watchos_simulator)
+
+ # Also implies that the tests should be skipped
+ self.assertFalse(args.test_watchos_device)
+ self.assertFalse(args.test_watchos_simulator)
+
+ def test_implied_defaults_validation_test(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--validation-test'])
+ self.assertTrue(args.test)
+
+ def test_implied_defaults_test_optimized(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--test-optimized'])
+ self.assertTrue(args.test)
+
+ def test_implied_defaults_test_optimize_for_size(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--test-optimize-for-size'])
+ self.assertTrue(args.test)
+
+ def test_implied_defaults_skip_all_tests(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args([
+ '--test', '0',
+ '--validation-test', '0',
+ '--long-test', '0',
+ ])
+
+ self.assertFalse(args.test_linux)
+ self.assertFalse(args.test_freebsd)
+ self.assertFalse(args.test_cygwin)
+ self.assertFalse(args.test_osx)
+ self.assertFalse(args.test_ios)
+ self.assertFalse(args.test_tvos)
+ self.assertFalse(args.test_watchos)
+
+ def test_implied_defaults_skip_test_ios(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-test-ios'])
+ self.assertFalse(args.test_ios_device)
+ self.assertFalse(args.test_ios_simulator)
+
+ def test_implied_defaults_skip_test_tvos(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-test-tvos'])
+ self.assertFalse(args.test_tvos_device)
+ self.assertFalse(args.test_tvos_simulator)
+
+ def test_implied_defaults_skip_test_watchos(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-test-watchos'])
+ self.assertFalse(args.test_watchos_device)
+ self.assertFalse(args.test_watchos_simulator)
+
+ def test_implied_defaults_skip_build_android(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--android', '0'])
+ self.assertFalse(args.test_android_device)
+
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--skip-build-android'])
+ self.assertFalse(args.test_android_device)
+
+ def test_implied_defaults_host_test(self):
+ with self.assertNotRaises(ParserError):
+ args = self.parse_args(['--host-test', '0'])
+ self.assertFalse(args.test_ios_device)
+ self.assertFalse(args.test_tvos_device)
+ self.assertFalse(args.test_watchos_device)
+ self.assertFalse(args.test_android_device)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/utils/jobstats/jobstats.py b/utils/jobstats/jobstats.py
index 947a5e8..022ada9 100644
--- a/utils/jobstats/jobstats.py
+++ b/utils/jobstats/jobstats.py
@@ -61,11 +61,22 @@
assert(self.is_driver_job())
return self.driver_jobs_ran() + self.driver_jobs_skipped()
- def merged_with(self, other):
+ def merged_with(self, other, merge_by="sum"):
"""Return a new JobStats, holding the merger of self and other"""
merged_stats = {}
+ ops = {"sum": lambda a, b: a + b,
+ # Because 0 is also a sentinel on counters we do a modified
+ # "nonzero-min" here. Not ideal but best we can do.
+ "min": lambda a, b: (min(a, b)
+ if a != 0 and b != 0
+ else max(a, b)),
+ "max": lambda a, b: max(a, b)}
+ op = ops[merge_by]
for k, v in self.stats.items() + other.stats.items():
- merged_stats[k] = v + merged_stats.get(k, 0.0)
+ if k in merged_stats:
+ merged_stats[k] = op(v, merged_stats[k])
+ else:
+ merged_stats[k] = v
merged_kind = self.jobkind
if other.jobkind != merged_kind:
merged_kind = "<merged>"
@@ -160,7 +171,7 @@
def load_stats_dir(path, select_module=[], select_stat=[],
- exclude_timers=False):
+ exclude_timers=False, **kwargs):
"""Loads all stats-files found in path into a list of JobStats objects"""
jobstats = []
auxpat = (r"(?P<module>[^-]+)-(?P<input>[^-]+)-(?P<triple>[^-]+)" +
@@ -213,7 +224,8 @@
return jobstats
-def merge_all_jobstats(jobstats, select_module=[], group_by_module=False):
+def merge_all_jobstats(jobstats, select_module=[], group_by_module=False,
+ merge_by="sum", **kwargs):
"""Does a pairwise merge of the elements of list of jobs"""
m = None
if len(select_module) > 0:
@@ -221,15 +233,16 @@
if group_by_module:
def keyfunc(j):
return j.module
+ jobstats = list(jobstats)
jobstats.sort(key=keyfunc)
prefixed = []
for mod, group in itertools.groupby(jobstats, keyfunc):
- groupmerge = merge_all_jobstats(group)
+ groupmerge = merge_all_jobstats(group, merge_by=merge_by)
prefixed.append(groupmerge.prefixed_by(mod))
jobstats = prefixed
for j in jobstats:
if m is None:
m = j
else:
- m = m.merged_with(j)
+ m = m.merged_with(j, merge_by=merge_by)
return m
diff --git a/utils/process-stats-dir.py b/utils/process-stats-dir.py
index cbef76e..c9a3425 100755
--- a/utils/process-stats-dir.py
+++ b/utils/process-stats-dir.py
@@ -36,9 +36,6 @@
def load_paired_stats_dirs(args):
assert(len(args.remainder) == 2)
paired_stats = []
- mod = args.select_module
- stat = args.select_stat
- xt = args.exclude_timers
(old, new) = args.remainder
for p in sorted(os.listdir(old)):
full_old = os.path.join(old, p)
@@ -46,14 +43,8 @@
if not (os.path.exists(full_old) and os.path.isdir(full_old) and
os.path.exists(full_new) and os.path.isdir(full_new)):
continue
- old_stats = load_stats_dir(full_old,
- select_module=mod,
- select_stat=stat,
- exclude_timers=xt)
- new_stats = load_stats_dir(full_new,
- select_module=mod,
- select_stat=stat,
- exclude_timers=xt)
+ old_stats = load_stats_dir(full_old, **vars(args))
+ new_stats = load_stats_dir(full_new, **vars(args))
if len(old_stats) == 0 or len(new_stats) == 0:
continue
paired_stats.append((p, (old_stats, new_stats)))
@@ -63,22 +54,14 @@
def write_catapult_trace(args):
allstats = []
for path in args.remainder:
- allstats += load_stats_dir(path,
- select_module=args.select_module,
- select_stat=args.select_stat,
- exclude_timers=args.exclude_timers)
+ allstats += load_stats_dir(path, **vars(args))
json.dump([s.to_catapult_trace_obj() for s in allstats], args.output)
def write_lnt_values(args):
for d in args.remainder:
- stats = load_stats_dir(d,
- select_module=args.select_module,
- select_stat=args.select_stat,
- exclude_timers=args.exclude_timers)
- merged = merge_all_jobstats(stats,
- select_module=args.select_module,
- group_by_module=args.group_by_module)
+ stats = load_stats_dir(d, **vars(args))
+ merged = merge_all_jobstats(stats, **vars(args))
j = merged.to_lnt_test_obj(args)
if args.lnt_submit is None:
json.dump(j, args.output, indent=4)
@@ -107,16 +90,11 @@
out = csv.DictWriter(args.output, fieldnames, dialect='excel-tab')
out.writeheader()
- sel = args.select_module
for (name, (oldstats, newstats)) in load_paired_stats_dirs(args):
olddriver = merge_all_jobstats((x for x in oldstats
- if x.is_driver_job()),
- select_module=sel,
- group_by_module=args.group_by_module)
+ if x.is_driver_job()), **vars(args))
newdriver = merge_all_jobstats((x for x in newstats
- if x.is_driver_job()),
- select_module=sel,
- group_by_module=args.group_by_module)
+ if x.is_driver_job()), **vars(args))
if olddriver is None or newdriver is None:
continue
oldpct = olddriver.incrementality_percentage()
@@ -137,10 +115,7 @@
out.writeheader()
for path in args.remainder:
- stats = load_stats_dir(path,
- select_module=args.select_module,
- select_stat=args.select_stat,
- exclude_timers=args.exclude_timers)
+ stats = load_stats_dir(path, **vars(args))
for s in stats:
if s.is_driver_job():
pct = s.incrementality_percentage()
@@ -223,16 +198,12 @@
with open(args.set_csv_baseline, "wb") as f:
out = csv.DictWriter(f, fieldnames, dialect='excel-tab',
quoting=csv.QUOTE_NONNUMERIC)
- mod = args.select_module
- stat = args.select_stat
- xt = args.exclude_timers
m = merge_all_jobstats((s for d in args.remainder
- for s in load_stats_dir(d,
- select_module=mod,
- select_stat=stat,
- exclude_timers=xt)),
- select_module=mod,
- group_by_module=args.group_by_module)
+ for s in load_stats_dir(d, **vars(args))),
+ **vars(args))
+ if m is None:
+ print "no stats found"
+ return 1
changed = 0
newepoch = int(time.time())
for name in sorted(m.stats.keys()):
@@ -303,16 +274,9 @@
def compare_to_csv_baseline(args):
old_stats = read_stats_dict_from_csv(args.compare_to_csv_baseline)
- mod = args.select_module
- stat = args.select_stat
- xt = args.exclude_timers
m = merge_all_jobstats((s for d in args.remainder
- for s in load_stats_dir(d,
- select_module=mod,
- select_stat=stat,
- exclude_timers=xt)),
- select_module=mod,
- group_by_module=args.group_by_module)
+ for s in load_stats_dir(d, **vars(args))),
+ **vars(args))
old_stats = dict((k, v) for (k, (_, v)) in old_stats.items())
new_stats = m.stats
@@ -325,20 +289,10 @@
raise ValueError("Expected exactly 2 stats-dirs")
(old, new) = args.remainder
- old_stats = merge_all_jobstats(
- load_stats_dir(old,
- select_module=args.select_module,
- select_stat=args.select_stat,
- exclude_timers=args.exclude_timers),
- select_module=args.select_module,
- group_by_module=args.group_by_module)
- new_stats = merge_all_jobstats(
- load_stats_dir(new,
- select_module=args.select_module,
- select_stat=args.select_stat,
- exclude_timers=args.exclude_timers),
- select_module=args.select_module,
- group_by_module=args.group_by_module)
+ old_stats = merge_all_jobstats(load_stats_dir(old, **vars(args)),
+ **vars(args))
+ new_stats = merge_all_jobstats(load_stats_dir(new, **vars(args)),
+ **vars(args))
return write_comparison(args, old_stats.stats, new_stats.stats)
@@ -395,6 +349,10 @@
default=False,
action="store_true",
help="Sort comparison results in descending order")
+ parser.add_argument("--merge-by",
+ default="sum",
+ type=str,
+ help="Merge identical metrics by (sum|min|max)")
parser.add_argument("--markdown",
default=False,
action="store_true",
diff --git a/utils/swift_build_support/swift_build_support/arguments.py b/utils/swift_build_support/swift_build_support/arguments.py
index 436ebb1..d55cfbe 100644
--- a/utils/swift_build_support/swift_build_support/arguments.py
+++ b/utils/swift_build_support/swift_build_support/arguments.py
@@ -190,6 +190,7 @@
option_strings,
dest,
default=False,
+ const=True,
metavar="BOOL",
help=None):
super(_OptionalBoolAction, self).__init__(
@@ -200,10 +201,40 @@
nargs="?",
type=type.bool,
help=help,
- const=True)
+ const=const)
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, values)
_register(action, 'optional_bool', _OptionalBoolAction)
+
+
+class _OptionalTrueAction(_OptionalBoolAction):
+ """Action that defaults to False when absent and to True when parsed with
+ the option to override the value by passing a bool-like value as an
+ argument.
+ """
+
+ def __init__(self, *args, **kwargs):
+ kwargs['const'] = True
+ kwargs['default'] = kwargs.pop('default', False)
+ super(_OptionalTrueAction, self).__init__(*args, **kwargs)
+
+
+_register(action, 'optional_true', _OptionalTrueAction)
+
+
+class _OptionalFalseAction(_OptionalBoolAction):
+ """Action that defaults to True when absent and to False when parsed with
+ the option to override the value by passing a bool-like value as an
+ argument.
+ """
+
+ def __init__(self, *args, **kwargs):
+ kwargs['const'] = False
+ kwargs['default'] = kwargs.pop('default', True)
+ super(_OptionalFalseAction, self).__init__(*args, **kwargs)
+
+
+_register(action, 'optional_false', _OptionalFalseAction)
diff --git a/validation-test/Evolution/test_class_add_override.swift b/validation-test/Evolution/test_class_add_override.swift
index 63760c7..596b752 100644
--- a/validation-test/Evolution/test_class_add_override.swift
+++ b/validation-test/Evolution/test_class_add_override.swift
@@ -1,6 +1,5 @@
// RUN: %target-resilience-test
// REQUIRES: executable_test
-// REQUIRES: no_asan
import StdlibUnittest
import class_add_override
diff --git a/validation-test/Evolution/test_class_add_property.swift b/validation-test/Evolution/test_class_add_property.swift
index f925624..64ebd58 100644
--- a/validation-test/Evolution/test_class_add_property.swift
+++ b/validation-test/Evolution/test_class_add_property.swift
@@ -1,6 +1,5 @@
// RUN: %target-resilience-test
// REQUIRES: executable_test
-// REQUIRES: no_asan
import StdlibUnittest
import class_add_property
diff --git a/validation-test/Evolution/test_class_change_size.swift b/validation-test/Evolution/test_class_change_size.swift
index c37d407..deffdbd 100644
--- a/validation-test/Evolution/test_class_change_size.swift
+++ b/validation-test/Evolution/test_class_change_size.swift
@@ -1,6 +1,5 @@
// RUN: %target-resilience-test
// REQUIRES: executable_test
-// REQUIRES: no_asan
import StdlibUnittest
import class_change_size
diff --git a/validation-test/Sema/type_checker_perf/slow/rdar17024694.swift b/validation-test/Sema/type_checker_perf/fast/rdar17024694.swift
similarity index 67%
rename from validation-test/Sema/type_checker_perf/slow/rdar17024694.swift
rename to validation-test/Sema/type_checker_perf/fast/rdar17024694.swift
index 52498ef..fa0c86c 100644
--- a/validation-test/Sema/type_checker_perf/slow/rdar17024694.swift
+++ b/validation-test/Sema/type_checker_perf/fast/rdar17024694.swift
@@ -2,7 +2,7 @@
// REQUIRES: tools-release,no_asserts
2...100.reversed().filter({ $0 % 11 == 0 }).map {
- // expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
+ // expected-error@-1 {{value of type 'Int' has no member 'reversed'}}
"\($0) bottles of beer on the wall, \($0) bottles of beer;\n"
+ " take eleven down, pass 'em around, \($0-11) bottles of beer on the wall!"
}
diff --git a/validation-test/Sema/type_checker_perf/fast/rdar21720888.swift.gyb b/validation-test/Sema/type_checker_perf/fast/rdar21720888.swift.gyb
new file mode 100644
index 0000000..b1d9d24
--- /dev/null
+++ b/validation-test/Sema/type_checker_perf/fast/rdar21720888.swift.gyb
@@ -0,0 +1,9 @@
+// RUN: %scale-test --begin 1 --end 10 --step 1 --select incrementScopeCounter %s
+// REQUIRES: OS=macosx
+// REQUIRES: asserts
+
+_ = [
+%for i in range(0, N):
+ (label: "string"),
+%end
+]
diff --git a/validation-test/Sema/type_checker_perf/slow/rdar21720888.swift.gyb b/validation-test/Sema/type_checker_perf/slow/rdar21720888.swift.gyb
deleted file mode 100644
index efb6d5c..0000000
--- a/validation-test/Sema/type_checker_perf/slow/rdar21720888.swift.gyb
+++ /dev/null
@@ -1,9 +0,0 @@
-// RUN: %scale-test --invert-result --begin 2 --end 7 --step 1 --select incrementScopeCounter %s
-// REQUIRES: OS=macosx
-// REQUIRES: asserts
-
-_ = [
-%for i in range(0, N):
- (label: "string"),
-%end
-]
diff --git a/validation-test/stdlib/ArrayTraps.swift.gyb b/validation-test/stdlib/ArrayTraps.swift.gyb
index f9da22c..0c2e8dd 100644
--- a/validation-test/stdlib/ArrayTraps.swift.gyb
+++ b/validation-test/stdlib/ArrayTraps.swift.gyb
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %gyb %s -o %t/ArrayTraps.swift
-// RUN: %line-directive %t/ArrayTraps.swift -- %target-build-swift %t/ArrayTraps.swift -o %t/a.out_Debug
+// RUN: %line-directive %t/ArrayTraps.swift -- %target-build-swift %t/ArrayTraps.swift -o %t/a.out_Debug -Onone
// RUN: %line-directive %t/ArrayTraps.swift -- %target-build-swift %t/ArrayTraps.swift -o %t/a.out_Release -O
//
// RUN: %line-directive %t/ArrayTraps.swift -- %target-run %t/a.out_Debug
diff --git a/validation-test/stdlib/ArrayTrapsObjC.swift.gyb b/validation-test/stdlib/ArrayTrapsObjC.swift.gyb
index 825f0fc..0d3882d 100644
--- a/validation-test/stdlib/ArrayTrapsObjC.swift.gyb
+++ b/validation-test/stdlib/ArrayTrapsObjC.swift.gyb
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %gyb %s -o %t/ArrayTraps.swift
-// RUN: %line-directive %t/ArrayTraps.swift -- %target-build-swift %t/ArrayTraps.swift -o %t/a.out_Debug
+// RUN: %line-directive %t/ArrayTraps.swift -- %target-build-swift %t/ArrayTraps.swift -o %t/a.out_Debug -Onone
// RUN: %line-directive %t/ArrayTraps.swift -- %target-build-swift %t/ArrayTraps.swift -o %t/a.out_Release -O
//
// RUN: %line-directive %t/ArrayTraps.swift -- %target-run %t/a.out_Debug
diff --git a/validation-test/stdlib/Assert.swift b/validation-test/stdlib/Assert.swift
index 748be9e..627f0ee 100644
--- a/validation-test/stdlib/Assert.swift
+++ b/validation-test/stdlib/Assert.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -Xfrontend -disable-access-control -o %t/Assert_Debug
+// RUN: %target-build-swift %s -Xfrontend -disable-access-control -o %t/Assert_Debug -Onone
// RUN: %target-build-swift %s -Xfrontend -disable-access-control -o %t/Assert_Release -O
// RUN: %target-build-swift %s -Xfrontend -disable-access-control -o %t/Assert_Unchecked -Ounchecked
//
diff --git a/validation-test/stdlib/DictionaryTrapsObjC.swift b/validation-test/stdlib/DictionaryTrapsObjC.swift
index 80dcdfe..1627f94 100644
--- a/validation-test/stdlib/DictionaryTrapsObjC.swift
+++ b/validation-test/stdlib/DictionaryTrapsObjC.swift
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
-// RUN: %target-build-swift %s -o %t/a.out_Debug
+// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-run %t/a.out_Debug
diff --git a/validation-test/stdlib/FixedPointArithmeticTraps.swift.gyb b/validation-test/stdlib/FixedPointArithmeticTraps.swift.gyb
index a497b80..cd28dab 100644
--- a/validation-test/stdlib/FixedPointArithmeticTraps.swift.gyb
+++ b/validation-test/stdlib/FixedPointArithmeticTraps.swift.gyb
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %gyb %s -o %t/FixedPointArithmeticTraps.swift
-// RUN: %line-directive %t/FixedPointArithmeticTraps.swift -- %target-build-swift %t/FixedPointArithmeticTraps.swift -o %t/a.out_Debug
+// RUN: %line-directive %t/FixedPointArithmeticTraps.swift -- %target-build-swift %t/FixedPointArithmeticTraps.swift -o %t/a.out_Debug -Onone
// RUN: %line-directive %t/FixedPointArithmeticTraps.swift -- %target-build-swift %t/FixedPointArithmeticTraps.swift -o %t/a.out_Release -O
//
// RUN: %line-directive %t/FixedPointArithmeticTraps.swift -- %target-run %t/a.out_Debug
diff --git a/validation-test/stdlib/FixedPointConversion.swift.gyb b/validation-test/stdlib/FixedPointConversion.swift.gyb
index 13e75ff..fc3d7c5 100644
--- a/validation-test/stdlib/FixedPointConversion.swift.gyb
+++ b/validation-test/stdlib/FixedPointConversion.swift.gyb
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %S/../../utils/gyb %s -o %t/FixedPointConversion.swift
-// RUN: %S/../../utils/line-directive %t/FixedPointConversion.swift -- %target-build-swift %t/FixedPointConversion.swift -o %t/a.out_Debug
+// RUN: %S/../../utils/line-directive %t/FixedPointConversion.swift -- %target-build-swift %t/FixedPointConversion.swift -o %t/a.out_Debug -Onone
// RUN: %S/../../utils/line-directive %t/FixedPointConversion.swift -- %target-build-swift %t/FixedPointConversion.swift -o %t/a.out_Release -O
//
// RUN: %S/../../utils/line-directive %t/FixedPointConversion.swift -- %target-run %t/a.out_Debug
diff --git a/validation-test/stdlib/FloatingPointConversion.swift.gyb b/validation-test/stdlib/FloatingPointConversion.swift.gyb
index 1632b6c..9882102 100644
--- a/validation-test/stdlib/FloatingPointConversion.swift.gyb
+++ b/validation-test/stdlib/FloatingPointConversion.swift.gyb
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: %gyb %s -o %t/FloatingPointConversion.swift
-// RUN: %line-directive %t/FloatingPointConversion.swift -- %target-build-swift %t/FloatingPointConversion.swift -Xfrontend -disable-access-control -o %t/a.out_Debug
+// RUN: %line-directive %t/FloatingPointConversion.swift -- %target-build-swift %t/FloatingPointConversion.swift -Xfrontend -disable-access-control -o %t/a.out_Debug -Onone
// RUN: %line-directive %t/FloatingPointConversion.swift -- %target-build-swift %t/FloatingPointConversion.swift -Xfrontend -disable-access-control -o %t/a.out_Release -O
//
// RUN: %line-directive %t/FloatingPointConversion.swift -- %target-run %t/a.out_Debug
diff --git a/validation-test/stdlib/InvalidStrideable.swift b/validation-test/stdlib/InvalidStrideable.swift
new file mode 100644
index 0000000..3306f63
--- /dev/null
+++ b/validation-test/stdlib/InvalidStrideable.swift
@@ -0,0 +1,43 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-build-swift -emit-executable -DTEST_EQUATABLE -o %t/InvalidStrideableEq %s
+// RUN: ! %target-run %t/InvalidStrideableEq 2>&1 | %FileCheck %s --check-prefix=CHECK-EQUATABLE
+// RUN: %target-build-swift -emit-executable -DTEST_COMPARABLE -o %t/InvalidStrideableCmp %s
+// RUN: ! %target-run %t/InvalidStrideableCmp 2>&1 | %FileCheck %s --check-prefix=CHECK-COMPARABLE
+// REQUIRES: executable_test
+
+//
+// Check that a circular Strideable inheriting witnesses from Stdlib crashes
+// with a rich error message.
+//
+
+struct InvalidStrideable : Strideable, SignedNumeric {
+ typealias Magnitude = InvalidStrideable
+ init?<T>(exactly: T) where T : BinaryInteger { return nil }
+ var magnitude: InvalidStrideable { return self }
+
+ static func += (lhs: inout InvalidStrideable, rhs: InvalidStrideable) { }
+ static func -= (lhs: inout InvalidStrideable, rhs: InvalidStrideable) { }
+ static func *= (lhs: inout InvalidStrideable, rhs: InvalidStrideable) { }
+
+ static func + (lhs: InvalidStrideable, rhs: InvalidStrideable) -> InvalidStrideable { return rhs }
+ static func - (lhs: InvalidStrideable, rhs: InvalidStrideable) -> InvalidStrideable { return rhs }
+ static func * (lhs: InvalidStrideable, rhs: InvalidStrideable) -> InvalidStrideable { return rhs }
+
+ typealias IntegerLiteralType = Int
+ init(integerLiteral : Int) {}
+
+ typealias Stride = InvalidStrideable
+
+ init() {}
+
+ func distance(to rhs: InvalidStrideable) -> InvalidStrideable { return self }
+ func advanced(by n: InvalidStrideable) -> InvalidStrideable { return self }
+}
+
+#if TEST_EQUATABLE
+ // CHECK-EQUATABLE: fatal error: Strideable conformance where 'Stride == Self' requires user-defined implementation of the '==' operator
+ _ = InvalidStrideable() == InvalidStrideable()
+#else
+ // CHECK-COMPARABLE: fatal error: Strideable conformance where 'Stride == Self' requires user-defined implementation of the '<' operator
+ _ = InvalidStrideable() < InvalidStrideable() // Will trap with error message
+#endif