diff --git a/.dir-locals.el b/.dir-locals.el
index bd65e5345441f..feea22ea295c1 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -2,7 +2,7 @@
;
; This source file is part of the Swift.org open source project
;
-; Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+; Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
; Licensed under Apache License v2.0 with Runtime Library Exception
;
; See http://swift.org/LICENSE.txt for license information
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc79f27731e14..9f9c92edcdba2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,49 @@
-Latest
-------
+
+Swift 3
+-------
+
+* Curried function syntax has been removed, and now produces a compile-time
+ error.
+
+
+Swift 2.2
+---------
+
+* Associated types in protocols can now be specified with a new 'associatedtype'
+ declaration, to replace the use of 'typealias':
+
+ protocol P {
+ associatedtype Ty
+ }
+
+ The typealias keyword is still allowed (but deprecated and produces a warning)
+ in Swift 2.2. This warning will become an error in Swift 3.
+
+* Curried function syntax has been deprecated, and is slated to be removed in
+ Swift 3.
+
+* The ++ and -- operators have been deprecated, and are slated to be removed in
+ Swift 3.0. As a replacement, please use "x += 1" on integer or floating point
+ types, and "x = x.successor()" on Index types.
+
+* The operator identifier lexer grammar has been revised to simplify the rules
+ for operators that start with a dot ("."). The new rule is that an operator
+ that starts with a dot may contain other dots in it, but operators that start
+ with some other character may not contain dots. For example:
+
+ ```
+ x....foo --> "x" "...." "foo"
+ x&%^.foo --> "x" "&%^" ".foo"
+ ```
+
+ This eliminates a special case for the ..< operator, folding it into a simple
+ and consistent rule.
+
+* The "C-style for loop", which is spelled `for init; comparison; increment {}`
+ has been deprecated and is slated for removal in Swift 3.0. See
+ [SE-0007](https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md)
+ for more information.
+
* Three new doc comment fields, namely `- keyword:`, `- recommended:`
and `- recommendedover:`, allow Swift users to cooperate with code
completion engine to deliver more effective code completion results.
@@ -31,7 +75,8 @@ Latest
* `ArraySlice.removeFirst()` now preserves element indices.
* Global `anyGenerator()` functions have been changed into initializers on
- `AnyGenerator`, making the API more intuitive and idiomatic.
+ `AnyGenerator`, making the API more intuitive and idiomatic. They have been
+ deprecated in Swift 2.2, and will be removed in Swift 3.
* Closures appearing inside generic types and generic methods can now be
converted to C function pointers as long as no generic type parameters
@@ -58,6 +103,78 @@ Latest
**(rdar://problem/21683348)**
+* Argument labels and parameter names can now be any keyword except
+ `var`, `let`, or `inout`. For example:
+
+ NSURLProtectionSpace(host: "somedomain.com", port: 443, protocol: "https", realm: "Some Domain", authenticationMethod: "Basic")
+
+ would previously have required `protocol` to be surrounded in
+ back-ticks. For more information, see
+ [SE-0001](https://github.com/apple/swift-evolution/blob/master/proposals/0001-keywords-as-argument-labels.md).
+
+* Tuples (up to arity 6) whose elements are all `Comparable` or `Equatable` now
+ implement the full set of comparison/equality operators. The comparison
+ operators are defined in terms of [lexicographical order][]. See [SE-0015][]
+ for more information.
+
+[lexicographical order]: https://en.wikipedia.org/wiki/Lexicographical_order
+[SE-0015]: https://github.com/apple/swift-evolution/blob/master/proposals/0015-tuple-comparison-operators.md
+
+* The `@objc(SomeName)` attribute is now supported on enums and enum cases to
+ rename the generated Objective-C declaration.
+
+ **(rdar://problem/21930334)**
+
+* When referencing a function or initializer, one can provide the
+ complete name, including argument labels. For example:
+
+ let fn1 = someView.insertSubview(_:at:)
+ let fn2 = someView.insertSubview(_:aboveSubview:)
+
+ let buttonFactory = UIButton.init(type:)
+
+ For more information, see [SE-0021](https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md).
+
+* There is a new build configuration function, `#if swift(>=x.y)`, which
+ tests if the current Swift language version is at least `x.y`. This
+ allows you to conditionally compile code for multiple language
+ versions in the same file, even with different syntax, by deactivating
+ parsing in inactive code blocks. For example:
+
+ ```swift
+ #if swift(>=2.2)
+ // Only this code will be parsed in Swift 3
+ func foo(x: Int) -> (y: Int) -> () {}
+ #else
+ // This code is ignored entirely.
+ func foo(x: Int)(y: Int) {}
+ #endif
+ ```
+
+ For more information, see [SE-0020](https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md).
+
+* The Objective-C selector of a Swift method can now be determined
+ directly with the #selector expression, e.g.,:
+
+ let sel = #selector(insertSubview(_:aboveSubview:)) // sel has type Selector
+
+ Along with this change, the use of string literals as selectors has
+ been deprecated, e.g.,
+
+ let sel: Selector = "insertSubview:aboveSubview:"
+
+ Generally, such string literals should be replaced with uses of
+ `#selector`, and the compiler will provide Fix-Its that use
+ `#selector`. In cases where they is not possible (e.g., when referring
+ to the getter of a property), one can still directly construct
+ selectors, e.g.,:
+
+ let sel = Selector("propertyName")
+
+ Note that the compiler is now checking the string literals used to
+ construct Selectors to ensure that they are well-formed Objective-C
+ selectors and that there is an '@objc' method with that selector.
+
2015-09-17 [Xcode 7.1, Swift 2.1]
----------
@@ -67,7 +184,7 @@ Latest
allows you to use C enum pattern matching in switch statements with no
additional code. **(17287720)**
-* The `NSNumberunsignedIntegerValue` property now has the type `UInt` instead
+* The `NSNumber.unsignedIntegerValue` property now has the type `UInt` instead
of `Int`, as do other methods and properties that use the `NSUInteger` type
in Objective-C and whose names contain `unsigned..`. Most other uses of
`NSUInteger` in system frameworks are imported as `Int` as they were in
@@ -1342,7 +1459,7 @@ Latest
unique elements with full value semantics. It bridges with `NSSet`, providing
functionality analogous to `Array` and `Dictionary`. **(14661754)**
-* The `if–let` construct has been expanded to allow testing multiple optionals
+* The `if-let` construct has been expanded to allow testing multiple optionals
and guarding conditions in a single `if` (or `while`) statement using syntax
similar to generic constraints:
@@ -1356,7 +1473,7 @@ Latest
conditions, without introducing undesirable nesting (for instance, to avoid
the optional unwrapping _"pyramid of doom"_).
- Further, `if–let` now also supports a single leading boolean condition along
+ Further, `if-let` now also supports a single leading boolean condition along
with optional binding `let` clauses. For example:
```swift
@@ -1366,7 +1483,7 @@ Latest
**(19797158, 19382942)**
-* The `if–let` syntax has been extended to support a single leading boolean
+* The `if-let` syntax has been extended to support a single leading boolean
condition along with optional binding `let` clauses.
For example:
@@ -3865,9 +3982,9 @@ Latest
themselves.
Overall, a property now may either be "stored" (the default), "computed"
- (have a `get:` and optionally a `set:` specifier), or a observed
+ (have a `get:` and optionally a `set:` specifier), or an observed
(`willSet`/`didSet`) property. It is not possible to have a custom getter
- or setter on a observed property, since they have storage.
+ or setter on an observed property, since they have storage.
Two known-missing bits are:
- **(rdar://problem/15920332) didSet/willSet variables need to allow initializers**
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 916e3afc3dbff..83abf47494762 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,10 @@ option(SWIFT_STDLIB_ASSERTIONS
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
"${SWIFT_STDLIB_ASSERTIONS_default}")
+option(SWIFT_SERIALIZE_STDLIB_UNITTEST
+ "Compile the StdlibUnittest module with -sil-serialize-all to increase the test coverage for the optimizer"
+ FALSE)
+
option(SWIFT_BUILD_TOOLS
"Build the Swift compiler and other tools"
TRUE)
@@ -44,9 +48,9 @@ option(SWIFT_BUILD_STATIC_STDLIB
"Build static variants of the Swift standard library and SDK overlay"
FALSE)
-option(SWIFT_INCLUDE_BENCHMARKS
- "Create targets for running swift benchmarks"
- TRUE)
+option(SWIFT_BUILD_PERF_TESTSUITE
+ "Create targets for swift performance benchmarks."
+ FALSE)
option(SWIFT_INCLUDE_TESTS "Create targets for building/running tests." TRUE)
@@ -54,7 +58,7 @@ option(SWIFT_INCLUDE_DOCS
"Create targets for building docs."
TRUE)
-set(SWIFT_VERSION "2.2" CACHE STRING
+set(SWIFT_VERSION "3.0" CACHE STRING
"The user-visible version of the Swift compiler")
set(SWIFT_VENDOR "" CACHE STRING
"The vendor name of the Swift compiler")
@@ -69,7 +73,7 @@ set(SWIFT_ENABLE_GOLD_LINKER FALSE CACHE BOOL
"Enable using the gold linker when available")
set(_SWIFT_KNOWN_INSTALL_COMPONENTS
- "compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;editor-integration;tools;testsuite-tools;dev;sourcekit-xpc-service;sourcekit-inproc")
+ "compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;editor-integration;tools;testsuite-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc")
# Set the SWIFT_INSTALL_COMPONENTS variable to the default value if it is not passed in via -D
set(SWIFT_INSTALL_COMPONENTS "${_SWIFT_KNOWN_INSTALL_COMPONENTS}" CACHE STRING
@@ -125,6 +129,9 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
"Whether to enable CrashReporter integration"
FALSE)
+set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
+ "The name of the toolchain to pass to 'xcrun'")
+
set(SWIFT_DARWIN_ICU_INCLUDE_PATH "" CACHE STRING
"Path to the directory where the ICU headers are located")
@@ -151,7 +158,7 @@ option(SWIFT_AST_VERIFIER
"Enable the AST verifier in the built compiler, and run it on every compilation"
TRUE)
-option(SWIFT_VERIFY_ALL
+option(SWIFT_SIL_VERIFY_ALL
"Run SIL verification after each transform when building Swift files in the build process"
FALSE)
@@ -180,11 +187,7 @@ set(SWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS "" CACHE STRING
"A list of [module_regexp1;flags1;module_regexp2;flags2,...] which can be used to apply specific flags to modules that match a cmake regexp. It always applies the first regexp that matches.")
set(SWIFT_EXPERIMENTAL_EXTRA_NEGATIVE_REGEXP_FLAGS "" CACHE STRING
- "A list of [module_regexp1;flags1;module_regexp2;flags2,...] which can be used to apply specific flags to modules that do not match a cmake regexp. It always applies the first regexp that does not matche. The reason this is necessary is that cmake does not provide negative matches in the regex. Instead you have to use NOT in the if statement requiring a separate variable.")
-
-option(SWIFT_RUNTIME_ENABLE_DTRACE
- "Should the runtime be built with dtrace instrumentation enabled"
- FALSE)
+ "A list of [module_regexp1;flags1;module_regexp2;flags2,...] which can be used to apply specific flags to modules that do not match a cmake regexp. It always applies the first regexp that does not match. The reason this is necessary is that cmake does not provide negative matches in the regex. Instead you have to use NOT in the if statement requiring a separate variable.")
option(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
"Should the runtime be built with support for non-thread-safe leak detecting entrypoints"
@@ -222,9 +225,6 @@ endif()
option(SWIFT_BUILD_SOURCEKIT
"Build SourceKit"
${SWIFT_BUILD_SOURCEKIT_default})
-# Force updating the cache, remove the following after a couple of weeks or so.
-set(SWIFT_BUILD_SOURCEKIT ${SWIFT_BUILD_SOURCEKIT_default}
- CACHE BOOL "Build SourceKit" FORCE)
#
# Include CMake modules
@@ -398,6 +398,11 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
configure_sdk_unix(LINUX "Linux" "linux" "linux" "x86_64" "x86_64-unknown-linux-gnu")
set(SWIFT_HOST_VARIANT_ARCH "x86_64")
set(SWIFT_PRIMARY_VARIANT_ARCH_default "x86_64")
+ # FIXME: This only matches ARMv6l (by far the most common variant).
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv6l")
+ configure_sdk_unix(LINUX "Linux" "linux" "linux" "armv6" "armv6-unknown-linux-gnueabihf")
+ set(SWIFT_HOST_VARIANT_ARCH "armv6")
+ set(SWIFT_PRIMARY_VARIANT_ARCH_default "armv6")
# FIXME: This only matches ARMv7l (by far the most common variant).
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
configure_sdk_unix(LINUX "Linux" "linux" "linux" "armv7" "armv7-unknown-linux-gnueabihf")
@@ -407,6 +412,14 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
configure_sdk_unix(LINUX "Linux" "linux" "linux" "aarch64" "aarch64-unknown-linux-gnu")
set(SWIFT_HOST_VARIANT_ARCH "aarch64")
set(SWIFT_PRIMARY_VARIANT_ARCH_default "aarch64")
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
+ configure_sdk_unix(LINUX "Linux" "linux" "linux" "powerpc64" "powerpc64-unknown-linux-gnu")
+ set(SWIFT_HOST_VARIANT_ARCH "powerpc64")
+ set(SWIFT_PRIMARY_VARIANT_ARCH_default "powerpc64")
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64le")
+ configure_sdk_unix(LINUX "Linux" "linux" "linux" "powerpc64le" "powerpc64le-unknown-linux-gnu")
+ set(SWIFT_HOST_VARIANT_ARCH "powerpc64le")
+ set(SWIFT_PRIMARY_VARIANT_ARCH_default "powerpc64le")
else()
message(FATAL_ERROR "Unknown or unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
@@ -461,7 +474,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
endif()
if(XCODE)
- # FIXME: Can not cross-compile stdlib using Xcode. Xcode insists on
+ # FIXME: Cannot cross-compile stdlib using Xcode. Xcode insists on
# passing -mmacosx-version-min to the compiler, and we want to pass
# -mios-version-min. Clang sees both options and complains.
set(swift_can_crosscompile_stdlib FALSE)
@@ -584,6 +597,11 @@ endif()
set(SWIFT_PRIMARY_VARIANT_SUFFIX
"-${SWIFT_SDK_${SWIFT_PRIMARY_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_PRIMARY_VARIANT_ARCH}")
+# Clear universal library names to prevent adding duplicates
+foreach(sdk ${SWIFT_SDKS})
+ unset(UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR} CACHE)
+endforeach()
+
message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_HOST_VARIANT_ARCH}")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
@@ -610,6 +628,10 @@ if(LIBXML2_FOUND)
set(SWIFT_HAVE_LIBXML 1)
endif()
+if (LLVM_ENABLE_DOXYGEN)
+ message(STATUS "Doxygen: enabled")
+endif()
+
#
# Set up global CMake variables for API notes.
#
@@ -633,7 +655,7 @@ if(SWIFT_BUILD_TOOLS)
endif()
add_subdirectory(utils)
add_subdirectory(stdlib)
-if(SWIFT_INCLUDE_BENCHMARKS)
+if(SWIFT_BUILD_PERF_TESTSUITE)
add_subdirectory(benchmark)
endif()
if(SWIFT_INCLUDE_TESTS)
@@ -644,6 +666,10 @@ if(SWIFT_INCLUDE_DOCS)
add_subdirectory(docs)
endif()
+swift_install_in_component(license
+ FILES "LICENSE.txt"
+ DESTINATION "share/swift")
+
# Add a documentation target so that documentation shows up in the
# Xcode project.
if(XCODE)
diff --git a/README.md b/README.md
index ec5d9470ea915..070dd10827e2d 100644
--- a/README.md
+++ b/README.md
@@ -56,9 +56,9 @@ with version 2 shipped with Ubuntu.
If you are building on Ubuntu 14.04 LTS, you'll need to upgrade your clang
compiler for C++14 support and create a symlink:
- sudo apt-get install clang-3.6
- sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
- sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100
+ sudo apt-get install clang-3.6
+ sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
+ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100
### Getting Sources for Swift and Related Projects
diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt
index 360f26884a7da..7ef0477f168db 100644
--- a/benchmark/CMakeLists.txt
+++ b/benchmark/CMakeLists.txt
@@ -1,13 +1,10 @@
-option(SWIFT_INCLUDE_PERF_TESTSUITE "Create targets for swift performance benchmarks." NO)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Performance test harness only builds on Darwin.
- if (SWIFT_INCLUDE_PERF_TESTSUITE)
- set(PERF_TESTSUITE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PerfTestSuite" CACHE STRING "Path to swift performance testsuite repo.")
- if(EXISTS ${PERF_TESTSUITE_DIR}/CMakeLists.txt)
- add_subdirectory(${PERF_TESTSUITE_DIR})
- else()
- message(FATAL_ERROR "Can't find the Swift performance suite at ${PERF_TESTSUITE_DIR}/.")
- endif()
+ set(PERF_TESTSUITE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PerfTestSuite" CACHE STRING "Path to swift performance testsuite repo.")
+ if(EXISTS ${PERF_TESTSUITE_DIR}/CMakeLists.txt)
+ add_subdirectory(${PERF_TESTSUITE_DIR})
+ else()
+ message(FATAL_ERROR "Can't find the Swift performance suite at ${PERF_TESTSUITE_DIR}/.")
endif()
endif()
diff --git a/bindings/xml/comment-xml-schema.rng b/bindings/xml/comment-xml-schema.rng
index 6ee793715ff33..468efa042537e 100644
--- a/bindings/xml/comment-xml-schema.rng
+++ b/bindings/xml/comment-xml-schema.rng
@@ -767,6 +767,9 @@
+
+
+
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 9af22f6a23067..2da4d1582771f 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -47,9 +47,9 @@ function(compute_library_subdir result_var_name sdk arch)
set("${result_var_name}" "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}" PARENT_SCOPE)
endfunction()
-
function(_add_variant_c_compile_link_flags
- sdk arch build_type enable_assertions result_var_name)
+ sdk arch build_type enable_assertions analyze_code_coverage
+ result_var_name)
set(result
${${result_var_name}}
"-target" "${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}")
@@ -62,13 +62,19 @@ function(_add_variant_c_compile_link_flags
"-arch" "${arch}"
"-F" "${SWIFT_SDK_${sdk}_PATH}/../../../Developer/Library/Frameworks"
"-m${SWIFT_SDK_${sdk}_VERSION_MIN_NAME}-version-min=${SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION}")
+
+ if(analyze_code_coverage)
+ list(APPEND result "-fprofile-instr-generate=swift-%p.profraw"
+ "-fcoverage-mapping")
+ endif()
endif()
set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
function(_add_variant_c_compile_flags
- sdk arch build_type enable_assertions result_var_name)
+ sdk arch build_type enable_assertions analyze_code_coverage
+ result_var_name)
set(result ${${result_var_name}})
_add_variant_c_compile_link_flags(
@@ -76,6 +82,7 @@ function(_add_variant_c_compile_flags
"${arch}"
"${build_type}"
"${enable_assertions}"
+ FALSE
result)
is_build_type_optimized("${build_type}" optimized)
@@ -103,6 +110,11 @@ function(_add_variant_c_compile_flags
list(APPEND result "-DNDEBUG")
endif()
+ if(analyze_code_coverage)
+ list(APPEND result "-fprofile-instr-generate=swift-%p.profraw"
+ "-fcoverage-mapping")
+ endif()
+
set("${result_var_name}" "${result}" PARENT_SCOPE)
endfunction()
@@ -139,7 +151,8 @@ function(_add_variant_swift_compile_flags
endfunction()
function(_add_variant_link_flags
- sdk arch build_type enable_assertions result_var_name)
+ sdk arch build_type enable_assertions analyze_code_coverage
+ result_var_name)
if("${sdk}" STREQUAL "")
message(FATAL_ERROR "Should specify an SDK")
@@ -156,12 +169,19 @@ function(_add_variant_link_flags
"${arch}"
"${build_type}"
"${enable_assertions}"
+ "${analyze_code_coverage}"
result)
if("${sdk}" STREQUAL "LINUX")
- list(APPEND result "-lpthread" "-ldl")
+ if("${arch}" STREQUAL "armv7")
+ list(APPEND result "-lpthread" "-ldl" "-Wl,-Bsymbolic")
+ elseif("${arch}" STREQUAL "armv6")
+ list(APPEND result "-lpthread" "-ldl" "-Wl,-Bsymbolic")
+ else()
+ list(APPEND result "-lpthread" "-ldl")
+ endif()
elseif("${sdk}" STREQUAL "FREEBSD")
- # No extra libraries required.
+ list(APPEND result "-lpthread" "-Wl,-Bsymbolic")
else()
list(APPEND result "-lobjc")
endif()
@@ -298,7 +318,7 @@ function(_compile_swift_files dependency_target_out_var_name)
# Don't include libarclite in any build products by default.
list(APPEND swift_flags "-no-link-objc-runtime")
- if(SWIFT_VERIFY_ALL)
+ if(SWIFT_SIL_VERIFY_ALL)
list(APPEND swift_flags "-Xfrontend" "-sil-verify-all")
endif()
@@ -770,6 +790,11 @@ function(_add_swift_library_single target name)
endif()
endif()
+ if (SWIFT_COMPILER_VERSION)
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
+ set(SWIFTLIB_SINGLE_LINK_FLAGS "${SWIFTLIB_SINGLE_LINK_FLAGS}" "-Xlinker" "-current_version" "-Xlinker" "${SWIFT_COMPILER_VERSION}" "-Xlinker" "-compatibility_version" "-Xlinker" "1")
+ endif()
+ endif()
if(XCODE)
string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
@@ -896,8 +921,12 @@ function(_add_swift_library_single target name)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
set(install_name_dir "@rpath")
+
if(SWIFTLIB_SINGLE_IS_STDLIB)
- set(install_name_dir "${SWIFT_DARWIN_STDLIB_INSTALL_NAME_DIR}")
+ # Always use @rpath for XCTest.
+ if(NOT "${module_name}" STREQUAL "XCTest")
+ set(install_name_dir "${SWIFT_DARWIN_STDLIB_INSTALL_NAME_DIR}")
+ endif()
endif()
set_target_properties("${target}"
@@ -1041,18 +1070,21 @@ function(_add_swift_library_single target name)
else()
set(build_type "${CMAKE_BUILD_TYPE}")
set(enable_assertions "${LLVM_ENABLE_ASSERTIONS}")
+ set(analyze_code_coverage "${SWIFT_ANALYZE_CODE_COVERAGE}")
endif()
_add_variant_c_compile_flags(
"${SWIFTLIB_SINGLE_SDK}"
"${SWIFTLIB_SINGLE_ARCHITECTURE}"
"${build_type}"
"${enable_assertions}"
+ "${analyze_code_coverage}"
c_compile_flags)
_add_variant_link_flags(
"${SWIFTLIB_SINGLE_SDK}"
"${SWIFTLIB_SINGLE_ARCHITECTURE}"
"${build_type}"
"${enable_assertions}"
+ "${analyze_code_coverage}"
link_flags)
# Handle gold linker flags for shared libraries.
@@ -1445,6 +1477,12 @@ function(add_swift_library name)
"${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
+ # Cache universal libraries for dependency purposes
+ set(UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}
+ ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}}
+ ${UNIVERSAL_LIBRARY_NAME}
+ CACHE INTERNAL "UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
+
set(lipo_target "${name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
_add_swift_lipo_target(
${lipo_target}
@@ -1513,6 +1551,11 @@ function(add_swift_library name)
add_dependencies("swift-stdlib${VARIANT_SUFFIX}"
${lipo_target}
${lipo_target_static})
+ if(NOT "${name}" STREQUAL "swiftStdlibCollectionUnittest")
+ add_dependencies("swift-test-stdlib${VARIANT_SUFFIX}"
+ ${lipo_target}
+ ${lipo_target_static})
+ endif()
endforeach()
endif()
endforeach()
@@ -1612,14 +1655,14 @@ function(_add_swift_executable_single name)
"${SWIFTEXE_SINGLE_ARCHITECTURE}"
"${CMAKE_BUILD_TYPE}"
"${LLVM_ENABLE_ASSERTIONS}"
- FALSE
+ "${SWIFT_ANALYZE_CODE_COVERAGE}"
c_compile_flags)
_add_variant_link_flags(
"${SWIFTEXE_SINGLE_SDK}"
"${SWIFTEXE_SINGLE_ARCHITECTURE}"
"${CMAKE_BUILD_TYPE}"
"${LLVM_ENABLE_ASSERTIONS}"
- FALSE
+ "${SWIFT_ANALYZE_CODE_COVERAGE}"
link_flags)
list(APPEND link_flags
@@ -1847,37 +1890,3 @@ function(add_swift_executable name)
${SWIFTEXE_DONT_STRIP_NON_MAIN_SYMBOLS_FLAG}
${SWIFTEXE_DISABLE_ASLR_FLAG})
endfunction()
-
-function(add_swift_llvm_loadable_module name)
- add_llvm_loadable_module(${name} ${ARGN})
- set(sdk "${SWIFT_HOST_VARIANT_SDK}")
- set(arch "${SWIFT_HOST_VARIANT_ARCH}")
-
- # Determine compiler flags.
- set(c_compile_flags)
- _add_variant_c_compile_flags(
- "${sdk}"
- "${arch}"
- "${CMAKE_BUILD_TYPE}"
- "${LLVM_ENABLE_ASSERTIONS}"
- FALSE
- c_compile_flags)
-
- set(link_flags)
- _add_variant_link_flags(
- "${sdk}"
- "${arch}"
- "${CMAKE_BUILD_TYPE}"
- "${LLVM_ENABLE_ASSERTIONS}"
- FALSE
- link_flags)
-
- # Convert variables to space-separated strings.
- _list_escape_for_shell("${c_compile_flags}" c_compile_flags)
- _list_escape_for_shell("${link_flags}" link_flags)
-
- set_property(TARGET ${name} APPEND_STRING PROPERTY
- COMPILE_FLAGS " ${c_compile_flags}")
- set_property(TARGET ${name} APPEND_STRING PROPERTY
- LINK_FLAGS " ${link_flags}")
-endfunction()
diff --git a/cmake/modules/SwiftSetIfArchBitness.cmake b/cmake/modules/SwiftSetIfArchBitness.cmake
index 83d80533f6792..5dc03cc89a6cc 100644
--- a/cmake/modules/SwiftSetIfArchBitness.cmake
+++ b/cmake/modules/SwiftSetIfArchBitness.cmake
@@ -7,13 +7,16 @@ function(set_if_arch_bitness var_name)
${ARGN})
if("${SIA_ARCH}" STREQUAL "i386" OR
+ "${SIA_ARCH}" STREQUAL "armv6" OR
"${SIA_ARCH}" STREQUAL "armv7" OR
"${SIA_ARCH}" STREQUAL "armv7k" OR
"${SIA_ARCH}" STREQUAL "armv7s")
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)
elseif("${SIA_ARCH}" STREQUAL "x86_64" OR
"${SIA_ARCH}" STREQUAL "arm64" OR
- "${SIA_ARCH}" STREQUAL "aarch64")
+ "${SIA_ARCH}" STREQUAL "aarch64" OR
+ "${SIA_ARCH}" STREQUAL "powerpc64" OR
+ "${SIA_ARCH}" STREQUAL "powerpc64le")
set("${var_name}" "${SIA_CASE_64_BIT}" PARENT_SCOPE)
else()
message(FATAL_ERROR "Unknown architecture: ${SIA_ARCH}")
diff --git a/cmake/modules/SwiftSharedCMakeConfig.cmake b/cmake/modules/SwiftSharedCMakeConfig.cmake
index c1d96bceaf403..f9ed4f690f1ca 100644
--- a/cmake/modules/SwiftSharedCMakeConfig.cmake
+++ b/cmake/modules/SwiftSharedCMakeConfig.cmake
@@ -261,6 +261,11 @@ macro(swift_common_standalone_build_config product is_cross_compiling)
set(LLVM_INCLUDE_TESTS TRUE)
set(LLVM_INCLUDE_DOCS TRUE)
+
+ option(LLVM_ENABLE_DOXYGEN "Enable doxygen support" FALSE)
+ if (LLVM_ENABLE_DOXYGEN)
+ find_package(Doxygen REQUIRED)
+ endif()
endmacro()
# Common cmake project config for unified builds.
diff --git a/docs/ABI.rst b/docs/ABI.rst
index 1c4edc8518b70..eac5ffa982c3f 100644
--- a/docs/ABI.rst
+++ b/docs/ABI.rst
@@ -410,7 +410,7 @@ contain the following fields:
not factored into tuple metadata uniquing.
- The **element vector** begins at **offset 3** and consists of a vector of
- type–offset pairs. The metadata for the *n*\ th element's type is a pointer
+ type-offset pairs. The metadata for the *n*\ th element's type is a pointer
at **offset 3+2*n**. The offset in bytes from the beginning of the tuple to
the beginning of the *n*\ th element is at **offset 3+2*n+1**.
@@ -743,15 +743,17 @@ Globals
global ::= 'PA' .* // partial application forwarder
global ::= 'PAo' .* // ObjC partial application forwarder
global ::= 'w' value-witness-kind type // value witness
- global ::= 'WV' type // value witness table
- global ::= 'Wo' entity // witness table offset
- global ::= 'Wv' directness entity // field offset
- global ::= 'WP' protocol-conformance // protocol witness table
global ::= 'Wa' protocol-conformance // protocol witness table accessor
+ global ::= 'WG' protocol-conformance // generic protocol witness table
+ global ::= 'WI' protocol-conformance // generic protocol witness table instantiation function
global ::= 'Wl' type protocol-conformance // lazy protocol witness table accessor
global ::= 'WL' protocol-conformance // lazy protocol witness table cache variable
- global ::= 'WD' protocol-conformance // dependent proto witness table generator
- global ::= 'Wd' protocol-conformance // dependent proto witness table template
+ global ::= 'Wo' entity // witness table offset
+ global ::= 'WP' protocol-conformance // protocol witness table
+ global ::= 'Wt' protocol-conformance identifier // associated type metadata accessor
+ global ::= 'WT' protocol-conformance identifier nominal-type // associated type witness table accessor
+ global ::= 'Wv' directness entity // field offset
+ global ::= 'WV' type // value witness table
global ::= entity // some identifiable thing
global ::= 'TO' global // ObjC-as-swift thunk
global ::= 'To' global // swift-as-ObjC thunk
@@ -939,6 +941,7 @@ Types
nominal-type-kind ::= 'C' // class
nominal-type-kind ::= 'O' // enum
nominal-type-kind ::= 'V' // struct
+ declaration-name ::= context decl-name
archetype ::= 'Q' index // archetype with depth=0, idx=N
archetype ::= 'Qd' index index // archetype with depth=M+1, idx=N
archetype ::= associated-type
@@ -1175,12 +1178,12 @@ for the first time. The first argument type will mangle in long form,
``CC3zim4zang4zung``, and in doing so, ``zim`` will acquire substitution ``S_``,
``zim.zang`` will acquire substitution ``S0_``, and ``zim.zang.zung`` will
acquire ``S1_``. The second argument is the same as the first and will mangle
-using its substitution, ``CS1_``. The
+using its substitution, ``S1_``. The
third argument type will mangle using the substitution for ``zim``,
``CS_7zippity``. (It also acquires substitution ``S2_`` which would be used
if it mangled again.) The result type will mangle using the substitution for
-``zim.zang``, ``CS0_zoo`` (and acquire substitution ``S3_``). The full
-function type thus mangles as ``fTCC3zim4zang4zungCS1_CS_7zippity_CS0_zoo``.
+``zim.zang``, ``CS0_3zoo`` (and acquire substitution ``S3_``). The full
+function type thus mangles as ``fTCC3zim4zang4zungS1_CS_7zippity_CS0_3zoo``.
::
diff --git a/docs/ARCOptimization.rst b/docs/ARCOptimization.rst
index 725d650610c73..edd04f8697551 100644
--- a/docs/ARCOptimization.rst
+++ b/docs/ARCOptimization.rst
@@ -137,7 +137,7 @@ lower directly to is_unique instructions in SIL.
The is_unique instruction takes the address of a reference, and
although it does not actually change the reference, the reference must
appear mutable to the optimizer. This forces the optimizer to preserve
-a retain distinct from what’s required to maintain lifetime for any of
+a retain distinct from what's required to maintain lifetime for any of
the reference's source-level copies, because the called function is
allowed to replace the reference, thereby releasing the
referent. Consider the following sequence of rules:
@@ -225,6 +225,493 @@ these cases:
- isUniqueOrPinned_native : (inout T[?]) -> Int1
These builtins perform an implicit cast to NativeObject before
-checking uniqueness. There’s no way at SIL level to cast the address
+checking uniqueness. There's no way at SIL level to cast the address
of a reference, so we need to encapsulate this operation as part of
the builtin.
+
+Semantic Tags
+=============
+
+ARC takes advantage of certain semantic tags. This section documents these
+semantics and their meanings.
+
+arc.programtermination_point
+----------------------------
+
+If this semantic tag is applied to a function, then we know that:
+
+- The function does not touch any reference counted objects.
+- After the function is executed, all reference counted objects are leaked
+ (most likely in preparation for program termination).
+
+This allows one, when performing ARC code motion, to ignore blocks that contain
+an apply to this function as long as the block does not have any other side
+effect having instructions.
+
+ARC Sequence Optimization
+=========================
+
+TODO: Fill this in.
+
+ARC Loop Hoisting
+=================
+
+Abstract
+--------
+
+This section describes the ARCLoopHoisting algorithm that hoists retains and
+releases out of loops. This is a high level description that justifies the
+correction of the algorithm and describes its design. In the following
+discussion we talk about the algorithm conceptually and show its safety and
+considerations necessary for good performance.
+
+*NOTE* In the following when we refer to "hoisting", we are not just talking
+about upward code motion of retains, but also downward code motion of releases.
+
+Loop Canonicalization
+---------------------
+
+In the following we assume that all loops are canonicalized such that:
+
+1. The loop has a pre-header.
+2. The loop has one backedge.
+3. All exiting edges have a unique exit block.
+
+Motiviation
+-----------
+
+Consider the following simple loop::
+
+ bb0:
+ br bb1
+
+ bb1:
+ retain %x (1)
+ apply %f(%x)
+ apply %f(%x)
+ release %x (2)
+ cond_br ..., bb1, bb2
+
+ bb2:
+ return ...
+
+When it is safe to hoist (1),(2) out of the loop? Imagine if we know the trip
+count of the loop is 3 and completely unroll the loop so the whole function is
+one basic block. In such a case, we know the function looks as follows::
+
+ bb0:
+ # Loop Iteration 0
+ retain %x
+ apply %f(%x)
+ apply %f(%x)
+ release %x (4)
+
+ # Loop Iteration 1
+ retain %x (5)
+ apply %f(%x)
+ apply %f(%x)
+ release %x (6)
+
+ # Loop Iteration 2
+ retain %x (7)
+ apply %f(%x)
+ apply %f(%x)
+ release %x
+
+ return ...
+
+Notice how (3) can be paired with (4) and (5) can be paired with (6). Assume
+that we eliminate those. Then the function looks as follows::
+
+ bb0:
+ # Loop Iteration 0
+ retain %x
+ apply %f(%x)
+ apply %f(%x)
+
+ # Loop Iteration 1
+ apply %f(%x)
+ apply %f(%x)
+
+ # Loop Iteration 2
+ apply %f(%x)
+ apply %f(%x)
+ release %x
+
+ return ...
+
+We can then re-roll the loop, yielding the following loop::
+
+ bb0:
+ retain %x (8)
+ br bb1
+
+ bb1:
+ apply %f(%x)
+ apply %f(%x)
+ cond_br ..., bb1, bb2
+
+ bb2:
+ release %x (9)
+ return ...
+
+Notice that this transformation is equivalent to just hoisting (1) and (2) out
+of the loop in the original example. This form of hoisting is what is termed
+"ARCLoopHoisting". What is key to notice is that even though we are performing
+"hoisting" we are actually pairing releases from one iteration with retains in
+the next iteration and then eliminating the pairs. This realization will guide
+our further analysis.
+
+Correctness
+-----------
+
+In this simple loop case, the proof of correctness is very simple to see
+conceptually. But in a more general case, when is safe to perform this
+optimization? We must consider three areas of concern:
+
+1. Are the retains/releases upon the same reference count? This can be found
+ conservatively by using RCIdentityAnalysis.
+
+2. Can we move retains, releases in the unrolled case as we have specified?
+ This is simple since it is always safe to move a retain earlier and a release
+ later in the dynamic execution of a program. This can only extend the life of
+ a variable which is a legal and generally profitable in terms of allowing for
+ this optimization.
+
+3. How do we pair all necessary retains/releases to ensure we do not unbalance
+ retain/release counts in the loop? Consider a set of retains and a set of
+ releases that we wish to hoist out of a loop. We can only hoist the retain,
+ release sets out of the loop if all paths in the given loop region from the
+ entrance to the backedge. have exactly one retain or release from this set.
+
+4. Any early exits that we must move a retain past or a release by must be
+ compensated appropriately. This will be discussed in the next section.
+
+Assuming that our optimization does all of these things, we should be able to
+hoist with safety.
+
+Compensating Early Exits for Lost Dynamic Reference Counts
+----------------------------------------------------------
+
+Lets say that we have the following loop canonicalized SIL::
+
+ bb0(%0 : $Builtin.NativeObject):
+ br bb1
+
+ bb1:
+ strong_retain %0 : $Builtin.NativeObject
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject
+ cond_br ..., bb2, bb3
+
+ bb2:
+ cond_br ..., bb1, bb4
+
+ bb3:
+ br bb5
+
+ bb4:
+ br bb5
+
+ bb6:
+ return ...
+
+Can we hoist the retain/release pair here? Lets assume the loop is 3 iterations
+and we completely unroll it. Then we have::
+
+ bb0:
+ strong_retain %0 : $Builtin.NativeObject (1)
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (2)
+ cond_br ..., bb1, bb4
+
+ bb1: // preds: bb0
+ strong_retain %0 : $Builtin.NativeObject (3)
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (4)
+ cond_br ..., bb2, bb4
+
+ bb2: // preds: bb1
+ strong_retain %0 : $Builtin.NativeObject (5)
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (6)
+ cond_br ..., bb3, bb4
+
+ bb3: // preds: bb2
+ br bb5
+
+ bb4: // preds: bb0, bb1, bb2
+ br bb5
+
+ bb5: // preds: bb3, bb4
+ return ...
+
+We want to be able to pair and eliminate (2)/(3) and (4)/(5). In order to do
+that, we need to move (2) from bb0 into bb1 and (4) from bb1 into bb2. In order
+to do this, we need to move a release along all paths into bb4 lest we lose
+dynamic releases along that path. We also sink (6) in order to not have an extra
+release along that path. This then give us::
+
+ bb0:
+ strong_retain %0 : $Builtin.NativeObject (1)
+
+ bb1:
+ apply %f(%0)
+ apply %f(%0)
+ cond_br ..., bb2, bb3
+
+ bb2:
+ cond_br ..., bb1, bb4
+
+ bb3:
+ strong_release %0 : $Builtin.NativeObject (6*)
+ br bb5
+
+ bb4:
+ strong_release %0 : $Builtin.NativeObject (7*)
+ br bb5
+
+ bb5: // preds: bb3, bb4
+ return ...
+
+An easy inductive proof follows.
+
+What if we have the opposite problem, that of moving a retain past an early
+exit. Consider the following::
+
+ bb0(%0 : $Builtin.NativeObject):
+ br bb1
+
+ bb1:
+ cond_br ..., bb2, bb3
+
+ bb2:
+ strong_retain %0 : $Builtin.NativeObject
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject
+ cond_br ..., bb1, bb4
+
+ bb3:
+ br bb5
+
+ bb4:
+ br bb5
+
+ bb6:
+ return ...
+
+Lets unroll this loop::
+
+ bb0(%0 : $Builtin.NativeObject):
+ br bb1
+
+ # Iteration 1
+ bb1: // preds: bb0
+ cond_br ..., bb2, bb8
+
+ bb2: // preds: bb1
+ strong_retain %0 : $Builtin.NativeObject (1)
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (2)
+ br bb3
+
+ # Iteration 2
+ bb3: // preds: bb2
+ cond_br ..., bb4, bb8
+
+ bb4: // preds: bb3
+ strong_retain %0 : $Builtin.NativeObject (3)
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (4)
+ br bb5
+
+ # Iteration 3
+ bb5: // preds: bb4
+ cond_br ..., bb6, bb8
+
+ bb6: // preds: bb5
+ strong_retain %0 : $Builtin.NativeObject (5)
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (6)
+ cond_br ..., bb7, bb8
+
+ bb7: // preds: bb6
+ br bb9
+
+ bb8: // Preds: bb1, bb3, bb5, bb6
+ br bb9
+
+ bb9:
+ return ...
+
+First we want to move the retain into the previous iteration. This means that we
+have to move a retain over the cond_br in bb1, bb3, bb5. If we were to do that
+then bb8 would have an extra dynamic retain along that path. In order to fix
+that issue, we need to balance that release by putting a release in bb8. But we
+cannot move a release into bb8 without considering the terminator of bb6 since
+bb6 is also a predecessor of bb8. Luckily, we have (6). Notice that bb7 has one
+predecessor to bb6 so we can safely move 1 release along that path as well. Thus
+we perform that code motion, yielding the following::
+
+ bb0(%0 : $Builtin.NativeObject):
+ br bb1
+
+ # Iteration 1
+ bb1: // preds: bb0
+ strong_retain %0 : $Builtin.NativeObject (1)
+ cond_br ..., bb2, bb8
+
+ bb2: // preds: bb1
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (2)
+ br bb3
+
+ # Iteration 2
+ bb3: // preds: bb2
+ strong_retain %0 : $Builtin.NativeObject (3)
+ cond_br ..., bb4, bb8
+
+ bb4: // preds: bb3
+ apply %f(%0)
+ apply %f(%0)
+ strong_release %0 : $Builtin.NativeObject (4)
+ br bb5
+
+ # Iteration 3
+ bb5: // preds: bb4
+ strong_retain %0 : $Builtin.NativeObject (5)
+ cond_br ..., bb6, bb8
+
+ bb6: // preds: bb5
+ apply %f(%0)
+ apply %f(%0)
+ cond_br ..., bb7, bb8
+
+ bb7: // preds: bb6
+ strong_release %0 : $Builtin.NativeObject (7*)
+ br bb9
+
+ bb8: // Preds: bb1, bb3, bb5, bb6
+ strong_release %0 : $Builtin.NativeObject (8*)
+ br bb9
+
+ bb9:
+ return ...
+
+Then we move (1), (3), (4) into the single predecessor of their parent block and
+eliminate (3), (5) through a pairing with (2), (4) respectively. This yields
+then::
+
+ bb0(%0 : $Builtin.NativeObject):
+ strong_retain %0 : $Builtin.NativeObject (1)
+ br bb1
+
+ # Iteration 1
+ bb1: // preds: bb0
+ cond_br ..., bb2, bb8
+
+ bb2: // preds: bb1
+ apply %f(%0)
+ apply %f(%0)
+ br bb3
+
+ # Iteration 2
+ bb3: // preds: bb2
+ cond_br ..., bb4, bb8
+
+ bb4: // preds: bb3
+ apply %f(%0)
+ apply %f(%0)
+ br bb5
+
+ # Iteration 3
+ bb5: // preds: bb4
+ cond_br ..., bb6, bb8
+
+ bb6: // preds: bb5
+ apply %f(%0)
+ apply %f(%0)
+ cond_br ..., bb7, bb8
+
+ bb7: // preds: bb6
+ strong_release %0 : $Builtin.NativeObject (7*)
+ br bb9
+
+ bb8: // Preds: bb1, bb3, bb5, bb6
+ strong_release %0 : $Builtin.NativeObject (8*)
+ br bb9
+
+ bb9:
+ return ...
+
+Then we finish by rerolling the loop::
+
+ bb0(%0 : $Builtin.NativeObject):
+ strong_retain %0 : $Builtin.NativeObject (1)
+ br bb1
+
+ # Iteration 1
+ bb1: // preds: bb0
+ cond_br ..., bb2, bb8
+
+ bb2:
+ apply %f(%0)
+ apply %f(%0)
+ cond_br bb1, bb7
+
+ bb7:
+ strong_release %0 : $Builtin.NativeObject (7*)
+ br bb9
+
+ bb8: // Preds: bb1, bb3, bb5, bb6
+ strong_release %0 : $Builtin.NativeObject (8*)
+ br bb9
+
+ bb9:
+ return ...
+
+
+Uniqueness Check Complications
+------------------------------
+
+A final concern that we must consider is if we introduce extra copy on write
+copies through our optimization. To see this, consider the following simple
+IR sequence::
+
+ bb0(%0 : $Builtin.NativeObject):
+ // refcount(%0) == n
+ is_unique %0 : $Builtin.NativeObject
+ // refcount(%0) == n
+ strong_retain %0 : $Builtin.NativeObject
+ // refcount(%0) == n+1
+
+If n is not 1, then trivially is_unique will return false. So assume that n is 1
+for our purposes so no copy is occurring here. Thus we have::
+
+ bb0(%0 : $Builtin.NativeObject):
+ // refcount(%0) == 1
+ is_unique %0 : $Builtin.NativeObject
+ // refcount(%0) == 1
+ strong_retain %0 : $Builtin.NativeObject
+ // refcount(%0) == 2
+
+Now imagine that we move the strong_retain before the is_unique. Then we have::
+
+ bb0(%0 : $Builtin.NativeObject):
+ // refcount(%0) == 1
+ strong_retain %0 : $Builtin.NativeObject
+ // refcount(%0) == 2
+ is_unique %0 : $Builtin.NativeObject
+
+Thus is_unique is guaranteed to return false introducing a copy that was not
+needed. We wish to avoid that if it is at all possible.
+
diff --git a/docs/AccessControlInStdlib.rst b/docs/AccessControlInStdlib.rst
index 5b20b7699e0ef..9bf32bc54a97e 100644
--- a/docs/AccessControlInStdlib.rst
+++ b/docs/AccessControlInStdlib.rst
@@ -6,7 +6,7 @@ Scope and introduction
This document defines the policy for applying access control modifiers and
related naming conventions for the Swift standard library and overlays.
-In this document, “stdlib” refers to the core standard library and
+In this document, "stdlib" refers to the core standard library and
overlays for system frameworks written in Swift.
Swift has three levels of access control --- private, internal
@@ -60,7 +60,7 @@ explicitly everywhere in the stdlib to avoid confusion.
.. Note:: No declaration should omit an access
-To create a “single point of truth” about whether a name is intended
+To create a "single point of truth" about whether a name is intended
for user consumption, the following names should all use the `leading
underscore rule`_:
@@ -77,7 +77,7 @@ underscore rule`_:
`private`
=========
-The `private` modifier can not be used in the stdlib at least until
+The `private` modifier cannot be used in the stdlib at least until
rdar://17631278 is fixed.
Leading Underscore Rule
diff --git a/docs/Arrays.rst b/docs/Arrays.rst
index 766d30522b8bd..2204209a354af 100644
--- a/docs/Arrays.rst
+++ b/docs/Arrays.rst
@@ -53,34 +53,34 @@ Swift provides three generic array types, all of which have amortized
O(1) growth. In this document, statements about **ArrayType** apply
to all three of the components.
-* ``ContiguousArray`` is the fastest and simplest of the three—use this
- when you need "C array" performance. The elements of a
+* ``ContiguousArray`` is the fastest and simplest of the three—use
+ this when you need "C array" performance. The elements of a
``ContiguousArray`` are always stored contiguously in memory.
.. image:: ContiguousArray.png
-* ``Array`` is like ``ContiguousArray``, but optimized for efficient
- conversions from Cocoa and back—when ``T`` can be a class type,
- ``Array`` can be backed by the (potentially non-contiguous)
+* ``Array`` is like ``ContiguousArray``, but optimized for
+ efficient conversions from Cocoa and back—when ``Element`` can be a class
+ type, ``Array`` can be backed by the (potentially non-contiguous)
storage of an arbitrary ``NSArray`` rather than by a Swift
- ``ContiguousArray``. ``Array`` also supports up- and down- casts
- between arrays of related class types. When ``T`` is known to be a
- non-class type, the performance of ``Array`` is identical to that
- of ``ContiguousArray``.
+ ``ContiguousArray``. ``Array`` also supports up- and downcasts
+ between arrays of related class types. When ``Element`` is known to be a
+ non-class type, the performance of ``Array`` is identical to that
+ of ``ContiguousArray``.
.. image:: ArrayImplementation.png
-* ``Slice`` is a subrange of some ``Array`` or
- ``ContiguousArray``; it's the result of using slice notation,
+* ``ArraySlice`` is a subrange of some ``Array`` or
+ ``ContiguousArray``; it's the result of using slice notation,
e.g. ``a[7...21]`` on any Swift array ``a``. A slice always has
contiguous storage and "C array" performance. Slicing an
- *ArrayType* is O(1) unless the source is an ``Array`` backed by
+ *ArrayType* is O(1) unless the source is an ``Array`` backed by
an ``NSArray`` that doesn't supply contiguous storage.
- ``Slice`` is recommended for transient computations but not for
+ ``ArraySlice`` is recommended for transient computations but not for
long-term storage. Since it references a sub-range of some shared
- backing buffer, a ``Slice`` may artificially prolong the lifetime of
- elements outside the ``Slice`` itself.
+ backing buffer, a ``ArraySlice`` may artificially prolong the lifetime of
+ elements outside the ``ArraySlice`` itself.
.. image:: Slice.png
@@ -169,43 +169,43 @@ conforms to ``_BridgedToObjectiveC``:
.. _trivial bridging:
-* **Trivial bridging** implicitly converts ``Base[]`` to
+* **Trivial bridging** implicitly converts ``[Base]`` to
``NSArray`` in O(1). This is simply a matter of returning the
Array's internal buffer, which is-a ``NSArray``.
.. _trivial bridging back:
* **Trivial bridging back** implicitly converts ``NSArray`` to
- ``AnyObject[]`` in O(1) plus the cost of calling ``copy()`` on
+ ``[AnyObject]`` in O(1) plus the cost of calling ``copy()`` on
the ``NSArray``. [#nocopy]_
* **Implicit conversions** between ``Array`` types
- - **Implicit upcasting** implicitly converts ``Derived[]`` to
- ``Base[]`` in O(1).
- - **Implicit bridging** implicitly converts ``X[]`` to
- ``X._ObjectiveCType[]`` in O(N).
+ - **Implicit upcasting** implicitly converts ``[Derived]`` to
+ ``[Base]`` in O(1).
+ - **Implicit bridging** implicitly converts ``[X]`` to
+ ``[X._ObjectiveCType]`` in O(N).
.. Note:: Either type of implicit conversion may be combined with
`trivial bridging`_ in an implicit conversion to ``NSArray``.
-* **Checked conversions** convert ``T[]`` to ``U[]?`` in O(N)
- via ``a as U[]``.
+* **Checked conversions** convert ``[T]`` to ``[U]?`` in O(N)
+ via ``a as [U]``.
- - **Checked downcasting** converts ``Base[]`` to ``Derived[]?``.
- - **Checked bridging back** converts ``T[]`` to ``X[]?`` where
+ - **Checked downcasting** converts ``[Base]`` to ``[Derived]?``.
+ - **Checked bridging back** converts ``[T]`` to ``[X]?`` where
``X._ObjectiveCType`` is ``T`` or a trivial subtype thereof.
-* **Forced conversions** convert ``AnyObject[]`` or ``NSArray`` to
- ``T[]`` implicitly, in bridging thunks between Swift and Objective-C.
+* **Forced conversions** convert ``[AnyObject]`` or ``NSArray`` to
+ ``[T]`` implicitly, in bridging thunks between Swift and Objective-C.
- For example, when a user writes a Swift method taking ``NSView[]``,
+ For example, when a user writes a Swift method taking ``[NSView]``,
it is exposed to Objective-C as a method taking ``NSArray``, which
- is force-converted to ``NSView[]`` when called from Objective-C.
+ is force-converted to ``[NSView]`` when called from Objective-C.
- - **Forced downcasting** converts ``AnyObject[]`` to ``Derived[]`` in
+ - **Forced downcasting** converts ``[AnyObject]`` to ``[Derived]`` in
O(1)
- - **Forced bridging back** converts ``AnyObject[]`` to ``X[]`` in O(N).
+ - **Forced bridging back** converts ``[AnyObject]`` to ``[X]`` in O(N).
A forced conversion where any element fails to convert is considered
a user programming error that may trap. In the case of forced
@@ -225,7 +225,7 @@ Upcasts
TODO: this section is outdated.
-When up-casting an ``Derived[]`` to ``Base[]``, a buffer of
+When up-casting an ``[Derived]`` to ``[Base]``, a buffer of
``Derived`` object can simply be ``unsafeBitCast``\ 'ed to a buffer
of elements of type ``Base``—as long as the resulting buffer is never
mutated. For example, we cannot allow a ``Base`` element to be
@@ -234,11 +234,11 @@ the elements with the (incorrect) static presumption that they have
``Derived`` type.
Furthermore, we can't (logically) copy the buffer just prior to
-mutation, since the ``Base[]`` may be copied prior to mutation,
+mutation, since the ``[Base]`` may be copied prior to mutation,
and our shared subscript assignment semantics imply that all copies
must observe its subscript assignments.
-Therefore, converting ``T[]`` to ``U[]`` is akin to
+Therefore, converting ``[T]`` to ``[U]`` is akin to
resizing: the new ``Array`` becomes logically independent. To avoid
an immediate O(N) conversion cost, and preserve shared subscript
assignment semantics, we use a layer of indirection in the data
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index d94e7b94cc560..d91a99b772ea6 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -82,7 +82,7 @@ if(LITRE_EXECUTABLE)
VERBATIM
)
- # Only update the real top-level CMakeLists.txt if something changed
+ # Only update the real top-level CMakeLists.txt if something changed
add_custom_command(
OUTPUT
"litre-tests/CMakeLists.txt"
diff --git a/docs/DebuggingTheCompiler.rst b/docs/DebuggingTheCompiler.rst
index 3241542440e36..52cc8d405d053 100644
--- a/docs/DebuggingTheCompiler.rst
+++ b/docs/DebuggingTheCompiler.rst
@@ -136,7 +136,7 @@ and check for the function name in the breakpoint condition::
(lldb) br set -c 'hasName("_TFC3nix1Xd")' -f SILFunction.cpp -l 91
-Sometimes you want to know which optimization does insert, remove or move a
+Sometimes you may want to know which optimization inserts, removes or moves a
certain instruction. To find out, set a breakpoint in
``ilist_traits::addNodeToList`` or
``ilist_traits::removeNodeFromList``, which are defined in
diff --git a/docs/ErrorHandling.rst b/docs/ErrorHandling.rst
index 547af4def253a..a7b14bd387477 100644
--- a/docs/ErrorHandling.rst
+++ b/docs/ErrorHandling.rst
@@ -578,7 +578,7 @@ of failability.
One limitation of this approach is that we need to be able to reconstruct
the selector to use when an overload of a method is introduced. For this
-reason, the import is likely to be limited to methods where the error
+reason, the import is likely to be limited to methods where the error
parameter is the last one and the corresponding selector
chunk is either ``error:`` or the first chunk (see below). Empirically,
this seems to do the right thing for all but two sets of APIs in the
diff --git a/docs/ErrorHandlingRationale.rst b/docs/ErrorHandlingRationale.rst
index 9ea61ca5277b0..bb25f838843e4 100644
--- a/docs/ErrorHandlingRationale.rst
+++ b/docs/ErrorHandlingRationale.rst
@@ -1,6 +1,8 @@
Error Handling Rationale and Proposal
*************************************
+.. contents::
+
This paper surveys the error-handling world, analyzes various ideas
which have been proposed or are in practice in other languages, and
ultimately proposes an error-handling scheme for Swift together
@@ -389,7 +391,7 @@ options as a programmer:
function called by your function.
- You can carefully arrange your function so that there are no
- critical sections where an universal error can leave things in an
+ critical sections where a universal error can leave things in an
unwanted state.
There are techniques for making the second more palatable. Chiefly,
@@ -636,7 +638,7 @@ of the disadvantages and investigate ways to ameliorate them:
- There are many situations where errors are not actually possible
because the programmer has carefully restricted the input. For
- example, matching :code:``/[0-9]{4}/`` and then parsing the result
+ example, matching ``/[0-9]{4}/`` and then parsing the result
as an integer. It needs to be convenient to do this in a context
that cannot actually propagate errors, but the facility to do this
needs to be carefully designed to discourage use for swallowing
@@ -741,8 +743,8 @@ This approach is therefore relatively even-handed about the error
vs. the non-error path, although it requires some care in order to
minimize code-size penalties for parallel error paths.
-``setjmp`` / ``longmp``
-~~~~~~~~~~~~~~~~~~~~~~~
+``setjmp`` / ``longjmp``
+~~~~~~~~~~~~~~~~~~~~~~~~
Another strategy to is to dynamically maintain a thread-local stack of
interesting frames. A function with an interesting frame must save
@@ -1043,9 +1045,9 @@ C++ has exceptions. Exceptions can have almost any type in the
language. Propagation typing is tied only to declarations; an
indirect function pointer is generally assumed to be able to throw.
Propagation typing used to allow functions to be specific about the
-kinds of exceptions they could throw (:code:``throws
+kinds of exceptions they could throw (``throws
(std::exception)``), but this is deprecated in favor of just indicating
-whether a function can throw (:code:``noexcept(false)``).
+whether a function can throw (``noexcept(false)``).
C++ aspires to making out-of-memory a recoverable condition, and so
allocation can throw. Therefore, it is essentially compulsory for the
@@ -1316,16 +1318,16 @@ generalized ``do`` statement::
}
Swift should also provide some tools for doing manual propagation. We
-should have a standard Rust-like :code:``Result`` enum in the
+should have a standard Rust-like ``Result`` enum in the
library, as well as a rich set of tools, e.g.:
- A function to evaluate an error-producing closure and capture the
- result as a :code:``Result``.
+ result as a ``Result``.
-- A function to unpack a :code:``Result`` by either returning its
+- A function to unpack a ``Result`` by either returning its
value or propagating the error in the current context.
-- A futures library that traffics in :code:``Result`` when
+- A futures library that traffics in ``Result`` when
applicable.
- An overload of ``dispatch_sync`` which takes an error-producing
@@ -1359,7 +1361,7 @@ declaration or type::
return try stream.readInt()
}
- // ‘throws’ is written before the arrow to give a sensible and
+ // 'throws' is written before the arrow to give a sensible and
// consistent grammar for function types and implicit () result types.
func baz() throws {
if let byte = try stream.getOOB() where byte == PROTO_RESET {
@@ -1367,7 +1369,7 @@ declaration or type::
}
}
- // ‘throws’ appears in a consistent position in function types.
+ // 'throws' appears in a consistent position in function types.
func fred(callback: (UInt8) throws -> ()) throws {
while true {
let code = try stream.readByte()
@@ -1380,7 +1382,7 @@ declaration or type::
// this function has type:
// (Int) -> (Int) throws -> Int
func jerry(i: Int)(j: Int) throws -> Int {
- // It’s not an error to use ‘throws’ on a function that can’t throw.
+ // It's not an error to use 'throws' on a function that can't throw.
return i + j
}
diff --git a/docs/Generics.rst b/docs/Generics.rst
index 7ba13d3f560d0..bd6808c8fb38f 100644
--- a/docs/Generics.rst
+++ b/docs/Generics.rst
@@ -51,7 +51,7 @@ The alternatives to generics tend to lead to poor solutions:
* Object-oriented languages tend to use "top" types (id in Objective-C,
java.lang.Object in pre-generics Java, etc.) for their containers and
- algorithms, which gives up static type safety. Pre- generics Java forced the
+ algorithms, which gives up static type safety. Pre-generics Java forced the
user to introduce run-time-checked type casts when interacting with containers
(which is overly verbose), while Objective-C relies on id's unsound implicit
conversion behavior to eliminate the need for casts.
@@ -242,7 +242,7 @@ us to cleanly describe a protocol for collections::
protocol Collection {
typealias Element
- func forEach(callback : (value : Element) -> void)
+ func forEach(callback : (value : Element) -> Void)
func add(value : Element)
}
@@ -313,7 +313,7 @@ also know how to "draw!"::
It is unlikely that Cowboy is meant to conform to Shape, but the method name and
signatures match, so implicit conformance deduces that Cowboy conforms to
Shape. Random collisions between types are fairly rare. However, when one is
-using protocol inheritance with fine- grained (semantic or mostly-semantic)
+using protocol inheritance with fine-grained (semantic or mostly-semantic)
differences between protocols in the hierarchy, they become more common. See
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1798.html for examples
of this problem as it surfaced with C++ concepts. It is not clear at this time
@@ -330,7 +330,7 @@ type::
struct EmployeeList : Collection { // EmployeeList is a collection
typealias Element = T
- func forEach(callback : (value : Element) -> void) { /* Implement this */ }
+ func forEach(callback : (value : Element) -> Void) { /* Implement this */ }
func add(value : Element) { /* Implement this */ }
}
@@ -367,7 +367,7 @@ extensions, e.g.,::
extension String : Collection {
typealias Element = char
- func forEach(callback : (value : Element) -> void) { /* use existing String routines to enumerate characters */ }
+ func forEach(callback : (value : Element) -> Void) { /* use existing String routines to enumerate characters */ }
func add(value : Element) { self += value /* append character */ }
}
@@ -579,7 +579,7 @@ OrderedCollection>) are just sugar for a where clause. For example, the
above find() signature is equivalent to::
func find(
- collection : C, value : C.Element)-> Int
+ collection : C, value : C.Element) -> Int
Note that find is shorthand for (and equivalent to) find, since
every type conforms to the Any protocol composition.
@@ -594,7 +594,7 @@ lets us describe an iteration of values of some given value type::
func next() -> Element
}
-Now, we want to express the notion of an enumerable collection, which provides a
+Now, we want to express the notion of an enumerable collection, which provides
iteration, which we do by adding requirements into the protocol::
protocol EnumerableCollection : Collection {
@@ -835,7 +835,7 @@ cannot disambiguate the tokens::
i.e.,::
- identifier operator identifier operator unspaced_lparen integer- literal comma integer-literal rparen
+ identifier operator identifier operator unspaced_lparen integer-literal comma integer-literal rparen
which can be interpreted as either::
diff --git a/docs/GitWorkflows.rst b/docs/GitWorkflows.rst
index 24e5ce8e23760..9f6dc650d4d72 100644
--- a/docs/GitWorkflows.rst
+++ b/docs/GitWorkflows.rst
@@ -11,7 +11,7 @@ transition to Git this document helps to address questions about how common SVN
workflows we use today translate to their Git counterparts as well as to discuss
Git workflow practices we plan on having — at least initially — after the Git
transition. Notably we will follow a model where commits to trunk — which is
-the ‘master’ branch in Git — has commits land (in the common case) via rebasing
+the 'master' branch in Git — has commits land (in the common case) via rebasing
instead of merging. This model is open to evolution later, but this mimics the
workflow we have today with SVN.
@@ -114,7 +114,7 @@ By default when updating, Git will attempt to merge the remote changes and your
local changes. Ignoring what that sentence means, this is not an SVN-esque
model. Instead we want any local changes that we have to be applied on top of
any new remote changes. The 'branch.autosetuprebase' flag causes this to be done
-automatically when ever one updates the local repository.
+automatically whenever one updates the local repository.
Update
------
@@ -261,7 +261,7 @@ command::
$ git log
-To see a oneline summary that includes just the title of the commit and its
+To see an oneline summary that includes just the title of the commit and its
hash, pass the '--oneline' command::
$ git log --oneline
diff --git a/docs/HighLevelSILOptimizations.rst b/docs/HighLevelSILOptimizations.rst
index b35c26063c94f..1ff20558230eb 100644
--- a/docs/HighLevelSILOptimizations.rst
+++ b/docs/HighLevelSILOptimizations.rst
@@ -132,7 +132,8 @@ Array
The following semantic tags describe Array operations. The operations
are first described in terms of the Array "state". Relations between the
operations are formally defined below. 'Array' refers to the standard library
-Array, ContigousArray, and ArraySlice data-structures.
+Array, ContiguousArray, and ArraySlice
+data-structures.
We consider the array state to consist of a set of disjoint elements
and a storage descriptor that encapsulates nonelement data such as the
@@ -156,7 +157,7 @@ array.init
may act as a guard to other potentially mutating operations, such as
``get_element_address``.
-array.uninitialized(count: Builtin.Word) -> (Array, Builtin.RawPointer)
+array.uninitialized(count: Builtin.Word) -> (Array, Builtin.RawPointer)
Creates an array with the specified number of elements. It initializes
the storage descriptor but not the array elements. The returned tuple
@@ -166,9 +167,9 @@ array.uninitialized(count: Builtin.Word) -> (Array, Builtin.RawPointer)
array.props.isCocoa/needsElementTypeCheck -> Bool
Reads storage descriptors properties (isCocoa, needsElementTypeCheck).
This is not control dependent or guarded. The optimizer has
- semantic knowledge of the state transfer those properties can not make:
- An array that is not ``isCocoa`` can not transfer to ``isCocoa``.
- An array that is not ``needsElementTypeCheck`` can not transfer to
+ semantic knowledge of the state transfer those properties cannot make:
+ An array that is not ``isCocoa`` cannot transfer to ``isCocoa``.
+ An array that is not ``needsElementTypeCheck`` cannot transfer to
``needsElementTypeCheck``.
array.get_element(index: Int) -> Element
@@ -262,7 +263,7 @@ check_subscript guards get_element, get_element_address
make_mutable interferes-with props.isCocoa/needsElementTypeCheck
get_elt_addr interferes-with get_element, get_element_address,
props.isCocoa/needsElementTypeCheck
-mutate_unknown itereferes-with get_element, check_subscript, get_count,
+mutate_unknown interferes-with get_element, check_subscript, get_count,
get_capacity, get_element_address,
props.isCocoa/needsElementTypeCheck
================ =============== ==========================================
diff --git a/docs/IndexInvalidation.rst b/docs/IndexInvalidation.rst
index 26f809a0ef5e5..aaa2de169a49b 100644
--- a/docs/IndexInvalidation.rst
+++ b/docs/IndexInvalidation.rst
@@ -128,7 +128,7 @@ Consequences:
any indices. Indices are composites of offsets, so replacing the value does
not change the shape of the data structure and preserves offsets.
-- A value type mutable linked list can not conform to
+- A value type mutable linked list cannot conform to
``MutableCollectionType``. An index for a linked list has to be implemented
as a pointer to the list node to provide O(1) element access. Mutating an
element of a non-uniquely referenced linked list will create a copy of the
diff --git a/docs/Lexicon.rst b/docs/Lexicon.rst
new file mode 100644
index 0000000000000..9461930ce1430
--- /dev/null
+++ b/docs/Lexicon.rst
@@ -0,0 +1,205 @@
+:orphan:
+
+.. title:: Lexicon
+.. default-role:: term
+
+.. @raise litre.TestsAreMissing
+
+This file defines several terms used by the Swift compiler and standard library
+source code, tests, and commit messages. See also the `LLVM lexicon`_.
+
+.. _LLVM lexicon: http://llvm.org/docs/Lexicon.html
+
+.. note::
+
+ This document uses Sphinx-specific features. If you are viewing this on
+ GitHub, you'll have to use raw mode, or download and build the docs
+ yourself.
+
+.. glossary::
+
+ archetype
+ A placeholder for a generic parameter or an associated type within a
+ generic context.
+
+ canonical SIL
+ SIL after the
+ `mandatory passes ` have run.
+ This can be used as input to IRGen to generate LLVM IR or object files.
+
+ Clang importer
+ The part of the compiler that reads C and Objective-C declarations and
+ exposes them as Swift. Essentially contains a small instance of Clang
+ running inside the Swift compiler, which is also used during IRGen.
+
+ conformance
+ A construct detailing how a particular type conforms to a particular
+ protocol. Represented in the compiler by the ProtocolConformance type at
+ the AST level. See also `witness table`.
+
+ DI (definite initialization / definitive initialization)
+ The feature that no uninitialized variables, constants, or properties will
+ be read by a program, or the analysis pass that operates on SIL to
+ guarantee this. This was `discussed on Apple's Swift blog`__.
+
+ __ https://developer.apple.com/swift/blog/?id=28
+
+ existential
+ A value whose type is a protocol composition (including a single protocol
+ and *zero* protocols; the latter is the ``Any`` type).
+
+ fragile
+ Describes a type or function where making changes will break binary
+ compatibility. See :doc:`LibraryEvolution.rst `.
+
+ IUO (implicitly unwrapped optional)
+ A type like Optional, but it implicitly converts to its wrapped type. If
+ the value is ``nil`` during such a conversion, the program traps just as
+ it would when a normal Optional is force-unwrapped. IUOs implicitly
+ convert to and from normal Optionals with the same wrapped type.
+
+ main module
+ The module for the file or files currently being compiled.
+
+ mandatory passes / mandatory optimizations
+ Transformations over SIL that run immediately after SIL generation. Once
+ all mandatory passes have run (and if no errors are found), the SIL is
+ considered `canonical `.
+
+ metatype
+ The type of a value representing a type. Greg Parker has a good
+ explanation of `Objective-C's "metaclasses"`__; because Swift has types
+ that are *not* classes, a more general term is used.
+
+ We also sometimes refer to a value representing a type as a "metatype
+ object" or just "metatype", usually within low-level contexts like IRGen
+ and LLDB. This is technically incorrect (it's just a "type object"), but
+ the malapropism happened early in the project and has stuck around.
+
+ __ http://sealiesoftware.com/blog/archive/2009/04/14/objc_explain_Classes_and_metaclasses.html
+
+ model
+ A type that conforms to a particular protocol. Sometimes "concrete
+ model". Example: "Array and Set are both models of CollectionType".
+
+ module
+ Has *many* uses in the Swift world. We may want to rename some of them.
+ #1 and #2 are the most common.
+
+ 1. A unit of API distribution and grouping. The ``import`` declaration
+ brings modules into scope. Represented as ModuleDecl in the compiler.
+ 2. A compilation unit; that is, source files that are compiled together.
+ These files may contain cross-references. Represented as "the main
+ module" (a specific ModuleDecl).
+ 3. (as "SIL module") A container for SIL to be compiled together, along
+ with various context for the compilation.
+ 4. (as "LLVM module") A collection of LLVM IR to be compiled together.
+ Always created in an LLVMContext.
+ 5. A file containing serialized AST and SIL information for a source file
+ or entire compilation unit. Often "swiftmodule file", with "swiftmodule"
+ pronounced as a single word.
+ 6. (as "Clang module") A set of self-contained C-family header files.
+ Represented by a ClangModuleUnit in the Swift compiler, each of which is
+ contained in its own ModuleDecl. For more information, see
+ `Clang's documentation for Modules`__.
+ 7. Shorthand for a "precompiled module file"; effectively "precompiled
+ headers" for an entire Clang module. Never used directly by Swift.
+ See also `module cache`.
+
+ __ http://clang.llvm.org/docs/Modules.html
+
+ module cache
+ Clang's cache directory for precompiled module files. As cache files, these
+ are not forward-compatible, and so cannot be loaded by different versions
+ of Clang (or programs using Clang, like the Swift compiler). Normally this
+ is fine, but occasionally a development compiler will not have proper
+ version information and may try to load older module files, resulting in
+ crashes in ``clang::ASTReader``.
+
+ open existential
+ An `existential` value with its dynamic type pulled out, so that the
+ compiler can do something with it.
+
+ PR
+ 1. "Problem Report": An issue reported in `LLVM's bug tracker`__.
+ See also `SR`.
+ 2. "pull request"
+
+ __ https://llvm.org/bugs/
+
+ primary file
+ The file currently being compiled, as opposed to the other files that are
+ only needed for context. See also
+ `Whole-Module Optimization `.
+
+ Radar
+ `Apple's bug-tracking system`__, or an issue reported on that system.
+
+ __ https://bugreport.apple.com
+
+ raw SIL
+ SIL just after being generated, not yet in a form that can be used for
+ IR generation.
+ See `mandatory passes `.
+
+ resilient
+ Describes a type or function where making certain changes will not break
+ binary compatibility. See :doc:`LibraryEvolution.rst `.
+
+ script mode
+ The parsing mode that allows top-level imperative code in a source file.
+
+ SIL
+ "Swift Intermediate Language". A high-level IR used by the Swift compiler
+ for flow-sensitive diagnostics, optimization, and LLVM IR generation.
+
+ -sil-serialize-all
+ A mode where all functions in a library are made available for inlining by
+ any client, regardless of access control. Also called "magic performance
+ mode" as a reminder of how this drastically changes compilation. Not
+ guaranteed to work on arbitrary code.
+
+ SR
+ An issue reported on `bugs.swift.org `_. A
+ backronym for "Swift Report"; really the name is derived from LLVM's
+ idiomatic use of "PR" ("Problem Report") for its bugs. We didn't go with
+ "PR" for Swift because we wanted to be able to unambiguously reference
+ LLVM bugs.
+
+ trap
+ A deterministic runtime failure. Can be used as both as a noun ("Using an
+ out-of-bounds index on an Array results in a trap") and a verb
+ ("Force-unwrapping a nil Optional will trap").
+
+ type metadata
+ The runtime representation of a type, and everything you can do with it.
+ Like a ``Class`` in Objective-C, but for any type.
+
+ value witness table
+ A runtime structure that describes how to do basic operations on an unknown
+ value, like "assign", "copy", and "destroy". (For example, does copying
+ this value require any retains?)
+
+ Only conceptually related to a `witness table`.
+
+ vtable (virtual dispatch table)
+ A map attached to a class of which implementation to use for each
+ overridable method in the class. Unlike an Objective-C method table,
+ vtable keys are just offsets, making lookup much simpler at the cost of
+ dynamism and duplicated information about *non*-overridden methods.
+
+ witness
+ The value or type that satisfies a protocol requirement.
+
+ witness table
+ The SIL (and runtime) representation of a `conformance`; essentially a
+ `vtable ` but for a protocol instead of
+ a class.
+
+ Only conceptually related to a `value witness table`.
+
+ WMO (whole-module optimization)
+ A compilation mode where all files in a module are compiled in a single
+ process. In this mode there is no `primary file`; all files are parsed,
+ type-checked, and optimized together at the SIL level. LLVM optimization
+ and object file generation may happen all together or in separate threads.
\ No newline at end of file
diff --git a/docs/LibraryEvolution.rst b/docs/LibraryEvolution.rst
index d20044a9077c4..3ef5616aba833 100644
--- a/docs/LibraryEvolution.rst
+++ b/docs/LibraryEvolution.rst
@@ -44,12 +44,8 @@ We also intend to provide tools to detect inadvertent changes in interfaces.
.. warning:: **This document is still in draft stages.** Large additions and
restructuring are still planned, including:
-
- * A summary for each declaration kind what changes are binary-compatible.
- * A proper definition for "versioned entity".
- * Several possible versioned attribute syntaxes, instead of just this one.
+
* A discussion of back-dating, and how it usually is not allowed.
- * A brief discussion of the implementation issues for fixed-layout value types with resilient members, and with non-public members.
* A revisal of the discussion on fixed-layout classes.
* A brief discussion of "deployment files", which represent distribution groupings that are themselves versioned. (For example, OS X 10.10.3 contains Foundation version 1153.20.) Deployment files are likely to provide a concrete implementation of "resilience domains".
* A way to specify "minimum deployment libraries", like today's minimum deployment targets.
@@ -104,7 +100,7 @@ for fallback behavior when the requested library version is not present::
func scareMySiblings() {
if #available(Magician 1.2) {
- conjureDemons()
+ summonDemons()
} else {
print("BOO!!")
}
@@ -124,129 +120,151 @@ versions.
Publishing Versioned API
========================
-A library's API is already marked with the ``public`` attribute. Versioning
-information can be added to any ``public`` entity with the ``@available``
-attribute, this time specifying *only* a version number. This declares when the
-entity was first exposed publicly in the current module.
+A library's API is already marked with the ``public`` attribute, but if a
+client wants to work with multiple releases of the library, the API needs
+versioning information as well. A *versioned entity* represents anything with a
+runtime presence that a client may rely on; its version records when the entity
+was first exposed publicly in its library. Put another way, it is the oldest
+version of the library where the entity may be used.
+
+- Classes, structs, enums, and protocols may all be versioned entities.
+- Methods, properties, subscripts, and initializers may be versioned entities.
+- Top-level functions, variables, and constants may be versioned entities.
+- Protocol conformances may be versioned entities, despite not explicitly having
+ a declaration in Swift, because a client may depend on them
+ See `New Conformances`_, below.
+
+In a versioned library, any top-level public entity from the list above may not
+be made ``public`` without an appropriate version. A public entity declared
+within a versioned type (or an extension of a versioned type) will default to
+having the same version as the type.
+
+Code within a library may generally use all other entities declared within the
+library (barring their own availability checks), since the entire library is
+shipped as a unit. That is, even if a particular API was introduced in v1.0,
+its (non-public) implementation may refer to APIs introduced in later versions.
+
+Swift libraries are strongly encouraged to use `semantic versioning`_, but this
+is not enforced by the language.
+
+.. _semantic versioning: http://semver.org
+
+Certain uses of ``internal`` entities require them to be part of a library's
+binary interface, which means they need to be versioned as well. See
+`Versioning Internal Declarations`_ below.
+
+The syntax for marking an entity as versioned has not yet been decided, but the
+rest of this document will use syntax #1 described below.
+
+Syntax #1: Attributes
+~~~~~~~~~~~~~~~~~~~~~
::
@available(1.2)
- public func conjureDemons()
-
-.. admonition:: TODO
+ public func summonDemons()
- Should this go on ``public`` instead? How does this play with SPI
- ?
+ @available(1.0) @inlineable(1.2)
+ public func summonElves()
Using the same attribute for both publishing and using versioned APIs helps tie
-the feature together and enforces a consistent set of rules. The one difference
-is that code within a library may always use all other entities declared within
-the library (barring their own availability checks), since the entire library
-is shipped as a unit. That is, even if a particular API was introduced in v1.0,
-its (non-public) implementation may refer to APIs introduced in later versions.
+the feature together and enforces a consistent set of rules. However, there are
+several other annotations described later in this document that also need
+versioning information, and it may not be obvious what the version number means
+outside the context of ``available``.
-Swift libraries are strongly encouraged to use `semantic versioning`_, but this
-is not enforced by the language.
-Some ``internal`` entities may also use ``@available``. See `Pinning`_ below.
+Syntax #2: Version Blocks
+~~~~~~~~~~~~~~~~~~~~~~~~~
-.. _semantic versioning: http://semver.org
+::
+ #version(1.2)
+ public func summonDemons()
-Giving Up Flexibility
-=====================
+ #version(1.0) {}
+ #version(1.2) { @inlineable }
+ public func summonElves()
-Fixed-layout Structs
-~~~~~~~~~~~~~~~~~~~~
+Since there are potentially many annotations on a declaration that need
+versioning information, it may make sense to group them together in some way.
+Only certain annotations would support being versioned in this way.
-By default, a library owner may add members to a public struct between releases
-without breaking binary compatibility. This requires a certain amount of care
-and indirection when dealing with values of struct type to account for the
-struct's size and non-`trivial` fields not being known in advance, which of
-course has performance implications.
-To opt out of this flexibility, a struct may be marked ``@fixed_layout``. This
-promises that no stored properties will be added to or removed from the struct,
-even ``private`` or ``internal`` ones. Methods and computed properties may
-still be added to the struct.
+Syntax #3: The ``public`` modifier
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The ``@fixed_layout`` attribute takes a version number, just like
-``@available``. This is so that clients can deploy against older versions of
-the library, which may have a different layout for the struct. (In this case
-the client must manipulate the struct as if the ``@fixed_layout`` attribute
-were absent.)
+::
-.. admonition:: TODO
+ public(1.2) func summonDemons()
- There's a benefit to knowing that a struct was ``@fixed_layout`` since it
- was first made available. How should that be spelled?
+ /* @inlineable ?? */
+ public(1.0) func summonElves()
+Putting the version on the public modifier is the most concise option. However,
+there's no obvious syntax here for adding versions to other annotations that
+may apply to a declaration.
-Fixed-layout Classes?
----------------------
+(Also, at one point there was a proposal to tag API only intended for certain
+clients using a similar syntax: ``public("Foundation")``, for example, for APIs
+only meant to be used by Foundation. These could then be stripped out of the
+public interface for a framework before being widely distributed. But that
+could easily use an alternate syntax.)
-There is some benefit to knowing that a class has a fixed layout---that is,
-that the stored properties of the class and all its superclasses are guaranteed
-not to change in future versions of a library. This would, for example, allow
-the class's memory to be allocated on the stack, as long as it can be proven
-that no references to the class escape. However, such a constraint is unlikely
-to be provable in practice from outside the class's own module, where its
-primary operations are opaquely defined. Thus, until a tangible benefit has
-been demonstrated, the ``@fixed_layout`` attribute will not apply to classes.
-(Another benefit would be to simplify the calculations needed for the offsets
-of stored properties within classes. However, it's unclear that this would have
-any significant benefit, particularly when most public properties are
-manipulated through their accessors.)
+Supported Evolution
+===================
+This section describes the various changes that are safe to make when releasing
+a new version of a library, i.e. changes that will not break binary
+compatibility. They are organized by declaration type.
-Closed Enums
-~~~~~~~~~~~~
+Anything *not* listed in this document should be assumed unsafe.
-By default, a library owner may add new cases to a public enum between releases
-without breaking binary compatibility. As with structs, this results in a fair
-amount of indirection when dealing with enum values, in order to potentially
-accommodate new values.
-.. note::
+Top-Level Functions
+~~~~~~~~~~~~~~~~~~~
- If an enum value has a known case, or can be proven to belong to a set of
- known cases, the compiler is of course free to use a more efficient
- representation for the value, just as it may discard fields of structs that
- are provably never accessed.
+A versioned top-level function is fairly restricted in how it can be changed.
+The following changes are permitted:
-A library owner may opt out of this flexibility by marking the enum as
-``@closed``. A "closed" enum may not have any ``private`` or ``internal`` cases
-and may not add new cases in the future. This guarantees to clients that the
-enum cases are exhaustive.
+- Changing the body of the function.
+- Changing *internal* parameter names (i.e. the names used within the function
+ body, not the labels that are part of the function's full name).
+- Reordering generic requirements (but not the generic parameters themselves).
+- Adding a default value to a parameter.
+- Changing a default value is permitted but discouraged; it changes the meaning
+ of existing source code.
.. note::
- Were a "closed" enum allowed to have non-public cases, clients of the
- library would still have to treat the enum as opaque and would still have
- to be able to handle unknown cases in their ``switch`` statements.
+ Today's implementation of default values puts the evaluation of the default
+ value expression in the library, rather than in the client like C++ or C#.
+ This is problematic if we want to allow adding new default values.
-The ``@closed`` attribute takes a version number, just like ``@available``.
-This is so that clients can deploy against older versions of the library, which
-may have non-public cases in the enum. (In this case the client must manipulate
-the enum as if the ``@closed`` attribute were absent.)
+.. admonition:: TODO
-Even for default "open" enums, adding new cases should not be done lightly. Any
-clients attempting to do an exhaustive switch over all enum cases will likely
-not handle new cases well.
+ Is *removing* a default value something we want to allow? It breaks source
+ compatibility, but not binary compatibility under the inlining model. That
+ said, changing a default value is discouraged, and removing + adding is the
+ same thing.
-.. note::
+No other changes are permitted; the following are particularly of note:
- One possibility would be a way to map new cases to older ones on older
- clients. This would only be useful for certain kinds of enums, though, and
- adds a lot of additional complexity, all of which would be tied up in
- versions. Our generalized switch patterns probably make it hard to nail
- down the behavior here.
+- A versioned function may not change its parameters or return type.
+- A versioned function may not change its generic requirements.
+- A versioned function may not change its external parameter names (labels).
+- A versioned function may not add, remove, or reorder parameters, whether or
+ not they have default values.
+
+.. admonition:: TODO
+
+ Can a throwing function become non-throwing? It's a "safe" change but
+ it's hard to document how it used to behave for backwards-deployers.
Inlineable Functions
-~~~~~~~~~~~~~~~~~~~~
+--------------------
Functions are a very common example of resilience: the function's declaration
is published as API, but its body may change between library versions as long
@@ -260,11 +278,11 @@ are a few common reasons for this:
save the overhead of a cross-library function call and allow further
optimization of callers.
-- The function accesses a fixed-layout struct with non-public members; this
+- The function accesses a fixed-contents struct with non-public members; this
allows the library author to preserve invariants while still allowing
efficient access to the struct.
-A public function marked with the ``@inlineable`` attribute makes its body
+A versioned function marked with the ``@inlineable`` attribute makes its body
available to clients as part of the module's public interface. The
``@inlineable`` attribute takes a version number, just like ``@available``;
clients may not assume that the body of the function is suitable when deploying
@@ -276,21 +294,24 @@ Clients are not required to inline a function marked ``@inlineable``.
It is legal to change the implementation of an inlineable function in the
next release of the library. However, any such change must be made with the
- understanding that it may or may not affect existing clients.
+ understanding that it may or may not affect existing clients. Existing
+ clients may use the new implementation, or they may use the implementation
+ from the time they were compiled, or they may use both inconsistently.
-Restrictions
-------------
+
+Restrictions on Inlineable Functions
+------------------------------------
Because the body of an inlineable function (or method, accessor, initializer,
or deinitializer) may be inlined into another module, it must not make any
assumptions that rely on knowledge of the current module. Here is a trivial
-example::
+example using methods::
public struct Point2D {
var x, y: Double
public init(x: Double, y: Double) { … }
}
-
+
extension Point2D {
@inlineable public func distanceTo(other: Point2D) -> Double {
let deltaX = self.x - other.x
@@ -317,12 +338,13 @@ the following restrictions on the bodies of inlineable functions:
functions declared within the inlineable function itself.
- **They must not reference any** ``internal`` **entities except for those that
- have been** `availability-pinned`_. See below for a discussion of pinning.
+ have been** `versioned`_. See below for a discussion of versioning internal
+ API.
- **They must not reference any entities less available than the function
itself.**
-.. _availability-pinned: #pinning
+.. _versioned: #versioning-internal-api
An inlineable function is still emitted into its own module's binary. This
makes it possible to take an existing function and make it inlineable, as long
@@ -339,73 +361,89 @@ Local Functions
---------------
If an inlineable function contains local functions or closures, these are
-implicitly made inlineable as well. This is important in case you decide to
-change the inlineable function later. If the inlineable function is emitted
-into a client module as described above, the local functions must be as well.
-(At the SIL level, these local functions are considered to have ``shared``
-linkage.)
-
-Pinning
--------
-
-An `availability-pinned` entity is simply an ``internal`` member, free
-function, or global binding that has been marked ``@available``. This promises
-that the entity will be available at link time in the containing module's
-binary. This makes it safe to refer to such an entity from an inlineable
-function. If a pinned entity is ever made ``public``, its availability should
-not be changed.
+implicitly made inlineable as well. This is important in case the library
+author decides to change the inlineable function later. If the inlineable
+function is emitted into a client module as described above, the local
+functions must be as well. (At the SIL level, these local functions are
+considered to have ``shared`` linkage.)
-.. note::
+Local functions are subject to the same restrictions as the inlineable
+functions containing them, as described above.
- Why isn't this a special form of ``public``? Because we don't want it to
- imply everything that ``public`` does, such as requiring overrides to be
- ``public``.
-Because a pinned class member may eventually be made public, it must be assumed
-that new overrides may eventually appear from outside the module unless the
-member is marked ``final`` or the class is not publicly subclassable.
+Top-Level Variables and Constants
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-We could do away with the entire "pinning" feature if we restricted inlineable
-functions to only refer to public entities. However, this removes one of the
-primary reasons to make something inlineable: to allow efficient access to a
-type while still protecting its invariants.
+Given a versioned module-scope variable declared with ``var``, the following
+changes are permitted:
-.. note::
+- Adding (but not removing) a public setter to a computed variable.
+- Adding or removing a non-public, non-versioned setter.
+- Changing from a stored variable to a computed variable, or vice versa, as
+ long as a previously-versioned setter is not removed.
+- Changing the body of an accessor.
+- Adding or removing an observing accessor (``willSet`` or ``didSet``) to/from
+ an existing variable. This is effectively the same as modifying the body of a
+ setter.
+- Changing the initial value of a stored variable.
- Types are not allowed to be pinned because that would have many more ripple
- effects. It's not technically impossible; it just requires a lot more
- thought.
+.. admonition:: TODO
+ We need to pin down how this interacts with the "Behaviors" proposal.
+ Behaviors that just change the accessors of a global are fine, but those
+ that provide new entry points are trickier.
-A Unifying Theme
-~~~~~~~~~~~~~~~~
+If a public setter is added after the property is first exposed (whether the
+property is stored or computed), it must be versioned independently of the
+property itself.
-So far this proposal has talked about three separate ways to lock down on three
-separate Swift entities: structs, enums, and functions. Each of these has a
-different set of constraints it enforces on the library author and promises it
-makes to clients. However, they all follow a common theme of giving up the
-flexibility of future changes in exchange for improved performance and perhaps
-some semantic guarantees. As such, we could consider using a common attribute,
-say ``@fixed``, ``@inline``, or ``@fragile``; either way, all attributes in
-this section can be referred to as "fragility attributes".
+.. admonition:: TODO
+ This needs syntax.
-Constants
-~~~~~~~~~
+Additionally, for a module-scope constant declared with ``let``, the following
+changes are permitted:
+
+- Changing the value of the constant.
-The ``let`` keyword creates a named constant whose value will not change for
-the lifetime of that entity; for a global or static constant, this lasts from
-when the constant is first accessed (and lazily initialized) until the end of
-program execution. However, different versions of the same library may choose
-to have different values for a constant---say, a string describing the
-library's copyright information.
+It is *not* safe to change a ``let`` constant into a variable or vice versa.
+Top-level constants are assumed not to change for the entire lifetime of the
+program once they have been initialized.
-In order to make use of a constant's value across library boundaries, the
-library owner may mark the constant as ``@inlineable``. As when applied to
-functions, the attribute takes a version number specifying which versions of
-the library will behave correctly if the value is inlined into client code.
+.. note:: We could make it safe to turn a read-only variable into a constant,
+ but currently do not promise that that is a binary-compatible change.
-Note that if the constant's initial value expression has any observable side
+
+Giving Up Flexibility
+---------------------
+
+Both top-level constants and variables can be marked ``@inlineable`` to allow
+clients to access them more efficiently. This restricts changes a fair amount:
+
+- Adding a versioned setter to a computed variable is still permitted.
+- Adding or removing a non-public, non-versioned setter is still permitted.
+- Changing from stored to computed or vice versa is forbidden, because it would
+ break existing clients.
+- Changing the body of an accessor is permitted but discouraged; existing
+ clients may use the new implementations, or they may use the implementations
+ from the time they were compiled, or a mix of both.
+- Adding/removing observing accessors is likewise permitted but discouraged,
+ for the same reason.
+- Changing the initial value of a stored variable is still permitted.
+- Changing the value of a constant is permitted but discouraged; like accessors,
+ existing clients may use the new value, or the value from when they were
+ compiled, or a mix of both.
+
+.. admonition:: TODO
+
+ It Would Be Nice(tm) to allow marking the *getter* of a top-level variable
+ inlineable while still allowing the setter to change. This would need
+ syntax, though.
+
+Any inlineable accessors must follow the rules for `inlineable functions`_,
+as described above.
+
+Note that if a constant's initial value expression has any observable side
effects, including the allocation of class instances, it must not be treated
as inlineable. A constant must always behave as if it is initialized exactly
once.
@@ -416,67 +454,450 @@ once.
restricted to things that can be lowered to compile-time constants?
-Properties
-~~~~~~~~~~
+Structs
+~~~~~~~
-By default, a stored property in a struct or class may be replaced by a
-computed property in later versions of a library. As shown above, the
-``@fixed_layout`` attribute promises that all stored properties currently in a
-type will remain stored in all future library versions, but sometimes that
-isn't a reasonable promise. In this case, a library owner may still want to
-allow clients to rely on a *specific* stored property remaining stored, by
-applying the ``@fixed`` attribute to the property.
+Swift structs are a little more flexible than their C counterparts. By default,
+the following changes are permitted:
+
+- Reordering any existing members, including stored properties.
+- Adding any new members, including stored properties.
+- Changing existing properties from stored to computed or vice versa.
+- Changing the body of any methods, initializers, or accessors.
+- Adding or removing an observing accessor (``willSet`` or ``didSet``) to/from
+ an existing property. This is effectively the same as modifying the body of a
+ setter.
+- Removing any non-public, non-versioned members, including stored properties.
+- Adding a new protocol conformance (with proper availability annotations).
+- Removing conformances to non-public protocols.
+
+The important most aspect of a Swift struct is its value semantics, not its
+layout.
.. admonition:: TODO
- Is it valid for a fixed property to have observing accessors, or is it more
- useful to promise that the setter is just a direct field access too? If it
- were spelled ``@fragile``, I would assume that accessors are permitted but
- they become inlineable, and so not having any accessors is just a
- degenerate case of that.
-
- Is this feature sufficiently useful to be proposed initially at all, or is
- it too granular?
+ We need to pin down how this, and the ``@fixed_contents`` attribute below,
+ interacts with the "Behaviors" proposal. Behaviors that just change the
+ accessors of a property are fine, but those that provide new entry points
+ are trickier.
+
+Like top-level constants, it is *not* safe to change a ``let`` property into a
+variable or vice versa. Properties declared with ``let`` are assumed not to
+change for the entire lifetime of the program once they have been initialized.
+
-Like all other attributes in this section, the ``@fixed`` attribute must
-specify in which version of the library clients may rely on the property being
-stored. The attribute may not be applied to non-final properties in classes.
+New Conformances
+----------------
+
+If a conformance is added to a type in version 1.1 of a library, it's important
+that it isn't accessed in version 1.0. This is obvious if the protocol itself
+was introduced in version 1.1, but needs special handling if both the protocol
+and the type were available earlier. In this case, the conformance *itself*
+needs to be labeled as being introduced in version 1.1, so that the compiler
+can enforce its safe use.
.. note::
- It would be possible to allow ``@fixed`` on non-final properties, and have
- it only apply when the client code is definitively working with an instance
- of the base class, not any of its subclasses. But this is probably too
- subtle, and makes it look like the attribute is doing something useful when
- it actually isn't.
+ This may feel like a regression from Objective-C, where `duck typing` would
+ allow a ``Wand`` to be passed as an ``id `` without ill effects.
+ However, ``Wand`` would still fail a ``-conformsToProtocol:`` check in
+ version 1.0 of the library, and so whether or not the client code will work
+ is dependent on what should be implementation details of the library.
+We've considered two possible syntaxes for this::
+ @available(1.1)
+ extension MyStruct : SomeProto {…}
-Other Promises About Types
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+and
-Advanced users may want to promise more specific things about various types.
-These are similar to the internal ``effects`` attribute we have for functions,
-except that they can be enforced by the compiler.
+::
-- ``trivial``: Promises that the type is `trivial`. Note that this is not a
- recursive property; a trivial type may still require indirection due to
- having an unknown size, and so a type containing that type is not considered
- trivial.
+ extension MyStruct : @available(1.1) SomeProto {…}
+
+The former requires fewer changes to the language grammar, but the latter could
+also be used on the declaration of the type itself (i.e. the ``struct``
+declaration).
+
+If we went with the former syntax, applying ``@available`` to an extension
+would override the default availability of entities declared within the
+extension; unlike access control, entities within the extension may freely
+declare themselves to be either more or less available than what the extension
+provides.
+
+
+Fixed-Contents Structs
+----------------------
+
+To opt out of this flexibility, a struct may be marked ``@fixed_contents``.
+This promises that no stored properties will be added to or removed from the
+struct, even ``private`` or ``internal`` ones. Additionally, all versioned
+stored properties in a ``@fixed_contents`` struct are implicitly declared
+``@inlineable`` (as described above for top-level variables). In effect:
+
+- Reordering stored instance properties relative to one another is not
+ permitted. Reordering all other members is still permitted.
+- Adding new stored instance properties (public or non-public) is not permitted.
+ Adding any other new members is still permitted.
+- Existing instance properties may not be changed from stored to computed or
+ vice versa.
+- Changing the body of any *existing* methods, initializers, computed property
+ accessors, or non-instance stored property accessors is permitted. Changing
+ the body of a stored instance property observing accessor is only permitted
+ if the property is not `versioned `.
+- Adding or removing observing accessors from any
+ `versioned ` stored instance properties (public or
+ non-public) is not permitted.
+- Removing stored instance properties is not permitted. Removing any other
+ non-public, non-versioned members is still permitted.
+- Adding a new protocol conformance is still permitted.
+- Removing conformances to non-public protocols is still permitted.
+
+Additionally, if the type of any stored instance property includes a struct or
+enum, that struct or enum must be `versioned `. This includes
+generic parameters and members of tuples.
-- ``size_in_bits(N)``: Promises that the type is not larger than a certain
- size. (It may be smaller.)
+.. note::
-- ``no_payload``: Promises that an enum does not have payloads on any of its
- cases (even the non-public ones).
+ This name is intentionally awful to encourage us to come up with a better
+ one.
-Collectively these features are known as "performance assertions", to
-underscore the fact that they do not affect how a type is used at the source
-level, but do allow for additional optimizations. We may also expose some of
-these qualities to static or dynamic queries for performance-sensitive code.
+A ``@fixed_contents`` struct is *not* guaranteed to use the same layout as a C
+struct with a similar "shape". If such a struct is necessary, it should be
+defined in a C header and imported into Swift.
+
+.. note::
+
+ We can add a *different* feature to control layout some day, or something
+ equivalent, but this feature should not restrict Swift from doing useful
+ things like minimizing member padding.
+
+.. note::
+
+ It would be possible to say that a ``@fixed_contents`` struct only
+ guarantees the "shape" of the struct, so to speak, while
+ leaving all property accesses to go through function calls. This would
+ allow stored properties to change their accessors, or (with the Behaviors
+ proposal) to change a behavior's implementation, or change from one
+ behavior to another. However, the *most common case* here is probably just
+ a simple C-like struct that groups together simple values, with only public
+ stored properties and no observing accessors, and having to opt into direct
+ access to those properties seems unnecessarily burdensome. The struct is
+ being declared ``@fixed_contents`` for a reason, after all: it's been
+ discovered that its use is causing performance issues.
+
+ Consequently, as a first pass we may just require all stored properties in
+ a ``@fixed_contents`` struct, public or non-public, to have trivial
+ accessors, i.e. no observing accessors and no behaviors.
+
+The ``@fixed_contents`` attribute takes a version number, just like
+``@available``. This is so that clients can deploy against older versions of
+the library, which may have a different layout for the struct. (In this case
+the client must manipulate the struct as if the ``@fixed_contents`` attribute
+were absent.)
+
+.. admonition:: TODO
+
+ We really shouldn't care about the *order* of the stored properties.
+
+
+Enums
+~~~~~
+
+By default, a library owner may add new cases to a public enum between releases
+without breaking binary compatibility. As with structs, this results in a fair
+amount of indirection when dealing with enum values, in order to potentially
+accommodate new values. More specifically, the following changes are permitted:
+
+- Adding a new case.
+- Reordering existing cases, although this is discouraged. In particular, if
+ an enum is RawRepresentable, changing the raw representations of cases may
+ break existing clients who use them for serialization.
+- Adding a raw type to an enum that does not have one.
+- Removing a non-public, non-versioned case.
+- Adding any other members.
+- Removing any non-public, non-versioned members.
+- Adding a new protocol conformance (with proper availability annotations).
+- Removing conformances to non-public protocols.
+
+.. note::
+
+ If an enum value has a known case, or can be proven to belong to a set of
+ known cases, the compiler is of course free to use a more efficient
+ representation for the value, just as it may discard fields of structs that
+ are provably never accessed.
+
+.. note::
+
+ Non-public cases in public enums don't exist at the moment, but they *can*
+ be useful, and they require essentially the same implementation work as
+ cases added in future versions of a library.
+
+.. admonition:: TODO
+
+ This states that adding/removing ``indirect`` (on either a case or the
+ entire enum) is considered a breaking change. Is that what we want?
+
+
+Closed Enums
+------------
+
+A library owner may opt out of this flexibility by marking a versioned enum as
+``@closed``. A "closed" enum may not have any cases with less access than the
+enum itself, and may not add new cases in the future. This guarantees to
+clients that the enum cases are exhaustive. In particular:
+
+- Adding new cases is not permitted
+- Reordering existing cases is not permitted.
+- Adding a raw type to an enum that does not have one is still permitted.
+- Removing a non-public case is not applicable.
+- Adding any other members is still permitted.
+- Removing any non-public, non-versioned members is still permitted.
+- Adding a new protocol conformance is still permitted.
+- Removing conformances to non-public protocols is still permitted.
+
+.. note::
+
+ Were a public "closed" enum allowed to have non-public cases, clients of
+ the library would still have to treat the enum as opaque and would still
+ have to be able to handle unknown cases in their ``switch`` statements.
+
+The ``@closed`` attribute takes a version number, just like ``@available``.
+This is so that clients can deploy against older versions of the library, which
+may have non-public cases in the enum. (In this case the client must manipulate
+the enum as if the ``@closed`` attribute were absent.) All cases that are not
+versioned become implicitly versioned with this number.
+
+Even for default "open" enums, adding new cases should not be done lightly. Any
+clients attempting to do an exhaustive switch over all enum cases will likely
+not handle new cases well.
+
+.. note::
+
+ One possibility would be a way to map new cases to older ones on older
+ clients. This would only be useful for certain kinds of enums, though, and
+ adds a lot of additional complexity, all of which would be tied up in
+ versions. Our generalized switch patterns probably make it hard to nail
+ down the behavior here.
+
+
+Protocols
+~~~~~~~~~
+
+There are very few safe changes to make to protocols:
+
+- A new non-type requirement may be added to a protocol, as long as it has an
+ unconstrained default implementation.
+- A new optional requirement may be added to an ``@objc`` protocol.
+- All members may be reordered, including associated types.
+
+However, any members may be added to protocol extensions, and non-public,
+non-versioned members may always be removed from protocol extensions.
+
+.. admonition:: TODO
+
+ We don't have an implementation model hammered out for adding new
+ defaulted requirements, but it is desirable.
+
+.. admonition:: TODO
+
+ It would also be nice to be able to add new associated types with default
+ values, but that seems trickier to implement.
+
+
+Classes
+~~~~~~~
+
+Because class instances are always accessed through references, they are very
+flexible and can change in many ways between releases. Like structs, classes
+support all of the following changes:
+
+- Reordering any existing members, including stored properties.
+- Changing existing properties from stored to computed or vice versa.
+- Changing the body of any methods, initializers, or accessors.
+- Adding or removing an observing accessor (``willSet`` or ``didSet``) to/from
+ an existing property. This is effectively the same as modifying the body of a
+ setter.
+- Removing any non-public, non-versioned members, including stored properties.
+- Adding a new protocol conformance (with proper availability annotations).
+- Removing conformances to non-public protocols.
+
+Omitted from this list is the free addition of new members. Here classes are a
+little more restrictive than structs; they only allow the following changes:
+
+- Adding a new convenience initializer.
+- Adding a new designated initializer, if the class is not publicly
+ subclassable.
+- Adding a deinitializer.
+- Adding new, non-overriding method, subscript, or property.
+- Adding a new overriding member, as long as its type does not change.
+ Changing the type could be incompatible with existing overrides in subclasses.
+
+Finally, classes allow the following changes that do not apply to structs:
+
+- "Moving" a method, subscript, or property up to its superclass. The
+ declaration of the original member must remain along with its original
+ availability, but its body may consist of simply calling the new superclass
+ implementation.
+- Changing a class's superclass ``A`` to another class ``B``, *if* class ``B``
+ is a subclass of ``A`` *and* class ``B``, along with any superclasses between
+ it and class ``A``, were introduced in the latest version of the library.
+- A non-final override of a method, subscript, property, or initializer may be
+ removed as long as the generic parameters, formal parameters, and return type
+ *exactly* match the overridden declaration. Any existing callers should
+ automatically use the superclass implementation.
+
+.. admonition:: TODO
+
+ The latter is very tricky to get right. We've seen it happen a few times in
+ Apple's SDKs, but at least one of them, `NSCollectionViewItem`_ becoming a
+ subclass of NSViewController instead of the root class NSObject, doesn't
+ strictly follow the rules. While NSViewController was introduced in the
+ same version of the OS, its superclass, NSResponder, was already present.
+ If a client app was deploying to an earlier version of the OS, would
+ NSCollectionViewItem be a subclass of NSResponder or not? How would the
+ compiler be able to enforce this?
+
+.. _NSCollectionViewItem: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/NSCollectionViewItem_Class/index.html
+
+Other than those detailed above, no other changes to a class or its members
+are permitted. In particular:
+
+- New designated initializers may not be added to a publicly-subclassable
+ class. This would change the inheritance of convenience initializers, which
+ existing subclasses may depend on.
+- New ``required`` initializers may not be added to a publicly-subclassable
+ class. There is no way to guarantee their presence on existing subclasses.
+- ``final`` may not be added to *or* removed from a class or any of its members.
+ The presence of ``final`` enables optimization; its absence means there may
+ be subclasses/overrides that would be broken by the change.
+- ``dynamic`` may not be added to *or* removed from any members. Existing
+ clients would not know to invoke the member dynamically.
+- A ``final`` override of a member may *not* be removed, even if the type
+ matches exactly; existing clients may be performing a direct call to the
+ implementation instead of using dynamic dispatch.
+
+.. note:: These restrictions tie in with the ongoing discussions about
+ "``final``-by-default" and "non-publicly-subclassable-by-default".
+
+
+Possible Restrictions on Classes
+--------------------------------
+
+In addition to ``final``, it may be useful to restrict the size of a class
+instance (like a struct's ``@fixed_contents``) or the number of overridable
+members in its virtual dispatch table. These annotations have not been designed.
+
+
+Extensions
+~~~~~~~~~~
+
+Non-protocol extensions largely follow the same rules as the types they extend.
+The following changes are permitted:
+
+- Adding new extensions and removing empty extensions.
+- Moving a member from one extension to another within the same module, as long
+ as both extensions have the exact same constraints.
+- Moving a member from an extension to the declaration of the base type,
+ provided that the declaration is in the same module. The reverse is permitted
+ for all members except stored properties, although note that moving all
+ initializers out of a type declaration may cause a new one to be implicitly
+ synthesized.
+
+Adding, removing, reordering, and modifying members follow the same rules as
+the base type; see the sections on structs, enums, and classes above.
+
+
+Protocol Extensions
+-------------------
+
+Protocol extensions follow slightly different rules; the following changes
+are permitted:
+
+- Adding new extensions and removing empty extensions.
+- Moving a member from one extension to another within the same module, as long
+ as both extensions have the exact same constraints.
+- Adding any new member.
+- Reordering members.
+- Removing any non-public, non-versioned member.
+- Changing the body of any methods, initializers, or accessors.
+
+
+Operators
+~~~~~~~~~
+
+Operator declarations are entirely compile-time constructs, so changing them
+does not have any affect on binary compatibility. However, they do affect
+*source* compatibility, so it is recommended that existing operators are not
+changed at all except for the following:
+
+- Making a non-associative operator left- or right-associative.
-All of these features take a version number, just like the more semantic
-fragility attributes above. The exact spelling is not proposed by this document.
+
+A Unifying Theme
+~~~~~~~~~~~~~~~~
+
+So far this proposal has talked about ways to give up flexibility for several
+different kinds of declarations: ``@inlineable`` for functions,
+``@fixed_contents`` for structs, etc. Each of these has a different set of
+constraints it enforces on the library author and promises it makes to clients.
+However, they all follow a common theme of giving up the flexibility of future
+changes in exchange for improved performance and perhaps some semantic
+guarantees. Therefore, all of these attributes are informally referred to as
+"fragility attributes".
+
+Given that these attributes share several characteristics, we could consider
+converging on a single common attribute, say ``@fixed``, ``@inline``, or
+``@fragile``. However, this may be problematic if the same declaration has
+multiple kinds of flexibility, as in the description of classes above.
+
+
+Versioning Internal Declarations
+================================
+
+The initial discussion on versioning focused on ``public`` APIs, making sure
+that a client knows what features they can use when a specific version of a
+library is present. Inlineable functions have much the same constraints, except
+the inlineable function is the client and the entities being used may not be
+``public``.
+
+Adding a versioning annotation to an ``internal`` entity promises that the
+entity will be available at link time in the containing module's binary. This
+makes it safe to refer to such an entity from an inlineable function. If the
+entity is ever made ``public``, its availability should not be changed; not
+only is it safe for new clients to rely on it, but *existing* clients require
+its presence as well.
+
+.. note::
+
+ Why isn't this a special form of ``public``? Because we don't want it to
+ imply everything that ``public`` does, such as requiring overrides to be
+ ``public``.
+
+Because a versioned class member may eventually be made ``public``, it must be
+assumed that new overrides may eventually appear from outside the module unless
+the member is marked ``final`` or the class is not publicly subclassable.
+
+Non-public conformances are never considered versioned, even if both the
+conforming type and the protocol are versioned.
+
+Entities declared ``private`` may not be versioned; the mangled name of such an
+entity includes an identifier based on the containing file, which means moving
+the declaration to another file changes the entity's mangled name. This implies
+that a client would not be able to find the entity at run time if the source
+code is reorganized, which is unacceptable.
+
+.. note::
+
+ There are ways around this limitation, the most simple being that versioned
+ ``private`` entities are subject to the same cross-file redeclaration rules
+ as ``internal`` entities. However, this is a purely additive feature, so to
+ keep things simple we'll stick with the basics.
+
+We could do away with the entire feature if we restricted inlineable functions
+and fixed-contents structs to only refer to public entities. However, this
+removes one of the primary reasons to make something inlineable: to allow
+efficient access to a type while still protecting its invariants.
Optimization
@@ -532,11 +953,11 @@ containing library is the version attached to the ``@inlineable`` attribute.
Code within this context must be treated as if the containing library were just
a normal dependency.
-A publicly inlineable function still has a public symbol, which may be used
-when the function is referenced from a client rather than called. This version
-of the function is not subject to the same restrictions as the version that
-may be inlined, and so it may be desirable to compile a function twice: once
-for inlining, once for maximum performance.
+A versioned inlineable function still has an exported symbol in the library
+binary, which may be used when the function is referenced from a client rather
+than called. This version of the function is not subject to the same
+restrictions as the version that may be inlined, and so it may be desirable to
+compile a function twice: once for inlining, once for maximum performance.
Local Availability Contexts
@@ -554,6 +975,37 @@ optimization that may be complicated to implement (and even to represent
properly in SIL), and so it is not a first priority.
+Other Promises About Types
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Advanced users may want to promise more specific things about various types.
+These are similar to the internal ``effects`` attribute we have for functions,
+except that they can be enforced by the compiler.
+
+- ``trivial``: Promises that the type is `trivial`.
+
+- ``size_in_bits(N)``: Promises that the type is not larger than a certain
+ size. (It may be smaller.)
+
+- ``fixed_size``: Promises that the type has *some* size known at compile-time,
+ allowing optimizations like promoting allocations to the stack. Only applies
+ to fixed-contents structs and closed enums, which can already infer this
+ information; the explicit annotation allows it to be enforced.
+
+Collectively these features are known as "performance assertions", to
+underscore the fact that they do not affect how a type is used at the source
+level, but do allow for additional optimizations. We may also expose some of
+these qualities to static or dynamic queries for performance-sensitive code.
+
+.. note:: Previous revisions of this document contained a ``no_payload``
+ assertion for enums. However, this doesn't actually offer any additional
+ optimization opportunities over combining ``trivial`` with ``size_in_bits``,
+ and the latter is more flexible.
+
+All of these features need to be versioned, just like the more semantic
+fragility attributes above. The exact spelling is not proposed by this document.
+
+
Resilience Domains
==================
@@ -581,56 +1033,6 @@ a client has the same resilience domain name as a library it is using, it may
assume that version of the library will be present at runtime.
-Protocol Conformances
-=====================
-
-Consider this scenario: a library is released containing both a ``MagicType``
-protocol and a ``Wand`` struct. ``Wand`` satisfies all the requirements of the
-``MagicType`` protocol, but the conformance was never actually declared in the
-library. Someone files a bug, and it gets fixed in version 1.1.
-
-Now, what happens when this client code is deployed against version 1.0 of the
-library?
-
-::
-
- // Library
- @available(1.0)
- public func classifyMagicItem(item: Item) -> MagicKind
-
- // Client
- let kind = classifyMagicItem(elderWand)
- log("\(elderWand): \(kind)")
-
-In order to call ``classifyMagicItem``, the client code needs access to the
-conformance of ``Wand`` to the ``MagicType`` protocol. But that conformance
-*didn't exist* in version 1.0, so the client program will fail on older systems.
-
-Therefore, a library author needs a way to declare that a type *now* conforms
-to a protocol when it previously didn't. The way to do this is by placing
-availability information on an extension::
-
- @available(1.1)
- extension Wand : MagicType {}
-
-Note that this is unnecessary if either ``Wand`` or ``MagicType`` were itself
-introduced in version 1.1; in that case, it would not be possible to access
-the conformance from a context that only required 1.0.
-
-As with access control, applying ``@available`` to an extension overrides the
-default availability of entities declared within the extension; unlike access
-control, entities within the extension may freely declare themselves to be
-either more or less available than what the extension provides.
-
-.. note::
-
- This may feel like a regression from Objective-C, where `duck typing` would
- allow a ``Wand`` to be passed as an ``id `` without ill effects.
- However, ``Wand`` would still fail a ``-conformsToProtocol:`` check in
- version 1.0 of the library, and so whether or not the client code will work
- is dependent on what should be implementation details of the library.
-
-
Checking Binary Compatibility
=============================
@@ -639,16 +1041,16 @@ check their work. Therefore, we intend to ship a tool that can compare two
versions of a library's public interface, and present any suspect differences
for verification. Important cases include but are not limited to:
-- Removal of public entities.
+- Removal of versioned entities.
-- Incompatible modifications to public entities, such as added protocol
+- Incompatible modifications to versioned entities, such as added protocol
conformances lacking versioning information.
-
+
- Unsafely-backdated "fragile" attributes as discussed in the `Giving Up
Flexibility`_ section.
-
-- Unsafe modifications to entities marked with the "fragile" attributes, such as
- adding a stored property to a ``@fixed_layout`` struct.
+
+- Unsafe modifications to entities marked with the "fragile" attributes, such as
+ adding a stored property to a ``@fixed_contents`` struct.
Automatic Versioning
@@ -709,7 +1111,7 @@ Glossary
API
An `entity` in a library that a `client` may use, or the collection of all
such entities in a library. (If contrasting with `SPI`, only those entities
- that are available to arbitrary clients.) Marked ``public`` in
+ that are available to arbitrary clients.) Marked ``public`` in
Swift. Stands for "Application Programming Interface".
availability context
@@ -718,15 +1120,12 @@ Glossary
are always properly nested, and the global availability context includes
the module's minimum deployment target and minimum dependency versions.
- availability-pinned
- See `Pinning`_.
-
backwards-compatible
A modification to an API that does not break existing clients. May also
describe the API in question.
binary compatibility
- A general term encompassing both backwards- and forwards-compatibility
+ A general term encompassing both backwards- and forwards-compatibility
concerns. Also known as "ABI compatibility".
client
@@ -741,7 +1140,9 @@ Glossary
(Note that this is a dynamic constraint.)
entity
- A type, function, member, or global in a Swift program.
+ A type, function, member, or global in a Swift program. Occasionally the
+ term "entities" also includes conformances, since these have a runtime
+ presence and are depended on by clients.
forwards-compatible
An API that is designed to handle future clients, perhaps allowing certain
@@ -753,7 +1154,7 @@ Glossary
module
The primary unit of code sharing in Swift. Code in a module is always built
together, though it may be spread across several source files.
-
+
performance assertion
See `Other Promises About Types`_.
@@ -768,9 +1169,12 @@ Glossary
target
In this document, a collection of code in a single Swift module that is
- built together; a "compilation unit". Roughly equivalent to a target in
+ built together; a "compilation unit". Roughly equivalent to a target in
Xcode.
trivial
A value whose assignment just requires a fixed-size bit-for-bit copy
without any indirection or reference-counting operations.
+
+ versioned entity
+ See `Publishing Versioned API`_.
diff --git a/docs/MutationModel.rst b/docs/MutationModel.rst
index dae65de7431d2..d75b4d8ea1c32 100644
--- a/docs/MutationModel.rst
+++ b/docs/MutationModel.rst
@@ -37,10 +37,10 @@ Consider::
}
var w = Window()
- w.title += " (parenthesized remark)”
+ w.title += " (parenthesized remark)"
What do we do with this? Since ``+=`` has an ``inout`` first
-argument, we detect this situation statically (hopefully one day we’ll
+argument, we detect this situation statically (hopefully one day we'll
have a better error message):
::
@@ -53,7 +53,7 @@ Great. Now what about this? [#append]_ ::
w.title.append(" (fool the compiler)")
-Today, we allow it, but since there’s no way to implement the
+Today, we allow it, but since there's no way to implement the
write-back onto ``w.title``, the changes are silently dropped.
Unsatisfying Approaches
@@ -101,14 +101,14 @@ Otherwise, it is considered **read-only**.
The implicit ``self`` parameter of a struct or enum method is semantically an
``inout`` parameter if and only if the method is attributed with
-``mutating``. Read-only methods do not “write back” onto their target
+``mutating``. Read-only methods do not "write back" onto their target
objects.
A program that applies the ``mutating`` to a method of a
class—or of a protocol attributed with ``@class_protocol``—is
ill-formed. [Note: it is logically consistent to think of all methods
of classes as read-only, even though they may in fact modify instance
-variables, because they never “write back” onto the source reference.]
+variables, because they never "write back" onto the source reference.]
Mutating Operations
-------------------
diff --git a/docs/OptimizationTips.rst b/docs/OptimizationTips.rst
index a8c66e01eb8fc..8f2280bdced4f 100644
--- a/docs/OptimizationTips.rst
+++ b/docs/OptimizationTips.rst
@@ -157,7 +157,7 @@ do not have any overriding declarations in the same file:
func usingE(e: E) {
e.doSomething() // There is no sub class in the file that declares this class.
// The compiler can remove virtual calls to doSomething()
- // and directly call A’s doSomething method.
+ // and directly call A's doSomething method.
}
func usingF(f: F) -> Int {
@@ -176,7 +176,7 @@ Advice: Use value types in Array
In Swift, types can be divided into two different categories: value types
(structs, enums, tuples) and reference types (classes). A key distinction is
-that value types can not be included inside an NSArray. Thus when using value
+that value types cannot be included inside an NSArray. Thus when using value
types, the optimizer can remove most of the overhead in Array that is necessary
to handle the possibility of the array being backed an NSArray.
@@ -265,7 +265,7 @@ Swift eliminates integer overflow bugs by checking for overflow when performing
normal arithmetic. These checks are not appropriate in high performance code
where one knows that no memory safety issues can result.
-Advice: Use unchecked integer arithmetic when you can prove that overflow can not occur
+Advice: Use unchecked integer arithmetic when you can prove that overflow cannot occur
---------------------------------------------------------------------------------------
In performance-critical code you can elide overflow checks if you know it is
@@ -446,7 +446,7 @@ argument drops from being O(n), depending on the size of the tree to O(1).
::
- struct tree : P {
+ struct Tree : P {
var node : [P?]
init() {
node = [ thing ]
diff --git a/docs/OptimizerDesign.md b/docs/OptimizerDesign.md
index dd653dad74912..e6e767ad0bf7b 100644
--- a/docs/OptimizerDesign.md
+++ b/docs/OptimizerDesign.md
@@ -25,7 +25,7 @@ phase (stands for intermediate representation generation phase) that lowers SIL
into LLVM IR. The LLVM backend optimizes and emits binary code for the compiled
program.
-Please refer to the document “Swift Intermediate Language (SIL)” for more
+Please refer to the document "Swift Intermediate Language (SIL)" for more
details about the SIL IR.
The compiler optimizer is responsible for optimizing the program using the
@@ -125,8 +125,8 @@ The mechanism that swift uses to invalidate analysis is broadcast-invalidation.
Passes ask the pass manager to invalidate specific traits. For example, a pass
like simplify-cfg will ask the pass manager to announce that it modified some
branches in the code. The pass manager will send a message to all of the
-available analysis that says “please invalidate yourself if you care about
-branches for function F“. The dominator tree would then invalidate the dominator
+available analysis that says "please invalidate yourself if you care about
+branches for function F". The dominator tree would then invalidate the dominator
tree for function F because it knows that changes to branches can mean that the
dominator tree was modified.
@@ -180,7 +180,7 @@ This is an example of the *@_semantics* attribute as used by Swift Array:
Notice that as soon as we inline functions that have the @_semantics attribute
the attribute is lost and the optimizer can't analyze the content of the
-function. For example, the optimizer can identify the array ‘count' method (that
+function. For example, the optimizer can identify the array 'count' method (that
returns the size of the array) and can hoist this method out of loops. However,
as soon as this method is inlined, the code looks to the optimizer like a memory
read from an undetermined memory location, and the optimizer can't optimize the
@@ -189,7 +189,7 @@ functions with the @_semantics attribute until after all of the data-structure
specific optimizations are done. Unfortunately, this lengthens our optimization
pipeline.
-Please refer to the document “High-Level SIL Optimizations” for more details.
+Please refer to the document "High-Level SIL Optimizations" for more details.
### Instruction Invalidation in SIL
@@ -241,4 +241,4 @@ TODO.
### List of passes
-The updated list of passes is available in the file “Passes.def”.
+The updated list of passes is available in the file "Passes.def".
diff --git a/docs/Pattern Matching.rst b/docs/Pattern Matching.rst
index d0bfedd6c2dfd..08dc743faa3bc 100644
--- a/docs/Pattern Matching.rst
+++ b/docs/Pattern Matching.rst
@@ -141,7 +141,7 @@ provide patterns for the other kinds of types as well.
Selection statement
-------------------
-This is the main way we expect users to employ non-obvious pattern- matching. We
+This is the main way we expect users to employ non-obvious pattern-matching. We
obviously need something with statement children, so this has to be a
statement. That's also fine because this kind of full pattern match is very
syntactically heavyweight, and nobody would want to embed it in the middle of an
@@ -354,7 +354,7 @@ imperative language — in contrast to, say, a functional language where
you're in an expression and you need to produce a value — there's a
colorable argument that non-exhaustive matches should be okay. I
dislike this, however, and propose that it should be an error to
-make an non-exhaustive switch; people who want non-exhaustive matches
+make a non-exhaustive switch; people who want non-exhaustive matches
can explicitly put in default cases.
Exhaustiveness actually isn't that difficult to check, at least over
ADTs. It's also really the behavior that I would expect from the
@@ -689,13 +689,13 @@ interpreted according to what is found:
value must match the named type (according to the rules below for
'is' patterns). It is okay for this to be trivially true.
- In addition, there must be an non-empty arguments clause, and each
+ In addition, there must be a non-empty arguments clause, and each
element in the clause must have an identifier. For each element,
the identifier must correspond to a known property of the named
type, and the value of that property must satisfy the element
pattern.
-- If the name resolves to a enum element, then the dynamic type
+- If the name resolves to an enum element, then the dynamic type
of the matched value must match the enum type as discussed above,
and the value must be of the specified element. There must be
an arguments clause if and only if the element has a value type.
diff --git a/docs/Runtime.md b/docs/Runtime.md
new file mode 100644
index 0000000000000..198b49ed60c14
--- /dev/null
+++ b/docs/Runtime.md
@@ -0,0 +1,404 @@
+# The Swift Runtime
+
+This document describes the ABI interface to the Swift runtime, which provides
+the following core functionality for Swift programs:
+
+- memory management, including allocation and reference counting;
+- the runtime type system, including dynamic casting, generic instantiation,
+ and protocol conformance registration;
+
+It is intended to describe only the runtime interface that compiler-generated
+code should conform to, not details of how things are implemented.
+
+The final runtime interface is currently a work-in-progress; it is a goal of
+Swift 3 to stabilize it. This document attempts to describe both the current
+state of the runtime and the intended endpoint of the stable interface.
+Changes that are intended to be made before stabilization are marked with
+**ABI TODO**. Entry points that only exist on Darwin platforms with
+ObjC interop, and
+information that only pertains to ObjC interop, are marked **ObjC-only**.
+
+## Deprecated entry points
+
+Entry points in this section are intended to be removed or internalized before
+ABI stabilization.
+
+### Exported C++ symbols
+
+**ABI TODO**: Any exported C++ symbols are implementation details that are not
+intended to be part of the stable runtime interface.
+
+### swift\_ClassMirror\_count
+### swift\_ClassMirror\_quickLookObject
+### swift\_ClassMirror\_subscript
+### swift\_EnumMirror\_caseName
+### swift\_EnumMirror\_count
+### swift\_EnumMirror\_subscript
+### swift\_MagicMirrorData\_objcValue
+### swift\_MagicMirrorData\_objcValueType
+### swift\_MagicMirrorData\_summary
+### swift\_MagicMirrorData\_value
+### swift\_MagicMirrorData\_valueType
+### swift\_ObjCMirror\_count
+### swift\_ObjCMirror\_subscript
+### swift\_StructMirror\_count
+### swift\_StructMirror\_subscript
+### swift\_TupleMirror\_count
+### swift\_TupleMirror\_subscript
+### swift\_reflectAny
+
+**ABI TODO**: These functions are implementation details of the standard
+library `reflect` interface. They will be superseded by a low-level
+runtime reflection API.
+
+### swift\_stdlib\_demangleName
+
+```
+@convention(thin) (string: UnsafePointer,
+ length: UInt,
+ @out String) -> ()
+```
+
+Given a pointer to a Swift mangled symbol name as a byte string of `length`
+characters, returns the demangled name as a `Swift.String`.
+
+**ABI TODO**: Decouple from the standard library `Swift.String` implementation.
+Rename with a non-`stdlib` naming scheme.
+
+## Memory allocation
+
+### TODO
+
+```
+000000000001cb30 T _swift_allocBox
+000000000001c990 T _swift_allocObject
+000000000001ca60 T _swift_bufferAllocate
+000000000001ca70 T _swift_bufferAllocateOnStack
+000000000001ca80 T _swift_bufferDeallocateFromStack
+000000000001ca90 T _swift_bufferHeaderSize
+000000000001cd30 T _swift_deallocBox
+000000000001d490 T _swift_deallocClassInstance
+000000000001cd60 T _swift_deallocObject
+000000000001d4c0 T _swift_deallocPartialClassInstance
+000000000001d400 T _swift_rootObjCDealloc
+000000000001c960 T _swift_slowAlloc
+000000000001c980 T _swift_slowDealloc
+000000000001ce10 T _swift_projectBox
+000000000001ca00 T _swift_initStackObject
+```
+
+## Reference counting
+
+### TODO
+
+```
+0000000000027ba0 T _swift_bridgeObjectRelease
+0000000000027c50 T _swift_bridgeObjectRelease_n
+0000000000027b50 T _swift_bridgeObjectRetain
+0000000000027be0 T _swift_bridgeObjectRetain_n
+000000000001ce70 T _swift_release
+000000000001cee0 T _swift_release_n
+000000000001ce30 T _swift_retain
+000000000001ce50 T _swift_retain_n
+000000000001d140 T _swift_tryPin
+000000000001d240 T _swift_tryRetain
+0000000000027b10 T _swift_unknownRelease
+0000000000027a70 T _swift_unknownRelease_n
+0000000000027ad0 T _swift_unknownRetain
+0000000000027a10 T _swift_unknownRetain_n
+0000000000027d50 T _swift_unknownUnownedAssign
+00000000000280a0 T _swift_unknownUnownedCopyAssign
+0000000000027fd0 T _swift_unknownUnownedCopyInit
+0000000000027ed0 T _swift_unknownUnownedDestroy
+0000000000027cb0 T _swift_unknownUnownedInit
+0000000000027f20 T _swift_unknownUnownedLoadStrong
+00000000000281f0 T _swift_unknownUnownedTakeAssign
+0000000000028070 T _swift_unknownUnownedTakeInit
+0000000000027f70 T _swift_unknownUnownedTakeStrong
+00000000000282b0 T _swift_unknownWeakAssign
+0000000000028560 T _swift_unknownWeakCopyAssign
+00000000000284e0 T _swift_unknownWeakCopyInit
+00000000000283e0 T _swift_unknownWeakDestroy
+0000000000028270 T _swift_unknownWeakInit
+0000000000028420 T _swift_unknownWeakLoadStrong
+0000000000028610 T _swift_unknownWeakTakeAssign
+0000000000028520 T _swift_unknownWeakTakeInit
+0000000000028470 T _swift_unknownWeakTakeStrong
+000000000001d3c0 T _swift_unownedCheck
+000000000001cfb0 T _swift_unownedRelease
+000000000001d0a0 T _swift_unownedRelease_n
+000000000001cf70 T _swift_unownedRetain
+000000000001cf60 T _swift_unownedRetainCount
+000000000001d2b0 T _swift_unownedRetainStrong
+000000000001d310 T _swift_unownedRetainStrongAndRelease
+000000000001d060 T _swift_unownedRetain_n
+000000000001d1b0 T _swift_unpin
+000000000001ca20 T _swift_verifyEndOfLifetime
+000000000001d680 T _swift_weakAssign
+000000000001d830 T _swift_weakCopyAssign
+000000000001d790 T _swift_weakCopyInit
+000000000001d770 T _swift_weakDestroy
+000000000001d640 T _swift_weakInit
+000000000001d6d0 T _swift_weakLoadStrong
+000000000001d8b0 T _swift_weakTakeAssign
+000000000001d800 T _swift_weakTakeInit
+000000000001d710 T _swift_weakTakeStrong
+000000000002afe0 T _swift_isUniquelyReferencedNonObjC
+000000000002af50 T _swift_isUniquelyReferencedNonObjC_nonNull
+000000000002b060 T _swift_isUniquelyReferencedNonObjC_nonNull_bridgeObject
+000000000002b200 T _swift_isUniquelyReferencedOrPinnedNonObjC_nonNull
+000000000002b130 T _swift_isUniquelyReferencedOrPinnedNonObjC_nonNull_bridgeObject
+000000000002b2f0 T _swift_isUniquelyReferencedOrPinned_native
+000000000002b290 T _swift_isUniquelyReferencedOrPinned_nonNull_native
+000000000002af00 T _swift_isUniquelyReferenced_native
+000000000002aea0 T _swift_isUniquelyReferenced_nonNull_native
+000000000001d280 T _swift_isDeallocating
+```
+
+**ABI TODO**: `_unsynchronized` r/r entry points
+
+## Error objects
+
+The `ErrorType` existential type uses a special single-word, reference-
+counted representation.
+
+**ObjC-only**: The representation is internal to the runtime in order
+to provide efficient bridging with the platform `NSError` and `CFError`
+implementations. On non-ObjC platforms this bridging is unnecessary, and
+the error object interface could be made more fragile.
+
+To preserve the encapsulation of the ErrorType representation, and
+allow for future representation optimizations, the runtime provides
+special entry points for allocating, projecting, and reference
+counting error values.
+
+
+```
+00000000000268e0 T _swift_allocError
+0000000000026d50 T _swift_bridgeErrorTypeToNSError
+0000000000026900 T _swift_deallocError
+0000000000027120 T _swift_errorRelease
+0000000000027100 T _swift_errorRetain
+0000000000026b80 T _swift_getErrorValue
+```
+
+**ABI TODO**: `_unsynchronized` r/r entry points
+
+**ABI TODO**: `_n` r/r entry points
+
+## Initialization
+
+### swift_once
+
+```
+@convention(thin) (Builtin.RawPointer, @convention(thin) () -> ()) -> ()
+```
+
+Used to lazily initialize global variables. The first parameter must
+point to a word-sized memory location that was initialized to zero at
+process start. It is undefined behavior to reference memory that has
+been initialized to something other than zero or written to by anything other
+than `swift_once` in the current process's lifetime. The function referenced by
+the second parameter will have been run exactly once in the time between
+process start and the function returns.
+
+## Dynamic casting
+
+```
+0000000000001470 T _swift_dynamicCast
+0000000000000a60 T _swift_dynamicCastClass
+0000000000000ae0 T _swift_dynamicCastClassUnconditional
+0000000000028750 T _swift_dynamicCastForeignClass
+000000000002ae20 T _swift_dynamicCastForeignClassMetatype
+000000000002ae30 T _swift_dynamicCastForeignClassMetatypeUnconditional
+0000000000028760 T _swift_dynamicCastForeignClassUnconditional
+00000000000011c0 T _swift_dynamicCastMetatype
+0000000000000cf0 T _swift_dynamicCastMetatypeToObjectConditional
+0000000000000d20 T _swift_dynamicCastMetatypeToObjectUnconditional
+00000000000012e0 T _swift_dynamicCastMetatypeUnconditional
+00000000000286c0 T _swift_dynamicCastObjCClass
+0000000000028bd0 T _swift_dynamicCastObjCClassMetatype
+0000000000028c00 T _swift_dynamicCastObjCClassMetatypeUnconditional
+0000000000028700 T _swift_dynamicCastObjCClassUnconditional
+0000000000028af0 T _swift_dynamicCastObjCProtocolConditional
+0000000000028a50 T _swift_dynamicCastObjCProtocolUnconditional
+0000000000028960 T _swift_dynamicCastTypeToObjCProtocolConditional
+00000000000287d0 T _swift_dynamicCastTypeToObjCProtocolUnconditional
+0000000000000de0 T _swift_dynamicCastUnknownClass
+0000000000000fd0 T _swift_dynamicCastUnknownClassUnconditional
+```
+
+## Debugging
+
+```
+0000000000027140 T _swift_willThrow
+```
+
+## Objective-C Bridging
+
+**ObjC-only**.
+
+**ABI TODO**: Decouple from the runtime as much as possible. Much of this
+should be implementable in the standard library now.
+
+```
+0000000000003b60 T _swift_bridgeNonVerbatimFromObjectiveC
+0000000000003c80 T _swift_bridgeNonVerbatimFromObjectiveCConditional
+00000000000037e0 T _swift_bridgeNonVerbatimToObjectiveC
+00000000000039c0 T _swift_getBridgedNonVerbatimObjectiveCType
+0000000000003d90 T _swift_isBridgedNonVerbatimToObjectiveC
+```
+
+## Code generation
+
+Certain common code paths are implemented in the runtime as a code size
+optimization.
+
+```
+0000000000023a40 T _swift_assignExistentialWithCopy
+000000000001dbf0 T _swift_copyPOD
+000000000001c560 T _swift_getEnumCaseMultiPayload
+000000000001be60 T _swift_getEnumCaseSinglePayload
+000000000001c400 T _swift_storeEnumTagMultiPayload
+000000000001bf90 T _swift_storeEnumTagSinglePayload
+```
+
+## Type metadata lookup
+
+These functions look up metadata for types that potentially require runtime
+instantiation or initialization, including structural types, generics, classes,
+and metadata for imported C and Objective-C types.
+
+**ABI TODO**: Instantiation APIs under flux as part of resilience work. For
+nominal types, `getGenericMetadata` is likely to become an implementation
+detail used to implement resilient per-type metadata accessor functions.
+
+```
+0000000000023230 T _swift_getExistentialMetatypeMetadata
+0000000000023630 T _swift_getExistentialTypeMetadata
+0000000000023b90 T _swift_getForeignTypeMetadata
+000000000001ef30 T _swift_getFunctionTypeMetadata
+000000000001eed0 T _swift_getFunctionTypeMetadata1
+000000000001f1f0 T _swift_getFunctionTypeMetadata2
+000000000001f250 T _swift_getFunctionTypeMetadata3
+000000000001e940 T _swift_getGenericMetadata
+0000000000022fd0 T _swift_getMetatypeMetadata
+000000000001ec50 T _swift_getObjCClassMetadata
+000000000001e6b0 T _swift_getResilientMetadata
+0000000000022260 T _swift_getTupleTypeMetadata
+00000000000225a0 T _swift_getTupleTypeMetadata2
+00000000000225d0 T _swift_getTupleTypeMetadata3
+0000000000028bc0 T _swift_getInitializedObjCClass
+```
+
+**ABI TODO**: Fast entry points for `getExistential*TypeMetadata1-3`. Static
+metadata for `Any` and `AnyObject` is probably worth considering too.
+
+## Type metadata initialization
+
+Calls to these entry points are emitted when instantiating type metadata at
+runtime.
+
+**ABI TODO**: Initialization APIs under flux as part of resilience work.
+
+```
+000000000001e3e0 T _swift_allocateGenericClassMetadata
+000000000001e620 T _swift_allocateGenericValueMetadata
+0000000000022be0 T _swift_initClassMetadata_UniversalStrategy
+000000000001c100 T _swift_initEnumMetadataMultiPayload
+000000000001bd60 T _swift_initEnumValueWitnessTableSinglePayload
+0000000000022a20 T _swift_initStructMetadata_UniversalStrategy
+0000000000024230 T _swift_initializeSuperclass
+0000000000028b60 T _swift_instantiateObjCClass
+```
+
+## Metatypes
+
+```
+0000000000000b60 T _swift_getDynamicType
+0000000000022fb0 T _swift_getObjectType
+00000000000006f0 T _swift_getTypeName
+00000000000040c0 T _swift_isClassType
+0000000000003f50 T _swift_isClassOrObjCExistentialType
+0000000000004130 T _swift_isOptionalType
+00000000000279f0 T _swift_objc_class_usesNativeSwiftReferenceCounting
+000000000002b340 T _swift_objc_class_unknownGetInstanceExtents
+000000000002b350 T _swift_class_getInstanceExtents
+0000000000004080 T _swift_class_getSuperclass
+```
+
+**ABI TODO**: getTypeByName entry point.
+
+**ABI TODO**: Should have a `getTypeKind` entry point with well-defined enum
+constants to supersede `swift_is*Type`.
+
+**ABI TODO**: Rename class metadata queries with a consistent naming scheme.
+
+## Protocol conformance lookup
+
+```
+0000000000002ef0 T _swift_registerProtocolConformances
+0000000000003060 T _swift_conformsToProtocol
+```
+
+## Error reporting
+
+```
+000000000001c7d0 T _swift_reportError
+000000000001c940 T _swift_deletedMethodError
+```
+
+## Standard metadata
+
+The Swift runtime exports standard metadata objects for `Builtin` types
+as well as standard value witness tables that can be freely adopted by
+types with common layout attributes. Note that, unlike public-facing types,
+the runtime does not guarantee a 1:1 mapping of Builtin types to metadata
+objects, and will reuse metadata objects to represent builtins with the same
+layout characteristics.
+
+```
+000000000004faa8 S __TMBB
+000000000004fab8 S __TMBO
+000000000004f9f8 S __TMBb
+000000000004f9c8 S __TMBi128_
+000000000004f998 S __TMBi16_
+000000000004f9d8 S __TMBi256_
+000000000004f9a8 S __TMBi32_
+000000000004f9b8 S __TMBi64_
+000000000004f988 S __TMBi8_
+000000000004f9e8 S __TMBo
+000000000004fac8 S __TMT_
+000000000004f568 S __TWVBO
+000000000004f4b0 S __TWVBb
+000000000004f0a8 S __TWVBi128_
+000000000004eec8 S __TWVBi16_
+000000000004f148 S __TWVBi256_
+000000000004ef68 S __TWVBi32_
+000000000004f008 S __TWVBi64_
+000000000004ee28 S __TWVBi8_
+000000000004f1e8 S __TWVBo
+000000000004f778 S __TWVFT_T_
+000000000004f3f8 S __TWVMBo
+000000000004f8e8 S __TWVT_
+000000000004f830 S __TWVXfT_T_
+000000000004f620 S __TWVXoBO
+000000000004f2a0 S __TWVXoBo
+000000000004f6d8 S __TWVXwGSqBO_
+000000000004f358 S __TWVXwGSqBo_
+```
+
+## Tasks
+
+- Moving to per-type instantiation functions instead of using
+ `getGenericMetadata` directly
+
+- `swift_objc_` naming convention for ObjC
+
+- Alternative ABIs for retain/release
+
+- Unsynchronized retain/release
+
+- Nonnull retain/release
+
+- Decouple dynamic casting, bridging, and reflection from the standard library
diff --git a/docs/SIL.rst b/docs/SIL.rst
index fd17000af32fb..2d41071bb3288 100644
--- a/docs/SIL.rst
+++ b/docs/SIL.rst
@@ -341,8 +341,6 @@ The type of a value in SIL shall be:
- the address of a legal SIL type, ``$*T``, or
-- the address of local storage of a legal SIL type, ``$*@local_storage T``.
-
A type ``T`` is a *legal SIL type* if:
- it is a function type which satisfies the constraints (below) on
@@ -386,22 +384,6 @@ type. Values of address type thus cannot be allocated, loaded, or stored
Addresses can be passed as arguments to functions if the corresponding
parameter is indirect. They cannot be returned.
-Local Storage Types
-```````````````````
-
-The *address of local storage for T* ``$*@local_storage T`` is a
-handle to a stack allocation of a variable of type ``$T``.
-
-For many types, the handle for a stack allocation is simply the
-allocated address itself. However, if a type is runtime-sized, the
-compiler must emit code to potentially dynamically allocate memory.
-SIL abstracts over such differences by using values of local-storage
-type as the first result of ``alloc_stack`` and the operand of
-``dealloc_stack``.
-
-Local-storage address types are not *first-class* in the same sense
-that address types are not first-class.
-
Box Types
`````````
@@ -424,7 +406,7 @@ number of ways:
- A SIL function type declares its conventional treatment of its
context value:
- - If it is ``@thin``, the function requires no context value.
+ - If it is ``@convention(thin)``, the function requires no context value.
- If it is ``@callee_owned``, the context value is treated as an
owned direct parameter.
@@ -594,7 +576,7 @@ generic constraints:
* Non-class protocol types
* @weak types
- Values of address-only type (“address-only values”) must reside in
+ Values of address-only type ("address-only values") must reside in
memory and can only be referenced in SIL by address. Addresses of
address-only values cannot be loaded from or stored to. SIL provides
special instructions for indirectly manipulating address-only
@@ -604,7 +586,7 @@ Some additional meaningful categories of type:
- A *heap object reference* type is a type whose representation consists of a
single strong-reference-counted pointer. This includes all class types,
- the ``Builtin.ObjectPointer`` and ``Builtin.ObjCPointer`` types, and
+ the ``Builtin.NativeObject`` and ``Builtin.UnknownObject`` types, and
archetypes that conform to one or more class protocols.
- A *reference type* is more general in that its low-level representation may
include additional global pointers alongside a strong-reference-counted
@@ -721,7 +703,7 @@ Values and Operands
sil-identifier ::= [A-Za-z_0-9]+
sil-value-name ::= '%' sil-identifier
- sil-value ::= sil-value-name ('#' [0-9]+)?
+ sil-value ::= sil-value-name
sil-value ::= 'undef'
sil-operand ::= sil-value ':' sil-type
@@ -729,17 +711,6 @@ SIL values are introduced with the ``%`` sigil and named by an
alphanumeric identifier, which references the instruction or basic block
argument that produces the value. SIL values may also refer to the keyword
'undef', which is a value of undefined contents.
-In SIL, a single instruction may produce multiple values. Operands that refer
-to multiple-value instructions choose the value by following the ``%name`` with
-``#`` and the index of the value. For example::
-
- // alloc_box produces two values--the refcounted pointer %box#0, and the
- // value address %box#1
- %box = alloc_box $Int64
- // Refer to the refcounted pointer
- strong_retain %box#0 : $@box Int64
- // Refer to the address
- store %value to %box#1 : $*Int64
Unlike LLVM IR, SIL instructions that take value operands *only* accept
value operands. References to literal constants, functions, global variables, or
@@ -864,16 +835,17 @@ partial application level. For a curried function declaration::
The declaration references and types for the different uncurry levels are as
follows::
- #example.foo!0 : $@thin (x:A) -> (y:B) -> (z:C) -> D
- #example.foo!1 : $@thin ((y:B), (x:A)) -> (z:C) -> D
- #example.foo!2 : $@thin ((z:C), (y:B), (x:A)) -> D
+ #example.foo!0 : $@convention(thin) (x:A) -> (y:B) -> (z:C) -> D
+ #example.foo!1 : $@convention(thin) ((y:B), (x:A)) -> (z:C) -> D
+ #example.foo!2 : $@convention(thin) ((z:C), (y:B), (x:A)) -> D
The deepest uncurry level is referred to as the **natural uncurry level**. In
this specific example, the reference at the natural uncurry level is
``#example.foo!2``. Note that the uncurried argument clauses are composed
right-to-left, as specified in the `calling convention`_. For uncurry levels
-less than the uncurry level, the entry point itself is ``@thin`` but returns a
-thick function value carrying the partially applied arguments for its context.
+less than the uncurry level, the entry point itself is ``@convention(thin)`` but
+returns a thick function value carrying the partially applied arguments for its
+context.
`Dynamic dispatch`_ instructions such as ``class method`` require their method
declaration reference to be uncurried to at least uncurry level 1 (which applies
@@ -1007,9 +979,9 @@ implements the method for that class::
func bas()
}
- sil @A_foo : $@thin (@owned A) -> ()
- sil @A_bar : $@thin (@owned A) -> ()
- sil @A_bas : $@thin (@owned A) -> ()
+ sil @A_foo : $@convention(thin) (@owned A) -> ()
+ sil @A_bar : $@convention(thin) (@owned A) -> ()
+ sil @A_bas : $@convention(thin) (@owned A) -> ()
sil_vtable A {
#A.foo!1: @A_foo
@@ -1021,7 +993,7 @@ implements the method for that class::
func bar()
}
- sil @B_bar : $@thin (@owned B) -> ()
+ sil @B_bar : $@convention(thin) (@owned B) -> ()
sil_vtable B {
#A.foo!1: @A_foo
@@ -1033,7 +1005,7 @@ implements the method for that class::
func bas()
}
- sil @C_bas : $@thin (@owned C) -> ()
+ sil @C_bas : $@convention(thin) (@owned C) -> ()
sil_vtable C {
#A.foo!1: @A_foo
@@ -1124,7 +1096,12 @@ Global Variables
SIL representation of a global variable.
-FIXME: to be written.
+Global variable access is performed by the ``alloc_global`` and ``global_addr``
+SIL instructions. Prior to performing any access on the global, the
+``alloc_global`` instruction must be performed to initialize the storage.
+
+Once a global's storage has been initialized, ``global_addr`` is used to
+project the value.
Dataflow Errors
---------------
@@ -1192,8 +1169,8 @@ Calling Convention
This section describes how Swift functions are emitted in SIL.
-Swift Calling Convention @cc(swift)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Swift Calling Convention @convention(swift)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Swift calling convention is the one used by default for native Swift
functions.
@@ -1388,13 +1365,13 @@ gets lowered to SIL as::
sil @inout : $(@inout Int) -> () {
entry(%x : $*Int):
- %1 = integer_literal 1 : $Int
+ %1 = integer_literal $Int, 1
store %1 to %x
return
}
-Swift Method Calling Convention @cc(method)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Swift Method Calling Convention @convention(method)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The method calling convention is currently identical to the freestanding
function convention. Methods are considered to be curried functions, taking
@@ -1408,8 +1385,8 @@ passed last::
sil @Foo_method_1 : $((x : Int), @inout Foo) -> Int { ... }
-Witness Method Calling Convention @cc(witness_method)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Witness Method Calling Convention @convention(witness_method)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The witness method calling convention is used by protocol witness methods in
`witness tables`_. It is identical to the ``method`` calling convention
@@ -1420,8 +1397,8 @@ witnesses must be polymorphically dispatchable on their ``Self`` type,
the ``Self``-related metadata for a witness must be passed in a maximally
abstracted manner.
-C Calling Convention @cc(cdecl)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+C Calling Convention @convention(c)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In Swift's C module importer, C types are always mapped to Swift types
considered trivial by SIL. SIL does not concern itself with platform
@@ -1431,8 +1408,8 @@ platform calling convention.
SIL (and therefore Swift) cannot currently invoke variadic C functions.
-Objective-C Calling Convention @cc(objc_method)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Objective-C Calling Convention @convention(objc_method)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reference Counts
````````````````
@@ -1523,7 +1500,7 @@ return a class reference::
bb0(%0 : $MyClass):
%1 = class_method %0 : $MyClass, #MyClass.foo!1
- %2 = apply %1(%0) : $@cc(method) @thin (@guaranteed MyClass) -> @owned MyOtherClass
+ %2 = apply %1(%0) : $@convention(method) (@guaranteed MyClass) -> @owned MyOtherClass
// use of %2 goes here; no use of %1
strong_release %2 : $MyOtherClass
strong_release %1 : $MyClass
@@ -1558,8 +1535,8 @@ A value ``%1`` is said to be *value-dependent* on a value ``%0`` if:
- ``%1`` is the result of ``mark_dependence`` and ``%0`` is either of
the operands.
-- ``%1`` is the value address of an allocation instruction of which
- ``%0`` is the local storage token or box reference.
+- ``%1`` is the value address of a box allocation instruction of which
+ ``%0`` is the box reference.
- ``%1`` is the result of a ``struct``, ``tuple``, or ``enum``
instruction and ``%0`` is an operand.
@@ -1633,13 +1610,15 @@ alloc_stack
sil-instruction ::= 'alloc_stack' sil-type (',' debug-var-attr)*
%1 = alloc_stack $T
- // %1#0 has type $*@local_storage T
- // %1#1 has type $*T
+ // %1 has type $*T
Allocates uninitialized memory that is sufficiently aligned on the stack
-to contain a value of type ``T``. The first result of the instruction
-is a local-storage handle suitable for passing to ``dealloc_stack``.
-The second result of the instruction is the address of the allocated memory.
+to contain a value of type ``T``. The result of the instruction is the address
+of the allocated memory.
+
+If a type is runtime-sized, the compiler must emit code to potentially
+dynamically allocate memory. So there is no guarantee that the allocated
+memory is really located on the stack.
``alloc_stack`` marks the start of the lifetime of the value; the
allocation must be balanced with a ``dealloc_stack`` instruction to
@@ -1700,15 +1679,13 @@ alloc_box
sil-instruction ::= 'alloc_box' sil-type (',' debug-var-attr)*
%1 = alloc_box $T
- // %1 has two values:
- // %1#0 has type $@box T
- // %1#1 has type $*T
+ // %1 has type $@box T
Allocates a reference-counted ``@box`` on the heap large enough to hold a value
of type ``T``, along with a retain count and any other metadata required by the
-runtime. The result of the instruction is a two-value operand; the first value
-is the reference-counted ``@box`` reference that owns the box, and the second
-value is the address of the value inside the box.
+runtime. The result of the instruction is the reference-counted ``@box``
+reference that owns the box. The ``project_box`` instruction is used to retrieve
+the address of the value inside the box.
The box will be initialized with a retain count of 1; the storage will be
uninitialized. The box owns the contained value, and releasing it to a retain
@@ -1734,22 +1711,36 @@ behavior if the value buffer is currently allocated.
The type operand must be a lowered object type.
+alloc_global
+````````````
+
+::
+
+ sil-instruction ::= 'alloc_global' sil-global-name
+
+ alloc_global @foo
+
+Initialize the storage for a global variable. This instruction has
+undefined behavior if the global variable has already been initialized.
+
+The type operand must be a lowered object type.
+
dealloc_stack
`````````````
::
sil-instruction ::= 'dealloc_stack' sil-operand
- dealloc_stack %0 : $*@local_storage T
- // %0 must be of a local-storage $*@local_storage T type
+ dealloc_stack %0 : $*T
+ // %0 must be of $*T type
Deallocates memory previously allocated by ``alloc_stack``. The
allocated value in memory must be uninitialized or destroyed prior to
being deallocated. This instruction marks the end of the lifetime for
the value created by the corresponding ``alloc_stack`` instruction. The operand
-must be the ``@local_storage`` of the shallowest live ``alloc_stack``
-allocation preceding the deallocation. In other words, deallocations must be
-in last-in, first-out stack order.
+must be the shallowest live ``alloc_stack`` allocation preceding the
+deallocation. In other words, deallocations must be in last-in, first-out
+stack order.
dealloc_box
```````````
@@ -2392,14 +2383,14 @@ function_ref
sil-instruction ::= 'function_ref' sil-function-name ':' sil-type
- %1 = function_ref @function : $@thin T -> U
- // $@thin T -> U must be a thin function type
+ %1 = function_ref @function : $@convention(thin) T -> U
+ // $@convention(thin) T -> U must be a thin function type
// %1 has type $T -> U
Creates a reference to a SIL function.
global_addr
-```````````````
+```````````
::
@@ -2407,7 +2398,10 @@ global_addr
%1 = global_addr @foo : $*Builtin.Word
-Creates a reference to the address of a global variable.
+Creates a reference to the address of a global variable which has been
+previously initialized by ``alloc_global``. It is undefined behavior to
+perform this operation on a global variable which has not been
+initialized.
integer_literal
```````````````
@@ -2445,6 +2439,7 @@ string_literal
sil-instruction ::= 'string_literal' encoding string-literal
encoding ::= 'utf8'
encoding ::= 'utf16'
+ encoding ::= 'objc_selector'
%1 = string_literal "asdf"
// %1 has type $Builtin.RawPointer
@@ -2452,7 +2447,10 @@ string_literal
Creates a reference to a string in the global string table. The result
is a pointer to the data. The referenced string is always null-terminated. The
string literal value is specified using Swift's string
-literal syntax (though ``\()`` interpolations are not allowed).
+literal syntax (though ``\()`` interpolations are not allowed). When
+the encoding is ``objc_selector``, the string literal produces a
+reference to a UTF-8-encoded Objective-C selector in the Objective-C
+method name segment.
Dynamic Dispatch
~~~~~~~~~~~~~~~~
@@ -2483,7 +2481,7 @@ class_method
sil-instruction ::= 'class_method' sil-method-attributes?
sil-operand ',' sil-decl-ref ':' sil-type
- %1 = class_method %0 : $T, #T.method!1 : $@thin U -> V
+ %1 = class_method %0 : $T, #T.method!1 : $@convention(thin) U -> V
// %0 must be of a class type or class metatype $T
// #T.method!1 must be a reference to a dynamically-dispatched method of T or
// of one of its superclasses, at uncurry level >= 1
@@ -2512,11 +2510,11 @@ super_method
sil-instruction ::= 'super_method' sil-method-attributes?
sil-operand ',' sil-decl-ref ':' sil-type
- %1 = super_method %0 : $T, #Super.method!1.foreign : $@thin U -> V
+ %1 = super_method %0 : $T, #Super.method!1.foreign : $@convention(thin) U -> V
// %0 must be of a non-root class type or class metatype $T
// #Super.method!1.foreign must be a reference to an ObjC method of T's
// superclass or of one of its ancestor classes, at uncurry level >= 1
- // %1 will be of type $@thin U -> V
+ // %1 will be of type $@convention(thin) U -> V
Looks up a method in the superclass of a class or class metatype instance.
Note that for native Swift methods, ``super.method`` calls are statically
@@ -2532,13 +2530,13 @@ witness_method
sil-type ',' sil-decl-ref ':' sil-type
%1 = witness_method $T, #Proto.method!1 \
- : $@thin @cc(witness_method) U -> V
+ : $@convention(witness_method) U -> V
// $T must be an archetype
// #Proto.method!1 must be a reference to a method of one of the protocol
// constraints on T
// U -> V must be the type of the referenced method,
// generic on Self
- // %1 will be of type $@thin U -> V
+ // %1 will be of type $@convention(thin) U -> V
Looks up the implementation of a protocol method for a generic type variable
constrained by that protocol. The result will be generic on the ``Self``
@@ -2553,20 +2551,20 @@ dynamic_method
sil-instruction ::= 'dynamic_method' sil-method-attributes?
sil-operand ',' sil-decl-ref ':' sil-type
- %1 = dynamic_method %0 : $P, #X.method!1 : $@thin U -> V
+ %1 = dynamic_method %0 : $P, #X.method!1 : $@convention(thin) U -> V
// %0 must be of a protocol or protocol composition type $P,
// where $P contains the Swift.DynamicLookup protocol
// #X.method!1 must be a reference to an @objc method of any class
// or protocol type
//
- // The "self" argument of the method type $@thin U -> V must be
- // Builtin.ObjCPointer
+ // The "self" argument of the method type $@convention(thin) U -> V must be
+ // Builtin.UnknownObject
Looks up the implementation of an Objective-C method with the same
selector as the named method for the dynamic type of the
value inside an existential container. The "self" operand of the result
function value is represented using an opaque type, the value for which must
-be projected out as a value of type ``Builtin.ObjCPointer``.
+be projected out as a value of type ``Builtin.UnknownObject``.
It is undefined behavior if the dynamic type of the operand does not
have an implementation for the Objective-C method with the selector to
@@ -2605,7 +2603,7 @@ apply
// %1, %2, etc. must be of the argument types $A, $B, etc.
// %r will be of the return type $R
- %r = apply %0(%1, %2, ...) : $(T, U, ...) -> R
+ %r = apply %0(%1, %2, ...) : $(T, U, ...) -> R
// %0 must be of a polymorphic function type $(T, U, ...) -> R
// %1, %2, etc. must be of the argument types after substitution $A, $B, etc.
// %r will be of the substituted return type $R'
@@ -2649,7 +2647,7 @@ partial_apply
// of the tail part of the argument tuple of %0
// %c will be of the partially-applied thick function type (Z...) -> R
- %c = partial_apply %0(%1, %2, ...) : $(Z..., T, U, ...) -> R
+ %c = partial_apply %0(%1, %2, ...) : $(Z..., T, U, ...) -> R
// %0 must be of a polymorphic function type $(T, U, ...) -> R
// %1, %2, etc. must be of the argument types after substitution $A, $B, etc.
// of the tail part of the argument tuple of %0
@@ -2685,28 +2683,30 @@ curried function in Swift::
emits curry thunks in SIL as follows (retains and releases omitted for
clarity)::
- func @foo : $@thin A -> B -> C -> D -> E {
+ func @foo : $@convention(thin) A -> B -> C -> D -> E {
entry(%a : $A):
- %foo_1 = function_ref @foo_1 : $@thin (B, A) -> C -> D -> E
- %thunk = partial_apply %foo_1(%a) : $@thin (B, A) -> C -> D -> E
+ %foo_1 = function_ref @foo_1 : $@convention(thin) (B, A) -> C -> D -> E
+ %thunk = partial_apply %foo_1(%a) : $@convention(thin) (B, A) -> C -> D -> E
return %thunk : $B -> C -> D -> E
}
- func @foo_1 : $@thin (B, A) -> C -> D -> E {
+ func @foo_1 : $@convention(thin) (B, A) -> C -> D -> E {
entry(%b : $B, %a : $A):
- %foo_2 = function_ref @foo_2 : $@thin (C, B, A) -> D -> E
- %thunk = partial_apply %foo_2(%b, %a) : $@thin (C, B, A) -> D -> E
+ %foo_2 = function_ref @foo_2 : $@convention(thin) (C, B, A) -> D -> E
+ %thunk = partial_apply %foo_2(%b, %a) \
+ : $@convention(thin) (C, B, A) -> D -> E
return %thunk : $(B, A) -> C -> D -> E
}
- func @foo_2 : $@thin (C, B, A) -> D -> E {
+ func @foo_2 : $@convention(thin) (C, B, A) -> D -> E {
entry(%c : $C, %b : $B, %a : $A):
- %foo_3 = function_ref @foo_3 : $@thin (D, C, B, A) -> E
- %thunk = partial_apply %foo_3(%c, %b, %a) : $@thin (D, C, B, A) -> E
+ %foo_3 = function_ref @foo_3 : $@convention(thin) (D, C, B, A) -> E
+ %thunk = partial_apply %foo_3(%c, %b, %a) \
+ : $@convention(thin) (D, C, B, A) -> E
return %thunk : $(C, B, A) -> D -> E
}
- func @foo_3 : $@thin (D, C, B, A) -> E {
+ func @foo_3 : $@convention(thin) (D, C, B, A) -> E {
entry(%d : $D, %c : $C, %b : $B, %a : $A):
// ... body of foo ...
}
@@ -2723,21 +2723,22 @@ following example::
lowers to an uncurried entry point and is curried in the enclosing function::
- func @bar : $@thin (Int, @box Int, *Int) -> Int {
+ func @bar : $@convention(thin) (Int, @box Int, *Int) -> Int {
entry(%y : $Int, %x_box : $@box Int, %x_address : $*Int):
// ... body of bar ...
}
- func @foo : $@thin Int -> Int {
+ func @foo : $@convention(thin) Int -> Int {
entry(%x : $Int):
// Create a box for the 'x' variable
%x_box = alloc_box $Int
- store %x to %x_box#1 : $*Int
+ %x_addr = project_box %x_box : $@box Int
+ store %x to %x_addr : $*Int
// Create the bar closure
%bar_uncurried = function_ref @bar : $(Int, Int) -> Int
- %bar = partial_apply %bar_uncurried(%x_box#0, %x_box#1) \
- : $(Int, Builtin.ObjectPointer, *Int) -> Int
+ %bar = partial_apply %bar_uncurried(%x_box, %x_addr) \
+ : $(Int, Builtin.NativeObject, *Int) -> Int
// Apply it
%1 = integer_literal $Int, 1
@@ -2775,8 +2776,8 @@ metatype
sil-instruction ::= 'metatype' sil-type
- %1 = metatype $T.metatype
- // %1 has type $T.metatype
+ %1 = metatype $T.Type
+ // %1 has type $T.Type
Creates a reference to the metatype object for type ``T``.
@@ -2786,9 +2787,9 @@ value_metatype
sil-instruction ::= 'value_metatype' sil-type ',' sil-operand
- %1 = value_metatype $T.metatype, %0 : $T
+ %1 = value_metatype $T.Type, %0 : $T
// %0 must be a value or address of type $T
- // %1 will be of type $T.metatype
+ // %1 will be of type $T.Type
Obtains a reference to the dynamic metatype of the value ``%0``.
@@ -2798,10 +2799,10 @@ existential_metatype
sil-instruction ::= 'existential_metatype' sil-type ',' sil-operand
- %1 = existential_metatype $P.metatype, %0 : $P
+ %1 = existential_metatype $P.Type, %0 : $P
// %0 must be a value of class protocol or protocol composition
// type $P, or an address of address-only protocol type $*P
- // %1 will be a $P.metatype value referencing the metatype of the
+ // %1 will be a $P.Type value referencing the metatype of the
// concrete value inside %0
Obtains the metatype of the concrete value
@@ -3001,16 +3002,16 @@ the enum is injected with an `inject_enum_addr`_ instruction::
sil @init_with_data : $(AddressOnlyType) -> AddressOnlyEnum {
entry(%0 : $*AddressOnlyEnum, %1 : $*AddressOnlyType):
// Store the data argument for the case.
- %2 = init_enum_data_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData
+ %2 = init_enum_data_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData!enumelt.1
copy_addr [take] %2 to [initialization] %1 : $*AddressOnlyType
// Inject the tag.
- inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData
+ inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.HasData!enumelt.1
return
}
sil @init_without_data : $() -> AddressOnlyEnum {
// No data. We only need to inject the tag.
- inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.NoData
+ inject_enum_addr %0 : $*AddressOnlyEnum, #AddressOnlyEnum.NoData!enumelt
return
}
@@ -3021,7 +3022,7 @@ discriminator and is done with the `switch_enum`_ terminator::
sil @switch_foo : $(Foo) -> () {
entry(%foo : $Foo):
- switch_enum %foo : $Foo, case #Foo.A: a_dest, case #Foo.B: b_dest
+ switch_enum %foo : $Foo, case #Foo.A!enumelt.1: a_dest, case #Foo.B!enumelt.1: b_dest
a_dest(%a : $Int):
/* use %a */
@@ -3038,14 +3039,15 @@ projecting the enum value with `unchecked_take_enum_data_addr`_::
sil @switch_foo : $ (Foo) -> () {
entry(%foo : $*Foo):
- switch_enum_addr %foo : $*Foo, case #Foo.A: a_dest, case #Foo.B: b_dest
+ switch_enum_addr %foo : $*Foo, case #Foo.A!enumelt.1: a_dest, \
+ case #Foo.B!enumelt.1: b_dest
a_dest:
- %a = unchecked_take_enum_data_addr %foo : $*Foo, #Foo.A
+ %a = unchecked_take_enum_data_addr %foo : $*Foo, #Foo.A!enumelt.1
/* use %a */
b_dest:
- %b = unchecked_take_enum_data_addr %foo : $*Foo, #Foo.B
+ %b = unchecked_take_enum_data_addr %foo : $*Foo, #Foo.B!enumelt.1
/* use %b */
}
@@ -3055,8 +3057,8 @@ enum
sil-instruction ::= 'enum' sil-type ',' sil-decl-ref (',' sil-operand)?
- %1 = enum $U, #U.EmptyCase
- %1 = enum $U, #U.DataCase, %0 : $T
+ %1 = enum $U, #U.EmptyCase!enumelt
+ %1 = enum $U, #U.DataCase!enumelt.1, %0 : $T
// $U must be an enum type
// #U.DataCase or #U.EmptyCase must be a case of enum $U
// If #U.Case has a data type $T, %0 must be a value of type $T
@@ -3072,7 +3074,7 @@ unchecked_enum_data
sil-instruction ::= 'unchecked_enum_data' sil-operand ',' sil-decl-ref
- %1 = unchecked_enum_data %0 : $U, #U.DataCase
+ %1 = unchecked_enum_data %0 : $U, #U.DataCase!enumelt.1
// $U must be an enum type
// #U.DataCase must be a case of enum $U with data
// %1 will be of object type $T for the data type of case U.DataCase
@@ -3087,7 +3089,7 @@ init_enum_data_addr
sil-instruction ::= 'init_enum_data_addr' sil-operand ',' sil-decl-ref
- %1 = init_enum_data_addr %0 : $*U, #U.DataCase
+ %1 = init_enum_data_addr %0 : $*U, #U.DataCase!enumelt.1
// $U must be an enum type
// #U.DataCase must be a case of enum $U with data
// %1 will be of address type $*T for the data type of case U.DataCase
@@ -3109,7 +3111,7 @@ inject_enum_addr
sil-instruction ::= 'inject_enum_addr' sil-operand ',' sil-decl-ref
- inject_enum_addr %0 : $*U, #U.Case
+ inject_enum_addr %0 : $*U, #U.Case!enumelt
// $U must be an enum type
// #U.Case must be a case of enum $U
// %0 will be overlaid with the tag for #U.Case
@@ -3129,7 +3131,7 @@ unchecked_take_enum_data_addr
sil-instruction ::= 'unchecked_take_enum_data_addr' sil-operand ',' sil-decl-ref
- %1 = unchecked_take_enum_data_addr %0 : $*U, #U.DataCase
+ %1 = unchecked_take_enum_data_addr %0 : $*U, #U.DataCase!enumelt.1
// $U must be an enum type
// #U.DataCase must be a case of enum $U with data
// %1 will be of address type $*T for the data type of case U.DataCase
@@ -3156,8 +3158,8 @@ select_enum
':' sil-type
%n = select_enum %0 : $U, \
- case #U.Case1: %1, \
- case #U.Case2: %2, /* ... */ \
+ case #U.Case1!enumelt: %1, \
+ case #U.Case2!enumelt: %2, /* ... */ \
default %3 : $T
// $U must be an enum type
@@ -3170,8 +3172,8 @@ enum value. This is equivalent to a trivial `switch_enum`_ branch sequence::
entry:
switch_enum %0 : $U, \
- case #U.Case1: bb1, \
- case #U.Case2: bb2, /* ... */ \
+ case #U.Case1!enumelt: bb1, \
+ case #U.Case2!enumelt: bb2, /* ... */ \
default bb_default
bb1:
br cont(%1 : $T) // value for #U.Case1
@@ -3195,8 +3197,8 @@ select_enum_addr
':' sil-type
%n = select_enum_addr %0 : $*U, \
- case #U.Case1: %1, \
- case #U.Case2: %2, /* ... */ \
+ case #U.Case1!enumelt: %1, \
+ case #U.Case2!enumelt: %2, /* ... */ \
default %3 : $T
// %0 must be the address of an enum type $*U
@@ -3265,6 +3267,7 @@ container may use one of several representations:
containers:
* `alloc_existential_box`_
+ * `project_existential_box`_
* `open_existential_box`_
* `dealloc_existential_box`_
@@ -3279,8 +3282,9 @@ more expensive ``alloc_existential_box``::
// The slow general way to form an ErrorType, allocating a box and
// storing to its value buffer:
%error1 = alloc_existential_box $ErrorType, $NSError
+ %addr = project_existential_box $NSError in %error1 : $ErrorType
strong_retain %nserror: $NSError
- store %nserror to %error1#1 : $NSError
+ store %nserror to %addr : $NSError
// The fast path supported for NSError:
strong_retain %nserror: $NSError
@@ -3422,7 +3426,7 @@ alloc_existential_box
// $P must be a protocol or protocol composition type with boxed
// representation
// $T must be an AST type that conforms to P
- // %1#0 will be of type $P
+ // %1 will be of type $P
// %1#1 will be of type $*T', where T' is the most abstracted lowering of T
Allocates a boxed existential container of type ``$P`` with space to hold a
@@ -3430,8 +3434,25 @@ value of type ``$T'``. The box is not fully initialized until a valid value
has been stored into the box. If the box must be deallocated before it is
fully initialized, ``dealloc_existential_box`` must be used. A fully
initialized box can be ``retain``-ed and ``release``-d like any
-reference-counted type. The address ``%0#1`` is dependent on the lifetime of
-the owner reference ``%0#0``.
+reference-counted type. The ``project_existential_box`` instruction is used
+to retrieve the address of the value inside the container.
+
+project_existential_box
+```````````````````````
+::
+
+ sil-instruction ::= 'project_existential_box' sil-type 'in' sil-operand
+
+ %1 = project_existential_box $T in %0 : $P
+ // %0 must be a value of boxed protocol or protocol composition type $P
+ // $T must be the most abstracted lowering of the AST type for which the box
+ // was allocated
+ // %1 will be of type $*T
+
+Projects the address of the value inside a boxed existential container.
+The address is dependent on the lifetime of the owner reference ``%0``.
+It is undefined behavior if the concrete type ``$T`` is not the same type for
+which the box was allocated with ``alloc_existential_box``.
open_existential_box
````````````````````
@@ -3626,7 +3647,7 @@ ref_to_raw_pointer
sil-instruction ::= 'ref_to_raw_pointer' sil-operand 'to' sil-type
%1 = ref_to_raw_pointer %0 : $C to $Builtin.RawPointer
- // $C must be a class type, or Builtin.ObjectPointer, or Builtin.ObjCPointer
+ // $C must be a class type, or Builtin.NativeObject, or Builtin.UnknownObject
// %1 will be of type $Builtin.RawPointer
Converts a heap object reference to a ``Builtin.RawPointer``. The ``RawPointer``
@@ -3641,7 +3662,7 @@ raw_pointer_to_ref
sil-instruction ::= 'raw_pointer_to_ref' sil-operand 'to' sil-type
%1 = raw_pointer_to_ref %0 : $Builtin.RawPointer to $C
- // $C must be a class type, or Builtin.ObjectPointer, or Builtin.ObjCPointer
+ // $C must be a class type, or Builtin.NativeObject, or Builtin.UnknownObject
// %1 will be of type $C
Converts a ``Builtin.RawPointer`` back to a heap object reference. Casting
@@ -3808,10 +3829,10 @@ thick_to_objc_metatype
sil-instruction ::= 'thick_to_objc_metatype' sil-operand 'to' sil-type
- %1 = thick_to_objc_metatype %0 : $@thick T.metatype to $@objc_metatype T.metatype
- // %0 must be of a thick metatype type $@thick T.metatype
+ %1 = thick_to_objc_metatype %0 : $@thick T.Type to $@objc_metatype T.Type
+ // %0 must be of a thick metatype type $@thick T.Type
// The destination type must be the corresponding Objective-C metatype type
- // %1 will be of type $@objc_metatype T.metatype
+ // %1 will be of type $@objc_metatype T.Type
Converts a thick metatype to an Objective-C class metatype. ``T`` must
be of class, class protocol, or class protocol composition type.
@@ -3822,10 +3843,10 @@ objc_to_thick_metatype
sil-instruction ::= 'objc_to_thick_metatype' sil-operand 'to' sil-type
- %1 = objc_to_thick_metatype %0 : $@objc_metatype T.metatype to $@thick T.metatype
- // %0 must be of an Objective-C metatype type $@objc_metatype T.metatype
+ %1 = objc_to_thick_metatype %0 : $@objc_metatype T.Type to $@thick T.Type
+ // %0 must be of an Objective-C metatype type $@objc_metatype T.Type
// The destination type must be the corresponding thick metatype type
- // %1 will be of type $@thick T.metatype
+ // %1 will be of type $@thick T.Type
Converts an Objective-C class metatype to a thick metatype. ``T`` must
be of class, class protocol, or class protocol composition type.
@@ -4045,7 +4066,7 @@ select_value
sil-instruction ::= 'select_value' sil-operand sil-select-value-case*
(',' 'default' sil-value)?
':' sil-type
- sil-selct-value-case ::= 'case' sil-value ':' sil-value
+ sil-select-value-case ::= 'case' sil-value ':' sil-value
%n = select_value %0 : $U, \
@@ -4058,7 +4079,7 @@ select_value
// %r1, %r2, %r3, etc. must have type $T
// %n has type $T
-Selects one of the "case" or "default" operands based on the case of an
+Selects one of the "case" or "default" operands based on the case of a
value. This is equivalent to a trivial `switch_value`_ branch sequence::
entry:
@@ -4086,8 +4107,8 @@ switch_enum
(',' sil-switch-default)?
sil-switch-enum-case ::= 'case' sil-decl-ref ':' sil-identifier
- switch_enum %0 : $U, case #U.Foo: label1, \
- case #U.Bar: label2, \
+ switch_enum %0 : $U, case #U.Foo!enumelt: label1, \
+ case #U.Bar!enumelt: label2, \
..., \
default labelN
@@ -4121,12 +4142,12 @@ original enum value. For example::
sil @sum_of_foo : $Foo -> Int {
entry(%x : $Foo):
switch_enum %x : $Foo, \
- case #Foo.Nothing: nothing, \
- case #Foo.OneInt: one_int, \
- case #Foo.TwoInts: two_ints
+ case #Foo.Nothing!enumelt: nothing, \
+ case #Foo.OneInt!enumelt.1: one_int, \
+ case #Foo.TwoInts!enumelt.1: two_ints
nothing:
- %zero = integer_literal 0 : $Int
+ %zero = integer_literal $Int, 0
return %zero : $Int
one_int(%y : $Int):
@@ -4162,8 +4183,8 @@ switch_enum_addr
(',' sil-switch-enum-case)*
(',' sil-switch-default)?
- switch_enum_addr %0 : $*U, case #U.Foo: label1, \
- case #U.Bar: label2, \
+ switch_enum_addr %0 : $*U, case #U.Foo!enumelt: label1, \
+ case #U.Bar!enumelt: label2, \
..., \
default labelN
diff --git a/docs/SequencesAndCollections.rst b/docs/SequencesAndCollections.rst
index f6272314b22e1..3478e89d62dee 100644
--- a/docs/SequencesAndCollections.rst
+++ b/docs/SequencesAndCollections.rst
@@ -60,8 +60,8 @@ As you can see, sequence does nothing more than deliver a generator.
To understand the need for generators, it's important to distinguish
the two kinds of sequences.
-* **Volatile** sequences like “stream of network packets,” carry
- their own traversal state, and are expected to be “consumed” as they
+* **Volatile** sequences like "stream of network packets," carry
+ their own traversal state, and are expected to be "consumed" as they
are traversed.
* **Stable** sequences, like arrays, should *not* be mutated by `for`\
@@ -215,7 +215,7 @@ that stability in generic code, we'll need another protocol.
Collections
===========
-A **collection** is a stable sequence with addressable “positions,”
+A **collection** is a stable sequence with addressable "positions,"
represented by an associated `Index` type::
protocol CollectionType : SequenceType {
diff --git a/docs/StdlibAPIGuidelines.rst b/docs/StdlibAPIGuidelines.rst
index 26004130fac61..230bac5ae3967 100644
--- a/docs/StdlibAPIGuidelines.rst
+++ b/docs/StdlibAPIGuidelines.rst
@@ -102,7 +102,7 @@ Subsequent Parameters
Other Differences
-----------------
-* We don't use namespace prefixes such as “`NS`”, relying instead on
+* We don't use namespace prefixes such as "`NS`", relying instead on
the language's own facilities.
* Names of types, protocols and enum cases are `UpperCamelCase`.
@@ -156,7 +156,7 @@ library, but are compatible with the Cocoa guidelines.
}
* Even unlabelled parameter names should be meaningful as they'll be
- referred to in comments and visible in “generated headers”
+ referred to in comments and visible in "generated headers"
(cmd-click in Xcode):
.. parsed-literal::
@@ -200,12 +200,12 @@ Acceptable Short or Non-Descriptive Names
func map(transformation: T->U) -> [U] // not this one
- func forEach(body: (S.Generator.Element)->())
+ func forEach(body: (S.Generator.Element) -> ())
Prefixes and Suffixes
---------------------
-* `Any` is used as a prefix to denote “type erasure,”
+* `Any` is used as a prefix to denote "type erasure,"
e.g. `AnySequence` wraps any sequence with element type `T`,
conforms to `SequenceType` itself, and forwards all operations to the
wrapped sequence. When handling the wrapper, the specific type of
diff --git a/docs/StdlibRationales.rst b/docs/StdlibRationales.rst
index 02d423d4b0a6d..6b90b80d14935 100644
--- a/docs/StdlibRationales.rst
+++ b/docs/StdlibRationales.rst
@@ -64,7 +64,7 @@ generally *should* use a keyword. For example, ``String(33, radix:
they're converting. Secondly, avoiding method or property syntax
provides a distinct context for code completion. Rather than
appearing in completions offered after ``.``, for example, the
- available conversions could show up whenever the user hit the “tab”
+ available conversions could show up whenever the user hit the "tab"
key after an expression.
Protocols with restricted conformance rules
diff --git a/docs/StringDesign.rst b/docs/StringDesign.rst
index 52fcfca9d8b6b..9480eb4f98c28 100644
--- a/docs/StringDesign.rst
+++ b/docs/StringDesign.rst
@@ -116,9 +116,9 @@ Goals
``String`` should:
* honor industry standards such as Unicode
-* when handling non-ASCII text, deliver “reasonably correct”
+* when handling non-ASCII text, deliver "reasonably correct"
results to users thinking only in terms of ASCII
-* when handling ASCII text, provide “expected behavior” to users
+* when handling ASCII text, provide "expected behavior" to users
thinking only in terms of ASCII
* be hard to use incorrectly
* be easy to use correctly
@@ -165,7 +165,7 @@ optimizations, including:
- In-place modification of uniquely-owned buffers
As a result, copying_ and slicing__ strings, in particular, can be
-viewed by most programmers as being “almost free.”
+viewed by most programmers as being "almost free."
__ sliceable_
@@ -197,7 +197,7 @@ Strings are **Value Types**
Distinct string variables have independent values: when you pass
someone a string they get a copy of the value, and when someone
passes you a string *you own it*. Nobody can change a string value
-“behind your back.”
+"behind your back."
.. parsed-literal::
|swift| class Cave {
@@ -219,7 +219,7 @@ passes you a string *you own it*. Nobody can change a string value
`// s: String =` :look:`"Hey"`\ :aside:`…and it doesn't.`
|swift| :look1:`t.addEcho()`\ :aside:`this call can't change c.lastSound…`
|swift| [s, c.lastSound, t]
- `// r0: String[] = ["Hey",` :look:`"HeyHey"`\ :aside:`…and it doesn't.`\ `, "HeyHeyHeyHey"]`
+ `// r0: [String] = ["Hey",` :look:`"HeyHey"`\ :aside:`…and it doesn't.`\ `, "HeyHeyHeyHey"]`
Strings are **Unicode-Aware**
-----------------------------
@@ -231,18 +231,18 @@ Strings are **Unicode-Aware**
specifies requires careful justification. So far, we have found two
possible points of deviation for Swift ``String``:
- 1. The `Unicode Text Segmentation Specification`_ says, “`do not
- break between CR and LF`__.” However, breaking extended
+ 1. The `Unicode Text Segmentation Specification`_ says, "`do not
+ break between CR and LF`__." However, breaking extended
grapheme clusters between CR and LF may necessary if we wish
- ``String`` to “behave normally” for users of pure ASCII. This
+ ``String`` to "behave normally" for users of pure ASCII. This
point is still open for discussion.
__ http://www.unicode.org/reports/tr29/#GB2
2. The `Unicode Text Segmentation Specification`_ says,
- “`do not break between regional indicator symbols`__.” However, it also
- says “(Sequences of more than two RI characters should be separated
- by other characters, such as U+200B ZWSP).” Although the
+ "`do not break between regional indicator symbols`__." However, it also
+ says "(Sequences of more than two RI characters should be separated
+ by other characters, such as U+200B ZWSP)." Although the
parenthesized note probably has less official weight than the other
admonition, breaking pairs of RI characters seems like the right
thing for us to do given that Cocoa already forms strings with
@@ -278,7 +278,7 @@ Strings are **Locale-Agnostic**
Strings neither carry their own locale information, nor provide
behaviors that depend on a global locale setting. Thus, for any pair
-of strings ``s1`` and ``s2``, “``s1 == s2``” yields the same result
+of strings ``s1`` and ``s2``, "``s1 == s2``" yields the same result
regardless of system state. Strings *do* provide a suitable
foundation on which to build locale-aware interfaces.\ [#locales]_
@@ -316,8 +316,8 @@ Strings are Composed of ``Character``\ s
cluster**, as specified by a default or tailored Unicode segmentation
algorithm. This term is `precisely defined`__ by the Unicode
specification, but it roughly means `what the user thinks of when she
-hears “character”`__. For example, the pair of code points “LATIN
-SMALL LETTER N, COMBINING TILDE” forms a single grapheme cluster, “ñ”.
+hears "character"`__. For example, the pair of code points "LATIN
+SMALL LETTER N, COMBINING TILDE" forms a single grapheme cluster, "ñ".
__ http://www.unicode.org/glossary/#grapheme_cluster
__ http://useless-factor.blogspot.com/2007/08/unicode-implementers-guide-part-4.html
@@ -342,8 +342,8 @@ __ http://www.unicode.org/glossary/#extended_grapheme_cluster
__ http://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table
This segmentation offers naïve users of English, Chinese, French, and
-probably a few other languages what we think of as the “expected
-results.” However, not every script_ can be segmented uniformly for
+probably a few other languages what we think of as the "expected
+results." However, not every script_ can be segmented uniformly for
all purposes. For example, searching and collation require different
segmentations in order to handle Indic scripts correctly. To that
end, strings support properties for more-specific segmentations:
@@ -386,9 +386,9 @@ Strings are **Sliceable**
.. parsed-literal::
|swift| s[r.start...r.end]
`// r2 : String = "awe"`
- |swift| s[\ :look1:`r.start...`\ ]\ :aside:`postfix slice operator means “through the end”`
+ |swift| s[\ :look1:`r.start...`\ ]\ :aside:`postfix slice operator means "through the end"`
`// r3 : String = "awesome"`
- |swift| s[\ :look1:`...r.start`\ ]\ :aside:`prefix slice operator means “from the beginning”`
+ |swift| s[\ :look1:`...r.start`\ ]\ :aside:`prefix slice operator means "from the beginning"`
`// r4 : String = "Strings are "`
|swift| :look1:`s[r]`\ :aside:`indexing with a range is the same as slicing`
`// r5 : String = "awe"`
@@ -579,7 +579,7 @@ How Would You Design It?
5. CodePoint substring search is just byte string search
6. Most programs that handle 8-bit files safely can handle UTF-8 safely
7. UTF-8 sequences sort in code point order.
- 8. UTF-8 has no “byte order.”
+ 8. UTF-8 has no "byte order."
__ http://research.swtch.com/2010/03/utf-8-bits-bytes-and-benefits.html
@@ -682,7 +682,7 @@ withRange:subrange]`` becomes ``str[subrange].doFoo(arg)``.
* Deprecated Cocoa APIs are not considered
- * A status of “*Remove*” below indicates a feature whose removal is
+ * A status of "*Remove*" below indicates a feature whose removal is
anticipated. Rationale is provided for these cases.
Indexing
@@ -806,18 +806,18 @@ Comparison
func **<=** (lhs: String, rhs: String) -> Bool
func **>=** (lhs: String, rhs: String) -> Bool
-``NSString`` comparison is “literal” by default. As the documentation
+``NSString`` comparison is "literal" by default. As the documentation
says of ``isEqualToString``,
- “Ö” represented as the composed character sequence “O” and umlaut
- would not compare equal to “Ö” represented as one Unicode character.
+ "Ö" represented as the composed character sequence "O" and umlaut
+ would not compare equal to "Ö" represented as one Unicode character.
By contrast, Swift string's primary comparison interface uses
Unicode's default collation_ algorithm, and is thus always
-“Unicode-correct.” Unlike comparisons that depend on locale, it is
+"Unicode-correct." Unlike comparisons that depend on locale, it is
also stable across changes in system state. However, *just like*
``NSString``\ 's ``isEqualToString`` and ``compare`` methods, it
-should not be expected to yield ideal (or even “proper”) results in
+should not be expected to yield ideal (or even "proper") results in
all contexts.
---------
@@ -940,7 +940,7 @@ Searching
:Swift:
.. parsed-literal::
- func **find**\ (match: (Character)->Bool) -> Range
+ func **find**\ (match: (Character) -> Bool) -> Range
.. Admonition:: Usage Example
@@ -1021,8 +1021,8 @@ Splitting
:Swift:
.. parsed-literal::
- func split(maxSplit: Int = Int.max()) -> String[]
- func split(separator: Character, maxSplit: Int = Int.max()) -> String[]
+ func split(maxSplit: Int = Int.max()) -> [String]
+ func split(separator: Character, maxSplit: Int = Int.max()) -> [String]
The semantics of these functions were taken from Python, which seems
to be a fairly good representative of what modern languages are
@@ -1038,7 +1038,7 @@ Splitting
func **split**\ (seq: Seq, isSeparator: IsSeparator, maxSplit: Int = Int.max(),
- allowEmptySlices: Bool = false ) -> Seq[]
+ allowEmptySlices: Bool = false ) -> [Seq]
Splitting
~~~~~~~~~
@@ -1084,10 +1084,10 @@ Capitalization
.. Note:: ``NSString`` capitalizes the first letter of each substring
separated by spaces, tabs, or line terminators, which is in
- no sense “Unicode-correct.” In most other languages that
+ no sense "Unicode-correct." In most other languages that
support a ``capitalize`` method, it operates only on the
first character of the string, and capitalization-by-word is
- named something like “``title``.” If Swift ``String``
+ named something like "``title``." If Swift ``String``
supports capitalization by word, it should be
Unicode-correct, but how we sort this particular area out is
still **TBD**.
@@ -1100,7 +1100,7 @@ Capitalization
:Swift:
.. parsed-literal::
- trim **trim**\ (match: (Character)->Bool) -> String
+ trim **trim**\ (match: (Character) -> Bool) -> String
.. Admonition:: Usage Example
@@ -1712,7 +1712,7 @@ Why YAGNI
* Derivation
* ...
-.. [#agnostic] Unicode specifies default (“un-tailored”)
+.. [#agnostic] Unicode specifies default ("un-tailored")
locale-independent collation_ and segmentation_ algorithms that
make reasonable sense in most contexts. Using these algorithms
allows strings to be naturally compared and combined, generating
@@ -1748,6 +1748,6 @@ Why YAGNI
been normalized, thus speeding up comparison operations.
.. [#elements] Since ``String`` is locale-agnostic_, its elements are
- determined using Unicode's default, “un-tailored” segmentation_
+ determined using Unicode's default, "un-tailored" segmentation_
algorithm.
diff --git a/docs/Testing.rst b/docs/Testing.rst
index 49d9805073742..8e5c39f8de1ed 100644
--- a/docs/Testing.rst
+++ b/docs/Testing.rst
@@ -313,6 +313,8 @@ Other substitutions:
* ``%platform-sdk-overlay-dir``: absolute path of the directory where the SDK
overlay module files for the target platform are stored.
+* ``%{python}``: run the same Python interpreter that's being used to run the
+ current ``lit`` test.
When writing a test where output (or IR, SIL) depends on the bitness of the
target CPU, use this pattern::
@@ -355,7 +357,7 @@ CPU=i386_or_x86_64`` to ``REQUIRES: CPU=x86_64``.
``swift_test_mode_optimize[_unchecked|none]_`` to specify a test mode
plus cpu configuration.
-``optimized_stdlib_``` to specify a optimized stdlib plus cpu
+``optimized_stdlib_``` to specify an optimized stdlib plus cpu
configuration.
Feature ``REQUIRES: executable_test``
diff --git a/docs/TextFormatting.rst b/docs/TextFormatting.rst
index 6c9bedfdc8ce7..30e47ef83eb5a 100644
--- a/docs/TextFormatting.rst
+++ b/docs/TextFormatting.rst
@@ -21,9 +21,9 @@ Scope
Goals
.....
-* The REPL and LLDB (“debuggers”) share formatting logic
-* All types are “debug-printable” automatically
-* Making a type “printable for humans” is super-easy
+* The REPL and LLDB ("debuggers") share formatting logic
+* All types are "debug-printable" automatically
+* Making a type "printable for humans" is super-easy
* ``toString()``-ability is a consequence of printability.
* Customizing a type's printed representations is super-easy
* Format variations such as numeric radix are explicit and readable
@@ -43,11 +43,11 @@ Non-Goals
that feature. Therefore, localization and dynamic format strings
should be designed together, and *under this proposal* the only
format strings are string literals containing interpolations
- (“``\(...)``”). Cocoa programmers can still use Cocoa localization
+ ("``\(...)``"). Cocoa programmers can still use Cocoa localization
APIs for localization jobs.
In Swift, only the most common cases need to be very terse.
- Anything “fancy” can afford to be a bit more verbose. If and when
+ Anything "fancy" can afford to be a bit more verbose. If and when
we address localization and design a full-featured dynamic string
formatter, it may make sense to incorporate features of ``printf``
into the design.
@@ -68,7 +68,7 @@ printed with ``print(x)``, and can be converted to ``String`` with
The simple extension story for beginners is as follows:
- “To make your type ``CustomStringConvertible``, simply declare conformance to
+ "To make your type ``CustomStringConvertible``, simply declare conformance to
``CustomStringConvertible``::
extension Person : CustomStringConvertible {}
@@ -152,9 +152,9 @@ directly to the ``OutputStream`` for efficiency reasons,
Producing a representation that can be consumed by the REPL
and LLDB to produce an equivalent object is strongly encouraged
where possible! For example, ``String.debugFormat()`` produces
- a representation starting and ending with “``"``”, where special
+ a representation starting and ending with "``"``", where special
characters are escaped, etc. A ``struct Point { var x, y: Int }``
- might be represented as “``Point(x: 3, y: 5)``”.
+ might be represented as "``Point(x: 3, y: 5)``".
(Non-Debug) Printing
....................
@@ -348,7 +348,7 @@ an underlying stream::
However, upcasing is a trivial example: many such transformations—such
as ``trim()`` or regex replacement—are stateful, which implies some
-way of indicating “end of input” so that buffered state can be
+way of indicating "end of input" so that buffered state can be
processed and written to the underlying stream:
.. parsed-literal::
@@ -422,10 +422,10 @@ If we were willing to say that only ``class``\ es can conform to
``OutputStream``\ s are passed around. Then, we'd simply need a
``class StringStream`` for creating ``String`` representations. It
would also make ``OutputStream`` adapters a *bit* simpler to use
-because you'd never need to “write back” explicitly onto the target
+because you'd never need to "write back" explicitly onto the target
stream. However, stateful ``OutputStream`` adapters would still need a
``close()`` method, which makes a perfect place to return a copy of
-the underlying stream, which can then be “written back”:
+the underlying stream, which can then be "written back":
.. parsed-literal::
diff --git a/docs/TypeChecker.rst b/docs/TypeChecker.rst
index fb1856eb30645..21fd3b77a1319 100644
--- a/docs/TypeChecker.rst
+++ b/docs/TypeChecker.rst
@@ -106,7 +106,7 @@ the Swift type system:
flavors of equality constraints:
- Exact equality constraints, or "binding", written ``T0 := X``
- for some type variable ``T0`` and type ``X``, which requires
+ for some type variable ``T0`` and type ``X``, which requires
that ``T0`` be exactly identical to ``X``;
- Equality constraints, written ``X == Y`` for types ``X`` and
``Y``, which require ``X`` and ``Y`` to have the same type,
diff --git a/docs/TypeReference.md b/docs/TypeReference.md
new file mode 100644
index 0000000000000..4b7b44d6ecddb
--- /dev/null
+++ b/docs/TypeReference.md
@@ -0,0 +1,66 @@
+# Symbolic Type References
+
+*Symbolic type references* are compact representations containing the
+minimum amount of information about type relationships primarily for the
+purposes of reflection.
+
+## Encoding
+
+These are encoded with a mostly textual mangling. Single characters
+denote the start of a mangling node but 32-bit integers can also be
+directly embedded.
+
+```
+typeref-symbol ::= prefix typeref
+
+typeref ::= 'b' relative-offset-to-name // Builtin type
+typeref ::= 'n' relative-offset-to-metadata // Internal nominal type
+typeref ::= 'N' relative-offset-to-name // External nominal type
+typeref ::= 'g' relative-offset-to-metadata count typeref-list // Internal bound generic type
+typeref ::= 'G' relative-offset-to-name count typeref-list // External bound generic type
+typeref ::= '?' index depth // Generic parameter
+typeref ::= 't' num-elements typeref-list // Tuple type
+typeref ::= 'f' func-representation count typeref typeref // Function type
+typeref ::= 'p' has-class-constrained-flag? count protocol-list // Protocol composition
+typeref ::= 'm' typeref // Metatype
+typeref ::= 'e' count protocol-list // Existential metatype
+
+has-class-constrained-flag ::= 'c'
+
+func-representation ::= 't' // Thin
+func-representation ::= 'T' // Thick
+func-representation ::= 'b' // Block
+
+base-255-i32 ::= <32-bit integer, variable length base-255 encoded>
+
+count ::= base-255-i32
+index ::= base-255-i32
+depth ::= base-255-i32
+relative-offset ::= base-255-i32
+```
+
+### Relative Offset, Index, and Depth tokens
+
+`Relative offset` tokens are the 32-bit integers packed into the type
+reference -- not a string of digits. These are used to efficiently
+reference other types internally in the current binary image, avoiding
+unnecessarily embedding redundant copies of type manglings, and
+"pointing" to a mangled string for external type references. This uses a
+base-255 encoding to avoid nulls in the sequence of bytes.
+
+The offset value is relative to the address of the offset itself so that
+a base address doesn't need to be threaded when parsing bytes.
+
+For external references to types defined in other images, the relative
+offset takes you to the mangled name string for symbol lookup.
+
+`Count`, `Index`, and `Depth` tokens are encoded this way as well.
+
+### Flags
+
+The flags of the field record is a 32-bit unsigned integer marking some
+statically known facts about the field's type, such as reference ownership.
+
+#### Flag bits
+
+TODO
diff --git a/docs/archive/LangRef.html b/docs/archive/LangRef.html
index 2ec564d90c9dd..5ee53490e7106 100644
--- a/docs/archive/LangRef.html
+++ b/docs/archive/LangRef.html
@@ -762,7 +762,7 @@ Infix Attributes
FIXME: Implement these restrictions.
- Resilience Attribute
+ Resilience Attribute
attribute-resilience ::= 'resilient'
@@ -1093,7 +1093,7 @@ Function Types
The result type of a function type must
be materializable. The argument type of a
- function is always required to be parenthesized (a tuple). The behavior
+ function is always required to be parenthesized (a tuple). The behavior
of function types may be modified with the autoclosure attribute.
@@ -1901,7 +1901,7 @@ Closure Expression
// both have type 'Int'.
magic(42, { $0 < $1 })
- // Compare the other way way.
+ // Compare the other way.
magic(42, { $1 < $0 })
// Provide parameter names, but infer the types.
diff --git a/docs/archive/LangRefNew.rst b/docs/archive/LangRefNew.rst
index 3355e66d19c23..a22b50e2d6075 100644
--- a/docs/archive/LangRefNew.rst
+++ b/docs/archive/LangRefNew.rst
@@ -1123,7 +1123,7 @@ label if it is a named pattern or a type annotation of a named pattern.
A tuple pattern whose body ends in ``'...'`` is a varargs tuple. The last
element of such a tuple must be a typed pattern, and the type of that pattern
-is changed from ``T`` to ``T[]``. The corresponding tuple type for a varargs
+is changed from ``T`` to ``[T]``. The corresponding tuple type for a varargs
tuple is a varargs tuple type.
As a special case, a tuple pattern with one element that has no label, has no
@@ -1150,7 +1150,7 @@ appear in declarations.
class D1 : B {}
class D2 : B {}
- var bs : B[] = [B(), D1(), D2()]
+ var bs : [B] = [B(), D1(), D2()]
for b in bs {
switch b {
@@ -1537,8 +1537,8 @@ Short Circuiting Logical Operators
::
- func && (lhs: Bool, rhs: ()->Bool) -> Bool
- func || (lhs: Bool, rhs: ()->Bool) -> Bool
+ func && (lhs: Bool, rhs: () -> Bool) -> Bool
+ func || (lhs: Bool, rhs: () -> Bool) -> Bool
Swift has a simplified precedence levels when compared with C. From highest to
lowest:
diff --git a/docs/archive/Resilience.rst b/docs/archive/Resilience.rst
index 84ec5f6d8ec19..e6112d0f6f9b1 100644
--- a/docs/archive/Resilience.rst
+++ b/docs/archive/Resilience.rst
@@ -42,7 +42,7 @@ program may depend on some number of other components; this graph of
dependencies can be assumed to be acyclic.
Because a component is distributed as a unit, ABI resilience within the
-component is not required. It may still help to serve as a build- time
+component is not required. It may still help to serve as a build-time
optimization, but Swift aims to offer substantially better build times than
C/C++ programs due to other properties of the language (the module system, the
lack of a preprocessor, the instantiation model, etc.).
@@ -254,7 +254,7 @@ versioned [fragile] attribute. There is also a [resilient] attribute, exclusive
to any form of [fragile], to explicitly describe a declaration as resilient.
Resilience is lexically inherited. It is not lexically constrained; a resilient
-language structure may have fragile sub-structures and vice- versa. The global
+language structure may have fragile sub-structures and vice-versa. The global
context is resilient, although since it is also [public] (and not [api]),
objects are not in practice constrained by resilience.
@@ -351,7 +351,7 @@ change a
Resilience affects pretty much every language feature.
Execution-time abstraction does not come without cost, and we do not wish to
-incur those costs where unnecessary. Many forms of execution- time abstraction
+incur those costs where unnecessary. Many forms of execution-time abstraction
are unnecessary except as a build-time optimization, because in practice the
software is deployed in large chunks that can be compiled at the same
time. Within such a resilience unit , many execution-time abstractions can be
@@ -364,7 +364,7 @@ outside its resilience unit.
A structure is said to be resilient if accesses to it rely only on its
-A structure is said to be universally non-resilient if it is non- resilient in
+A structure is said to be universally non-resilient if it is non-resilient in
all contexts in which it is accessible.
Many APIs are willing to selectively "lock down" some of their component
@@ -405,8 +405,8 @@ non-resilient.
Named types declared within a function are universally non-resilient.
-Named types with the [unchanging] annotation are universally non-
-resilient. Problem, because of the need/desire to make things depend on whether
+Named types with the [unchanging] annotation are universally non-resilient.
+Problem, because of the need/desire to make things depend on whether
a type is universally non-resilient. Makes it impossible to add [unchanging]
without breaking ABI. See the call section.
@@ -433,9 +433,9 @@ Named types
It is an error to place the [unchanging] annotation on any of these types:
-* a struct type with member types that are not universally non- resilient
+* a struct type with member types that are not universally non-resilient
-* an enum type with an enumerator whose type is not universally non- resilient
+* an enum type with an enumerator whose type is not universally non-resilient
* a class extension
@@ -450,8 +450,8 @@ It is an error to place the [unchanging] annotation on a class extension.
It is an error to place the [unchanging] annotation on a class whose primary
definition contains a field whose type is potentially resilient in a context
where the class is accessible. That is, if the class is exported, all of its
-fields must be universally non- resilient. If it is not exported, all of its
-fields must be non- resilient within its resilience unit.
+fields must be universally non-resilient. If it is not exported, all of its
+fields must be non-resilient within its resilience unit.
It is allowed to add fields to an [unchanging] class in a class extension. Such
fields are always side-stored, even if they are declared within the same
diff --git a/docs/conf.py b/docs/conf.py
index 0af7b9a7c9384..58da546ef97d5 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -10,7 +10,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys, os
+import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -47,9 +47,9 @@
# built documents.
#
# The short X.Y version.
-version = '2.2'
+version = '3.0'
# The full version, including alpha/beta/rc tags.
-release = '2.2'
+release = '3.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -100,10 +100,10 @@
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
- # Red links are a bit too garish
- "linkcolor" : "#577492",
- "visitedlinkcolor" : "#577492",
- "hoverlinkcolor" : "#551A8B"
+ # Red links are a bit too garish
+ "linkcolor": "#577492",
+ "visitedlinkcolor": "#577492",
+ "hoverlinkcolor": "#551A8B"
}
# Add any paths that contain custom themes here, relative to this directory.
@@ -178,21 +178,21 @@
# -- Options for LaTeX output --------------------------------------------------
latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
+ # The paper size ('letterpaper' or 'a4paper').
+ #'papersize': 'letterpaper',
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
+ # The font size ('10pt', '11pt' or '12pt').
+ #'pointsize': '10pt',
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
+ # Additional stuff for the LaTeX preamble.
+ #'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('contents', 'Swift.tex', u'Swift Documentation',
- u'LLVM project', 'manual'),
+ ('contents', 'Swift.tex', u'Swift Documentation',
+ u'LLVM project', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -235,9 +235,9 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('contents', 'Swift', u'Swift Documentation',
- u'LLVM project', 'Swift', 'One line description of project.',
- 'Miscellaneous'),
+ ('contents', 'Swift', u'Swift Documentation',
+ u'LLVM project', 'Swift', 'One line description of project.',
+ 'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
diff --git a/docs/doxygen.cfg.in b/docs/doxygen.cfg.in
index e9c3a6415fa23..6b56723b5d5f1 100644
--- a/docs/doxygen.cfg.in
+++ b/docs/doxygen.cfg.in
@@ -1063,7 +1063,7 @@ PERL_PATH =
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# generate an inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# or super classes. Setting the tag to NO turns the diagrams off. Note that
# this option is superseded by the HAVE_DOT option below. This is only a
# fallback. It is recommended to install and use dot, since it yields more
@@ -1239,7 +1239,7 @@ SEARCHENGINE = @enable_searchengine@
# using Javascript. Doxygen will generate the search PHP script and index
# file to put on the web server. The advantage of the server
# based approach is that it scales better to large projects and allows
-# full text search. The disadvances is that it is more difficult to setup
+# full text search. The disadvantage is that it is more difficult to setup
# and does not have live searching capabilities.
SERVER_BASED_SEARCH = @enable_server_based_search@
diff --git a/docs/doxygen.intro b/docs/doxygen.intro
index 8d953655bc6ab..f1ff0682a5829 100644
--- a/docs/doxygen.intro
+++ b/docs/doxygen.intro
@@ -4,7 +4,7 @@
/// Welcome to Swift.
///
/// This documentation describes the @b internal software that makes
-/// up Swift, not the @b external use of Swift. There are no instructions
+/// up Swift, not the @b external use of Swift. There are no instructions
/// here on how to use Swift, only the APIs that make up the software. For usage
/// instructions, please see the programmer's guide or reference manual.
///
diff --git a/docs/proposals/Accessors.rst b/docs/proposals/Accessors.rst
index f22b8c7c1f8d1..da5da10f0426b 100644
--- a/docs/proposals/Accessors.rst
+++ b/docs/proposals/Accessors.rst
@@ -704,7 +704,7 @@ that was technically copied beforehand. For example::
var oldArray : [Int] = []
// This function copies array before modifying it, but because that
- // copy is of an value undergoing modification, the copy will use
+ // copy is of a value undergoing modification, the copy will use
// the same buffer and therefore observe updates to the element.
func foo(inout element: Int) {
oldArray = array
diff --git a/docs/proposals/ArrayBridge.rst b/docs/proposals/ArrayBridge.rst
index a3bc33009952c..8f1c56f9c8c06 100644
--- a/docs/proposals/ArrayBridge.rst
+++ b/docs/proposals/ArrayBridge.rst
@@ -4,7 +4,7 @@
..
.. This source file is part of the Swift.org open source project
..
-.. Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+.. Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
.. Licensed under Apache License v2.0 with Runtime Library Exception
..
.. See http://swift.org/LICENSE.txt for license information
@@ -34,11 +34,11 @@ Being "great for Cocoa" means this must work and be efficient::
var a = [cocoaObject1, cocoaObject2]
someCocoaObject.takesAnNSArray(a)
- func processViews(views: AnyObject[]) { ... }
+ func processViews(views: [AnyObject]) { ... }
var b = someNSWindow.views // views is an NSArray
processViews(b)
- var c: AnyObject[] = someNSWindow.views
+ var c: [AnyObject] = someNSWindow.views
Being "great For C" means that an array created in Swift must have
C-like performance and be representable as a base pointer and
@@ -47,18 +47,18 @@ length, for interaction with C APIs, at zero cost.
Proposed Solution
=================
-``Array``, a.k.a. ``T[]``, is notionally an ``enum`` with two
+``Array``, a.k.a. ``[T]``, is notionally an ``enum`` with two
cases; call them ``Native`` and ``Cocoa``. The ``Native`` case stores
a ``ContiguousArray``, which has a known, contiguous buffer
representation and O(1) access to the address of any element. The
``Cocoa`` case stores an ``NSArray``.
``NSArray`` bridges bidirectionally in O(1) [#copy]_ to
-``AnyObject[]``. It also implicitly converts in to ``T[]``, where T
+``[AnyObject]``. It also implicitly converts in to ``[T]``, where T
is any class declared to be ``@objc``. No dynamic check of element
types is ever performed for arrays of ``@objc`` elements; instead we
simply let ``objc_msgSend`` fail when ``T``\ 's API turns out to be
-unsupported by the object. Any ``T[]``, where T is an ``@objc``
+unsupported by the object. Any ``[T]``, where T is an ``@objc``
class, converts implicitly to NSArray.
Optimization
@@ -92,7 +92,7 @@ fold this to "0" iff ``T`` is known to be a protocol other than
AnyObject, if it is known to be a non-\ ``@objc`` class, or if it is
known to be any struct, enum or tuple. Otherwise, the builtin is left
alone, and if it reaches IRGen, IRGen should conservatively fold it to
-"1". In the common case where ``Array`` is inlined and
+"1". In the common case where ``Array`` is inlined and
specialized, this will allow us to eliminate all of the overhead in
the important C cases.
@@ -114,7 +114,7 @@ We considered an approach where conversions between ``NSArray`` and
native Swift ``Array`` were entirely manual and quickly ruled it out
as failing to satisfy the requirements.
-We considered another promising proposal that would make ``T[]`` a
+We considered another promising proposal that would make ``[T]`` a
(hand-rolled) existential wrapper type. Among other things, we felt
this approach would expose multiple array types too prominently and
would tend to "bless" an inappropriately-specific protocol as the
diff --git a/docs/proposals/C Pointer Argument Interop.rst b/docs/proposals/C Pointer Argument Interop.rst
index 0be9dd9f19cbf..1d5823690272d 100644
--- a/docs/proposals/C Pointer Argument Interop.rst
+++ b/docs/proposals/C Pointer Argument Interop.rst
@@ -141,7 +141,7 @@ known, so a copy-on-write array buffer must be eagerly uniqued prior to the
address of the array being taken::
func loadFloatsFromData(data: NSData) {
- var a: Float[] = [0.0, 0.0, 0.0, 0.0]
+ var a: [Float] = [0.0, 0.0, 0.0, 0.0]
var b = a
// Should only mutate 'b' without affecting 'a', so its backing store
diff --git a/docs/proposals/C Pointer Interop Language Model.rst b/docs/proposals/C Pointer Interop Language Model.rst
index aa51aef2b0d89..2620a36247788 100644
--- a/docs/proposals/C Pointer Interop Language Model.rst
+++ b/docs/proposals/C Pointer Interop Language Model.rst
@@ -72,7 +72,7 @@ You can call it as any of::
var x: Float = 0.0
var p: UnsafeMutablePointer = nil
- var a: Float[] = [1.0, 2.0, 3.0]
+ var a: [Float] = [1.0, 2.0, 3.0]
foo(nil)
foo(p)
foo(&x)
@@ -86,7 +86,7 @@ You can call it as any of::
var x: Float = 0.0, y: Int = 0
var p: UnsafeMutablePointer = nil, q: UnsafeMutablePointer = nil
- var a: Float[] = [1.0, 2.0, 3.0], b: Int = [1, 2, 3]
+ var a: [Float] = [1.0, 2.0, 3.0], b: Int = [1, 2, 3]
bar(nil)
bar(p)
bar(q)
diff --git a/docs/proposals/DeclarationTypeChecker.rst b/docs/proposals/DeclarationTypeChecker.rst
index 6195f87e438c4..1872da6f5fd25 100644
--- a/docs/proposals/DeclarationTypeChecker.rst
+++ b/docs/proposals/DeclarationTypeChecker.rst
@@ -68,7 +68,7 @@ There are a few aspects of the language that make it challenging to implement th
extension C { }
extension B { struct Inner { } }
-Here, the name lookup used for the first extension needs to resolve the typealias, which depends on the second extension having already been bound. There is a similar dependency on resolving superclasses beforing binding extensions::
+Here, the name lookup used for the first extension needs to resolve the typealias, which depends on the second extension having already been bound. There is a similar dependency on resolving superclasses before binding extensions::
class X { struct Inner { } }
class Y : X { }
@@ -154,7 +154,7 @@ The proposed architecture is significantly different from the current type check
**Make name lookup phase-aware**: Name lookup is currently one of the worst offenders when violating phase ordering. Parameterize name lookup based on the phase at which it's operating. For example, asking for name lookup at the "extension binding" phase might not resolve type aliases, look into superclasses, or look into protocols.
-**Make type resolution phase-aware**: Type resolution effectively brings a given ``TypeRepr`` up to the "declaration type validation`` phase in one shot. Parameterize type resolution based on the target phase, and start minimizing the among of work that the type checking does. Use extension binding as a testbed for these more-minimal dependencies.
+**Make type resolution phase-aware**: Type resolution effectively brings a given ``TypeRepr`` up to the "declaration type validation`` phase in one shot. Parameterize type resolution based on the target phase, and start minimizing the amount of work that the type checking does. Use extension binding as a testbed for these more-minimal dependencies.
**Dependency graph and priority queue**: Extend the current-phase trait with an operation that enumerates the dependencies that need to be satisfied to bring a given AST node up to a particular phase. Start with ``TypeRepr`` nodes, and use the dependency graph and priority queue to satisfy all dependencies ahead of time, eliminating direct recursion from the type-resolution code path. Build circular-dependency detection within this test-bed.
@@ -165,7 +165,7 @@ The proposed architecture is significantly different from the current type check
How do we test it?
~~~~~~~~~~~~~~~~~~
-**Existing code continues to work**: As we move various parts of the type checker over to the dependency graph, existing Swift code should continue to work, since we'll have fallbacks to the existing logic and the new type checker should be strictly more lazy than the existing type checker.
+**Existing code continues to work**: As we move various parts of the type checker over to the dependency graph, existing Swift code should continue to work, since we'll have fallbacks to the existing logic and the new type checker should be strictly lazier than the existing type checker.
**Order-independence testing**: One of the intended improvements from this type checker architecture is that we should get more predictable order-independent behavior. To check this, we can randomly scramble the order in which we type-check declarations in the primary source file of a well-formed module and verify that we get the same results.
@@ -180,4 +180,4 @@ The proposed change is a major architectural shift, and it's only complete when
**Accessors that check the current phase**: When we're finished, each of the AST's accessors should assert that the AST node is in the appropriate phase. The number of such assertions that have been enabled is an indication of how well the type checker is respecting the dependencies.
-**Phases of AST nodes in non-primary files**: With the current type checker, every AST node in a non-primary file that gets touched when type-checking the primary file will end up being fully validated (currently, the "attribute checking" phase). As the type checker gets more lazy, the AST nodes in non-primary files will trend toward earlier phases. Tracking the number of nodes in non-primary files at each phase over time will help us establish how lazy the type checker is becoming.
+**Phases of AST nodes in non-primary files**: With the current type checker, every AST node in a non-primary file that gets touched when type-checking the primary file will end up being fully validated (currently, the "attribute checking" phase). As the type checker gets lazier, the AST nodes in non-primary files will trend toward earlier phases. Tracking the number of nodes in non-primary files at each phase over time will help us establish how lazy the type checker is becoming.
diff --git a/docs/proposals/Enums.rst b/docs/proposals/Enums.rst
index 46402160b1a1f..607596bd4d9b6 100644
--- a/docs/proposals/Enums.rst
+++ b/docs/proposals/Enums.rst
@@ -281,7 +281,7 @@ circumstances:
StringLiteralConvertible.
- None of the cases of the enum may have non-void payloads.
-If an enum declares an raw type, then its cases may declare raw
+If an enum declares a raw type, then its cases may declare raw
values. raw values must be integer, float, character, or string
literals, and must be unique within the enum. If the raw type is
IntegerLiteralConvertible, then the raw values default to
diff --git a/docs/proposals/InitializerInheritance.rst b/docs/proposals/InitializerInheritance.rst
index 688c0f36b34b6..8e833d72c85e6 100644
--- a/docs/proposals/InitializerInheritance.rst
+++ b/docs/proposals/InitializerInheritance.rst
@@ -50,16 +50,16 @@ We can also distinguish two ways to originally invoke an initializer:
Either kind of dispatched initialization poses a soundness problem
because there may not be a sound initializer with any given signature
in the most-derived class. In ObjC, initializers are normal instance
-methods and are therefore inherited like normal, but this isn’t really
+methods and are therefore inherited like normal, but this isn't really
quite right; initialization is different from a normal method in that
-it’s not inherently sensible to require subclasses to provide
+it's not inherently sensible to require subclasses to provide
initializers at all the signatures that their superclasses provide.
Subobject initializers
~~~~~~~~~~~~~~~~~~~~~~
The defining class of a subobject initializer is central to its
behavior. It can be soundly inherited by a class C only if is trivial
-to initialize the ivars of C, but it’s convenient to ignore that and
+to initialize the ivars of C, but it's convenient to ignore that and
assume that subobjects will always trivially wrap and delegate to
superclass subobject initializers.
@@ -75,7 +75,7 @@ initializer of a class C if and only if it is defined by C.
Complete object initializers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-The defining class of a complete object initializer doesn’t really
+The defining class of a complete object initializer doesn't really
matter. In principle, complete object initializers could just as well
be freestanding functions to which a metatype is passed. It can make
sense to inherit a complete object initializer.
@@ -90,11 +90,11 @@ A complete object initializer soundly acts like a complete object
initializer of a class C if and only if it delegates to an initializer
which soundly acts like a complete object initializer of C.
-These rules are not obvious to check statically because they’re
+These rules are not obvious to check statically because they're
dependent on the dynamic value of the most-derived class C. Therefore
any ability to check them depends on restricting C somehow relative to
the defining class of the initializer. Since, statically, we only
-know the defining class of the initializer, we can’t establish
+know the defining class of the initializer, we can't establish
soundness solely at the definition site; instead we have to prevent
unsound initializers from being called.
@@ -116,7 +116,7 @@ Virtual initializers
The above condition is not sufficient to make indirect initialization
sound, because it relies on the ability to simply not use an
initializer in cases where its delegation behavior isn't known to be
-sound, and we can’t do that to arbitrary code. For that, we would
+sound, and we can't do that to arbitrary code. For that, we would
need true virtual initializers.
A virtual initializer is a contract much more like that of a standard
@@ -378,7 +378,7 @@ a trivial ``NSDocument``::
In Swift, there would be no way to create an object of type
``MyDocument``. However, the frameworks will allocate an instance of
-``MyDocument`` and then send an message such as
+``MyDocument`` and then send a message such as
``initWithContentsOfURL:ofType:error:`` to the object. This will find
``-[NSDocument initWithContentsOfURL:ofType:error:]``, which delegates
to ``-[NSDocument init]``, leaving ``MyDocument``'s stored properties
diff --git a/docs/proposals/InoutCOWOptimization.rst b/docs/proposals/InoutCOWOptimization.rst
index cc88b59e77ffc..c784fda253786 100644
--- a/docs/proposals/InoutCOWOptimization.rst
+++ b/docs/proposals/InoutCOWOptimization.rst
@@ -25,8 +25,8 @@ The problem is caused as follows:
x[0].mutate()
- we “``subscript get``” ``x[0]`` into a temporary, mutate the
- temporary, and “``subscript set``” it back into ``x[0]``.
+ we "``subscript get``" ``x[0]`` into a temporary, mutate the
+ temporary, and "``subscript set``" it back into ``x[0]``.
* When the element itself is a COW type, that temporary implies a
retain count of at least 2 on the element's buffer.
@@ -51,7 +51,7 @@ could be written as follows:
protocol Sliceable {
...
@mutating
- func quickSort(compare: (StreamType.Element, StreamType.Element)->Bool) {
+ func quickSort(compare: (StreamType.Element, StreamType.Element) -> Bool) {
let (start,end) = (startIndex, endIndex)
if start != end && start.succ() != end {
let pivot = self[start]
diff --git a/docs/proposals/Inplace.rst b/docs/proposals/Inplace.rst
index 95d31e1623fc4..d2225fad20bf5 100644
--- a/docs/proposals/Inplace.rst
+++ b/docs/proposals/Inplace.rst
@@ -23,12 +23,12 @@ In recent standard library design meetings about the proper API for
sets, it was decided that the canonical ``Set`` interface should be
written in terms of methods: [#operators]_ ::
- struct Set {
- public func contains(x: T) -> Bool // x ∈ A, A ∋ x
- public func isSubsetOf(b: Set) -> Bool // A ⊆ B
- public func isStrictSubsetOf(b: Set) -> Bool // A ⊂ B
- public func isSupersetOf(b: Set) -> Bool // A ⊇ B
- public func isStrictSupersetOf(b: Set) -> Bool // A ⊃ B
+ struct Set {
+ public func contains(x: Element) -> Bool // x ∈ A, A ∋ x
+ public func isSubsetOf(b: Set) -> Bool // A ⊆ B
+ public func isStrictSubsetOf(b: Set) -> Bool // A ⊂ B
+ public func isSupersetOf(b: Set) -> Bool // A ⊇ B
+ public func isStrictSupersetOf(b: Set) -> Bool // A ⊃ B
...
}
@@ -36,17 +36,17 @@ When we started to look at the specifics, however, we ran into a
familiar pattern::
...
- public func union(b: Set) -> Set // A ∪ B
- public mutating func unionInPlace(b: Set) // A ∪= B
+ public func union(b: Set) -> Set // A ∪ B
+ public mutating func unionInPlace(b: Set) // A ∪= B
- public func intersect(b: Set) -> Set // A ∩ B
- public mutating func intersectInPlace(b: Set) // A ∩= B
+ public func intersect(b: Set) -> Set // A ∩ B
+ public mutating func intersectInPlace(b: Set) // A ∩= B
- public func subtract(b: Set) -> Set // A - B
- public mutating func subtractInPlace(b: Set) // A -= B
+ public func subtract(b: Set) -> Set // A - B
+ public mutating func subtractInPlace(b: Set) // A -= B
- public func exclusiveOr(b: Set) -> Set // A ⊕ B
- public mutating func exclusiveOrInPlace(b: Set) // A ⊕= B
+ public func exclusiveOr(b: Set) -> Set // A ⊕ B
+ public mutating func exclusiveOrInPlace(b: Set) // A ⊕= B
We had seen the same pattern when considering the API for
``String``, but in that case, there are no obvious operator
@@ -310,7 +310,7 @@ as though it were written:
.. parsed-literal::
{
- (var y: X)->X in
+ (var y: X) -> X in
y\ **.=**\ *f*\ (a₀, p₁: a₁, p₂: a₂, …p\ *n*: a\ *n*)
return y
}(x)
@@ -344,7 +344,7 @@ as though it were written:
.. parsed-literal::
{
- (var y: X)->X in
+ (var y: X) -> X in
y *op*\ **=**\ *expression*
return y
}(x)
@@ -424,7 +424,7 @@ fine::
foo.=advanced(10)
The alternative would be to say that explicitly-written assignment methods
-cannot work properly for immutable classes and “work” with reference
+cannot work properly for immutable classes and "work" with reference
semantics on other classes. We consider this approach indefensible,
especially when one considers that operators encourage writing
algorithms that can only work properly with value semantics and will
diff --git a/docs/proposals/OptimizerEffects.rst b/docs/proposals/OptimizerEffects.rst
index 1dafd11e9ca4a..c22b626cf8b18 100644
--- a/docs/proposals/OptimizerEffects.rst
+++ b/docs/proposals/OptimizerEffects.rst
@@ -482,7 +482,7 @@ destructor can have arbitrary side-effects. Therefore, it is not valid to hoist
the makeUnique in the code without proving that 'T's destructor cannot change
the uniqueness state. This is trivial for trivial types but requires a more
sophisticated analysis for class types (and in general cannot be disproved). In
-following example we can only hoist makeUnique if we can prove that elt's, and
+following example we can only hoist makeUnique if we can prove that elt's, and
elt2's destructor can't change the uniqueness state of the arrays.::
for i in 0 ..< min(a.size, b.size) {
@@ -795,7 +795,7 @@ Store (1) and load (2) do not alias and (3) is defined as ``readnone``. So (1)
could be moved over (3).
Currently inlining is prevented in high-level SIL for all functions which
-have an semantics or effect attribute. Therefore we could say that the
+have a semantics or effect attribute. Therefore we could say that the
implementor of a pure value type has to define effects on all member functions
which eventually can access or modify the storage.
diff --git a/docs/proposals/ValueSemantics.rst b/docs/proposals/ValueSemantics.rst
index 3541d407e0a09..c48dd11fb50bc 100644
--- a/docs/proposals/ValueSemantics.rst
+++ b/docs/proposals/ValueSemantics.rst
@@ -25,7 +25,7 @@ Value Semantics
---------------
For a type with value semantics, variable initialization, assignment,
-and argument-passing (hereafter, “the big three operations”) each
+and argument-passing (hereafter, "the big three operations") each
create an *independently modifiable copy* of the source value that is
*interchangeable with the source*. [#interchange]_
@@ -151,13 +151,13 @@ The Problem With Generics
The classic Liskov principle says the semantics of operations on
``Duck``\ 's subtypes need to be consistent with those on ``Duck`` itself,
-so that functions operating on ``Duck``\ s still “work” when passed a
+so that functions operating on ``Duck``\ s still "work" when passed a
``Mallard``. More generally, for a function to make meaningful
guarantees, the semantics of its sub-operations need to be consistent
regardless of the actual argument types passed.
The type of an argument passed by-value to an ordinary function is
-fully constrained, so the “big three” have knowable semantics. The
+fully constrained, so the "big three" have knowable semantics. The
type of an ordinary argument passed by-reference is constrained by
subtype polymorphism, where a (usually implicit) contract between
base- and sub-types can dictate consistency.
@@ -175,11 +175,11 @@ pseudo-random number generator). It needs to make one copy and do
in-place mutation of the state, rather than wholesale value
replacement via assignment, which might be expensive.
-Here’s a version of cycle_length that works when state is a mutable
+Here's a version of cycle_length that works when state is a mutable
value type::
func cycle_length(
- s : State, mutate : ( [inout] State )->()
+ s : State, mutate : ( [inout] State ) -> ()
) -> Int
requires State : EqualityComparable
{
@@ -196,7 +196,7 @@ value type::
The reason the above breaks when the state is in a class instance is
that the intended copy in line 1 instead creates a new reference to
the same state, and the comparison in line 2 (regardless of whether we
-decide ``!=`` does “identity” or “value” comparison) always succeeds.
+decide ``!=`` does "identity" or "value" comparison) always succeeds.
You can write a different implementation that only works on clonable
classes:
@@ -211,7 +211,7 @@ classes:
}
func cycle_length(
- s : State, mutate : ( [inout] State )->()
+ s : State, mutate : ( [inout] State ) -> ()
) -> Int
requires State : EqualityComparable, **Clonable**
{
@@ -233,8 +233,8 @@ clonable classes:
func cycle_length(
s : State,
- **next : (x : State)->State,**
- **equal : ([inout] x : State, [inout] y : State)->Bool**
+ **next : (x : State) -> State,**
+ **equal : ([inout] x : State, [inout] y : State) -> Bool**
) -> Int
requires State : EqualityComparable
{
diff --git a/docs/proposals/archive/Memory and Concurrency Model.rst b/docs/proposals/archive/Memory and Concurrency Model.rst
index 82dc4bd50d986..5a5fa6f95c58f 100644
--- a/docs/proposals/archive/Memory and Concurrency Model.rst
+++ b/docs/proposals/archive/Memory and Concurrency Model.rst
@@ -48,7 +48,7 @@ Swift. Given a static type, it is obvious what kind it is from its
definition. These kinds are:
1. **Immutable Data** - Immutable data (which can have a constructor, but whose
- value cannot be changed after it completes) is sharable across actors, and it
+ value cannot be changed after it completes) is shareable across actors, and it
would make sense to unique them where possible. Immutable data can
(transitively) point to other immutable data, but it isn't valid (and the
compiler rejects) immutable data that is pointing to mutable data. For
@@ -322,7 +322,7 @@ covered by this model at all. For example, having multiple threads execute on
different slices of the same array would require copying the array to temporary
disjoint memory spaces to do operations, then recopy it back into place. This
data copying can be awkward and reduce the benefits of parallelism to make it
-non- profitable.
+non-profitable.
There are multiple different ways to tackle this. We can just throw it back into
the programmer's lap and tell them that the behavior is undefined if they get a
diff --git a/docs/proposals/archive/ProgramStructureAndCompilationModel.rst b/docs/proposals/archive/ProgramStructureAndCompilationModel.rst
index dd21306bbfd99..c659f44ea875d 100644
--- a/docs/proposals/archive/ProgramStructureAndCompilationModel.rst
+++ b/docs/proposals/archive/ProgramStructureAndCompilationModel.rst
@@ -57,7 +57,7 @@ world.
In the trivial hello world example, the source file gets implicitly dropped into
a default component (since it doesn't have a component declaration). The default
component has settings that corresponds to an executable. As the app grows and
-wants to start using sub- libraries, the author would have to know about
+wants to start using sub-libraries, the author would have to know about
components. This ensures a simple model for new people, because they don't need
to know anything about components until they want to define a library and stable
APIs.
@@ -132,7 +132,7 @@ Components can optionally be broken into a set of "**Subcomponents**", which are
organizational units within a top-level component. Subcomponents exist to
support extremely large components that have multiple different teams
contributing to a single large product. Subcomponents are purely an
-implementation detail of top- level components and have no runtime,
+implementation detail of top-level components and have no runtime,
naming/namespace, or other externally visible artifacts that persist once the
entire domain is built. If version 1.0 of a domain is shipped, version 1.1 can
completely reshuffle the internal subcomponent organization without affecting
@@ -275,7 +275,7 @@ diagnosed here.
If this directory is a subcomponent (as opposed to a top-level component), the
subcomponent declaration has already been read. If this subcomponent depends on
-any other components that are not up-to- date, those are recursively
+any other components that are not up-to-date, those are recursively
rebuilt. Explicit subcomponent dependencies are acyclic and cycles are diagnosed
here. Now all depended-on top-level components and subcomponents are built.
@@ -306,7 +306,7 @@ declared cyclic dependencies match the given and actual prototype. 2) resources
are copied or processed into the product directory. 3) the explicit dependence
graph is verified, extraneous edges are warned about, missing edges are errors.
-In terms of implementation, this should be relatively straight- forward, and is
+In terms of implementation, this should be relatively straight-forward, and is
carefully layered to be memory efficient (e.g. only processing an SCC at a time
instead of an entire component) as well as highly parallel for multicore
machines. For incremental builds, we will have a huge win because the
@@ -330,7 +330,7 @@ client builds against the component to type check the client and ensure that its
references are resolved.
Because we have the version number as well as the full interface to the
-component available in a consumable format is that we can build a SDK generation
+component available in a consumable format is that we can build an SDK generation
tool. This tool would take manifest files for a set of releases (e.g. iOS 4.0,
4.0.1, 4.0.2, 4.1, 4.1.1, 4.2) and build a single SDK manifest which would have
a mapping from symbol+type -> version list that indicates what the versions a
diff --git a/docs/proposals/containers_value_type.html b/docs/proposals/containers_value_type.html
index ff7855e29e464..c64d60c53cf5f 100644
--- a/docs/proposals/containers_value_type.html
+++ b/docs/proposals/containers_value_type.html
@@ -231,7 +231,7 @@
those used in Cocoa. Now there is absolutely nothing wrong with high
quality, strictly followed naming conventions. But they aren't checked
by the compiler. Having the compiler be able to confirm: yes, this
-argument can be modified / no, that argument can not be modified; is a
+argument can be modified / no, that argument cannot be modified; is a
tremendous productivity booster.
@@ -482,7 +482,7 @@ Summary
more easily spot the few cases where this is desired.
-- Swift can not provide such protection for types with reference semantics.
+- Swift cannot provide such protection for types with reference semantics.
diff --git a/docs/proposals/rejected/Bridging Container Protocols to Class Clusters.rst b/docs/proposals/rejected/Bridging Container Protocols to Class Clusters.rst
index cbef36e587f2d..f80400d1b6fc4 100644
--- a/docs/proposals/rejected/Bridging Container Protocols to Class Clusters.rst
+++ b/docs/proposals/rejected/Bridging Container Protocols to Class Clusters.rst
@@ -24,7 +24,7 @@ Here's what I propose instead:
Although I'll be talking about arrays in this proposal, I think the same
approach would work for ``NSDictionary`` and ``NSSet`` as well, mapping them
-to generic containers for associative map and and unordered container protocols
+to generic containers for associative map and unordered container protocols
respectively.
NSArray vs Array
diff --git a/docs/proposals/rejected/ClassConstruction.rst b/docs/proposals/rejected/ClassConstruction.rst
index 74452b7a1da9f..5b1ea48747c5d 100644
--- a/docs/proposals/rejected/ClassConstruction.rst
+++ b/docs/proposals/rejected/ClassConstruction.rst
@@ -7,7 +7,7 @@
.. warning:: This proposal was rejected, though it helped in the design of the
final Swift 1 initialization model.
-Objective-C's “designated initializers pattern seems at first to
+Objective-C's "designated initializers pattern seems at first to
create a great deal of complication. However, designated initializers
are simply the only sane response to Objective-C's initialization rules,
which are the root cause of the complication.
@@ -116,9 +116,9 @@ Proposal
========
I suggest we define Swift initialization to be as simple and
-easily-understood as possible, and avoid “interesting” interactions
+easily-understood as possible, and avoid "interesting" interactions
with the more complicated Objective-C initialization process. If we
-do this, we can treat Objective-C base classes as “sealed and safe”
+do this, we can treat Objective-C base classes as "sealed and safe"
for the purpose of initialization, and help programmers reason
effectively about initialization and their class invariants.
@@ -133,7 +133,7 @@ Here are the proposed rules:
Objective-C.
* ``self.init(…)`` calls in Swift never dispatch virtually. We have a
- safe model for “virtual initialization:” ``init`` methods can call
+ safe model for "virtual initialization:" ``init`` methods can call
overridable methods after all instance variables and superclasses
are initialized. Allowing *virtual* constructor delegation would
undermine that safety.
diff --git a/docs/proposals/rejected/Clonable.rst b/docs/proposals/rejected/Clonable.rst
index 949ecf93cb883..39bf2c5d08a41 100644
--- a/docs/proposals/rejected/Clonable.rst
+++ b/docs/proposals/rejected/Clonable.rst
@@ -15,7 +15,7 @@
language-level copying mechanism for classes.
**Abstract:** to better support the creation of value types, we
-propose a “magic” ``Clonable`` protocol and an annotation for describing
+propose a "magic" ``Clonable`` protocol and an annotation for describing
which instance variables should be cloned when a type is copied. This
proposal **augments revision 1** of the Clonable proposal with our
rationale for dropping our support for ``val`` and ``ref``, a
@@ -65,7 +65,7 @@ automatic, if we add that feature) forwarding.
By dropping ``val`` we also lose some terseness aggregating ``class``
contents into ``struct``\ s. However, since ``ref`` is being dropped
-there's less call for a symmetric ``val``. The extra “cruft” that
+there's less call for a symmetric ``val``. The extra "cruft" that
``[clone]`` adds actually seems appropriate when viewed as a special
bridge for ``class`` types, and less like a penalty against value
types.
@@ -125,7 +125,7 @@ variables marked ``[clone]``::
var somethingIJustReferTo : Bar
}
-When a ``Baz`` is copied by any of the “big three” operations (variable
+When a ``Baz`` is copied by any of the "big three" operations (variable
initialization, assignment, or function argument passing), even as
part of a larger ``struct``, its ``[clone]`` member is ``clone()``\ d.
Because ``Foo`` itself has a ``[clone]`` member, that is ``clone()``\ d
diff --git a/docs/proposals/rejected/Constructors.rst b/docs/proposals/rejected/Constructors.rst
index fc69a38f4b6ab..c88b9b7802571 100644
--- a/docs/proposals/rejected/Constructors.rst
+++ b/docs/proposals/rejected/Constructors.rst
@@ -461,11 +461,11 @@ zero-argument selector with no trailing colon, e.g.,::
maps to the selector ``initToMemory``.
-This mapping is reversible: given a selector in the “init” family,
-i.e., where the first word is “init”, we split the selector into its
+This mapping is reversible: given a selector in the "init" family,
+i.e., where the first word is "init", we split the selector into its
various pieces at the colons:
-* For the first piece, we remove the “init” and then lowercase the
+* For the first piece, we remove the "init" and then lowercase the
next character *unless* the second character is also uppercase. This
becomes the name of the first parameter to the constructor. If this
string is non-empty and the selector is a zero-argument selector
diff --git a/docs/proposals/valref.rst b/docs/proposals/valref.rst
index b2c9987ec7f65..7adbd9608778a 100644
--- a/docs/proposals/valref.rst
+++ b/docs/proposals/valref.rst
@@ -29,15 +29,15 @@ Introduction
Until recently, Swift's support for value semantics outside trivial
types like scalars and immutable strings has been weak. While the
-recent ``Clonable`` proposal makes new things possible in the “safe”
+recent ``Clonable`` proposal makes new things possible in the "safe"
zone, it leaves the language syntactically and semantically lumpy,
keeping interactions between value and reference types firmly outside
-the “easy” zone and failing to address the issue of generic
+the "easy" zone and failing to address the issue of generic
programming.
This proposal builds on the ``Clonable`` proposal to create a more
uniform, flexible, and interoperable type system while solving the
-generic programming problem and expanding the “easy” zone.
+generic programming problem and expanding the "easy" zone.
General Description
===================
@@ -68,8 +68,8 @@ When applied to ``class`` types, "copy" means to call the ``clone()``
method, which is generated by the compiler when the user has
explicitly declared conformance to the ``Clonable`` protocol.
-When we refer to variables being “declared ``val``” or “declared
-``ref``”, we mean to include the case of equivalent declarations using
+When we refer to variables being "declared ``val``" or "declared
+``ref``", we mean to include the case of equivalent declarations using
``var`` that request the default semantics for the type.
Unless otherwise specified, we discuss implementation details such as
@@ -178,8 +178,8 @@ Array elements can be explicitly declared ``val`` or ``ref``::
When a reference to an array appears without a variable name, it can
be written using the `usual syntax`__::
- var f : ()->ref Int[42] // a closure returning a reference to an array
- var b : ref Int[42] // equivalent to to "ref b : Int[42]"
+ var f : () -> ref Int[42] // a closure returning a reference to an array
+ var b : ref Int[42] // equivalent to "ref b : Int[42]"
__ `standalone types`_
@@ -191,8 +191,8 @@ brackets, that most users will never touch, e.g.::
var z : Array[ // an array of 42 integers-on-the-heap
var z : Array][, 2> // an array of 2 references to arrays
ref a : Array // a reference to an array of 42 integers
- var f : ()->ref Array // a closure returning a reference to an array
- var b : ref Array // equivalent to to "ref b : Int[42]"
+ var f : () -> ref Array // a closure returning a reference to an array
+ var b : ref Array // equivalent to "ref b : Int[42]"
Rules for copying array elements follow those of instance variables.
@@ -290,7 +290,7 @@ type parameter, as follows::
parameters::
// Fill an array with independent copies of x
- func fill(array:T[], x:T) {
+ func fill(array:[T], x:T) {
for i in 0...array.length {
array[i] = x
}
@@ -425,7 +425,7 @@ How This Design Improves Swift
matters.
4. We move the cases where values and references interact much closer
- to, and arguably into, the “easy” zone.
+ to, and arguably into, the "easy" zone.
How This Design Beats Rust/C++/C#/etc.
======================================
@@ -437,7 +437,7 @@ How This Design Beats Rust/C++/C#/etc.
rooting`__, etc. By contrast, there's a path to learning swift that
postpones the ``val``\ /``ref`` distinction, and that's pretty much
*all* one must learn to have a complete understanding of the object
- model in the “easy” and “safe” zones.
+ model in the "easy" and "safe" zones.
__ http://static.rust-lang.org/doc/tutorial.html#boxes-and-pointers
__ http://static.rust-lang.org/doc/tutorial-borrowed-ptr.html#named-lifetimes
@@ -560,7 +560,7 @@ example:
There's always the dreaded ``auto``.
* Should we drop ``let``\ /``var``\ /``auto`` for ivars, because it
- “just feels wrong” there?
+ "just feels wrong" there?
* ``ref`` is spelled like ``[inout]``, but they mean very different things
@@ -569,7 +569,7 @@ example:
``[inout]``.
* Should we spell ``[inout]`` differently? I think at a high level
- it means something like “``[rebind]`` the name to a new value.”
+ it means something like "``[rebind]`` the name to a new value."
* Do we want to consider replacing ``struct`` and/or ``class`` with
new names such as ``valtype`` and ``reftype``? We don't love those
diff --git a/docs/scripts/ns-html2rst b/docs/scripts/ns-html2rst
index 004cf6f6d6a29..82d8d92d70a4d 100755
--- a/docs/scripts/ns-html2rst
+++ b/docs/scripts/ns-html2rst
@@ -1,49 +1,53 @@
#!/usr/bin/env python
-import sys, re, subprocess
+from __future__ import print_function
+
+import re
+import subprocess
+import sys
def run():
if len(sys.argv) > 1:
- print """
+ print("""
ns-html2rst - Convert Cocoa HTML documentation into ReST
usage: nshtml2rst < NSString.html > NSString.rst
- """
- exit(0)
+ """)
+ sys.exit(0)
html = sys.stdin.read()
# Treat ](.*?)
',
- r'\1
',
- html, flags=re.MULTILINE|re.DOTALL)
+ r'(.*?)
',
+ r'\1
',
+ html, flags=re.MULTILINE | re.DOTALL)
# Strip all attributes from ...
containing class="..."
# The resulting classes confound ReST
html = re.sub(
- r']*class=[^>]*>(.*?)
',
- r'\1
',
- html, flags=re.MULTILINE|re.DOTALL)
+ r']*class=[^>]*>(.*?)
',
+ r'\1
',
+ html, flags=re.MULTILINE | re.DOTALL)
# Remove links from ..., which doesn't have a rendering in ReST
html = re.sub(
- r'(.*?)]*?>(.*?)(.*?)',
- r'\1\2\3',
- html, flags=re.MULTILINE|re.DOTALL)
+ r'(.*?)]*?>(.*?)(.*?)',
+ r'\1\2\3',
+ html, flags=re.MULTILINE | re.DOTALL)
# Let pandoc do most of the hard work
p = subprocess.Popen(
- args=['pandoc', '--reference-links', '-f', 'html', '-t', 'rst']
- , stdin=subprocess.PIPE
- , stdout=subprocess.PIPE
+ args=['pandoc', '--reference-links', '-f', 'html', '-t', 'rst'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE
)
- rst,stderr = p.communicate(html)
+ rst, stderr = p.communicate(html)
# HACKETY HACK HACK: Our html documents apparently contain some
# bogus heading level nesting. Just fix up the one we know about
# so that ReST doesn't complain later.
- rst = re.sub("(^|\n)('+)($|\n)",
- lambda m: m.group(1) + len(m.group(2))*'^' +m.group(3),
+ rst = re.sub("(^|\n)('+)($|\n)",
+ lambda m: m.group(1) + len(m.group(2)) * '^' + m.group(3),
rst, flags=re.MULTILINE)
sys.stdout.write(rst)
diff --git a/include/swift/ABI/Class.h b/include/swift/ABI/Class.h
index 8a3807fef4e10..9b1c7ad858a56 100644
--- a/include/swift/ABI/Class.h
+++ b/include/swift/ABI/Class.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/ABI/MetadataKind.def b/include/swift/ABI/MetadataKind.def
index 9bef04dfd9c92..7747bd9def2e9 100644
--- a/include/swift/ABI/MetadataKind.def
+++ b/include/swift/ABI/MetadataKind.def
@@ -1,8 +1,8 @@
-//===--- MetadataKind.def --------------------------------------*- C++ -*--===//
+//===--- MetadataKind.def ---------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/ABI/MetadataValues.h b/include/swift/ABI/MetadataValues.h
index 73ec6843095eb..21d833580cfe4 100644
--- a/include/swift/ABI/MetadataValues.h
+++ b/include/swift/ABI/MetadataValues.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -19,6 +19,8 @@
#ifndef SWIFT_ABI_METADATAVALUES_H
#define SWIFT_ABI_METADATAVALUES_H
+#include "swift/AST/Ownership.h"
+
#include
#include
@@ -92,9 +94,57 @@ enum : unsigned {
/// Number of words reserved in generic metadata patterns.
NumGenericMetadataPrivateDataWords = 16,
};
+
+/// Records information about a type's fields.
+struct FieldRecordFlags {
+protected:
+ using int_type = unsigned;
+ int_type Data;
+
+ enum : int_type {
+ InternalExternalMask = 0x00000001U,
+ InternalExternalShift = 0,
+ OwnershipMask = 0x00000006U,
+ OwnershipShift = 1,
+ };
+
+public:
+ FieldRecordFlags() : Data(0) {}
+
+ /// True if this field has a type defined in the same image
+ /// as the type that contains it.
+ constexpr bool isInternal() const {
+ return ((Data >> InternalExternalShift) & InternalExternalMask) == 0;
+ }
+
+ /// True if this field has a type that is defined in another
+ /// image as the type that contains it.
+ constexpr bool isExternal() const {
+ return !isInternal();
+ }
+
+ /// Get the ownership semantics if the field has a reference type.
+ constexpr Ownership getOwnership() const {
+ return Ownership((Data >> OwnershipShift) & OwnershipMask);
+ }
+
+ void setInternal(bool internal) {
+ if (internal)
+ Data &= ~InternalExternalMask;
+ else
+ Data |= InternalExternalMask;
+ }
+
+ void setOwnership(Ownership ownership) {
+ Data &= ~OwnershipMask;
+ Data |= int_type(ownership) << OwnershipShift;
+ }
+
+ int_type getValue() const { return Data; }
+};
-/// Kinds of protocol conformance record.
-enum class ProtocolConformanceTypeKind : unsigned {
+/// Kinds of type metadata/protocol conformance records.
+enum class TypeMetadataRecordKind : unsigned {
/// The conformance is universal and might apply to any type.
/// getDirectType() is nil.
Universal,
@@ -117,10 +167,10 @@ enum class ProtocolConformanceTypeKind : unsigned {
/// and classes could be emitted as UniqueDirectType.
UniqueIndirectClass,
- /// The conformance is for a generic type.
- /// getGenericPattern() points to the generic metadata pattern used to
- /// form instances of the type.
- UniqueGenericPattern,
+ /// The conformance is for a generic or resilient type.
+ /// getNominalTypeDescriptor() points to the nominal type descriptor shared
+ /// by all metadata instantiations of this type.
+ UniqueNominalTypeDescriptor,
/// The conformance is for a nongeneric class type.
/// getDirectType() points to the unique class object.
@@ -130,7 +180,7 @@ enum class ProtocolConformanceTypeKind : unsigned {
/// platforms, the class object always is the type metadata.
UniqueDirectClass = 0xF,
};
-
+
/// Kinds of reference to protocol conformance.
enum class ProtocolConformanceReferenceKind : unsigned {
/// A direct reference to a protocol witness table.
@@ -139,32 +189,51 @@ enum class ProtocolConformanceReferenceKind : unsigned {
/// table.
WitnessTableAccessor,
};
-
-struct ProtocolConformanceFlags {
-private:
+
+// Type metadata record discriminant
+struct TypeMetadataRecordFlags {
+protected:
using int_type = unsigned;
int_type Data;
enum : int_type {
TypeKindMask = 0x0000000FU,
TypeKindShift = 0,
- ConformanceKindMask = 0x00000010U,
- ConformanceKindShift = 4,
};
public:
- constexpr ProtocolConformanceFlags() : Data(0) {}
- constexpr ProtocolConformanceFlags(int_type Data) : Data(Data) {}
+ constexpr TypeMetadataRecordFlags() : Data(0) {}
+ constexpr TypeMetadataRecordFlags(int_type Data) : Data(Data) {}
- constexpr ProtocolConformanceTypeKind getTypeKind() const {
- return ProtocolConformanceTypeKind((Data >> TypeKindShift) & TypeKindMask);
+ constexpr TypeMetadataRecordKind getTypeKind() const {
+ return TypeMetadataRecordKind((Data >> TypeKindShift) & TypeKindMask);
}
+ constexpr TypeMetadataRecordFlags withTypeKind(
+ TypeMetadataRecordKind ptk) const {
+ return TypeMetadataRecordFlags(
+ (Data & ~TypeKindMask) | (int_type(ptk) << TypeKindShift));
+ }
+
+ int_type getValue() const { return Data; }
+};
+
+// Protocol conformance discriminant
+struct ProtocolConformanceFlags : public TypeMetadataRecordFlags {
+private:
+ enum : int_type {
+ ConformanceKindMask = 0x00000010U,
+ ConformanceKindShift = 4,
+ };
+
+public:
+ constexpr ProtocolConformanceFlags() : TypeMetadataRecordFlags(0) {}
+ constexpr ProtocolConformanceFlags(int_type Data) : TypeMetadataRecordFlags(Data) {}
+
constexpr ProtocolConformanceFlags withTypeKind(
- ProtocolConformanceTypeKind ptk) const {
+ TypeMetadataRecordKind ptk) const {
return ProtocolConformanceFlags(
(Data & ~TypeKindMask) | (int_type(ptk) << TypeKindShift));
}
-
constexpr ProtocolConformanceReferenceKind getConformanceKind() const {
return ProtocolConformanceReferenceKind((Data >> ConformanceKindShift)
& ConformanceKindMask);
@@ -174,8 +243,6 @@ struct ProtocolConformanceFlags {
return ProtocolConformanceFlags(
(Data & ~ConformanceKindMask) | (int_type(pck) << ConformanceKindShift));
}
-
- int_type getValue() const { return Data; }
};
/// Flag that indicates whether an existential type is class-constrained or not.
diff --git a/include/swift/ABI/System.h b/include/swift/ABI/System.h
index f0214fd427b85..2ccb7bf149b6b 100644
--- a/include/swift/ABI/System.h
+++ b/include/swift/ABI/System.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -93,4 +93,9 @@
#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL
#define SWIFT_ABI_ARM64_OBJC_NUM_RESERVED_LOW_BITS 0
+/*********************************** powerpc64 ************************************/
+
+// Heap objects are pointer-aligned, so the low three bits are unused.
+#define SWIFT_ABI_POWERPC64_SWIFT_SPARE_BITS_MASK 0x0000000000000007ULL
+
#endif /* SWIFT_ABI_SYSTEM_H */
diff --git a/include/swift/AST/AST.h b/include/swift/AST/AST.h
index b0b68744720da..283ceb1e7d7d4 100644
--- a/include/swift/AST/AST.h
+++ b/include/swift/AST/AST.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -25,6 +25,7 @@
#include "swift/AST/ExprHandle.h"
#include "swift/AST/Initializer.h"
#include "swift/AST/Module.h"
+#include "swift/AST/ParameterList.h"
#include "swift/AST/Pattern.h"
#include "swift/AST/Stmt.h"
#include "swift/AST/Types.h"
diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h
index d799e024e2734..b09bab0563ce7 100644
--- a/include/swift/AST/ASTContext.h
+++ b/include/swift/AST/ASTContext.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -34,7 +34,6 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Allocator.h"
#include
#include
@@ -100,6 +99,26 @@ enum class AllocationArena {
ConstraintSolver
};
+/// Lists the set of "known" Foundation entities that are used in the
+/// compiler.
+///
+/// While the names of Foundation types aren't likely to change in
+/// Objective-C, their mapping into Swift can. Therefore, when
+/// referring to names of Foundation entities in Swift, use this enum
+/// and \c ASTContext::getSwiftName or \c ASTContext::getSwiftId.
+enum class KnownFoundationEntity {
+#define FOUNDATION_ENTITY(Name) Name,
+#include "swift/AST/KnownFoundationEntities.def"
+};
+
+/// Retrieve the Foundation entity kind for the given Objective-C
+/// entity name.
+Optional getKnownFoundationEntity(StringRef name);
+
+/// Determine with the non-prefixed name of the given known Foundation
+/// entity conflicts with the Swift standard library.
+bool nameConflictsWithStandardLibrary(KnownFoundationEntity entity);
+
/// Callback function used when referring to a type member of a given
/// type variable.
typedef std::function
@@ -281,7 +300,7 @@ class ASTContext {
template
typename std::remove_reference::type *AllocateObjectCopy(T &&t,
AllocationArena arena = AllocationArena::Permanent) const {
- // This function can not be named AllocateCopy because it would always win
+ // This function cannot be named AllocateCopy because it would always win
// overload resolution over the AllocateCopy(ArrayRef).
using TNoRef = typename std::remove_reference::type;
TNoRef *res = (TNoRef *) Allocate(sizeof(TNoRef), alignof(TNoRef), arena);
@@ -487,7 +506,7 @@ class ASTContext {
// Retrieve the declaration of Swift._stdlib_isOSVersionAtLeast.
FuncDecl *getIsOSVersionAtLeastDecl(LazyResolver *resolver) const;
- /// \brief Look for the declaration with the given name within the
+ /// Look for the declaration with the given name within the
/// swift module.
void lookupInSwiftModule(StringRef name,
SmallVectorImpl &results) const;
@@ -500,9 +519,10 @@ class ASTContext {
Type type,
LazyResolver *resolver) const;
- /// \brief Notify all of the mutation listeners that the given declaration
- /// was just added.
- void addedExternalDecl(Decl *decl);
+ /// Add a declaration to a list of declarations that need to be emitted
+ /// as part of the current module or source file, but are otherwise not
+ /// nested within it.
+ void addExternalDecl(Decl *decl);
/// Add a cleanup function to be called when the ASTContext is deallocated.
void addCleanup(std::function cleanup);
@@ -590,7 +610,7 @@ class ASTContext {
/// one.
void loadExtensions(NominalTypeDecl *nominal, unsigned previousGeneration);
- /// \brief Load the methods within the given class that that produce
+ /// \brief Load the methods within the given class that produce
/// Objective-C class or instance methods with the given selector.
///
/// \param classDecl The class in which we are searching for @objc methods.
@@ -604,7 +624,7 @@ class ASTContext {
///
/// \param previousGeneration The previous generation with which this
/// callback was invoked. The list of methods will already contain all of
- /// the results from generations up and and including \c previousGeneration.
+ /// the results from generations up and including \c previousGeneration.
///
/// \param methods The list of @objc methods in this class that have this
/// selector and are instance/class methods as requested. This list will be
@@ -780,6 +800,16 @@ class ASTContext {
/// protocols that conflict with methods.
bool diagnoseObjCUnsatisfiedOptReqConflicts(SourceFile &sf);
+ /// Retrieve the Swift name for the given Foundation entity, where
+ /// "NS" prefix stripping will apply under omit-needless-words.
+ StringRef getSwiftName(KnownFoundationEntity kind);
+
+ /// Retrieve the Swift identifier for the given Foundation entity, where
+ /// "NS" prefix stripping will apply under omit-needless-words.
+ Identifier getSwiftId(KnownFoundationEntity kind) {
+ return getIdentifier(getSwiftName(kind));
+ }
+
/// Try to dump the context of the given archetype.
void dumpArchetypeContext(ArchetypeType *archetype,
unsigned indent = 0) const;
@@ -791,7 +821,7 @@ class ASTContext {
/// Collect visible clang modules from the ClangModuleLoader. These modules are
/// not necessarily loaded.
- void getVisibleTopLevelClangeModules(SmallVectorImpl &Modules) const;
+ void getVisibleTopLevelClangModules(SmallVectorImpl &Modules) const;
/// Retrieve or create the stored archetype builder for the given
/// canonical generic signature and module.
diff --git a/include/swift/AST/ASTNode.h b/include/swift/AST/ASTNode.h
index 2570d04a8a148..da20251935ddb 100644
--- a/include/swift/AST/ASTNode.h
+++ b/include/swift/AST/ASTNode.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -18,7 +18,6 @@
#define SWIFT_AST_AST_NODE_H
#include "llvm/ADT/PointerUnion.h"
-#include "swift/AST/ASTWalker.h"
#include "swift/AST/TypeAlignments.h"
namespace swift {
@@ -27,6 +26,7 @@ namespace swift {
class Decl;
class SourceLoc;
class SourceRange;
+ class ASTWalker;
struct ASTNode : public llvm::PointerUnion3 {
// Inherit the constructors from PointerUnion.
diff --git a/include/swift/AST/ASTPrinter.h b/include/swift/AST/ASTPrinter.h
index e56eac35ae955..80ddd1ada7a3d 100644
--- a/include/swift/AST/ASTPrinter.h
+++ b/include/swift/AST/ASTPrinter.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -30,10 +30,13 @@ namespace swift {
/// Describes the context in which a name is being printed, which
/// affects the keywords that need to be escaped.
enum class PrintNameContext {
- // Normal context
+ /// Normal context
Normal,
- // Generic parameter context, where 'Self' is not escaped.
+ /// Generic parameter context, where 'Self' is not escaped.
GenericParameter,
+ /// Function parameter context, where keywords other than let/var/inout are
+ /// not escaped.
+ FunctionParameter,
};
/// An abstract class used to print an AST.
@@ -79,6 +82,8 @@ class ASTPrinter {
ASTPrinter &operator<<(unsigned long long N);
ASTPrinter &operator<<(UUID UU);
+ ASTPrinter &operator<<(DeclName name);
+
void printName(Identifier Name,
PrintNameContext Context = PrintNameContext::Normal);
@@ -102,7 +107,7 @@ class ASTPrinter {
PendingDeclLocCallback = D;
}
- /// To sanitize a malformatted utf8 string to a well-formatted one.
+ /// To sanitize a malformed utf8 string to a well-formed one.
static std::string sanitizeUtf8(StringRef Text);
static bool printTypeInterface(Type Ty, DeclContext *DC, std::string &Result);
static bool printTypeInterface(Type Ty, DeclContext *DC, llvm::raw_ostream &Out);
diff --git a/include/swift/AST/ASTVisitor.h b/include/swift/AST/ASTVisitor.h
index e48987a12494f..acdcae3192adc 100644
--- a/include/swift/AST/ASTVisitor.h
+++ b/include/swift/AST/ASTVisitor.h
@@ -1,8 +1,8 @@
-//===-- ASTVisitor.h - Decl, Expr and Stmt Visitor --------------*- C++ -*-===//
+//===--- ASTVisitor.h - Decl, Expr and Stmt Visitor -------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -27,6 +27,7 @@
#include "llvm/Support/ErrorHandling.h"
namespace swift {
+ class ParameterList;
/// ASTVisitor - This is a simple visitor class for Swift expressions.
template(AA)...); \
}
#include "swift/AST/Attr.def"
+
+ bool visit(ParameterList *PL) {
+ return static_cast(this)->visitParameterList(PL);
+ }
+
+ bool visitParameterList(ParameterList *PL) { return false; }
};
diff --git a/include/swift/AST/ASTWalker.h b/include/swift/AST/ASTWalker.h
index b5115f0a26b21..43fb12cb6abfe 100644
--- a/include/swift/AST/ASTWalker.h
+++ b/include/swift/AST/ASTWalker.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -25,6 +25,7 @@ class Stmt;
class Pattern;
class TypeRepr;
struct TypeLoc;
+class ParameterList;
/// \brief An abstract class used to traverse an AST.
class ASTWalker {
@@ -182,6 +183,18 @@ class ASTWalker {
/// params in an AbstractFunctionDecl.
virtual bool shouldWalkIntoFunctionGenericParams() { return false; }
+ /// walkToParameterListPre - This method is called when first visiting a
+ /// ParameterList, before walking into its parameters. If it returns false,
+ /// the subtree is skipped.
+ ///
+ virtual bool walkToParameterListPre(ParameterList *PL) { return true; }
+
+ /// walkToParameterListPost - This method is called after visiting the
+ /// children of a parameter list. If it returns false, the remaining
+ /// traversal is terminated and returns failure.
+ virtual bool walkToParameterListPost(ParameterList *PL) { return true; }
+
+
protected:
ASTWalker() = default;
ASTWalker(const ASTWalker &) = default;
diff --git a/include/swift/AST/AnyFunctionRef.h b/include/swift/AST/AnyFunctionRef.h
index d72c8548aabc2..01455fb313272 100644
--- a/include/swift/AST/AnyFunctionRef.h
+++ b/include/swift/AST/AnyFunctionRef.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -61,10 +61,10 @@ class AnyFunctionRef {
getCaptureInfo().getLocalCaptures(Result);
}
- ArrayRef getBodyParamPatterns() const {
+ ArrayRef getParameterLists() const {
if (auto *AFD = TheFunction.dyn_cast())
- return AFD->getBodyParamPatterns();
- return TheFunction.get()->getParamPatterns();
+ return AFD->getParameterLists();
+ return TheFunction.get()->getParameterLists();
}
bool hasType() const {
diff --git a/include/swift/AST/ArchetypeBuilder.h b/include/swift/AST/ArchetypeBuilder.h
index c66cf6e72ddef..cb95ff800d0f2 100644
--- a/include/swift/AST/ArchetypeBuilder.h
+++ b/include/swift/AST/ArchetypeBuilder.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -176,7 +176,7 @@ class ArchetypeBuilder {
void visitPotentialArchetypes(F f);
public:
- /// Construct a new archtype builder.
+ /// Construct a new archetype builder.
///
/// \param mod The module in which the builder will create archetypes.
///
@@ -251,6 +251,14 @@ class ArchetypeBuilder {
bool addGenericSignature(GenericSignature *sig, bool adoptArchetypes,
bool treatRequirementsAsExplicit = false);
+ /// \brief Get a generic signature based on the provided complete list
+ /// of generic parameter types.
+ ///
+ /// \returns a generic signature build based on the provided list of
+ /// generic parameter types.
+ GenericSignature *
+ getGenericSignature(ArrayRef genericParamsTypes);
+
/// Infer requirements from the given type, recursively.
///
/// This routine infers requirements from a type that occurs within the
@@ -281,12 +289,12 @@ class ArchetypeBuilder {
/// because the type \c Dictionary cannot be formed without it.
///
/// \returns true if an error occurred, false otherwise.
- bool inferRequirements(Pattern *pattern, GenericParamList *genericParams);
+ bool inferRequirements(ParameterList *params,GenericParamList *genericParams);
/// Finalize the set of requirements, performing any remaining checking
/// required before generating archetypes.
///
- /// \returns true if an error occurs, false otherwse.
+ /// \returns true if an error occurs, false otherwise.
bool finalize(SourceLoc loc);
/// \brief Resolve the given type to the potential archetype it names.
diff --git a/include/swift/AST/Attr.def b/include/swift/AST/Attr.def
index 3cf4e8803722a..e87775cafa3ee 100644
--- a/include/swift/AST/Attr.def
+++ b/include/swift/AST/Attr.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -37,7 +37,6 @@ TYPE_ATTR(noreturn)
// SIL-specific attributes
TYPE_ATTR(block_storage)
TYPE_ATTR(box)
-TYPE_ATTR(local_storage)
TYPE_ATTR(sil_unowned)
TYPE_ATTR(sil_unmanaged)
TYPE_ATTR(sil_weak)
@@ -92,7 +91,7 @@ SIMPLE_DECL_ATTR(final, Final,
DECL_ATTR(objc, ObjC,
OnFunc | OnClass | OnProtocol | OnVar | OnSubscript |
- OnConstructor | OnDestructor | OnEnum, 3)
+ OnConstructor | OnDestructor | OnEnum | OnEnumElement, 3)
SIMPLE_DECL_ATTR(required, Required,
OnConstructor|DeclModifier, 4)
@@ -100,7 +99,10 @@ SIMPLE_DECL_ATTR(required, Required,
SIMPLE_DECL_ATTR(optional, Optional,
OnConstructor|OnFunc|OnVar|OnSubscript|DeclModifier, 5)
-/// NOTE: 6 is unused.
+DECL_ATTR(swift3_migration, Swift3Migration,
+ OnEnum | OnStruct | OnClass | OnProtocol | OnTypeAlias |
+ OnVar | OnSubscript | OnConstructor | OnFunc | OnEnumElement |
+ OnGenericTypeParam | OnAssociatedType | LongAttribute, 6)
SIMPLE_DECL_ATTR(noreturn, NoReturn, OnFunc, 7)
@@ -140,7 +142,7 @@ DECL_ATTR(inline, Inline, OnFunc | OnConstructor, 20)
DECL_ATTR(_semantics, Semantics,
OnFunc | OnConstructor | OnDestructor | OnSubscript |
- UserInaccessible, 21)
+ AllowMultipleAttributes | UserInaccessible, 21)
SIMPLE_DECL_ATTR(dynamic, Dynamic,
OnFunc | OnVar | OnSubscript | OnConstructor | DeclModifier, 22)
@@ -160,7 +162,7 @@ SIMPLE_DECL_ATTR(nonobjc, NonObjC,
OnFunc | OnVar | OnSubscript | OnConstructor, 30)
SIMPLE_DECL_ATTR(_fixed_layout, FixedLayout,
- OnClass | OnStruct | OnEnum | UserInaccessible, 31)
+ OnVar | OnClass | OnStruct | OnEnum | UserInaccessible, 31)
// Non-serialized attributes.
diff --git a/include/swift/AST/Attr.h b/include/swift/AST/Attr.h
index 37b60898d28e3..87c22839e7d69 100644
--- a/include/swift/AST/Attr.h
+++ b/include/swift/AST/Attr.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -19,6 +19,8 @@
#include "swift/Basic/SourceLoc.h"
#include "swift/Basic/UUID.h"
+#include "swift/Basic/STLExtras.h"
+#include "swift/Basic/Range.h"
#include "swift/AST/Identifier.h"
#include "swift/AST/KnownProtocols.h"
#include "swift/AST/Ownership.h"
@@ -642,7 +644,7 @@ enum class MinVersionComparison {
Unavailable,
/// The entity might be unavailable, because it was introduced after
- /// the minimimum version.
+ /// the minimum version.
PotentiallyUnavailable,
/// The entity has been obsoleted.
@@ -1148,6 +1150,28 @@ class WarnUnusedResultAttr : public DeclAttribute {
}
};
+/// The @swift3_migration attribute which describes the transformations
+/// required to migrate the given Swift 2.x API to Swift 3.
+class Swift3MigrationAttr : public DeclAttribute {
+ DeclName Renamed;
+ StringRef Message;
+
+public:
+ Swift3MigrationAttr(SourceLoc atLoc, SourceLoc attrLoc, SourceLoc lParenLoc,
+ DeclName renamed, StringRef message, SourceLoc rParenLoc,
+ bool implicit)
+ : DeclAttribute(DAK_Swift3Migration, atLoc, SourceRange(attrLoc, rParenLoc),
+ implicit),
+ Renamed(renamed), Message(message) { }
+
+ DeclName getRenamed() const { return Renamed; }
+ StringRef getMessage() const { return Message; }
+
+ static bool classof(const DeclAttribute *DA) {
+ return DA->getKind() == DAK_Swift3Migration;
+ }
+};
+
/// \brief Attributes that may be applied to declarations.
class DeclAttributes {
/// Linked list of declaration attributes.
@@ -1258,6 +1282,34 @@ class DeclAttributes {
return nullptr;
}
+private:
+ /// Predicate used to filter MatchingAttributeRange.
+ template struct ToAttributeKind {
+ ToAttributeKind() {}
+
+ Optional
+ operator()(const DeclAttribute *Attr) const {
+ if (isa(Attr) && (Attr->isValid() || AllowInvalid))
+ return Attr;
+ return None;
+ }
+ };
+
+public:
+ template
+ using AttributeKindRange =
+ OptionalTransformRange,
+ ToAttributeKind,
+ const_iterator>;
+
+ /// Return a range with all attributes in DeclAttributes with AttrKind
+ /// ATTR.
+ template
+ AttributeKindRange getAttributes() const {
+ return AttributeKindRange(
+ make_range(begin(), end()), ToAttributeKind());
+ }
+
// Remove the given attribute from the list of attributes. Used when
// the attribute was semantically invalid.
void removeAttribute(const DeclAttribute *attr) {
diff --git a/include/swift/AST/Availability.h b/include/swift/AST/Availability.h
index f69d30af68e78..cd38482080e99 100644
--- a/include/swift/AST/Availability.h
+++ b/include/swift/AST/Availability.h
@@ -1,8 +1,8 @@
-//===--- Availability.h - Swift Availability Structures -----*- C++ -*-===//
+//===--- Availability.h - Swift Availability Structures ---------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -35,7 +35,7 @@ class VersionRange {
// The concretization of lattice elements is:
// Empty: empty
// All: all versions
- // x.y.x: all versions greater than or equal to to x.y.z
+ // x.y.x: all versions greater than or equal to x.y.z
enum class ExtremalRange { Empty, All };
@@ -117,7 +117,7 @@ class VersionRange {
}
/// Mutates this range to be the union of itself and Other. This is the
- /// join operator (least upper bound) in the veresion range lattice.
+ /// join operator (least upper bound) in the version range lattice.
void unionWith(const VersionRange &Other) {
// With the existing lattice this operation is precise. If the lattice
// is ever extended it is important that this operation be an
diff --git a/include/swift/AST/AvailabilitySpec.h b/include/swift/AST/AvailabilitySpec.h
index 12e34af9ef35a..faff239576238 100644
--- a/include/swift/AST/AvailabilitySpec.h
+++ b/include/swift/AST/AvailabilitySpec.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -89,6 +89,12 @@ class VersionConstraintAvailabilitySpec : public AvailabilitySpec {
static bool classof(const AvailabilitySpec *Spec) {
return Spec->getKind() == AvailabilitySpecKind::VersionConstraint;
}
+
+ void *
+ operator new(size_t Bytes, ASTContext &C,
+ unsigned Alignment = alignof(VersionConstraintAvailabilitySpec)){
+ return AvailabilitySpec::operator new(Bytes, C, Alignment);
+ }
};
/// A wildcard availability specification that guards execution
@@ -115,6 +121,12 @@ class OtherPlatformAvailabilitySpec : public AvailabilitySpec {
static bool classof(const AvailabilitySpec *Spec) {
return Spec->getKind() == AvailabilitySpecKind::OtherPlatform;
}
+
+ void *
+ operator new(size_t Bytes, ASTContext &C,
+ unsigned Alignment = alignof(OtherPlatformAvailabilitySpec)) {
+ return AvailabilitySpec::operator new(Bytes, C, Alignment);
+ }
};
} // end namespace swift
diff --git a/include/swift/AST/Builtins.def b/include/swift/AST/Builtins.def
index 9a01ac1f3b14c..ad64e4c4a8cbb 100644
--- a/include/swift/AST/Builtins.def
+++ b/include/swift/AST/Builtins.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -188,36 +188,6 @@ BUILTIN_SIL_OPERATION(Assign, "assign", Special)
/// Init has type (T, Builtin.RawPointer) -> ()
BUILTIN_SIL_OPERATION(Init, "initialize", Special)
-/// MarkDependence has type (T, U) -> T
-BUILTIN_SIL_OPERATION(MarkDependence, "markDependence", Special)
-
-/// allocValueBuffer : (inout Builtin.UnsafeValueBuffer, T.Type)
-/// -> Builtin.RawPointer
-BUILTIN_SIL_OPERATION(AllocValueBuffer, "allocValueBuffer", Special)
-
-/// projectValueBuffer : (inout Builtin.UnsafeValueBuffer, T.Type)
-/// -> Builtin.RawPointer
-BUILTIN_SIL_OPERATION(ProjectValueBuffer, "projectValueBuffer", Special)
-
-/// deallocValueBuffer : (inout Builtin.UnsafeValueBuffer, T.Type)
-/// -> ()
-BUILTIN_SIL_OPERATION(DeallocValueBuffer, "deallocValueBuffer", Special)
-
-/// MakeMaterializeForSetCallback has type
-/// ((Builtin.RawPointer,
-/// inout Builtin.UnsafeValueBuffer,
-/// inout T,
-/// T.Type) -> ())
-/// -> Builtin.RawPointer
-///
-/// The first argument is the address returned from materializeForSet.
-/// The second argument is the same Builtin.UnsafeValueBuffer
-/// that was passed to materializeForSet.
-/// The third argument is self.
-/// The last argument is the metatype for self.
-BUILTIN_SIL_OPERATION(MakeMaterializeForSetCallback,
- "makeMaterializeForSetCallback", Special)
-
/// CastToUnknownObject has type (T) -> Builtin.UnknownObject.
BUILTIN_SIL_OPERATION(CastToUnknownObject, "castToUnknownObject", Special)
@@ -291,7 +261,7 @@ BUILTIN_SIL_OPERATION(FixLifetime, "fixLifetime", Special)
///
/// This builtin takes an inout object reference and returns a boolean. Passing
/// the reference inout forces the optimizer to preserve a retain distinct from
-/// what’s required to maintain lifetime for any of the reference's source-level
+/// what's required to maintain lifetime for any of the reference's source-level
/// copies, because the called function is allowed to replace the reference,
/// thereby releasing the referent.
///
diff --git a/include/swift/AST/Builtins.h b/include/swift/AST/Builtins.h
index 66b74381686b8..07933bd22f0d9 100644
--- a/include/swift/AST/Builtins.h
+++ b/include/swift/AST/Builtins.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -91,7 +91,7 @@ getLLVMIntrinsicIDForBuiltinWithOverflow(BuiltinValueKind ID);
/// Returns null if the name does not identifier a known builtin value.
ValueDecl *getBuiltinValueDecl(ASTContext &Context, Identifier Name);
-/// \brief Returns the name of a builtin declaration given an builtin ID.
+/// \brief Returns the name of a builtin declaration given a builtin ID.
StringRef getBuiltinName(BuiltinValueKind ID);
/// \brief The information identifying the builtin - its kind and types.
diff --git a/include/swift/AST/CanTypeVisitor.h b/include/swift/AST/CanTypeVisitor.h
index 345706d33e94b..0904ee40d2232 100644
--- a/include/swift/AST/CanTypeVisitor.h
+++ b/include/swift/AST/CanTypeVisitor.h
@@ -1,8 +1,8 @@
-//===-- CanTypeVisitor.h - TypeVisitor specialization -----------*- C++ -*-===//
+//===--- CanTypeVisitor.h - TypeVisitor specialization ----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/CaptureInfo.h b/include/swift/AST/CaptureInfo.h
index d60af9c679861..8ca4faab21d7f 100644
--- a/include/swift/AST/CaptureInfo.h
+++ b/include/swift/AST/CaptureInfo.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/ClangModuleLoader.h b/include/swift/AST/ClangModuleLoader.h
index cbc9266e2ae1e..f9062a26d0512 100644
--- a/include/swift/AST/ClangModuleLoader.h
+++ b/include/swift/AST/ClangModuleLoader.h
@@ -1,8 +1,8 @@
-//===--- ClangModuleLoader.h - Clang Module Loader Interface --*- C++ -*- -===//
+//===--- ClangModuleLoader.h - Clang Module Loader Interface ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/Comment.h b/include/swift/AST/Comment.h
index 50e8793a97343..8b823fa54756b 100644
--- a/include/swift/AST/Comment.h
+++ b/include/swift/AST/Comment.h
@@ -1,8 +1,8 @@
-//===--- Comment.h - Swift-specific comment parsing -----------------------===//
+//===--- Comment.h - Swift-specific comment parsing -------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/ConcreteDeclRef.h b/include/swift/AST/ConcreteDeclRef.h
index 8afa6b9670ad3..abddc14eaccce 100644
--- a/include/swift/AST/ConcreteDeclRef.h
+++ b/include/swift/AST/ConcreteDeclRef.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/DebuggerClient.h b/include/swift/AST/DebuggerClient.h
index 6f6d9c523220b..70dcc573736bc 100644
--- a/include/swift/AST/DebuggerClient.h
+++ b/include/swift/AST/DebuggerClient.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h
index 44687313a8cab..2bf860e8e5d08 100644
--- a/include/swift/AST/Decl.h
+++ b/include/swift/AST/Decl.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -17,29 +17,14 @@
#ifndef SWIFT_DECL_H
#define SWIFT_DECL_H
-#include "swift/AST/Attr.h"
#include "swift/AST/CaptureInfo.h"
-#include "swift/AST/DeclContext.h"
#include "swift/AST/DefaultArgumentKind.h"
#include "swift/AST/GenericSignature.h"
-#include "swift/AST/KnownProtocols.h"
-#include "swift/AST/Identifier.h"
#include "swift/AST/LazyResolver.h"
-#include "swift/AST/Requirement.h"
-#include "swift/AST/Substitution.h"
-#include "swift/AST/Type.h"
-#include "swift/AST/TypeLoc.h"
#include "swift/Basic/OptionalEnum.h"
#include "swift/Basic/Range.h"
-#include "swift/Basic/SourceLoc.h"
-#include "swift/Basic/STLExtras.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallPtrSet.h"
-#include
namespace clang {
class Decl;
@@ -76,12 +61,13 @@ namespace swift {
class NameAliasType;
class EnumCaseDecl;
class EnumElementDecl;
+ class ParameterList;
class Pattern;
struct PrintOptions;
class ProtocolDecl;
class ProtocolType;
struct RawComment;
- enum class Resilience : unsigned char;
+ enum class ResilienceExpansion : unsigned;
class TypeAliasDecl;
class Stmt;
class SubscriptDecl;
@@ -209,7 +195,7 @@ enum class CircularityCheck {
Checked
};
-/// Keeps track of whrther a given class inherits initializers from its
+/// Keeps track of whether a given class inherits initializers from its
/// superclass.
enum class StoredInheritsSuperclassInits {
/// We have not yet checked.
@@ -386,8 +372,8 @@ class alignas(1 << DeclAlignInBits) Decl {
/// \see AbstractFunctionDecl::BodyKind
unsigned BodyKind : 3;
- /// Number of curried parameter patterns (tuples).
- unsigned NumParamPatterns : 6;
+ /// Number of curried parameter lists.
+ unsigned NumParameterLists : 6;
/// Whether we are overridden later.
unsigned Overridden : 1;
@@ -871,7 +857,7 @@ class alignas(1 << DeclAlignInBits) Decl {
// Only allow allocation of Decls using the allocator in ASTContext
// or by doing a placement new.
- void *operator new(size_t Bytes, ASTContext &C,
+ void *operator new(size_t Bytes, const ASTContext &C,
unsigned Alignment = alignof(Decl));
void *operator new(size_t Bytes, void *Mem) {
assert(Mem);
@@ -899,6 +885,20 @@ void *allocateMemoryForDecl(AllocatorTy &allocator, size_t baseSize,
return mem;
}
+enum class RequirementReprKind : unsigned int {
+ /// A type bound T : P, where T is a type that depends on a generic
+ /// parameter and P is some type that should bound T, either as a concrete
+ /// supertype or a protocol to which T must conform.
+ TypeConstraint,
+
+ /// A same-type requirement T == U, where T and U are types that shall be
+ /// equivalent.
+ SameType,
+
+ // Note: there is code that packs this enum in a 2-bit bitfield. Audit users
+ // when adding enumerators.
+};
+
/// \brief A single requirement in a 'where' clause, which places additional
/// restrictions on the generic parameters or associated types of a generic
/// function, type, or protocol.
@@ -909,14 +909,14 @@ void *allocateMemoryForDecl(AllocatorTy &allocator, size_t baseSize,
/// \c GenericParamList assumes these are POD-like.
class RequirementRepr {
SourceLoc SeparatorLoc;
- RequirementKind Kind : 2;
+ RequirementReprKind Kind : 2;
bool Invalid : 1;
TypeLoc Types[2];
/// Set during deserialization; used to print out the requirements accurately
/// for the generated interface.
StringRef AsWrittenString;
- RequirementRepr(SourceLoc SeparatorLoc, RequirementKind Kind,
+ RequirementRepr(SourceLoc SeparatorLoc, RequirementReprKind Kind,
TypeLoc FirstType, TypeLoc SecondType)
: SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false),
Types{FirstType, SecondType} { }
@@ -924,7 +924,7 @@ class RequirementRepr {
void printImpl(raw_ostream &OS, bool AsWritten) const;
public:
- /// \brief Construct a new conformance requirement.
+ /// \brief Construct a new type-constraint requirement.
///
/// \param Subject The type that must conform to the given protocol or
/// composition, or be a subclass of the given class type.
@@ -932,10 +932,10 @@ class RequirementRepr {
/// this requirement was implied.
/// \param Constraint The protocol or protocol composition to which the
/// subject must conform, or superclass from which the subject must inherit.
- static RequirementRepr getConformance(TypeLoc Subject,
- SourceLoc ColonLoc,
- TypeLoc Constraint) {
- return { ColonLoc, RequirementKind::Conformance, Subject, Constraint };
+ static RequirementRepr getTypeConstraint(TypeLoc Subject,
+ SourceLoc ColonLoc,
+ TypeLoc Constraint) {
+ return { ColonLoc, RequirementReprKind::TypeConstraint, Subject, Constraint };
}
/// \brief Construct a new same-type requirement.
@@ -945,13 +945,13 @@ class RequirementRepr {
/// an invalid location if this requirement was implied.
/// \param SecondType The second type.
static RequirementRepr getSameType(TypeLoc FirstType,
- SourceLoc EqualLoc,
- TypeLoc SecondType) {
- return { EqualLoc, RequirementKind::SameType, FirstType, SecondType };
+ SourceLoc EqualLoc,
+ TypeLoc SecondType) {
+ return { EqualLoc, RequirementReprKind::SameType, FirstType, SecondType };
}
/// \brief Determine the kind of requirement
- RequirementKind getKind() const { return Kind; }
+ RequirementReprKind getKind() const { return Kind; }
/// \brief Determine whether this requirement is invalid.
bool isInvalid() const { return Invalid; }
@@ -959,98 +959,98 @@ class RequirementRepr {
/// \brief Mark this requirement invalid.
void setInvalid() { Invalid = true; }
- /// \brief For a conformance requirement, return the subject of the
+ /// \brief For a type-bound requirement, return the subject of the
/// conformance relationship.
Type getSubject() const {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[0].getType();
}
TypeRepr *getSubjectRepr() const {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[0].getTypeRepr();
}
TypeLoc &getSubjectLoc() {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[0];
}
const TypeLoc &getSubjectLoc() const {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[0];
}
- /// \brief For a conformance requirement, return the protocol or to which
+ /// \brief For a type-bound requirement, return the protocol or to which
/// the subject conforms or superclass it inherits.
Type getConstraint() const {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[1].getType();
}
TypeLoc &getConstraintLoc() {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[1];
}
const TypeLoc &getConstraintLoc() const {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return Types[1];
}
/// \brief Retrieve the location of the ':' in an explicitly-written
/// conformance requirement.
SourceLoc getColonLoc() const {
- assert(getKind() == RequirementKind::Conformance);
+ assert(getKind() == RequirementReprKind::TypeConstraint);
return SeparatorLoc;
}
/// \brief Retrieve the first type of a same-type requirement.
Type getFirstType() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[0].getType();
}
TypeRepr *getFirstTypeRepr() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[0].getTypeRepr();
}
TypeLoc &getFirstTypeLoc() {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[0];
}
const TypeLoc &getFirstTypeLoc() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[0];
}
/// \brief Retrieve the second type of a same-type requirement.
Type getSecondType() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[1].getType();
}
TypeRepr *getSecondTypeRepr() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[1].getTypeRepr();
}
TypeLoc &getSecondTypeLoc() {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[1];
}
const TypeLoc &getSecondTypeLoc() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return Types[1];
}
/// \brief Retrieve the location of the '==' in an explicitly-written
/// same-type requirement.
SourceLoc getEqualLoc() const {
- assert(getKind() == RequirementKind::SameType);
+ assert(getKind() == RequirementReprKind::SameType);
return SeparatorLoc;
}
@@ -1063,6 +1063,11 @@ class RequirementRepr {
AsWrittenString = Str;
}
+ /// Further analyze the written string, if it's not empty, to collect the first
+ /// type, the second type and the requirement kind.
+ Optional>
+ getAsAnalyzedWrittenString() const;
+
SourceRange getSourceRange() const {
return SourceRange(Types[0].getSourceRange().Start,
Types[1].getSourceRange().End);
@@ -1874,18 +1879,36 @@ class ExtensionRange {
/// the initializer can be null if there is none.
class PatternBindingEntry {
Pattern *ThePattern;
- llvm::PointerIntPair InitAndChecked;
-
+
+ enum class Flags {
+ Checked = 1 << 0,
+ Removed = 1 << 1
+ };
+
+ // When the initializer is removed we don't actually clear the pointer
+ // because we might need to get initializer's source range. Since the
+ // initializer is ASTContext-allocated it is safe.
+ llvm::PointerIntPair> InitCheckedAndRemoved;
+
public:
PatternBindingEntry(Pattern *P, Expr *E)
- : ThePattern(P), InitAndChecked(E, false) {}
+ : ThePattern(P), InitCheckedAndRemoved(E, {}) {}
Pattern *getPattern() const { return ThePattern; }
void setPattern(Pattern *P) { ThePattern = P; }
- Expr *getInit() const { return InitAndChecked.getPointer(); }
- void setInit(Expr *E) { InitAndChecked.setPointer(E); }
- bool isInitializerChecked() const { return InitAndChecked.getInt(); }
- void setInitializerChecked() { InitAndChecked.setInt(true); }
+ Expr *getInit() const {
+ return (InitCheckedAndRemoved.getInt().contains(Flags::Removed))
+ ? nullptr : InitCheckedAndRemoved.getPointer();
+ }
+ SourceRange getOrigInitRange() const;
+ void setInit(Expr *E);
+ bool isInitializerChecked() const {
+ return InitCheckedAndRemoved.getInt().contains(Flags::Checked);
+ }
+ void setInitializerChecked() {
+ InitCheckedAndRemoved.setInt(
+ InitCheckedAndRemoved.getInt() | Flags::Checked);
+ }
};
/// \brief This decl contains a pattern and optional initializer for a set
@@ -1923,11 +1946,7 @@ class PatternBindingDecl : public Decl {
StaticSpellingKind StaticSpelling,
SourceLoc VarLoc,
Pattern *Pat, Expr *E,
- DeclContext *Parent) {
- return create(Ctx, StaticLoc, StaticSpelling, VarLoc,
- PatternBindingEntry(Pat, E), Parent);
- }
-
+ DeclContext *Parent);
SourceLoc getStartLoc() const {
return StaticLoc.isValid() ? StaticLoc : VarLoc;
@@ -1945,6 +1964,10 @@ class PatternBindingDecl : public Decl {
return getPatternList()[i].getInit();
}
+ SourceRange getOrigInitRange(unsigned i) const {
+ return getPatternList()[i].getOrigInitRange();
+ }
+
void setInit(unsigned i, Expr *E) {
getMutablePatternList()[i].setInit(E);
}
@@ -2177,6 +2200,7 @@ class ValueDecl : public Decl {
/// Retrieve the full name of the declaration.
/// TODO: Rename to getName?
DeclName getFullName() const { return Name; }
+ void setName(DeclName name) { Name = name; }
/// Retrieve the base name of the declaration, ignoring any argument
/// names.
@@ -2242,16 +2266,6 @@ class ValueDecl : public Decl {
/// If \p DC is null, returns true only if this declaration is public.
bool isAccessibleFrom(const DeclContext *DC) const;
- /// Get the innermost declaration context that can provide generic
- /// parameters used within this declaration.
- DeclContext *getPotentialGenericDeclContext();
-
- /// Get the innermost declaration context that can provide generic
- /// parameters used within this declaration.
- const DeclContext *getPotentialGenericDeclContext() const {
- return const_cast(this)->getPotentialGenericDeclContext();
- }
-
/// Retrieve the "interface" type of this value, which is the type used when
/// the declaration is viewed from the outside. For a generic function,
/// this will have generic function type using generic parameters rather than
@@ -2405,7 +2419,7 @@ class TypeAliasDecl : public TypeDecl {
/// The type that represents this (sugared) name alias.
mutable NameAliasType *AliasTy;
- SourceLoc TypeAliasLoc; // The location of the 'typalias' keyword
+ SourceLoc TypeAliasLoc; // The location of the 'typealias' keyword
TypeLoc UnderlyingTy;
public:
@@ -2745,7 +2759,7 @@ class NominalTypeDecl : public TypeDecl, public DeclContext,
friend class DeclContext;
friend class IterableDeclContext;
friend ArrayRef
- ValueDecl::getSatisfiedProtocolRequirements(bool) const;
+ ValueDecl::getSatisfiedProtocolRequirements(bool Sorted) const;
protected:
Type DeclaredTy;
@@ -2787,13 +2801,17 @@ class NominalTypeDecl : public TypeDecl, public DeclContext,
/// \brief Does this declaration expose a fixed layout to all resilience
/// domains?
+ ///
+ /// For structs, this means clients can assume the number and order of
+ /// stored properties will not change.
+ ///
+ /// For enums, this means clients can assume the number and order of
+ /// cases will not change.
bool hasFixedLayout() const;
/// \brief Does this declaration expose a fixed layout to the given
/// module?
- bool hasFixedLayout(ModuleDecl *M) const {
- return (hasFixedLayout() || M == getModuleContext());
- }
+ bool hasFixedLayout(ModuleDecl *M, ResilienceExpansion expansion) const;
void setMemberLoader(LazyMemberLoader *resolver, uint64_t contextData);
bool hasLazyMembers() const {
@@ -2808,7 +2826,7 @@ class NominalTypeDecl : public TypeDecl, public DeclContext,
return ValidatingGenericSignature;
}
- /// \brief Returns true if this this decl contains delayed value or protocol
+ /// \brief Returns true if this decl contains delayed value or protocol
/// declarations.
bool hasDelayedMembers() const {
return NominalTypeDeclBits.HasDelayedMembers;
@@ -2850,12 +2868,12 @@ class NominalTypeDecl : public TypeDecl, public DeclContext,
/// Set the generic signature of this type.
void setGenericSignature(GenericSignature *sig);
- /// Retrieve the generic parameter types.
- ArrayRef getGenericParamTypes() const {
+ /// Retrieve the innermost generic parameter types.
+ ArrayRef getInnermostGenericParamTypes() const {
if (!GenericSig)
return { };
- return GenericSig->getGenericParams();
+ return GenericSig->getInnermostGenericParams();
}
/// Retrieve the generic requirements.
@@ -3271,7 +3289,7 @@ class ClassDecl : public NominalTypeDecl {
return ClassDeclBits.Foreign;
}
void setForeign(bool isForeign = true) {
- ClassDeclBits.Foreign = true;
+ ClassDeclBits.Foreign = isForeign;
}
/// Find a method of a class that overrides a given method.
@@ -3620,9 +3638,9 @@ class AbstractStorageDecl : public ValueDecl {
/// to and may be overridden.
/// 2) When a stored property satisfies a protocol requirement, these
/// accessors end up as entries in the witness table.
- /// 3) Perhaps someday these will be used by accesses outside of this
- /// resilience domain, when the owning type is resilient.
- ///
+ /// 3) When a stored property is accessed outside of the storage
+ /// declaration's resilience domain, when the owning type or
+ /// global variable is resilient.
StoredWithTrivialAccessors,
/// This is a stored property with either a didSet specifier or a
@@ -4022,6 +4040,18 @@ class AbstractStorageDecl : public ValueDecl {
AccessStrategy getAccessStrategy(AccessSemantics semantics,
AccessKind accessKind) const;
+ /// \brief Does this declaration expose a fixed layout to all resilience
+ /// domains?
+ ///
+ /// Roughly speaking, this means we can make assumptions about whether
+ /// the storage is stored or computed, and if stored, the precise access
+ /// pattern to be used.
+ bool hasFixedLayout() const;
+
+ /// \brief Does this declaration expose a fixed layout to the given
+ /// module?
+ bool hasFixedLayout(ModuleDecl *M, ResilienceExpansion expansion) const;
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&
@@ -4032,7 +4062,7 @@ class AbstractStorageDecl : public ValueDecl {
/// VarDecl - 'var' and 'let' declarations.
class VarDecl : public AbstractStorageDecl {
protected:
- llvm::PointerUnion3 ParentPattern;
+ llvm::PointerUnion ParentPattern;
VarDecl(DeclKind Kind, bool IsStatic, bool IsLet, SourceLoc NameLoc,
Identifier Name, Type Ty, DeclContext *DC)
@@ -4085,9 +4115,9 @@ class VarDecl : public AbstractStorageDecl {
ParentPattern = PBD;
}
- /// Return the Pattern involved in initializing this VarDecl. However, recall that
- /// the Pattern may be involved in initializing more than just this one vardecl.
- /// For example, if this is a VarDecl for "x", the pattern may be
+ /// Return the Pattern involved in initializing this VarDecl. However, recall
+ /// that the Pattern may be involved in initializing more than just this one
+ /// vardecl. For example, if this is a VarDecl for "x", the pattern may be
/// "(x, y)" and the initializer on the PatternBindingDecl may be "(1,2)" or
/// "foo()".
///
@@ -4173,7 +4203,7 @@ class VarDecl : public AbstractStorageDecl {
void emitLetToVarNoteIfSimple(DeclContext *UseDC) const;
/// Returns true if the name is the self identifier and is implicit.
- bool isImplicitSelf() const;
+ bool isSelfParameter() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
@@ -4185,15 +4215,34 @@ class VarDecl : public AbstractStorageDecl {
class ParamDecl : public VarDecl {
Identifier ArgumentName;
SourceLoc ArgumentNameLoc;
+ SourceLoc LetVarInOutLoc;
+ /// This is the type specified, including location information.
+ TypeLoc typeLoc;
+
+ /// The default value, if any, along with whether this is varargs.
+ llvm::PointerIntPair DefaultValueAndIsVariadic;
+
+ /// True if the type is implicitly specified in the source, but this has an
+ /// apparently valid typeRepr. This is used in accessors, which look like:
+ /// set (value) {
+ /// but need to get the typeRepr from the property as a whole so Sema can
+ /// resolve the type.
+ bool IsTypeLocImplicit = false;
+
+ /// Information about a symbolic default argument, like __FILE__.
+ DefaultArgumentKind defaultArgumentKind = DefaultArgumentKind::None;
+
public:
- ParamDecl(bool isLet, SourceLoc argumentNameLoc,
+ ParamDecl(bool isLet, SourceLoc letVarInOutLoc, SourceLoc argumentNameLoc,
Identifier argumentName, SourceLoc parameterNameLoc,
- Identifier parameterName, Type ty, DeclContext *dc)
- : VarDecl(DeclKind::Param, /*IsStatic=*/false, isLet, parameterNameLoc,
- parameterName, ty, dc),
- ArgumentName(argumentName), ArgumentNameLoc(argumentNameLoc) { }
+ Identifier parameterName, Type ty, DeclContext *dc);
+ /// Clone constructor, allocates a new ParamDecl identical to the first.
+ /// Intentionally not defined as a typical copy constructor to avoid
+ /// accidental copies.
+ ParamDecl(ParamDecl *PD);
+
/// Retrieve the argument (API) name for this function parameter.
Identifier getArgumentName() const { return ArgumentName; }
@@ -4203,20 +4252,57 @@ class ParamDecl : public VarDecl {
/// was specified separately from the parameter name.
SourceLoc getArgumentNameLoc() const { return ArgumentNameLoc; }
- SourceRange getSourceRange() const {
- if (ArgumentNameLoc.isValid() && getNameLoc().isInvalid())
- return ArgumentNameLoc;
- if (ArgumentNameLoc.isInvalid() && getNameLoc().isValid())
- return getNameLoc();
- return SourceRange(ArgumentNameLoc, getNameLoc());
- }
+ SourceLoc getLetVarInOutLoc() const { return LetVarInOutLoc; }
+
+ TypeLoc &getTypeLoc() { return typeLoc; }
+ TypeLoc getTypeLoc() const { return typeLoc; }
- Pattern *getParamParentPattern() const {
- return ParentPattern.dyn_cast();
+ bool isTypeLocImplicit() const { return IsTypeLocImplicit; }
+ void setIsTypeLocImplicit(bool val) { IsTypeLocImplicit = val; }
+
+ bool isDefaultArgument() const {
+ return defaultArgumentKind != DefaultArgumentKind::None;
+ }
+ DefaultArgumentKind getDefaultArgumentKind() const {
+ return defaultArgumentKind;
+ }
+ void setDefaultArgumentKind(DefaultArgumentKind K) {
+ defaultArgumentKind = K;
+ }
+
+ void setDefaultValue(ExprHandle *H) {
+ DefaultValueAndIsVariadic.setPointer(H);
}
- void setParamParentPattern(Pattern *Pat) {
- ParentPattern = Pat;
+ ExprHandle *getDefaultValue() const {
+ return DefaultValueAndIsVariadic.getPointer();
}
+ /// Whether or not this parameter is varargs.
+ bool isVariadic() const { return DefaultValueAndIsVariadic.getInt(); }
+ void setVariadic(bool value = true) {DefaultValueAndIsVariadic.setInt(value);}
+
+ /// Remove the type of this varargs element designator, without the array
+ /// type wrapping it. A parameter like "Int..." will have formal parameter
+ /// type of "[Int]" and this returns "Int".
+ static Type getVarargBaseTy(Type VarArgT);
+
+ /// Remove the type of this varargs element designator, without the array
+ /// type wrapping it.
+ Type getVarargBaseTy() const {
+ assert(isVariadic());
+ return getVarargBaseTy(getType());
+ }
+
+ SourceRange getSourceRange() const;
+
+ /// Create an implicit 'self' decl for a method in the specified decl context.
+ /// If 'static' is true, then this is self for a static method in the type.
+ ///
+ /// Note that this decl is created, but it is returned with an incorrect
+ /// DeclContext that needs to be set correctly. This is automatically handled
+ /// when a function is created with this as part of its argument list.
+ ///
+ static ParamDecl *createSelf(SourceLoc loc, DeclContext *DC,
+ bool isStatic = false, bool isInOut = false);
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
@@ -4264,15 +4350,16 @@ enum class ObjCSubscriptKind {
/// A given type can have multiple subscript declarations, so long as the
/// signatures (indices and element type) are distinct.
///
-class SubscriptDecl : public AbstractStorageDecl {
+class SubscriptDecl : public AbstractStorageDecl, public DeclContext {
SourceLoc ArrowLoc;
- Pattern *Indices;
+ ParameterList *Indices;
TypeLoc ElementTy;
public:
- SubscriptDecl(DeclName Name, SourceLoc SubscriptLoc, Pattern *Indices,
+ SubscriptDecl(DeclName Name, SourceLoc SubscriptLoc, ParameterList *Indices,
SourceLoc ArrowLoc, TypeLoc ElementTy, DeclContext *Parent)
: AbstractStorageDecl(DeclKind::Subscript, Parent, Name, SubscriptLoc),
+ DeclContext(DeclContextKind::SubscriptDecl, Parent),
ArrowLoc(ArrowLoc), Indices(nullptr), ElementTy(ElementTy) {
setIndices(Indices);
}
@@ -4282,9 +4369,9 @@ class SubscriptDecl : public AbstractStorageDecl {
SourceRange getSourceRange() const;
/// \brief Retrieve the indices for this subscript operation.
- Pattern *getIndices() { return Indices; }
- const Pattern *getIndices() const { return Indices; }
- void setIndices(Pattern *p);
+ ParameterList *getIndices() { return Indices; }
+ const ParameterList *getIndices() const { return Indices; }
+ void setIndices(ParameterList *p);
/// Retrieve the type of the indices.
Type getIndicesType() const;
@@ -4313,6 +4400,13 @@ class SubscriptDecl : public AbstractStorageDecl {
static bool classof(const Decl *D) {
return D->getKind() == DeclKind::Subscript;
}
+
+ static bool classof(const DeclContext *DC) {
+ return DC->getContextKind() == DeclContextKind::SubscriptDecl;
+ }
+
+ using DeclContext::operator new;
+ using Decl::getASTContext;
};
/// \brief Base class for function-like declarations.
@@ -4373,22 +4467,20 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
CaptureInfo Captures;
AbstractFunctionDecl(DeclKind Kind, DeclContext *Parent, DeclName Name,
- SourceLoc NameLoc, unsigned NumParamPatterns,
+ SourceLoc NameLoc, unsigned NumParameterLists,
GenericParamList *GenericParams)
: ValueDecl(Kind, Parent, Name, NameLoc),
DeclContext(DeclContextKind::AbstractFunctionDecl, Parent),
Body(nullptr), GenericParams(nullptr), GenericSig(nullptr) {
setBodyKind(BodyKind::None);
setGenericParams(GenericParams);
- AbstractFunctionDeclBits.NumParamPatterns = NumParamPatterns;
+ AbstractFunctionDeclBits.NumParameterLists = NumParameterLists;
AbstractFunctionDeclBits.Overridden = false;
// Verify no bitfield truncation.
- assert(AbstractFunctionDeclBits.NumParamPatterns == NumParamPatterns);
+ assert(AbstractFunctionDeclBits.NumParameterLists == NumParameterLists);
}
- MutableArrayRef getBodyParamBuffer();
-
void setBodyKind(BodyKind K) {
AbstractFunctionDeclBits.BodyKind = unsigned(K);
}
@@ -4440,14 +4532,14 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
}
void setBody(BraceStmt *S, BodyKind NewBodyKind = BodyKind::Parsed) {
assert(getBodyKind() != BodyKind::Skipped &&
- "can not set a body if it was skipped");
+ "cannot set a body if it was skipped");
Body = S;
setBodyKind(NewBodyKind);
}
/// \brief Note that the body was skipped for this function. Function body
- /// can not be attached after this call.
+ /// cannot be attached after this call.
void setBodySkipped(SourceRange bodyRange) {
assert(getBodyKind() == BodyKind::None);
BodyRange = bodyRange;
@@ -4521,8 +4613,8 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
/// Determine whether the name of the ith argument is an API name by default.
bool argumentNameIsAPIByDefault(unsigned i) const;
- unsigned getNumParamPatterns() const {
- return AbstractFunctionDeclBits.NumParamPatterns;
+ unsigned getNumParameterLists() const {
+ return AbstractFunctionDeclBits.NumParameterLists;
}
/// \brief Returns the "natural" number of argument clauses taken by this
@@ -4547,7 +4639,7 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
/// func const(x : Int) -> () -> Int { return { x } } // NAC==1
/// \endcode
unsigned getNaturalArgumentCount() const {
- return getNumParamPatterns();
+ return getNumParameterLists();
}
/// \brief Returns the parameter pattern(s) for the function definition that
@@ -4555,13 +4647,17 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
///
/// The number of "top-level" elements in this pattern will match the number
/// of argument names in the compound name of the function or constructor.
- MutableArrayRef getBodyParamPatterns() {
- return getBodyParamBuffer();
+ MutableArrayRef getParameterLists();
+ ArrayRef getParameterLists() const {
+ auto paramLists =
+ const_cast(this)->getParameterLists();
+ return ArrayRef(paramLists.data(),paramLists.size());
}
- ArrayRef getBodyParamPatterns() const {
- auto Patterns =
- const_cast(this)->getBodyParamBuffer();
- return ArrayRef(Patterns.data(), Patterns.size());
+ ParameterList *getParameterList(unsigned i) {
+ return getParameterLists()[i];
+ }
+ const ParameterList *getParameterList(unsigned i) const {
+ return getParameterLists()[i];
}
/// \brief If this is a method in a type or extension thereof, compute
@@ -4584,7 +4680,10 @@ class AbstractFunctionDecl : public ValueDecl, public DeclContext {
///
/// Note that some functions don't have an implicit 'self' decl, for example,
/// free functions. In this case nullptr is returned.
- VarDecl *getImplicitSelfDecl() const;
+ const ParamDecl *getImplicitSelfDecl() const {
+ return const_cast(this)->getImplicitSelfDecl();
+ }
+ ParamDecl *getImplicitSelfDecl();
/// \brief Retrieve the set of parameters to a generic function, or null if
/// this function is not generic.
@@ -4649,7 +4748,7 @@ class FuncDecl : public AbstractFunctionDecl {
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
SourceLoc FuncLoc; // Location of the 'func' token.
SourceLoc ThrowsLoc; // Location of the 'throws' token.
- SourceLoc AccessorKeywordLoc; // Location of the accessor keyword token, e,g. 'set'.
+ SourceLoc AccessorKeywordLoc; // Location of the accessor keyword, e.g. 'set'.
TypeLoc FnRetType;
@@ -4668,23 +4767,24 @@ class FuncDecl : public AbstractFunctionDecl {
/// which property and what kind of accessor.
llvm::PointerIntPair AccessorDecl;
llvm::PointerUnion OverriddenOrDerivedForDecl;
- llvm::PointerIntPair OperatorAndAddressorKind;
+ llvm::PointerIntPair OperatorAndAddressorKind;
FuncDecl(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
SourceLoc FuncLoc, DeclName Name,
SourceLoc NameLoc, SourceLoc ThrowsLoc,
SourceLoc AccessorKeywordLoc,
- unsigned NumParamPatterns,
+ unsigned NumParameterLists,
GenericParamList *GenericParams, Type Ty, DeclContext *Parent)
: AbstractFunctionDecl(DeclKind::Func, Parent, Name, NameLoc,
- NumParamPatterns, GenericParams),
+ NumParameterLists, GenericParams),
StaticLoc(StaticLoc), FuncLoc(FuncLoc), ThrowsLoc(ThrowsLoc),
AccessorKeywordLoc(AccessorKeywordLoc),
OverriddenOrDerivedForDecl(),
OperatorAndAddressorKind(nullptr, AddressorKind::NotAddressor) {
FuncDeclBits.IsStatic = StaticLoc.isValid() || getName().isOperator();
FuncDeclBits.StaticSpelling = static_cast(StaticSpelling);
- assert(NumParamPatterns > 0 && "Must have at least an empty tuple arg");
+ assert(NumParameterLists > 0 && "Must have at least an empty tuple arg");
setType(Ty);
FuncDeclBits.Mutating = false;
FuncDeclBits.HasDynamicSelf = false;
@@ -4700,7 +4800,7 @@ class FuncDecl : public AbstractFunctionDecl {
SourceLoc NameLoc, SourceLoc ThrowsLoc,
SourceLoc AccessorKeywordLoc,
GenericParamList *GenericParams, Type Ty,
- unsigned NumParamPatterns,
+ unsigned NumParameterLists,
DeclContext *Parent,
ClangNode ClangN);
@@ -4712,7 +4812,7 @@ class FuncDecl : public AbstractFunctionDecl {
SourceLoc NameLoc, SourceLoc ThrowsLoc,
SourceLoc AccessorKeywordLoc,
GenericParamList *GenericParams, Type Ty,
- unsigned NumParamPatterns,
+ unsigned NumParameterLists,
DeclContext *Parent);
static FuncDecl *create(ASTContext &Context, SourceLoc StaticLoc,
@@ -4720,7 +4820,7 @@ class FuncDecl : public AbstractFunctionDecl {
SourceLoc FuncLoc, DeclName Name, SourceLoc NameLoc,
SourceLoc ThrowsLoc, SourceLoc AccessorKeywordLoc,
GenericParamList *GenericParams,
- Type Ty, ArrayRef BodyParams,
+ Type Ty, ArrayRef ParameterLists,
TypeLoc FnRetType, DeclContext *Parent,
ClangNode ClangN = ClangNode());
@@ -4743,6 +4843,25 @@ class FuncDecl : public AbstractFunctionDecl {
FuncDeclBits.Mutating = Mutating;
}
+ /// \brief Returns the parameter lists(s) for the function definition.
+ ///
+ /// The number of "top-level" elements will match the number of argument names
+ /// in the compound name of the function or constructor.
+ MutableArrayRef getParameterLists() {
+ auto Ptr = reinterpret_cast(cast(this) + 1);
+ return { Ptr, getNumParameterLists() };
+ }
+ ArrayRef getParameterLists() const {
+ return AbstractFunctionDecl::getParameterLists();
+ }
+ ParameterList *getParameterList(unsigned i) {
+ return getParameterLists()[i];
+ }
+ const ParameterList *getParameterList(unsigned i) const {
+ return getParameterLists()[i];
+ }
+
+
bool getHaveSearchedForCommonOverloadReturnType() {
return HaveSearchedForCommonOverloadReturnType;
}
@@ -4760,7 +4879,7 @@ class FuncDecl : public AbstractFunctionDecl {
/// attribute. For example a "mutating set" accessor.
bool isExplicitNonMutating() const;
- void setDeserializedSignature(ArrayRef BodyParams,
+ void setDeserializedSignature(ArrayRef ParameterLists,
TypeLoc FnRetType);
SourceLoc getStaticLoc() const { return StaticLoc; }
@@ -4769,7 +4888,7 @@ class FuncDecl : public AbstractFunctionDecl {
SourceLoc getAccessorKeywordLoc() const {return AccessorKeywordLoc; }
SourceLoc getStartLoc() const {
- return StaticLoc.isValid() ? StaticLoc : FuncLoc;
+ return StaticLoc.isValid() && !isAccessor() ? StaticLoc : FuncLoc;
}
SourceRange getSourceRange() const;
@@ -4806,22 +4925,24 @@ class FuncDecl : public AbstractFunctionDecl {
}
/// isUnaryOperator - Determine whether this is a unary operator
- /// implementation, in other words, the name of the function is an operator,
- /// and the argument list consists syntactically of a single-element tuple
- /// pattern. This check is syntactic rather than type-based in order to allow
+ /// implementation. This check is a syntactic rather than type-based check,
+ /// which looks at the number of parameters specified, in order to allow
/// for the definition of unary operators on tuples, as in:
- /// func [prefix] + (_:(a:Int, b:Int))
+ ///
+ /// prefix func + (param : (a:Int, b:Int))
+ ///
/// This also allows the unary-operator-ness of a func decl to be determined
/// prior to type checking.
bool isUnaryOperator() const;
/// isBinaryOperator - Determine whether this is a binary operator
- /// implementation, in other words, the name of the function is an operator,
- /// and the argument list consists syntactically of a two-element tuple
- /// pattern. This check is syntactic rather than type-based in order to
- /// distinguish a binary operator from a unary operator on tuples, as in:
- /// func [prefix] + (_:(a:Int, b:Int)) // unary operator +(1,2)
- /// func [infix] + (a:Int, b:Int) // binary operator 1 + 2
+ /// implementation. This check is a syntactic rather than type-based check,
+ /// which looks at the number of parameters specified, in order to allow
+ /// distinguishing a binary operator from a unary operator on tuples, as in:
+ ///
+ /// prefix func + (_:(a:Int, b:Int)) // unary operator +(1,2)
+ /// infix func + (a:Int, b:Int) // binary operator 1 + 2
+ ///
/// This also allows the binary-operator-ness of a func decl to be determined
/// prior to type checking.
bool isBinaryOperator() const;
@@ -5152,8 +5273,6 @@ enum class CtorInitializerKind {
/// }
/// \endcode
class ConstructorDecl : public AbstractFunctionDecl {
- friend class AbstractFunctionDecl;
-
/// The failability of this initializer, which is an OptionalTypeKind.
unsigned Failability : 2;
@@ -5163,7 +5282,7 @@ class ConstructorDecl : public AbstractFunctionDecl {
// Location of the 'throws' token.
SourceLoc ThrowsLoc;
- Pattern *BodyParams[2];
+ ParameterList *ParameterLists[2];
/// The type of the initializing constructor.
Type InitializerType;
@@ -5182,11 +5301,11 @@ class ConstructorDecl : public AbstractFunctionDecl {
public:
ConstructorDecl(DeclName Name, SourceLoc ConstructorLoc,
OptionalTypeKind Failability, SourceLoc FailabilityLoc,
- Pattern *SelfBodyParam, Pattern *BodyParams,
+ ParamDecl *selfParam, ParameterList *BodyParams,
GenericParamList *GenericParams,
SourceLoc throwsLoc, DeclContext *Parent);
- void setBodyParams(Pattern *selfPattern, Pattern *bodyParams);
+ void setParameterLists(ParamDecl *selfParam, ParameterList *bodyParams);
SourceLoc getConstructorLoc() const { return getNameLoc(); }
SourceLoc getStartLoc() const { return getConstructorLoc(); }
@@ -5211,6 +5330,26 @@ class ConstructorDecl : public AbstractFunctionDecl {
Expr *getSuperInitCall() { return CallToSuperInit; }
void setSuperInitCall(Expr *CallExpr) { CallToSuperInit = CallExpr; }
+ MutableArrayRef getParameterLists() {
+ return { ParameterLists, 2 };
+ }
+ ArrayRef getParameterLists() const {
+ return AbstractFunctionDecl::getParameterLists();
+ }
+ ParameterList *getParameterList(unsigned i) {
+ return getParameterLists()[i];
+ }
+ const ParameterList *getParameterList(unsigned i) const {
+ return getParameterLists()[i];
+ }
+
+ /// Returns the normal parameters to the initializer, not including self.
+ ParameterList *getParameters() { return ParameterLists[1]; }
+
+ /// Returns the normal parameters to the initializer, not including self.
+ const ParameterList *getParameters() const { return ParameterLists[1]; }
+
+
/// Specifies the kind of initialization call performed within the body
/// of the constructor, e.g., self.init or super.init.
enum class BodyInitKind {
@@ -5359,14 +5498,22 @@ class ConstructorDecl : public AbstractFunctionDecl {
/// }
/// \endcode
class DestructorDecl : public AbstractFunctionDecl {
- friend class AbstractFunctionDecl;
- Pattern *SelfPattern;
+ ParameterList *SelfParameter;
public:
DestructorDecl(Identifier NameHack, SourceLoc DestructorLoc,
- Pattern *SelfPattern, DeclContext *Parent);
+ ParamDecl *selfDecl, DeclContext *Parent);
- void setSelfPattern(Pattern *selfPattern);
+ void setSelfDecl(ParamDecl *selfDecl);
+ MutableArrayRef getParameterLists() {
+ return { &SelfParameter, 1 };
+ }
+ ArrayRef getParameterLists() const {
+ return { &SelfParameter, 1 };
+ }
+
+
+
SourceLoc getDestructorLoc() const { return getNameLoc(); }
SourceLoc getStartLoc() const { return getDestructorLoc(); }
SourceRange getSourceRange() const;
@@ -5625,25 +5772,17 @@ inline bool AbstractStorageDecl::isStatic() const {
return false;
}
-inline MutableArrayRef AbstractFunctionDecl::getBodyParamBuffer() {
- unsigned NumPatterns = AbstractFunctionDeclBits.NumParamPatterns;
- Pattern **Ptr;
+inline MutableArrayRef
+AbstractFunctionDecl::getParameterLists() {
switch (getKind()) {
default: llvm_unreachable("Unknown AbstractFunctionDecl!");
case DeclKind::Constructor:
- Ptr = cast(this)->BodyParams;
- break;
-
+ return cast(this)->getParameterLists();
case DeclKind::Destructor:
- Ptr = &cast(this)->SelfPattern;
- break;
-
+ return cast(this)->getParameterLists();
case DeclKind::Func:
- // Body patterns are tail allocated.
- Ptr = reinterpret_cast(cast(this) + 1);
- break;
+ return cast(this)->getParameterLists();
}
- return MutableArrayRef(Ptr, NumPatterns);
}
inline DeclIterator &DeclIterator::operator++() {
diff --git a/include/swift/AST/DeclContext.h b/include/swift/AST/DeclContext.h
index 82324598c60c2..34dbb0aa44471 100644
--- a/include/swift/AST/DeclContext.h
+++ b/include/swift/AST/DeclContext.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -66,6 +66,7 @@ enum class DeclContextKind : uint8_t {
AbstractClosureExpr,
Initializer,
TopLevelCodeDecl,
+ SubscriptDecl,
AbstractFunctionDecl,
SerializedLocal,
Last_LocalDeclContextKind = SerializedLocal,
@@ -245,7 +246,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
/// ClassDecl, otherwise return null.
ClassDecl *isClassOrClassExtensionContext() const;
- /// If this DeclContext is a enum, or an extension on a enum, return the
+ /// If this DeclContext is an enum, or an extension on an enum, return the
/// EnumDecl, otherwise return null.
EnumDecl *isEnumOrEnumExtensionContext() const;
@@ -404,6 +405,12 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
LazyResolver *typeResolver,
SmallVectorImpl &decls) const;
+ /// Look up all Objective-C methods with the given selector visible
+ /// in the enclosing module.
+ void lookupAllObjCMethods(
+ ObjCSelector selector,
+ SmallVectorImpl &results) const;
+
/// Return the ASTContext for a specified DeclContext by
/// walking up to the enclosing module and returning its ASTContext.
ASTContext &getASTContext() const;
diff --git a/include/swift/AST/DeclNameLoc.h b/include/swift/AST/DeclNameLoc.h
new file mode 100644
index 0000000000000..2d41bf0776445
--- /dev/null
+++ b/include/swift/AST/DeclNameLoc.h
@@ -0,0 +1,115 @@
+//===--- DeclNameLoc.h - Declaration Name Location Info ---------*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the DeclNameLoc class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SWIFT_AST_DECL_NAME_LOC_H
+#define SWIFT_AST_DECL_NAME_LOC_H
+
+#include "swift/Basic/LLVM.h"
+#include "swift/Basic/SourceLoc.h"
+
+namespace swift {
+
+class ASTContext;
+
+/// Source location information for a declaration name (\c DeclName)
+/// written in the source.
+class DeclNameLoc {
+ /// Source location information.
+ ///
+ /// If \c NumArgumentLabels == 0, this is the SourceLoc for the base name.
+ /// Otherwise, it points to an array of SourceLocs, which contains:
+ /// * The base name location
+ /// * The left parentheses location
+ /// * The right parentheses location
+ /// * The locations of each of the argument labels.
+ const void *LocationInfo;
+
+ /// The number of argument labels stored in the name.
+ unsigned NumArgumentLabels;
+
+ enum {
+ BaseNameIndex = 0,
+ LParenIndex = 1,
+ RParenIndex = 2,
+ FirstArgumentLabelIndex = 3,
+ };
+
+ /// Retrieve a pointer to either the only source location that was
+ /// stored or to the array of source locations that was stored.
+ SourceLoc const * getSourceLocs() const {
+ if (NumArgumentLabels == 0)
+ return reinterpret_cast(&LocationInfo);
+
+ return reinterpret_cast(LocationInfo);
+ }
+
+public:
+ /// Create an invalid declaration name location.
+ DeclNameLoc() : LocationInfo(0), NumArgumentLabels(0) { }
+
+ /// Create declaration name location information for a base name.
+ explicit DeclNameLoc(SourceLoc baseNameLoc)
+ : LocationInfo(baseNameLoc.getOpaquePointerValue()),
+ NumArgumentLabels(0) { }
+
+ /// Create declaration name location information for a compound
+ /// name.
+ DeclNameLoc(ASTContext &ctx, SourceLoc baseNameLoc,
+ SourceLoc lParenLoc,
+ ArrayRef argumentLabelLocs,
+ SourceLoc rParenLoc);
+
+ /// Whether the location information is valid.
+ bool isValid() const { return getBaseNameLoc().isValid(); }
+
+ /// Whether the location information is invalid.
+ bool isInvalid() const { return getBaseNameLoc().isInvalid(); }
+
+ /// Retrieve the location of the base name.
+ SourceLoc getBaseNameLoc() const {
+ return getSourceLocs()[BaseNameIndex];
+ }
+
+ /// Retrieve the location of the left parentheses.
+ SourceLoc getLParenLoc() const {
+ if (NumArgumentLabels == 0) return SourceLoc();
+ return getSourceLocs()[LParenIndex];
+ }
+
+ /// Retrieve the location of the right parentheses.
+ SourceLoc getRParenLoc() const {
+ if (NumArgumentLabels == 0) return SourceLoc();
+ return getSourceLocs()[RParenIndex];
+ }
+
+ /// Retrieve the location of an argument label.
+ SourceLoc getArgumentLabelLoc(unsigned index) const {
+ if (index >= NumArgumentLabels)
+ return SourceLoc();
+ return getSourceLocs()[FirstArgumentLabelIndex + index];
+ }
+
+ /// Retrieve the complete source range for this declaration name.
+ SourceRange getSourceRange() const {
+ if (NumArgumentLabels == 0) return getBaseNameLoc();
+
+ return SourceRange(getBaseNameLoc(), getRParenLoc());
+ }
+};
+
+}
+
+#endif // SWIFT_AST_DECL_NAME_LOC_H
diff --git a/include/swift/AST/DeclNodes.def b/include/swift/AST/DeclNodes.def
index 9f349abd502ac..d1cbbf47ccb73 100644
--- a/include/swift/AST/DeclNodes.def
+++ b/include/swift/AST/DeclNodes.def
@@ -1,8 +1,8 @@
-//===-- DeclNodes.def - Swift Declaration AST Metaprogramming -*- C++ -*-===//
+//===--- DeclNodes.def - Swift Declaration AST Metaprogramming --*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/DefaultArgumentKind.h b/include/swift/AST/DefaultArgumentKind.h
index a53a88d3e346f..14ef3124b60f5 100644
--- a/include/swift/AST/DefaultArgumentKind.h
+++ b/include/swift/AST/DefaultArgumentKind.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -17,10 +17,16 @@
#ifndef SWIFT_DEFAULTARGUMENTKIND_H
#define SWIFT_DEFAULTARGUMENTKIND_H
+namespace llvm {
+class StringRef;
+}
+
namespace swift {
+class Expr;
+
/// Describes the kind of default argument a tuple pattern element has.
-enum class DefaultArgumentKind {
+enum class DefaultArgumentKind : unsigned {
/// No default argument.
None,
/// A normal default argument.
@@ -38,8 +44,22 @@ enum class DefaultArgumentKind {
Function,
/// The __DSO_HANDLE__ default argument, which is expanded at the call site.
DSOHandle,
+ /// The "nil" literal.
+ Nil,
+ /// An empty array literal.
+ EmptyArray,
+ /// An empty dictionary literal.
+ EmptyDictionary,
};
+/// Retrieve the spelling of this default argument in source code, or
+/// an empty string if it has none.
+llvm::StringRef getDefaultArgumentSpelling(DefaultArgumentKind kind);
+
+/// Infer a default argument kind from an expression, if the
+/// expression is the canonical way to spell that default argument.
+DefaultArgumentKind inferDefaultArgumentKind(Expr *expr);
+
} // end namespace swift
#endif // LLVM_SWIFT_DEFAULTARGUMENTKIND_H
diff --git a/include/swift/AST/DiagnosticEngine.h b/include/swift/AST/DiagnosticEngine.h
index 1331f8bdb1d98..fa260b304de5e 100644
--- a/include/swift/AST/DiagnosticEngine.h
+++ b/include/swift/AST/DiagnosticEngine.h
@@ -1,8 +1,8 @@
-//===- DiagnosticEngine.h - Diagnostic Display Engine -----------*- C++ -*-===//
+//===--- DiagnosticEngine.h - Diagnostic Display Engine ---------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -18,18 +18,9 @@
#ifndef SWIFT_BASIC_DIAGNOSTICENGINE_H
#define SWIFT_BASIC_DIAGNOSTICENGINE_H
-#include "swift/Basic/LLVM.h"
-#include "swift/AST/Identifier.h"
-#include "swift/AST/Type.h"
#include "swift/AST/TypeLoc.h"
+#include "swift/AST/DeclNameLoc.h"
#include "swift/Basic/DiagnosticConsumer.h"
-#include "swift/Basic/SourceLoc.h"
-#include "clang/Basic/VersionTuple.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringRef.h"
-#include
-#include
namespace swift {
class Decl;
@@ -388,6 +379,84 @@ namespace swift {
return fixItReplaceChars(Start, End, {});
}
};
+
+ /// \brief Class to track, map, and remap diagnostic severity and fatality
+ ///
+ class DiagnosticState {
+ public:
+ /// \brief Describes the current behavior to take with a diagnostic
+ enum class Behavior : uint8_t {
+ Unspecified,
+ Ignore,
+ Note,
+ Warning,
+ Error,
+ Fatal,
+ };
+
+ private:
+ /// \brief Whether we should continue to emit diagnostics, even after a
+ /// fatal error
+ bool showDiagnosticsAfterFatalError = false;
+
+ /// \brief Don't emit any warnings
+ bool suppressWarnings = false;
+
+ /// \brief Emit all warnings as errors
+ bool warningsAsErrors = false;
+
+ /// \brief Whether a fatal error has occurred
+ bool fatalErrorOccurred = false;
+
+ /// \brief Whether any error diagnostics have been emitted.
+ bool anyErrorOccurred = false;
+
+ /// \brief Track the previous emitted Behavior, useful for notes
+ Behavior previousBehavior = Behavior::Unspecified;
+
+ /// \brief Track settable, per-diagnostic state that we store
+ std::vector perDiagnosticBehavior;
+
+ public:
+ DiagnosticState();
+
+ /// \brief Figure out the Behavior for the given diagnostic, taking current
+ /// state such as fatality into account.
+ Behavior determineBehavior(DiagID id);
+
+ bool hadAnyError() const { return anyErrorOccurred; }
+ bool hasFatalErrorOccurred() const { return fatalErrorOccurred; }
+
+ void setShowDiagnosticsAfterFatalError(bool val = true) {
+ showDiagnosticsAfterFatalError = val;
+ }
+
+ /// \brief Whether to skip emitting warnings
+ void setSuppressWarnings(bool val) { suppressWarnings = val; }
+ bool getSuppressWarnings() const { return suppressWarnings; }
+
+ /// \brief Whether to treat warnings as errors
+ void setWarningsAsErrors(bool val) { warningsAsErrors = val; }
+ bool getWarningsAsErrors() const { return warningsAsErrors; }
+
+ void resetHadAnyError() {
+ anyErrorOccurred = false;
+ fatalErrorOccurred = false;
+ }
+
+ /// Set per-diagnostic behavior
+ void setDiagnosticBehavior(DiagID id, Behavior behavior) {
+ perDiagnosticBehavior[(unsigned)id] = behavior;
+ }
+
+ private:
+ // Make the state movable only
+ DiagnosticState(const DiagnosticState &) = delete;
+ const DiagnosticState &operator=(const DiagnosticState &) = delete;
+
+ DiagnosticState(DiagnosticState &&) = default;
+ DiagnosticState &operator=(DiagnosticState &&) = default;
+ };
/// \brief Class responsible for formatting diagnostics and presenting them
/// to the user.
@@ -400,19 +469,8 @@ namespace swift {
/// emitting diagnostics.
SmallVector Consumers;
- /// HadAnyError - True if any error diagnostics have been emitted.
- bool HadAnyError;
-
- enum class FatalErrorState {
- None,
- JustEmitted,
- Fatal
- };
-
- /// Sticky flag set to \c true when a fatal error is emitted.
- FatalErrorState FatalState = FatalErrorState::None;
-
- bool ShowDiagnosticsAfterFatalError = false;
+ /// \brief Tracks diagnostic behaviors and state
+ DiagnosticState state;
/// \brief The currently active diagnostic, if there is one.
Optional ActiveDiagnostic;
@@ -434,25 +492,38 @@ namespace swift {
public:
explicit DiagnosticEngine(SourceManager &SourceMgr)
- : SourceMgr(SourceMgr), HadAnyError(false), ActiveDiagnostic() {
+ : SourceMgr(SourceMgr), ActiveDiagnostic() {
}
/// hadAnyError - return true if any *error* diagnostics have been emitted.
- bool hadAnyError() const {
- return HadAnyError;
- }
+ bool hadAnyError() const { return state.hadAnyError(); }
bool hasFatalErrorOccurred() const {
- return FatalState != FatalErrorState::None;
+ return state.hasFatalErrorOccurred();
+ }
+
+ void setShowDiagnosticsAfterFatalError(bool val = true) {
+ state.setShowDiagnosticsAfterFatalError(val);
+ }
+
+ /// \brief Whether to skip emitting warnings
+ void setSuppressWarnings(bool val) { state.setSuppressWarnings(val); }
+ bool getSuppressWarnings() const {
+ return state.getSuppressWarnings();
+ }
+
+ /// \brief Whether to treat warnings as errors
+ void setWarningsAsErrors(bool val) { state.setWarningsAsErrors(val); }
+ bool getWarningsAsErrors() const {
+ return state.getWarningsAsErrors();
}
- void setShowDiagnosticsAfterFatalError(bool Val = true) {
- ShowDiagnosticsAfterFatalError = Val;
+ void ignoreDiagnostic(DiagID id) {
+ state.setDiagnosticBehavior(id, DiagnosticState::Behavior::Ignore);
}
void resetHadAnyError() {
- HadAnyError = false;
- FatalState = FatalErrorState::None;
+ state.resetHadAnyError();
}
/// \brief Add an additional DiagnosticConsumer to receive diagnostics.
@@ -489,6 +560,24 @@ namespace swift {
return InFlightDiagnostic(*this);
}
+ /// \brief Emit a diagnostic using a preformatted array of diagnostic
+ /// arguments.
+ ///
+ /// \param Loc The declaration name location to which the
+ /// diagnostic refers in the source code.
+ ///
+ /// \param ID The diagnostic ID.
+ ///
+ /// \param Args The preformatted set of diagnostic arguments. The caller
+ /// must ensure that the diagnostic arguments have the appropriate type.
+ ///
+ /// \returns An in-flight diagnostic, to which additional information can
+ /// be attached.
+ InFlightDiagnostic diagnose(DeclNameLoc Loc, DiagID ID,
+ ArrayRef Args) {
+ return diagnose(Loc.getBaseNameLoc(), ID, Args);
+ }
+
/// \brief Emit an already-constructed diagnostic at the given location.
///
/// \param Loc The location to which the diagnostic refers in the source
@@ -524,6 +613,25 @@ namespace swift {
return InFlightDiagnostic(*this);
}
+ /// \brief Emit a diagnostic with the given set of diagnostic arguments.
+ ///
+ /// \param Loc The declaration name location to which the
+ /// diagnostic refers in the source code.
+ ///
+ /// \param ID The diagnostic to be emitted.
+ ///
+ /// \param Args The diagnostic arguments, which will be converted to
+ /// the types expected by the diagnostic \p ID.
+ template
+ InFlightDiagnostic
+ diagnose(DeclNameLoc Loc, Diag ID,
+ typename detail::PassArgument::type... Args) {
+ assert(!ActiveDiagnostic && "Already have an active diagnostic");
+ ActiveDiagnostic = Diagnostic(ID, std::move(Args)...);
+ ActiveDiagnostic->setLoc(Loc.getBaseNameLoc());
+ return InFlightDiagnostic(*this);
+ }
+
/// \brief Emit a diagnostic using a preformatted array of diagnostic
/// arguments.
///
@@ -582,10 +690,7 @@ namespace swift {
/// \returns true if diagnostic is marked with PointsToFirstBadToken
/// option.
- bool isDiagnosticPointsToFirstBadToken(DiagID ID) const;
-
- /// \returns true if diagnostic is marked as fatal.
- bool isDiagnosticFatal(DiagID ID) const;
+ bool isDiagnosticPointsToFirstBadToken(DiagID id) const;
private:
/// \brief Flush the active diagnostic.
diff --git a/include/swift/AST/DiagnosticsAll.def b/include/swift/AST/DiagnosticsAll.def
index d808b5ea6b84c..f8c337b278442 100644
--- a/include/swift/AST/DiagnosticsAll.def
+++ b/include/swift/AST/DiagnosticsAll.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsAll.def - Diagnostics Text Index --------------*- C++ -*-===//
+//===--- DiagnosticsAll.def - Diagnostics Text Index ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -19,18 +19,18 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
#define DIAG_NO_UNDEF
diff --git a/include/swift/AST/DiagnosticsClangImporter.def b/include/swift/AST/DiagnosticsClangImporter.def
index 9371fc5ed01b1..4226cfa2eb376 100644
--- a/include/swift/AST/DiagnosticsClangImporter.def
+++ b/include/swift/AST/DiagnosticsClangImporter.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsClangImporter.def - Diagnostics Text ----------*- C++ -*-===//
+//===--- DiagnosticsClangImporter.def - Diagnostics Text --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -22,39 +22,39 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
-WARNING(warning_from_clang,none,none,
+WARNING(warning_from_clang,none,
"%0", (StringRef))
-ERROR(error_from_clang,none,none,
+ERROR(error_from_clang,none,
"%0", (StringRef))
-NOTE(note_from_clang,none,none,
+NOTE(note_from_clang,none,
"%0", (StringRef))
-ERROR(clang_cannot_build_module,none,Fatal,
+ERROR(clang_cannot_build_module,Fatal,
"could not build Objective-C module '%0'", (StringRef))
-ERROR(bridging_header_missing,none,Fatal,
+ERROR(bridging_header_missing,Fatal,
"bridging header '%0' does not exist", (StringRef))
-ERROR(bridging_header_error,none,Fatal,
+ERROR(bridging_header_error,Fatal,
"failed to import bridging header '%0'", (StringRef))
-WARNING(could_not_rewrite_bridging_header,none,none,
+WARNING(could_not_rewrite_bridging_header,none,
"failed to serialize bridging header; "
"target may not be debuggable outside of its original project", ())
-WARNING(invalid_swift_name_method,none,none,
+WARNING(invalid_swift_name_method,none,
"too %select{few|many}0 parameters in swift_name attribute (expected %1; "
"got %2)", (bool, unsigned, unsigned))
diff --git a/include/swift/AST/DiagnosticsClangImporter.h b/include/swift/AST/DiagnosticsClangImporter.h
index 754beefa0ba55..280c790f1a5e3 100644
--- a/include/swift/AST/DiagnosticsClangImporter.h
+++ b/include/swift/AST/DiagnosticsClangImporter.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsClangImporter.h - Diagnostic Definitions ------*- C++ -*-===//
+//===--- DiagnosticsClangImporter.h - Diagnostic Definitions ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
namespace diag {
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsClangImporter.def"
}
diff --git a/include/swift/AST/DiagnosticsCommon.def b/include/swift/AST/DiagnosticsCommon.def
index 7004c58209a8a..841c6e3a500da 100644
--- a/include/swift/AST/DiagnosticsCommon.def
+++ b/include/swift/AST/DiagnosticsCommon.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsCommon.def - Diagnostics Text -----------------*- C++ -*-===//
+//===--- DiagnosticsCommon.def - Diagnostics Text ---------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -22,69 +22,63 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
-ERROR(invalid_diagnostic,common,none,
+ERROR(invalid_diagnostic,none,
"INTERNAL ERROR: this diagnostic should not be produced", ())
-ERROR(not_implemented,TODO,none,
+ERROR(not_implemented,none,
"INTERNAL ERROR: feature not implemented: %0", (StringRef))
-ERROR(error_opening_output,common,none,
+ERROR(error_opening_output,none,
"error opening '%0' for output: %1", (StringRef, StringRef))
-NOTE(previous_decldef,common,none,
+NOTE(previous_decldef,none,
"previous %select{declaration|definition}0 of %1 is here",
(bool, Identifier))
// Generic disambiguation
-NOTE(while_parsing_as_left_angle_bracket,common,none,
+NOTE(while_parsing_as_left_angle_bracket,none,
"while parsing this '<' as a type parameter bracket", ())
-NOTE(while_parsing_as_less_operator,common,none,
+NOTE(while_parsing_as_less_operator,none,
"while parsing this '<' as an operator", ())
// FIXME: This is used both as a parse error (a literal "super" outside a
// method) and a type-checker error ("super" in a method of a non-class type).
-ERROR(super_not_in_class_method,common,none,
+ERROR(super_not_in_class_method,none,
"'super' cannot be used outside of class members", ())
-ERROR(class_func_not_in_class,common,none,
+ERROR(class_func_not_in_class,none,
"class methods are only allowed within classes; "
"use 'static' to declare a static method", ())
-ERROR(class_var_not_in_class,common,none,
+ERROR(class_var_not_in_class,none,
"class properties are only allowed within classes; "
"use 'static' to declare a static property", ())
// FIXME: Used by both the parser and the type-checker.
-ERROR(func_decl_without_brace,decl_parsing,PointsToFirstBadToken,
+ERROR(func_decl_without_brace,PointsToFirstBadToken,
"expected '{' in body of function declaration", ())
-ERROR(unsupported_fixed_length_array,type_parsing,none,
- "fixed-length arrays are not yet supported", ())
-ERROR(new_array_syntax,type_parsing,none,
- "array types are now written with the brackets around the element type",
- ())
-
-NOTE(convert_let_to_var,sema,none,
+NOTE(convert_let_to_var,none,
"change 'let' to 'var' to make it mutable", ())
-NOTE(change_let_to_var_param,sema,none,
+NOTE(change_let_to_var_param,none,
"change 'let' parameter to 'var' to make it mutable", ())
-NOTE(mark_param_var,sema,none,
+NOTE(mark_param_var,none,
"mark parameter with 'var' to make it mutable", ())
diff --git a/include/swift/AST/DiagnosticsCommon.h b/include/swift/AST/DiagnosticsCommon.h
index cec28f3c3d76b..3bce585013bbd 100644
--- a/include/swift/AST/DiagnosticsCommon.h
+++ b/include/swift/AST/DiagnosticsCommon.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsCommon.h - Shared Diagnostic Definitions ------*- C++ -*-===//
+//===--- DiagnosticsCommon.h - Shared Diagnostic Definitions ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -46,7 +46,7 @@ namespace swift {
using DeclAttribute = const DeclAttribute *;
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsCommon.def"
}
diff --git a/include/swift/AST/DiagnosticsDriver.def b/include/swift/AST/DiagnosticsDriver.def
index 15cc058c5c683..a8bd1c035332c 100644
--- a/include/swift/AST/DiagnosticsDriver.def
+++ b/include/swift/AST/DiagnosticsDriver.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsDriver.def - Diagnostics Text -----------------*- C++ -*-===//
+//===--- DiagnosticsDriver.def - Diagnostics Text ---------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,98 +23,102 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
-WARNING(warning_parallel_execution_not_supported,driver,none,
+WARNING(warning_parallel_execution_not_supported,none,
"parallel execution not supported; falling back to serial execution",
())
-ERROR(error_unable_to_execute_command,driver,none,
+ERROR(error_unable_to_execute_command,none,
"unable to execute command: %0", (StringRef))
-ERROR(error_command_signalled,driver,none,
+ERROR(error_command_signalled,none,
"%0 command failed due to signal (use -v to see invocation)", (StringRef))
-ERROR(error_command_failed,driver,none,
+ERROR(error_command_failed,none,
"%0 command failed with exit code %1 (use -v to see invocation)",
(StringRef, int))
-ERROR(error_expected_one_frontend_job,driver,none,
+ERROR(error_expected_one_frontend_job,none,
"unable to handle compilation, expected exactly one frontend job", ())
-ERROR(error_expected_frontend_command,driver,none,
+ERROR(error_expected_frontend_command,none,
"expected a swift frontend command", ())
-ERROR(error_cannot_specify__o_for_multiple_outputs,driver,none,
+ERROR(error_cannot_specify__o_for_multiple_outputs,none,
"cannot specify -o when generating multiple output files", ())
-ERROR(error_unable_to_load_output_file_map,driver, none,
+ERROR(error_unable_to_load_output_file_map, none,
"unable to load output file map", ())
-ERROR(error_no_output_file_map_specified,driver,none,
+ERROR(error_no_output_file_map_specified,none,
"no output file map specified", ())
-ERROR(error_unable_to_make_temporary_file,driver,none,
+ERROR(error_unable_to_make_temporary_file,none,
"unable to make temporary file: %0", (StringRef))
-ERROR(error_no_input_files,driver,none,
+ERROR(error_no_input_files,none,
"no input files", ())
-ERROR(error_unexpected_input_file,driver,none,
+ERROR(error_unexpected_input_file,none,
"unexpected input file: %0", (StringRef))
-ERROR(error_unknown_target,driver,none,
+ERROR(error_unknown_target,none,
"unknown target '%0'", (StringRef))
-ERROR(error_framework_bridging_header,driver,none,
- "using bridging headers with framework targets is unsupported", ())
+ERROR(error_framework_bridging_header,none,
+ "using bridging headers with framework targets is unsupported", ())
-ERROR(error_i_mode,driver,none,
+ERROR(error_i_mode,none,
"the flag '-i' is no longer required and has been removed; "
"use '%0 input-filename'", (StringRef))
-WARNING(warning_unnecessary_repl_mode,driver,none,
+WARNING(warning_unnecessary_repl_mode,none,
"unnecessary option '%0'; this is the default for '%1' "
"with no input files", (StringRef, StringRef))
-ERROR(error_unsupported_option,driver,none,
+ERROR(error_unsupported_option,none,
"unsupported option '%0' for '%1'; did you mean '%2 %0'?",
(StringRef, StringRef, StringRef))
-WARNING(incremental_requires_output_file_map,driver,none,
+WARNING(incremental_requires_output_file_map,none,
"ignoring -incremental (currently requires an output file map)", ())
-WARNING(incremental_requires_build_record_entry,driver,none,
+WARNING(incremental_requires_build_record_entry,none,
"ignoring -incremental; output file map has no master dependencies "
"entry (\"%0\" under \"\")", (StringRef))
-ERROR(error_os_minimum_deployment,driver,none,
+ERROR(error_os_minimum_deployment,none,
"Swift requires a minimum deployment target of %0", (StringRef))
-ERROR(error_sdk_too_old,driver,none,
+ERROR(error_sdk_too_old,none,
"Swift does not support the SDK '%0'", (StringRef))
-ERROR(error_two_files_same_name,driver,none,
+ERROR(error_two_files_same_name,none,
"filename \"%0\" used twice: '%1' and '%2'",
(StringRef, StringRef, StringRef))
-NOTE(note_explain_two_files_same_name,driver,none,
+NOTE(note_explain_two_files_same_name,none,
"filenames are used to distinguish private declarations with the same "
"name", ())
-WARNING(warn_cannot_stat_input,driver,none,
+WARNING(warn_cannot_stat_input,none,
"unable to determine when '%0' was last modified: %1",
(StringRef, StringRef))
-ERROR(error_input_changed_during_build,driver,none,
+ERROR(error_input_changed_during_build,none,
"input file '%0' was modified during the build",
(StringRef))
+ERROR(error_conflicting_options, none,
+ "conflicting options '%0' and '%1'",
+ (StringRef, StringRef))
+
#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
# undef DIAG
diff --git a/include/swift/AST/DiagnosticsDriver.h b/include/swift/AST/DiagnosticsDriver.h
index 133eb7c337435..a2d1a5385fe67 100644
--- a/include/swift/AST/DiagnosticsDriver.h
+++ b/include/swift/AST/DiagnosticsDriver.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsDriver.h - Diagnostic Definitions -------------*- C++ -*-===//
+//===--- DiagnosticsDriver.h - Diagnostic Definitions -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -25,7 +25,7 @@
namespace swift {
namespace diag {
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsDriver.def"
}
diff --git a/include/swift/AST/DiagnosticsFrontend.def b/include/swift/AST/DiagnosticsFrontend.def
index 683c66bdb4b60..124a3c49de582 100644
--- a/include/swift/AST/DiagnosticsFrontend.def
+++ b/include/swift/AST/DiagnosticsFrontend.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsFrontend.def - Diagnostics Text ---------------*- C++ -*-===//
+//===--- DiagnosticsFrontend.def - Diagnostics Text -------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,116 +23,114 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
-WARNING(warning_no_such_sdk,frontend,none,
+WARNING(warning_no_such_sdk,none,
"no such SDK: '%0'", (StringRef))
-ERROR(error_no_frontend_args, frontend, none,
+ERROR(error_no_frontend_args, none,
"no arguments provided to '-frontend'", ())
-ERROR(error_no_such_file_or_directory,frontend,none,
+ERROR(error_no_such_file_or_directory,none,
"no such file or directory: '%0'", (StringRef))
-ERROR(error_unsupported_target_os, frontend, none,
+ERROR(error_unsupported_target_os, none,
"unsupported target OS: '%0'", (StringRef))
-ERROR(error_unsupported_target_arch, frontend, none,
+ERROR(error_unsupported_target_arch, none,
"unsupported target architecture: '%0'", (StringRef))
-ERROR(cannot_open_file,frontend,none,
+ERROR(cannot_open_file,none,
"cannot open file '%0' (%1)", (StringRef, StringRef))
-ERROR(cannot_open_serialized_file,frontend,none,
+ERROR(cannot_open_serialized_file,none,
"cannot open file '%0' for diagnostics emission (%1)", (StringRef, StringRef))
-ERROR(error_open_input_file,frontend,none,
+ERROR(error_open_input_file,none,
"error opening input file '%0' (%1)", (StringRef, StringRef))
-ERROR(error_clang_importer_not_linked_in,frontend,none,
- "clang importer not available", ())
-ERROR(error_clang_importer_create_fail,frontend,none,
+ERROR(error_clang_importer_create_fail,none,
"clang importer creation failed", ())
-ERROR(error_missing_arg_value,frontend,none,
+ERROR(error_missing_arg_value,none,
"missing argument value for '%0', expected %1 argument(s)",
(StringRef, unsigned))
-ERROR(error_unknown_arg,frontend,none,
+ERROR(error_unknown_arg,none,
"unknown argument: '%0'", (StringRef))
-ERROR(error_invalid_arg_value,frontend,none,
+ERROR(error_invalid_arg_value,none,
"invalid value '%1' in '%0'", (StringRef, StringRef))
-ERROR(error_immediate_mode_missing_stdlib,frontend,none,
+ERROR(error_immediate_mode_missing_stdlib,none,
"could not load the swift standard library", ())
-ERROR(error_immediate_mode_missing_library,frontend,none,
+ERROR(error_immediate_mode_missing_library,none,
"could not load %select{shared library|framework}0 '%1'",
(unsigned, StringRef))
-ERROR(error_immediate_mode_primary_file,frontend,none,
+ERROR(error_immediate_mode_primary_file,none,
"immediate mode is incompatible with -primary-file", ())
-ERROR(error_missing_frontend_action,frontend,none,
+ERROR(error_missing_frontend_action,none,
"no frontend action was selected", ())
-ERROR(error_mode_cannot_emit_dependencies,frontend,none,
+ERROR(error_mode_cannot_emit_dependencies,none,
"this mode does not support emitting dependency files", ())
-ERROR(error_mode_cannot_emit_header,frontend,none,
+ERROR(error_mode_cannot_emit_header,none,
"this mode does not support emitting Objective-C headers", ())
-ERROR(error_mode_cannot_emit_module,frontend,none,
+ERROR(error_mode_cannot_emit_module,none,
"this mode does not support emitting modules", ())
-ERROR(error_mode_cannot_emit_module_doc,frontend,none,
+ERROR(error_mode_cannot_emit_module_doc,none,
"this mode does not support emitting module documentation files", ())
-WARNING(emit_reference_dependencies_without_primary_file,frontend,none,
+WARNING(emit_reference_dependencies_without_primary_file,none,
"ignoring -emit-reference-dependencies (requires -primary-file)", ())
-ERROR(error_bad_module_name,frontend,none,
+ERROR(error_bad_module_name,none,
"module name \"%0\" is not a valid identifier"
"%select{|; use -module-name flag to specify an alternate name}1",
(StringRef, bool))
-ERROR(error_stdlib_module_name,frontend,none,
+ERROR(error_stdlib_module_name,none,
"module name \"%0\" is reserved for the standard library"
"%select{|; use -module-name flag to specify an alternate name}1",
(StringRef, bool))
-ERROR(error_stdlib_not_found,frontend,Fatal,
+ERROR(error_stdlib_not_found,Fatal,
"unable to load standard library for target '%0'", (StringRef))
-ERROR(error_underlying_module_not_found,frontend,none,
+ERROR(error_underlying_module_not_found,none,
"underlying Objective-C module %0 not found", (Identifier))
-ERROR(error_repl_requires_no_input_files,frontend,none,
+ERROR(error_repl_requires_no_input_files,none,
"REPL mode requires no input files", ())
-ERROR(error_mode_requires_one_input_file,frontend,none,
+ERROR(error_mode_requires_one_input_file,none,
"this mode requires a single input file", ())
-ERROR(error_mode_requires_an_input_file,frontend,none,
+ERROR(error_mode_requires_an_input_file,none,
"this mode requires at least one input file", ())
-ERROR(error_mode_requires_one_sil_multi_sib,frontend,none,
+ERROR(error_mode_requires_one_sil_multi_sib,none,
"this mode requires .sil for primary-file and only .sib for other inputs", ())
-ERROR(error_no_output_filename_specified,frontend,none,
+ERROR(error_no_output_filename_specified,none,
"an output filename was not specified for a mode which requires an output "
"filename", ())
-ERROR(error_implicit_output_file_is_directory,frontend,none,
+ERROR(error_implicit_output_file_is_directory,none,
"the implicit output file '%0' is a directory; explicitly specify a filename "
"using -o", (StringRef))
-ERROR(repl_must_be_initialized,sema,none,
+ERROR(repl_must_be_initialized,none,
"variables currently must have an initial value when entered at the "
"top level of the REPL", ())
-ERROR(error_doing_code_completion,frontend,none,
+ERROR(error_doing_code_completion,none,
"compiler is in code completion mode (benign diagnostic)", ())
-ERROR(verify_encountered_fatal,frontend,none,
+ERROR(verify_encountered_fatal,none,
"fatal error encountered while in -verify mode", ())
-ERROR(error_parse_input_file,frontend,none,
+ERROR(error_parse_input_file,none,
"error parsing input file '%0' (%1)", (StringRef, StringRef))
#ifndef DIAG_NO_UNDEF
diff --git a/include/swift/AST/DiagnosticsFrontend.h b/include/swift/AST/DiagnosticsFrontend.h
index 9fc1b3d98fdef..26eeb6028ae03 100644
--- a/include/swift/AST/DiagnosticsFrontend.h
+++ b/include/swift/AST/DiagnosticsFrontend.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsFrontend.h - Diagnostic Definitions -----------*- C++ -*-===//
+//===--- DiagnosticsFrontend.h - Diagnostic Definitions ---------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
namespace diag {
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsFrontend.def"
}
diff --git a/include/swift/AST/DiagnosticsIRGen.def b/include/swift/AST/DiagnosticsIRGen.def
index 8eb159a901d92..0e149387e2865 100644
--- a/include/swift/AST/DiagnosticsIRGen.def
+++ b/include/swift/AST/DiagnosticsIRGen.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsIRGen.def - Diagnostics Text ------------------*- C++ -*-===//
+//===--- DiagnosticsIRGen.def - Diagnostics Text ----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -22,45 +22,45 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
-ERROR(no_llvm_target,irgen,none,
+ERROR(no_llvm_target,none,
"error loading LLVM target for triple '%0': %1", (StringRef, StringRef))
-ERROR(error_codegen_init_fail,irgen,none,
+ERROR(error_codegen_init_fail,none,
"cannot initialize code generation passes for target", ())
-ERROR(irgen_unimplemented,irgen,none,
+ERROR(irgen_unimplemented,none,
"unimplemented IR generation feature %0", (StringRef))
-ERROR(irgen_failure,irgen,none, "IR generation failure: %0", (StringRef))
+ERROR(irgen_failure,none, "IR generation failure: %0", (StringRef))
-ERROR(type_to_verify_not_found,irgen,none, "unable to find type '%0' to verify",
+ERROR(type_to_verify_not_found,none, "unable to find type '%0' to verify",
(StringRef))
-ERROR(type_to_verify_ambiguous,irgen,none, "type to verify '%0' is ambiguous",
+ERROR(type_to_verify_ambiguous,none, "type to verify '%0' is ambiguous",
(StringRef))
-ERROR(type_to_verify_dependent,irgen,none,
+ERROR(type_to_verify_dependent,none,
"type to verify '%0' has unbound generic parameters",
(StringRef))
-ERROR(too_few_output_filenames,irgen,none,
+ERROR(too_few_output_filenames,none,
"too few output file names specified", ())
-ERROR(no_input_files_for_mt,irgen,none,
+ERROR(no_input_files_for_mt,none,
"no swift input files for multi-threaded compilation", ())
-ERROR(alignment_dynamic_type_layout_unsupported,irgen,none,
+ERROR(alignment_dynamic_type_layout_unsupported,none,
"@_alignment is not supported on types with dynamic layout", ())
-ERROR(alignment_less_than_natural,irgen,none,
+ERROR(alignment_less_than_natural,none,
"@_alignment cannot decrease alignment below natural alignment of %0",
(unsigned))
diff --git a/include/swift/AST/DiagnosticsIRGen.h b/include/swift/AST/DiagnosticsIRGen.h
index 13a46d7be2343..928bcb6a5b45d 100644
--- a/include/swift/AST/DiagnosticsIRGen.h
+++ b/include/swift/AST/DiagnosticsIRGen.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsIRGen.h - Diagnostic Definitions --------------*- C++ -*-===//
+//===--- DiagnosticsIRGen.h - Diagnostic Definitions ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
namespace diag {
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsIRGen.def"
}
diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def
index 3cbd855a324fd..133557e90db5b 100644
--- a/include/swift/AST/DiagnosticsParse.def
+++ b/include/swift/AST/DiagnosticsParse.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsParse.def - Diagnostics Text ------------------*- C++ -*-===//
+//===--- DiagnosticsParse.def - Diagnostics Text ----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -22,1248 +22,1255 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
//==============================================================================
// Lexing and Parsing diagnostics
//==============================================================================
-NOTE(opening_brace,parsing,none,
+NOTE(opening_brace,none,
"to match this opening '{'", ())
-NOTE(opening_bracket,parsing,none,
+NOTE(opening_bracket,none,
"to match this opening '['", ())
-NOTE(opening_paren,parsing,none,
+NOTE(opening_paren,none,
"to match this opening '('", ())
-NOTE(opening_angle,parsing,none,
+NOTE(opening_angle,none,
"to match this opening '<'", ())
-ERROR(extra_rbrace,parsing,none,
+ERROR(extra_rbrace,none,
"extraneous '}' at top level", ())
-ERROR(unexpected_config_block_terminator,parsing,none,
+ERROR(unexpected_config_block_terminator,none,
"unexpected configuration block terminator", ())
-ERROR(expected_build_configuration_expression,parsing,none,
+ERROR(expected_build_configuration_expression,none,
"expected a build configuration expression to follow the #if clause", ())
-ERROR(extra_tokens_config_directive,parsing,none,
+ERROR(extra_tokens_config_directive,none,
"extra tokens at the end of the build configuration directive", ())
-ERROR(unexpected_line_directive,parsing,none,
+ERROR(unexpected_line_directive,none,
"parameterless closing #line directive "
"without prior opening #line directive", ())
-ERROR(expected_line_directive_number,parsing,none,
+ERROR(expected_line_directive_number,none,
"expected starting line number for #line directive", ())
-ERROR(expected_line_directive_name,parsing,none,
+ERROR(expected_line_directive_name,none,
"expected filename string literal for #line directive", ())
-ERROR(extra_tokens_line_directive,parsing,none,
+ERROR(extra_tokens_line_directive,none,
"extra tokens at the end of #line directive", ())
-ERROR(line_directive_line_zero,parsing,none,
+ERROR(line_directive_line_zero,none,
"the line number needs to be greater than zero", ())
+WARNING(escaped_parameter_name,none,
+ "keyword '%0' does not need to be escaped in argument list",
+ (StringRef))
+
//------------------------------------------------------------------------------
// Lexer diagnostics
//------------------------------------------------------------------------------
-WARNING(lex_nul_character,lexing,none,
+WARNING(lex_nul_character,none,
"nul character embedded in middle of file", ())
-ERROR(lex_utf16_bom_marker,lexing,none,
+ERROR(lex_utf16_bom_marker,none,
"input files must be encoded as UTF-8 instead of UTF-16", ())
-ERROR(lex_hashbang_not_allowed,lexing,none,
+ERROR(lex_hashbang_not_allowed,none,
"hashbang line is allowed only in the main file", ())
-ERROR(lex_unprintable_ascii_character,lexing,none,
+ERROR(lex_unprintable_ascii_character,none,
"unprintable ASCII character found in source file", ())
-ERROR(lex_invalid_utf8,lexing,none,
+ERROR(lex_invalid_utf8,none,
"invalid UTF-8 found in source file", ())
-ERROR(lex_single_quote_string,lexing,none,
+ERROR(lex_single_quote_string,none,
"single-quoted string literal found, use '\"'", ())
-ERROR(lex_invalid_curly_quote,lexing,none,
+ERROR(lex_invalid_curly_quote,none,
"unicode curly quote found, replace with '\"'", ())
-ERROR(lex_unterminated_block_comment,lexing,none,
+ERROR(lex_unterminated_block_comment,none,
"unterminated '/*' comment", ())
-NOTE(lex_comment_start,lexing,none,
+NOTE(lex_comment_start,none,
"comment started here", ())
-ERROR(lex_unterminated_string,lexing,none,
+ERROR(lex_unterminated_string,none,
"unterminated string literal", ())
-ERROR(lex_invalid_escape,lexing,none,
+ERROR(lex_invalid_escape,none,
"invalid escape sequence in literal", ())
-ERROR(lex_invalid_u_escape,lexing,none,
+ERROR(lex_invalid_u_escape,none,
"\\u{...} escape sequence expects between 1 and 8 hex digits", ())
-ERROR(lex_invalid_u_escape_rbrace,lexing,none,
+ERROR(lex_invalid_u_escape_rbrace,none,
"expected '}' in \\u{...} escape sequence", ())
-ERROR(lex_invalid_unicode_scalar,lexing,none,
+ERROR(lex_invalid_unicode_scalar,none,
"invalid unicode scalar", ())
-ERROR(lex_unicode_escape_braces,lexing,none,
+ERROR(lex_unicode_escape_braces,none,
"expected hexadecimal code in braces after unicode escape", ())
-ERROR(lex_invalid_character,lexing,none,
+ERROR(lex_invalid_character,none,
"invalid character in source file", ())
-ERROR(lex_invalid_identifier_start_character,lexing,none,
+ERROR(lex_invalid_identifier_start_character,none,
"an identifier cannot begin with this character", ())
-ERROR(lex_expected_digit_in_fp_exponent,lexing,none,
+ERROR(lex_expected_digit_in_fp_exponent,none,
"expected a digit in floating point exponent", ())
-ERROR(lex_expected_digit_in_int_literal,lexing,none,
+ERROR(lex_expected_digit_in_int_literal,none,
"expected a digit after integer literal prefix", ())
-ERROR(lex_expected_binary_exponent_in_hex_float_literal,lexing,none,
+ERROR(lex_expected_binary_exponent_in_hex_float_literal,none,
"hexadecimal floating point literal must end with an exponent", ())
-ERROR(lex_unexpected_block_comment_end,lexing,none,
+ERROR(lex_unexpected_block_comment_end,none,
"unexpected end of block comment", ())
-ERROR(lex_unary_equal_is_reserved,lexing,none,
- "%select{prefix|postfix}0 '=' is reserved", (unsigned))
-ERROR(lex_unary_postfix_dot_is_reserved,lexing,none,
- "postfix '.' is reserved", ())
-ERROR(lex_editor_placeholder,lexing,none,
+ERROR(lex_unary_equal,none,
+ "'=' must have consistent whitespace on both sides", ())
+ERROR(extra_whitespace_period,none,
+ "extraneous whitespace after '.' is not permitted", ())
+ERROR(lex_editor_placeholder,none,
"editor placeholder in source file", ())
-WARNING(lex_editor_placeholder_in_playground,lexing,none,
+WARNING(lex_editor_placeholder_in_playground,none,
"editor placeholder in source file", ())
//------------------------------------------------------------------------------
// Declaration parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(declaration_same_line_without_semi,decl_parsing,none,
+ERROR(declaration_same_line_without_semi,none,
"consecutive declarations on a line must be separated by ';'", ())
-ERROR(expected_decl,decl_parsing,none,
+ERROR(expected_decl,none,
"expected declaration", ())
-ERROR(expected_identifier_in_decl,decl_parsing,none,
+ERROR(expected_identifier_in_decl,none,
"expected identifier in %0 declaration", (StringRef))
-ERROR(expected_identifier_after_case_comma,decl_parsing,none,
+ERROR(expected_identifier_after_case_comma,none,
"expected identifier after comma in enum 'case' declaration", ())
-ERROR(decl_redefinition,decl_parsing,none,
+ERROR(decl_redefinition,none,
"%select{declaration|definition}0 conflicts with previous value",
(bool))
-ERROR(let_cannot_be_computed_property,decl_parsing,none,
+ERROR(let_cannot_be_computed_property,none,
"'let' declarations cannot be computed properties", ())
-ERROR(let_cannot_be_observing_property,decl_parsing,none,
+ERROR(let_cannot_be_observing_property,none,
"'let' declarations cannot be observing properties", ())
-ERROR(let_cannot_be_addressed_property,decl_parsing,none,
+ERROR(let_cannot_be_addressed_property,none,
"'let' declarations cannot have addressors", ())
-ERROR(disallowed_var_multiple_getset,decl_parsing,none,
+ERROR(disallowed_var_multiple_getset,none,
"'var' declarations with multiple variables cannot have explicit"
" getters/setters", ())
-ERROR(disallowed_type,decl_parsing,none,
+ERROR(disallowed_type,none,
"type not allowed here", ())
-ERROR(disallowed_init,decl_parsing,none,
+ERROR(disallowed_init,none,
"initial value is not allowed here", ())
-ERROR(var_init_self_referential,expr_parsing,none,
+ERROR(var_init_self_referential,none,
"variable used within its own initial value", ())
-ERROR(disallowed_enum_element,decl_parsing,none,
+ERROR(disallowed_enum_element,none,
"enum 'case' is not allowed outside of an enum", ())
-ERROR(decl_inner_scope,decl_parsing,none,
+ERROR(decl_inner_scope,none,
"declaration is only valid at file scope", ())
-ERROR(decl_not_static,decl_parsing,none,
+ERROR(decl_not_static,none,
"declaration cannot be marked %0", (StaticSpellingKind))
-ERROR(ownership_not_attribute,decl_parsing,none,
- "'@%0' is not an attribute, use the '%0' keyword instead",
- (StringRef))
-
-ERROR(cskeyword_not_attribute,decl_parsing,none,
+ERROR(cskeyword_not_attribute,none,
"'%0' is a declaration modifier, not an attribute", (StringRef))
-ERROR(convenience_invalid,sema_tcd,none,
- "'convenience' is not valid on this declaration", ())
-
-ERROR(decl_already_static,decl_parsing,none,
+ERROR(decl_already_static,none,
"%0 specified twice", (StaticSpellingKind))
-ERROR(autoclosure_is_decl_attribute,attribute_parsing,none,
- "@autoclosure is now an attribute of the parameter "
- "declaration, not its type", ())
-ERROR(autoclosure_not_on_enums,attribute_parsing,none,
- "@autoclosure is only allowed on parameters, not on enum cases", ())
-
-ERROR(enum_case_dot_prefix,decl_parsing,none,
+ERROR(enum_case_dot_prefix,none,
"extraneous '.' in enum 'case' declaration", ())
// Variable getters/setters
-ERROR(static_var_decl_global_scope,decl_parsing,none,
+ERROR(static_var_decl_global_scope,none,
"%select{ERROR|static properties|class properties}0 may only be declared on a type",
(StaticSpellingKind))
-ERROR(computed_property_no_accessors, decl_parsing, none,
+ERROR(computed_property_no_accessors, none,
"computed property must have accessors specified", ())
-ERROR(expected_getset_in_protocol,decl_parsing,none,
+ERROR(expected_getset_in_protocol,none,
"expected get or set in a protocol property", ())
-ERROR(computed_property_missing_type,decl_parsing,none,
+ERROR(computed_property_missing_type,none,
"computed property must have an explicit type", ())
-ERROR(getset_nontrivial_pattern,decl_parsing,none,
+ERROR(getset_nontrivial_pattern,none,
"getter/setter can only be defined for a single variable", ())
-ERROR(expected_rbrace_in_getset,decl_parsing,none,
+ERROR(expected_rbrace_in_getset,none,
"expected '}' at end of variable get/set clause", ())
-ERROR(duplicate_property_accessor,decl_parsing,none,
+ERROR(duplicate_property_accessor,none,
"duplicate definition of %0", (StringRef))
-NOTE(previous_accessor,decl_parsing,none,
+NOTE(previous_accessor,none,
"previous definition of %0 is here", (StringRef))
-ERROR(conflicting_property_addressor,decl_parsing,none,
+ERROR(conflicting_property_addressor,none,
"%select{variable|subscript}0 already has a "
"%select{addressor|mutable addressor}1", (unsigned, unsigned))
-ERROR(expected_accessor_name,decl_parsing,none,
+ERROR(expected_accessor_name,none,
"expected %select{GETTER|setter|willSet|didSet}0 parameter name",
(unsigned))
-ERROR(expected_rparen_set_name,decl_parsing,none,
+ERROR(expected_rparen_set_name,none,
"expected ')' after setter parameter name",())
-ERROR(expected_rparen_willSet_name,decl_parsing,none,
+ERROR(expected_rparen_willSet_name,none,
"expected ')' after willSet parameter name",())
-ERROR(expected_rparen_didSet_name,decl_parsing,none,
+ERROR(expected_rparen_didSet_name,none,
"expected ')' after didSet parameter name",())
-ERROR(expected_lbrace_accessor,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_accessor,PointsToFirstBadToken,
"expected '{' to start %0 definition", (StringRef))
-ERROR(expected_accessor_kw,decl_parsing,none,
+ERROR(expected_accessor_kw,none,
"expected 'get', 'set', 'willSet', or 'didSet' keyword to "
"start an accessor definition",())
-ERROR(var_set_without_get,decl_parsing,none,
+ERROR(var_set_without_get,none,
"variable with a setter must also have a getter", ())
-ERROR(observingproperty_with_getset,decl_parsing,none,
+ERROR(observingproperty_with_getset,none,
"%select{willSet|didSet}0 variable may not also have a "
"%select{get|set}1 specifier", (unsigned, unsigned))
-ERROR(observingproperty_without_mutableaddress,decl_parsing,none,
+ERROR(observingproperty_without_mutableaddress,none,
"%select{willSet|didSet}0 variable with addressor must provide a "
"'mutableAddress' accessor", (unsigned))
-ERROR(observingproperty_in_subscript,decl_parsing,none,
+ERROR(observingproperty_in_subscript,none,
"%select{willSet|didSet}0 is not allowed in subscripts", (unsigned))
-ERROR(getset_init,decl_parsing,none,
+ERROR(getset_init,none,
"variable with getter/setter cannot have an initial value", ())
-ERROR(getset_cannot_be_implied,decl_parsing,none,
+ERROR(getset_cannot_be_implied,none,
"variable with implied type cannot have implied getter/setter", ())
-ERROR(mutableaddressor_without_address,decl_parsing,none,
+ERROR(mutableaddressor_without_address,none,
"%select{variable|subscript}0 must provide either a getter or "
"'address' if it provides 'mutableAddress'", (unsigned))
-ERROR(mutableaddressor_with_setter,decl_parsing,none,
+ERROR(mutableaddressor_with_setter,none,
"%select{variable|subscript}0 cannot provide both 'mutableAddress' "
" and a setter", (unsigned))
-ERROR(addressor_with_getter,decl_parsing,none,
+ERROR(addressor_with_getter,none,
"%select{variable|subscript}0 cannot provide both 'address' and "
"a getter", (unsigned))
-ERROR(addressor_with_setter,decl_parsing,none,
+ERROR(addressor_with_setter,none,
"%select{variable|subscript}0 cannot provide both 'address' and "
"a setter; use an ordinary getter instead", (unsigned))
// Import
-ERROR(decl_expected_module_name,decl_parsing,none,
+ERROR(decl_expected_module_name,none,
"expected module name in import declaration", ())
// Extension
-ERROR(expected_lbrace_extension,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_extension,PointsToFirstBadToken,
"expected '{' in extension", ())
-ERROR(expected_rbrace_extension,decl_parsing,none,
+ERROR(expected_rbrace_extension,none,
"expected '}' at end of extension", ())
-ERROR(extension_type_expected,decl_parse,none,
+ERROR(extension_type_expected,none,
"expected type name in extension declaration", ())
// TypeAlias
-ERROR(expected_equal_in_typealias,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_equal_in_typealias,PointsToFirstBadToken,
"expected '=' in typealias declaration", ())
-ERROR(expected_type_in_typealias,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_type_in_typealias,PointsToFirstBadToken,
"expected type in typealias declaration", ())
// Func
-ERROR(func_decl_nonglobal_operator,decl_parsing,none,
+ERROR(func_decl_nonglobal_operator,none,
"operators are only allowed at global scope", ())
-ERROR(func_decl_without_paren,decl_parsing,PointsToFirstBadToken,
+ERROR(func_decl_without_paren,PointsToFirstBadToken,
"expected '(' in argument list of function declaration", ())
-ERROR(static_func_decl_global_scope,decl_parsing,none,
+ERROR(static_func_decl_global_scope,none,
"%select{ERROR|static methods|class methods}0 may only be declared on a type",
(StaticSpellingKind))
-ERROR(func_decl_expected_arrow,decl_parsing,none,
+ERROR(func_decl_expected_arrow,none,
"expected '->' after function parameter tuple", ())
-ERROR(func_static_not_allowed,decl_parsing,none,
- "static functions are not allowed in this context, "
- "use 'class' to declare a class method", ())
-ERROR(func_conversion,decl_parsing,none,
- "'__conversion' functions are no longer allowed", ())
// Enum
-ERROR(expected_lbrace_enum,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_enum,PointsToFirstBadToken,
"expected '{' in enum", ())
-ERROR(expected_rbrace_enum,decl_parsing,none,
+ERROR(expected_rbrace_enum,none,
"expected '}' at end of enum", ())
// Struct
-ERROR(expected_lbrace_struct,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_struct,PointsToFirstBadToken,
"expected '{' in struct", ())
-ERROR(expected_rbrace_struct,decl_parsing,none,
+ERROR(expected_rbrace_struct,none,
"expected '}' in struct", ())
// Class
-ERROR(expected_lbrace_class,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_class,PointsToFirstBadToken,
"expected '{' in class", ())
-ERROR(expected_rbrace_class,decl_parsing,none,
+ERROR(expected_rbrace_class,none,
"expected '}' in class", ())
// Protocol
-ERROR(generic_arguments_protocol,decl_parsing,PointsToFirstBadToken,
+ERROR(generic_arguments_protocol,PointsToFirstBadToken,
"protocols do not allow generic parameters; use associated types instead",
())
-ERROR(expected_lbrace_protocol,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_protocol,PointsToFirstBadToken,
"expected '{' in protocol type", ())
-ERROR(expected_rbrace_protocol,decl_parsing,none,
+ERROR(expected_rbrace_protocol,none,
"expected '}' in protocol", ())
-ERROR(protocol_setter_name,decl_parsing,none,
+ERROR(protocol_setter_name,none,
"setter in a protocol cannot have a name", ())
-ERROR(protocol_method_with_body,decl_parsing,none,
+ERROR(protocol_method_with_body,none,
"protocol methods may not have bodies", ())
-ERROR(protocol_init_with_body,decl_parsing,none,
+ERROR(protocol_init_with_body,none,
"protocol initializers may not have bodies", ())
// Subscripting
-ERROR(subscript_decl_wrong_scope,decl_parsing,none,
+ERROR(subscript_decl_wrong_scope,none,
"'subscript' functions may only be declared within a type", ())
-ERROR(expected_lparen_subscript,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lparen_subscript,PointsToFirstBadToken,
"expected '(' for subscript parameters", ())
-ERROR(expected_arrow_subscript,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_arrow_subscript,PointsToFirstBadToken,
"expected '->' for subscript element type", ())
-ERROR(expected_type_subscript,type_parsing,PointsToFirstBadToken,
+ERROR(expected_type_subscript,PointsToFirstBadToken,
"expected subscripting element type", ())
-ERROR(expected_lbrace_subscript,decl_parsing,PointsToFirstBadToken,
- "expected '{' for subscripting", ())
-ERROR(subscript_without_get,decl_parsing,none,
+ERROR(expected_lbrace_subscript,PointsToFirstBadToken,
+ "expected '{' in subscript to specify getter and setter implementation",
+ ())
+ERROR(expected_lbrace_subscript_protocol,PointsToFirstBadToken,
+ "subscript in protocol must have explicit { get } or "
+ "{ get set } specifier", ())
+ERROR(subscript_without_get,none,
"subscript declarations must have a getter", ())
-ERROR(subscript_static,decl_parsing,none,
+ERROR(subscript_static,none,
"subscript cannot be marked %0", (StaticSpellingKind))
// initializer
-ERROR(initializer_decl_wrong_scope,decl_parsing,none,
+ERROR(initializer_decl_wrong_scope,none,
"initializers may only be declared within a type", ())
-ERROR(expected_lparen_initializer,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lparen_initializer,PointsToFirstBadToken,
"expected '(' for initializer parameters", ())
// Destructor
-ERROR(destructor_decl_outside_class,decl_parsing,none,
+ERROR(destructor_decl_outside_class,none,
"deinitializers may only be declared within a class", ())
-ERROR(expected_lbrace_destructor,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_destructor,PointsToFirstBadToken,
"expected '{' for deinitializer", ())
-ERROR(opened_destructor_expected_rparen,attribute_parsing,none,
+ERROR(opened_destructor_expected_rparen,none,
"expected ')' to close parameter list", ())
-ERROR(destructor_params,decl_parsing,none,
+ERROR(destructor_params,none,
"no parameter clause allowed on deinitializer", ())
// Operator
-ERROR(operator_decl_inner_scope,decl_parsing,none,
+ERROR(operator_decl_inner_scope,none,
"'operator' may only be declared at file scope", ())
-ERROR(expected_operator_name_after_operator,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_operator_name_after_operator,PointsToFirstBadToken,
"expected operator name in operator declaration", ())
-ERROR(operator_decl_no_fixity,decl_parsing,none,
+ERROR(identifier_when_expecting_operator,PointsToFirstBadToken,
+ "%0 is considered to be an identifier, not an operator", (Identifier))
+
+ERROR(operator_decl_no_fixity,none,
"operator must be declared as 'prefix', 'postfix', or 'infix'", ())
-ERROR(expected_lbrace_after_operator,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_operator,PointsToFirstBadToken,
"expected '{' after operator name in 'operator' declaration", ())
-ERROR(expected_operator_attribute,decl_parsing,none,
+ERROR(expected_operator_attribute,none,
"expected operator attribute identifier in 'operator' declaration body", ())
-ERROR(unknown_prefix_operator_attribute,decl_parsing,none,
+ERROR(unknown_prefix_operator_attribute,none,
"'%0' is not a valid prefix operator attribute", (StringRef))
-ERROR(unknown_postfix_operator_attribute,decl_parsing,none,
+ERROR(unknown_postfix_operator_attribute,none,
"'%0' is not a valid postfix operator attribute", (StringRef))
-ERROR(unknown_infix_operator_attribute,decl_parsing,none,
+ERROR(unknown_infix_operator_attribute,none,
"'%0' is not a valid infix operator attribute", (StringRef))
-ERROR(operator_associativity_redeclared,decl_parsing,none,
+ERROR(operator_associativity_redeclared,none,
"'associativity' for infix operator declared multiple times", ())
-ERROR(expected_infix_operator_associativity,decl_parsing,none,
+ERROR(expected_infix_operator_associativity,none,
"expected identifier after 'associativity' in 'operator' declaration body", ())
-ERROR(unknown_infix_operator_associativity,decl_parsing,none,
+ERROR(unknown_infix_operator_associativity,none,
"'%0' is not a valid infix operator associativity; must be 'none', 'left', or 'right'", (StringRef))
-ERROR(operator_precedence_redeclared,decl_parsing,none,
+ERROR(operator_precedence_redeclared,none,
"'precedence' for infix operator declared multiple times", ())
-ERROR(operator_assignment_redeclared,decl_parsing,none,
+ERROR(operator_assignment_redeclared,none,
"'assignment' for infix operator declared multiple times", ())
-ERROR(expected_infix_operator_precedence,decl_parsing,none,
+ERROR(expected_infix_operator_precedence,none,
"expected integer literal after 'precedence' in 'operator' declaration body", ())
-ERROR(invalid_infix_operator_precedence,decl_parsing,none,
+ERROR(invalid_infix_operator_precedence,none,
"'precedence' must be in the range of 0 to 255", ())
// SIL
-ERROR(inout_not_attribute, decl_parsing, none,
+ERROR(inout_not_attribute, none,
"@inout is no longer an attribute", ())
-ERROR(only_allowed_in_sil, decl_parsing,none,
+ERROR(only_allowed_in_sil,none,
"'%0' only allowed in SIL modules", (StringRef))
-ERROR(expected_sil_type, decl_parsing,none,
+ERROR(expected_sil_type,none,
"expected type in SIL code", ())
-ERROR(expected_sil_colon_value_ref,decl_parsing,none,
+ERROR(expected_sil_colon_value_ref,none,
"expected ':' before type in SIL value reference", ())
-ERROR(expected_sil_value_name,decl_parsing,none,
+ERROR(expected_sil_value_name,none,
"expected SIL value name", ())
-ERROR(expected_sil_value_name_result_number,decl_parsing,none,
- "expected result number in SIL value name", ())
-ERROR(invalid_sil_value_name_result_number,decl_parsing,none,
- "invalid result number in SIL value", ())
-ERROR(expected_sil_type_kind, decl_parsing,none,
+ERROR(expected_sil_type_kind,none,
"expected SIL type to %0", (StringRef))
-ERROR(expected_sil_constant, decl_parsing,none,
+ERROR(expected_sil_constant,none,
"expected constant in SIL code", ())
-ERROR(referenced_value_no_accessor, decl_parsing,none,
+ERROR(referenced_value_no_accessor,none,
"referenced declaration has no %select{getter|setter}0", (unsigned))
-ERROR(sil_local_storage_non_address, decl_parsing,none,
- "can only work with the address of local storage", ())
// SIL Values
-ERROR(sil_value_redefinition, decl_parsing,none,
+ERROR(sil_value_redefinition,none,
"redefinition of value '%0'", (StringRef))
-ERROR(sil_value_use_type_mismatch, decl_parsing,none,
+ERROR(sil_value_use_type_mismatch,none,
"value '%0' defined with mismatching type %1 (expected %2)", (StringRef, Type, Type))
-ERROR(sil_value_def_type_mismatch, decl_parsing,none,
+ERROR(sil_value_def_type_mismatch,none,
"value '%0' used with mismatching type %1 (expected %2)", (StringRef, Type, Type))
-ERROR(sil_use_of_undefined_value, decl_parsing,none,
+ERROR(sil_use_of_undefined_value,none,
"use of undefined value '%0'", (StringRef))
-NOTE(sil_prior_reference,parsing,none,
+NOTE(sil_prior_reference,none,
"prior reference was here", ())
// SIL Instructions
-ERROR(expected_sil_instr_start_of_line,decl_parsing,none,
+ERROR(expected_sil_instr_start_of_line,none,
"SIL instructions must be at the start of a line", ())
-ERROR(expected_equal_in_sil_instr,decl_parsing,none,
+ERROR(expected_equal_in_sil_instr,none,
"expected '=' in SIL instruction", ())
-ERROR(expected_sil_instr_opcode,decl_parsing,none,
+ERROR(expected_sil_instr_opcode,none,
"expected SIL instruction opcode", ())
-ERROR(expected_tok_in_sil_instr,decl_parsing,none,
+ERROR(expected_tok_in_sil_instr,none,
"expected '%0' in SIL instruction", (StringRef))
-ERROR(sil_string_no_encoding,decl_parsing,none,
+ERROR(sil_string_no_encoding,none,
"string_literal instruction requires an encoding", ())
-ERROR(sil_string_invalid_encoding,decl_parsing,none,
+ERROR(sil_string_invalid_encoding,none,
"unknown string literal encoding '%0'", (StringRef))
-ERROR(expected_tuple_type_in_tuple,decl_parsing,none,
+ERROR(expected_tuple_type_in_tuple,none,
"tuple instruction requires a tuple type", ())
-ERROR(sil_tuple_inst_wrong_value_count,decl_parsing,none,
+ERROR(sil_tuple_inst_wrong_value_count,none,
"tuple instruction requires %0 values", (unsigned))
-ERROR(sil_tuple_inst_wrong_field,decl_parsing,none,
+ERROR(sil_tuple_inst_wrong_field,none,
"tuple instruction requires a field number", ())
-ERROR(sil_struct_inst_wrong_field,decl_parsing,none,
+ERROR(sil_struct_inst_wrong_field,none,
"struct instruction requires a field name", ())
-ERROR(sil_ref_inst_wrong_field,decl_parsing,none,
+ERROR(sil_ref_inst_wrong_field,none,
"ref_element_addr instruction requires a field name", ())
-ERROR(sil_invalid_instr_operands,decl_parsing,none,
+ERROR(sil_invalid_instr_operands,none,
"invalid instruction operands", ())
-ERROR(sil_operand_not_address,decl_parsing,none,
+ERROR(sil_operand_not_address,none,
"%0 operand of '%1' must have address type", (StringRef, StringRef))
-ERROR(sil_operand_not_unowned_address,decl_parsing,none,
+ERROR(sil_operand_not_unowned_address,none,
"%0 operand of '%1' must have address of [unowned] type",
(StringRef, StringRef))
-ERROR(sil_operand_not_weak_address,decl_parsing,none,
+ERROR(sil_operand_not_weak_address,none,
"%0 operand of '%1' must have address of [weak] type",
(StringRef, StringRef))
-ERROR(sil_integer_literal_not_integer_type,decl_parsing,none,
+ERROR(sil_integer_literal_not_integer_type,none,
"integer_literal instruction requires a 'Builtin.Int' type", ())
-ERROR(sil_float_literal_not_float_type,decl_parsing,none,
+ERROR(sil_float_literal_not_float_type,none,
"float_literal instruction requires a 'Builtin.FP' type", ())
-ERROR(sil_apply_archetype_not_found,decl_parsing,none,
- "archetype name not found in polymorphic function type of apply instruction", ())
-ERROR(sil_substitutions_on_non_polymorphic_type,decl_parsing,none,
+ERROR(sil_substitutions_on_non_polymorphic_type,none,
"apply of non-polymorphic function cannot have substitutions", ())
-ERROR(sil_witness_method_not_protocol,decl_parsing,none,
+ERROR(sil_witness_method_not_protocol,none,
"witness_method is not a protocol method", ())
-ERROR(sil_witness_method_type_does_not_conform,decl_parsing,none,
+ERROR(sil_witness_method_type_does_not_conform,none,
"witness_method type does not conform to protocol", ())
-ERROR(sil_witness_archetype_not_found,decl_parsing,none,
- "archetype name not found in specialized protocol conformance", ())
-ERROR(sil_member_decl_not_found,decl_parsing,none,
+ERROR(sil_member_decl_not_found,none,
"member not found in method instructions", ())
-ERROR(sil_member_decl_type_mismatch, decl_parsing,none,
+ERROR(sil_member_decl_type_mismatch,none,
"member defined with mismatching type %0 (expected %1)", (Type, Type))
-ERROR(sil_substitution_mismatch,decl_parsing,none,
+ERROR(sil_substitution_mismatch,none,
"substitution conformances dont match archetype", ())
-ERROR(sil_missing_substitutions,decl_parsing,none,
+ERROR(sil_missing_substitutions,none,
"missing substitutions", ())
-ERROR(sil_too_many_substitutions,decl_parsing,none,
+ERROR(sil_too_many_substitutions,none,
"too many substitutions", ())
-ERROR(sil_dbg_unknown_key,decl_parsing,none,
+ERROR(sil_dbg_unknown_key,none,
"unknown key '%0' in debug variable declaration", (StringRef))
// SIL Basic Blocks
-ERROR(expected_sil_block_name, decl_parsing,none,
+ERROR(expected_sil_block_name,none,
"expected basic block name or '}'", ())
-ERROR(expected_sil_block_colon, decl_parsing,none,
+ERROR(expected_sil_block_colon,none,
"expected ':' after basic block name", ())
-ERROR(sil_undefined_basicblock_use, decl_parsing,none,
+ERROR(sil_undefined_basicblock_use,none,
"use of undefined basic block %0", (Identifier))
-ERROR(sil_basicblock_redefinition, decl_parsing,none,
+ERROR(sil_basicblock_redefinition,none,
"redefinition of basic block %0", (Identifier))
-ERROR(sil_basicblock_arg_rparen, decl_parsing,none,
+ERROR(sil_basicblock_arg_rparen,none,
"expected ')' in basic block argument list", ())
// SIL Functions
-ERROR(expected_sil_linkage_or_function, decl_parsing,none,
- "expected SIL linkage type or function name", ())
-ERROR(expected_sil_function_name, decl_parsing,none,
+ERROR(expected_sil_function_name,none,
"expected SIL function name", ())
-ERROR(expected_sil_rbrace, decl_parsing,none,
+ERROR(expected_sil_rbrace,none,
"expected '}' at the end of a sil body", ())
-ERROR(expected_sil_function_type, decl_parsing, none,
+ERROR(expected_sil_function_type, none,
"sil function expected to have SIL function type", ())
// SIL Stage
-ERROR(expected_sil_stage_name, decl_parsing, none,
+ERROR(expected_sil_stage_name, none,
"expected 'raw' or 'canonical' after 'sil_stage'", ())
-ERROR(multiple_sil_stage_decls, decl_parsing, none,
+ERROR(multiple_sil_stage_decls, none,
"sil_stage declared multiple times", ())
// SIL VTable
-ERROR(expected_sil_vtable_colon, decl_parsing,none,
+ERROR(expected_sil_vtable_colon,none,
"expected ':' in a vtable entry", ())
-ERROR(sil_vtable_func_not_found, decl_parsing,none,
+ERROR(sil_vtable_func_not_found,none,
"sil function not found %0", (Identifier))
-ERROR(sil_vtable_class_not_found, decl_parsing,none,
+ERROR(sil_vtable_class_not_found,none,
"sil class not found %0", (Identifier))
// SIL Global
-ERROR(sil_global_variable_not_found, decl_parsing,none,
+ERROR(sil_global_variable_not_found,none,
"sil global not found %0", (Identifier))
// SIL Witness Table
-ERROR(expected_sil_witness_colon, decl_parsing,none,
+ERROR(expected_sil_witness_colon,none,
"expected ':' in a witness table", ())
-ERROR(expected_sil_witness_lparen, decl_parsing,none,
+ERROR(expected_sil_witness_lparen,none,
"expected '(' in a witness table", ())
-ERROR(expected_sil_witness_rparen, decl_parsing,none,
+ERROR(expected_sil_witness_rparen,none,
"expected ')' in a witness table", ())
-ERROR(sil_witness_func_not_found, decl_parsing,none,
+ERROR(sil_witness_func_not_found,none,
"sil function not found %0", (Identifier))
-ERROR(sil_witness_protocol_not_found, decl_parsing,none,
+ERROR(sil_witness_protocol_not_found,none,
"sil protocol not found %0", (Identifier))
-ERROR(sil_witness_assoc_not_found, decl_parsing,none,
+ERROR(sil_witness_assoc_not_found,none,
"sil associated type decl not found %0", (Identifier))
-ERROR(sil_witness_protocol_conformance_not_found, decl_parsing,none,
+ERROR(sil_witness_protocol_conformance_not_found,none,
"sil protocol conformance not found", ())
// SIL Coverage Map
-ERROR(sil_coverage_func_not_found, decl_parsing, none,
+ERROR(sil_coverage_func_not_found, none,
"sil function not found %0", (Identifier))
-ERROR(sil_coverage_invalid_hash, decl_parsing, none,
+ERROR(sil_coverage_invalid_hash, none,
"expected coverage hash", ())
-ERROR(sil_coverage_expected_lbrace, decl_parsing, none,
+ERROR(sil_coverage_expected_lbrace, none,
"expected '{' in coverage map", ())
-ERROR(sil_coverage_expected_loc, decl_parsing, none,
+ERROR(sil_coverage_expected_loc, none,
"expected line:column pair", ())
-ERROR(sil_coverage_expected_arrow, decl_parsing, none,
+ERROR(sil_coverage_expected_arrow, none,
"expected '->' after start location", ())
-ERROR(sil_coverage_expected_colon, decl_parsing, none,
+ERROR(sil_coverage_expected_colon, none,
"expected ':' after source range", ())
-ERROR(sil_coverage_invalid_counter, decl_parsing, none,
+ERROR(sil_coverage_invalid_counter, none,
"expected counter expression, id, or 'zero'", ())
-ERROR(sil_coverage_expected_rparen, decl_parsing, none,
+ERROR(sil_coverage_expected_rparen, none,
"expected ')' to end counter expression", ())
-ERROR(sil_coverage_invalid_operator, decl_parsing, none,
+ERROR(sil_coverage_invalid_operator, none,
"expected '+' or '-'", ())
//------------------------------------------------------------------------------
// Type parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(expected_type,type_parsing,PointsToFirstBadToken,
+ERROR(expected_type,PointsToFirstBadToken,
"expected type", ())
-ERROR(expected_init_value,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_init_value,PointsToFirstBadToken,
"expected initial value after '='", ())
// Named types
-ERROR(expected_identifier_in_dotted_type,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_identifier_in_dotted_type,PointsToFirstBadToken,
"expected identifier in dotted type", ())
-ERROR(expected_identifier_for_type,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_identifier_for_type,PointsToFirstBadToken,
"expected identifier for type name", ())
-ERROR(expected_rangle_generic_arg_list,type_parsing,PointsToFirstBadToken,
+ERROR(expected_rangle_generic_arg_list,PointsToFirstBadToken,
"expected '>' to complete generic argument list", ())
// Function types
-ERROR(expected_type_function_result,type_parsing,PointsToFirstBadToken,
+ERROR(expected_type_function_result,PointsToFirstBadToken,
"expected type for function result", ())
-ERROR(generic_non_function,type_parsing,PointsToFirstBadToken,
+ERROR(generic_non_function,PointsToFirstBadToken,
"only syntactic function types can be generic", ())
-ERROR(throwing_non_function,type_parsing,PointsToFirstBadToken,
- "only function types may throw", ())
-ERROR(rethrowing_function_type,type_parsing,PointsToFirstBadToken,
+ERROR(rethrowing_function_type,PointsToFirstBadToken,
"only function declarations may be marked 'rethrows'", ())
-ERROR(throws_after_function_result,type_parsing,none,
+ERROR(throws_after_function_result,none,
"'throws' may only occur before '->'", ())
-ERROR(rethrows_after_function_result,type_parsing,none,
+ERROR(rethrows_after_function_result,none,
"'rethrows' may only occur before '->'", ())
-ERROR(throw_in_function_type,type_parsing,none,
+ERROR(throw_in_function_type,none,
"expected throwing specifier; did you mean 'throws'?", ())
// Enum Types
-ERROR(expected_expr_enum_case_raw_value,type_parsing,PointsToFirstBadToken,
+ERROR(expected_expr_enum_case_raw_value,PointsToFirstBadToken,
"expected expression after '=' in 'case'", ())
-ERROR(nonliteral_enum_case_raw_value,type_parsing,PointsToFirstBadToken,
+ERROR(nonliteral_enum_case_raw_value,PointsToFirstBadToken,
"raw value for enum case must be a literal", ())
// Collection Types
-ERROR(expected_expr_array_type,expr_parsing,PointsToFirstBadToken,
- "expected expression for size of array type", ())
-ERROR(expected_rbracket_array_type,type_parsing,PointsToFirstBadToken,
+ERROR(new_array_syntax,none,
+ "array types are now written with the brackets around the element type",
+ ())
+ERROR(expected_rbracket_array_type,PointsToFirstBadToken,
"expected ']' in array type", ())
-ERROR(expected_element_type,type_parsing,PointsToFirstBadToken,
+ERROR(expected_element_type,PointsToFirstBadToken,
"expected element type", ())
-ERROR(expected_dictionary_value_type,type_parsing,PointsToFirstBadToken,
+ERROR(expected_dictionary_value_type,PointsToFirstBadToken,
"expected dictionary value type", ())
-ERROR(expected_rbracket_dictionary_type,type_parsing,PointsToFirstBadToken,
+ERROR(expected_rbracket_dictionary_type,PointsToFirstBadToken,
"expected ']' in dictionary type", ())
// Tuple Types
-ERROR(expected_rparen_tuple_type_list,type_parsing,none,
+ERROR(expected_rparen_tuple_type_list,none,
"expected ')' at end of tuple list", ())
-ERROR(multiple_ellipsis_in_tuple,type_parsing,none,
+ERROR(multiple_ellipsis_in_tuple,none,
"only a single element can be variadic", ())
-ERROR(tuple_type_init,pattern_parsing,none,
+ERROR(tuple_type_init,none,
"default argument not permitted in a tuple type", ())
-ERROR(protocol_method_argument_init,type_parsing,none,
+ERROR(protocol_method_argument_init,none,
"default argument not permitted in a protocol method", ())
-ERROR(protocol_init_argument_init,type_parsing,none,
+ERROR(protocol_init_argument_init,none,
"default argument not permitted in a protocol initializer", ())
// Protocol Types
-ERROR(expected_langle_protocol,type_parsing,PointsToFirstBadToken,
+ERROR(expected_langle_protocol,PointsToFirstBadToken,
"expected '<' in protocol composition type", ())
-ERROR(expected_rangle_protocol,type_parsing,PointsToFirstBadToken,
+ERROR(expected_rangle_protocol,PointsToFirstBadToken,
"expected '>' to complete protocol composition type", ())
//------------------------------------------------------------------------------
// Pattern parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(expected_pattern,pattern_parsing,PointsToFirstBadToken,
+ERROR(expected_pattern,PointsToFirstBadToken,
"expected pattern", ())
-ERROR(expected_pattern_is_keyword,pattern_parsing,none,
+ERROR(expected_pattern_is_keyword,none,
"keyword '%0' cannot be used as an identifier", (StringRef))
-ERROR(expected_rparen_tuple_pattern_list,pattern_parsing,none,
+ERROR(expected_rparen_tuple_pattern_list,none,
"expected ')' at end of tuple pattern", ())
-ERROR(untyped_pattern_ellipsis,pattern_parsing,none,
+ERROR(untyped_pattern_ellipsis,none,
"'...' cannot be applied to a subpattern which is not explicitly typed", ())
-ERROR(non_func_decl_pattern_init,pattern_parsing,none,
- "default argument is only permitted for a non-curried function parameter",())
-WARNING(var_not_allowed_in_pattern,pattern_parsing, none,
- "Use of '%select{var|let}0' binding here is deprecated and will be removed in a future version of Swift", (unsigned))
-ERROR(var_pattern_in_var,pattern_parsing,none,
+ERROR(no_default_arg_closure,none,
+ "default arguments are not allowed in closures", ())
+ERROR(no_default_arg_subscript,none,
+ "default arguments are not allowed in subscripts", ())
+ERROR(no_default_arg_curried,none,
+ "default arguments are not allowed in curried parameter lists", ())
+ERROR(var_not_allowed_in_pattern, none,
+ "Use of 'var' binding here is not allowed", ())
+WARNING(let_on_param_is_redundant, none,
+ "'let' keyword is unnecessary; function parameters are immutable by default", (unsigned))
+ERROR(var_pattern_in_var,none,
"'%select{var|let}0' cannot appear nested inside another 'var' or "
"'let' pattern", (unsigned))
-ERROR(let_pattern_in_immutable_context,pattern_parsing,none,
+ERROR(let_pattern_in_immutable_context,none,
"'let' pattern is already in an immutable context", ())
-ERROR(inout_must_have_type,pattern_parsing,none,
+ERROR(inout_must_have_type,none,
"'inout' arguments must have a type specified", ())
-ERROR(inout_must_appear_before_param,pattern_parsing,none,
+ERROR(inout_must_appear_before_param,none,
"'inout' must appear before the parameter name", ())
-ERROR(expected_rparen_parameter,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_rparen_parameter,PointsToFirstBadToken,
"expected ')' in parameter", ())
-ERROR(expected_parameter_type,decl_parsing,PointsToFirstBadToken,
+ERROR(expected_parameter_type,PointsToFirstBadToken,
"expected parameter type following ':'", ())
-ERROR(multiple_parameter_ellipsis,decl_parsing,none,
+ERROR(missing_parameter_type,PointsToFirstBadToken,
+ "parameter requires an explicit type", ())
+ERROR(multiple_parameter_ellipsis,none,
"only a single variadic parameter '...' is permitted", ())
-ERROR(parameter_vararg_default,decl_parsing,none,
+ERROR(parameter_vararg_default,none,
"variadic parameter cannot have a default value", ())
-ERROR(parameter_backtick_missing_name,decl_parsing,PointsToFirstBadToken,
- "expected parameter name after '#'", ())
-ERROR(parameter_backtick_empty_name,decl_parsing,none,
- "expected non-empty parameter name after '#'", ())
-ERROR(parameter_inout_var_let,decl_parsing,none,
+ERROR(parameter_inout_var_let,none,
"parameter may not have multiple 'inout', 'var', or 'let' specifiers",
())
-WARNING(parameter_backtick_two_names,decl_parsing,none,
- "extraneous '#' in parameter; keyword argument and parameter name "
- "already specified separately", ())
-WARNING(parameter_extraneous_double_up,decl_parsing,none,
+WARNING(parameter_extraneous_double_up,none,
"extraneous duplicate parameter name; %0 already has an argument "
"label", (Identifier))
-ERROR(parameter_extraneous_pound,decl_parsing,none,
- "'#' has been removed from Swift; %0 already has an argument label",
- (Identifier))
-ERROR(parameter_pound_double_up,decl_parsing,none,
- "'#' has been removed from Swift; double up '%0 %0' to make the "
- "argument label the same as the parameter name", (StringRef))
-WARNING(parameter_extraneous_empty_name,decl_parsing,none,
+WARNING(parameter_extraneous_empty_name,none,
"extraneous '_' in parameter: %0 has no keyword argument name",
(Identifier))
-ERROR(parameter_operator_keyword_argument,decl_parsing,none,
- "operator cannot have keyword arguments", ())
+ERROR(parameter_operator_keyword_argument,none,
+ "%select{operator|closure}0 cannot have keyword arguments", (bool))
-ERROR(parameter_unnamed,decl_parsing,none,
+ERROR(parameter_unnamed,none,
"unnamed parameters must be written with the empty name '_'", ())
-WARNING(parameter_curry_syntax_removed,decl_parsing,none,
- "curried function declaration syntax will be removed in a future version of Swift; use a single parameter list", ())
+ERROR(parameter_curry_syntax_removed,none,
+ "curried function declaration syntax has been removed; use a single parameter list", ())
//------------------------------------------------------------------------------
// Statement parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(expected_stmt,stmt_parsing,none,
+ERROR(expected_stmt,none,
"expected statement", ())
-ERROR(illegal_top_level_stmt,stmt_parsing,none,
+ERROR(illegal_top_level_stmt,none,
"statements are not allowed at the top level", ())
-ERROR(illegal_top_level_expr,stmt_parsing,none,
+ERROR(illegal_top_level_expr,none,
"expressions are not allowed at the top level", ())
-ERROR(illegal_semi_stmt,stmt_parsing,none,
+ERROR(illegal_semi_stmt,none,
"';' statements are not allowed", ())
-ERROR(statement_begins_with_closure,stmt_parsing,none,
+ERROR(statement_begins_with_closure,none,
"statement cannot begin with a closure expression", ())
-ERROR(statement_same_line_without_semi,stmt_parsing,none,
+ERROR(statement_same_line_without_semi,none,
"consecutive statements on a line must be separated by ';'", ())
-ERROR(brace_stmt_invalid,stmt_parsing,none,
+ERROR(brace_stmt_invalid,none,
"braced block of statements is an unused closure", ())
-ERROR(invalid_label_on_stmt,stmt_parsing,none,
+ERROR(invalid_label_on_stmt,none,
"labels are only valid on loops, if, and switch statements", ())
-NOTE(discard_result_of_closure,stmt_parsing,none,
+NOTE(discard_result_of_closure,none,
"explicitly discard the result of the closure by assigning to '_'", ())
// Assignment statement
-ERROR(expected_expr_assignment,stmt_parsing,none,
+ERROR(expected_expr_assignment,none,
"expected expression in assignment", ())
// Brace Statement
-ERROR(expected_rbrace_in_brace_stmt,stmt_parsing,none,
+ERROR(expected_rbrace_in_brace_stmt,none,
"expected '}' at end of brace statement", ())
/// #if Statement
-ERROR(expected_close_to_config_stmt,stmt_parsing,none,
+ERROR(expected_close_to_config_stmt,none,
"expected #else or #endif at end of configuration block", ())
-ERROR(expected_close_after_else,stmt_parsing,none,
+ERROR(expected_close_after_else,none,
"further conditions after #else are unreachable", ())
+/// Associatedtype Statement
+WARNING(typealias_inside_protocol,none,
+ "use of 'typealias' to declare associated types is deprecated; use 'associatedtype' instead", ())
+ERROR(associatedtype_outside_protocol,none,
+ "associated types can only be defined in a protocol; define a type or introduce a 'typealias' to satisfy an associated type requirement", ())
+
// Return Statement
-ERROR(expected_expr_return,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_expr_return,PointsToFirstBadToken,
"expected expression in 'return' statement", ())
-WARNING(unindented_code_after_return,stmt_parsing,none,
+WARNING(unindented_code_after_return,none,
"expression following 'return' is treated as an argument of "
"the 'return'", ())
-NOTE(indent_expression_to_silence,stmt_parsing,none,
+NOTE(indent_expression_to_silence,none,
"indent the expression to silence this warning", ())
// Throw Statement
-ERROR(expected_expr_throw,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_expr_throw,PointsToFirstBadToken,
"expected expression in 'throw' statement", ())
// Defer Statement
-ERROR(expected_lbrace_after_defer,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_defer,PointsToFirstBadToken,
"expected '{' after 'defer'", ())
// If/While/Guard Conditions
-ERROR(expected_expr_conditional_letbinding,stmt_parsing,none,
+ERROR(expected_expr_conditional_letbinding,none,
"expected 'let' or 'var' in conditional", ())
-ERROR(expected_expr_conditional_letbinding_bool_conditions,stmt_parsing,none,
+ERROR(expected_expr_conditional_letbinding_bool_conditions,none,
"expected 'let' or 'var' in conditional; "
"use '&&' to join boolean conditions", ())
-ERROR(expected_simple_identifier_pattern,stmt_parsing,none,
- "expected simple identifier pattern in optional binding condition", ())
-ERROR(expected_expr_conditional_var,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_expr_conditional_var,PointsToFirstBadToken,
"expected expression after '=' in conditional binding", ())
-ERROR(expected_expr_conditional_where,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_expr_conditional_where,PointsToFirstBadToken,
"expected expression in conditional binding 'where' clause", ())
-ERROR(conditional_var_initializer_required,stmt_parsing,none,
+ERROR(conditional_var_initializer_required,none,
"variable binding in a condition requires an initializer", ())
-ERROR(wrong_condition_case_location,stmt_parsing,none,
+ERROR(wrong_condition_case_location,none,
"pattern matching binding is spelled with 'case %0', not '%0 case'",
(StringRef))
-ERROR(where_end_of_binding_use_letvar,stmt_parsing,none,
+ERROR(where_end_of_binding_use_letvar,none,
"binding ended by previous 'where' clause; "
"use '%0' to introduce a new one", (StringRef))
-ERROR(comma_should_be_where,stmt_parsing,none,
+ERROR(comma_should_be_where,none,
"boolean condition requires 'where' to separate it from variable binding",
())
// If Statement
-ERROR(expected_condition_if,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_condition_if,PointsToFirstBadToken,
"expected expression, var, or let in 'if' condition", ())
-ERROR(missing_condition_after_if,stmt_parsing,none,
+ERROR(missing_condition_after_if,none,
"missing condition in an 'if' statement", ())
-ERROR(expected_lbrace_after_if,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_if,PointsToFirstBadToken,
"expected '{' after 'if' condition", ())
-ERROR(expected_lbrace_after_else,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_else,PointsToFirstBadToken,
"expected '{' after 'else'", ())
// Guard Statement
-ERROR(expected_condition_guard,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_condition_guard,PointsToFirstBadToken,
"expected expression, var, let or case in 'guard' condition", ())
-ERROR(missing_condition_after_guard,stmt_parsing,none,
+ERROR(missing_condition_after_guard,none,
"missing condition in an 'guard' statement", ())
-ERROR(expected_else_after_guard,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_else_after_guard,PointsToFirstBadToken,
"expected 'else' after 'guard' condition", ())
-ERROR(expected_lbrace_after_guard,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_guard,PointsToFirstBadToken,
"expected '{' after 'guard' else", ())
-ERROR(bound_var_guard_body,expr_parsing,none,
+ERROR(bound_var_guard_body,none,
"variable declared in 'guard' condition is not usable in its body", ())
// While Statement
-ERROR(expected_condition_while,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_condition_while,PointsToFirstBadToken,
"expected expression, var, or let in 'while' condition", ())
-ERROR(missing_condition_after_while,stmt_parsing,none,
+ERROR(missing_condition_after_while,none,
"missing condition in a 'while' statement", ())
-ERROR(expected_lbrace_after_while,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_while,PointsToFirstBadToken,
"expected '{' after 'while' condition", ())
// Repeat/While Statement
-ERROR(expected_lbrace_after_repeat,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_repeat,PointsToFirstBadToken,
"expected '{' after 'repeat'", ())
-ERROR(expected_while_after_repeat_body,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_while_after_repeat_body,PointsToFirstBadToken,
"expected 'while' after body of 'repeat' statement", ())
-ERROR(expected_expr_repeat_while,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_expr_repeat_while,PointsToFirstBadToken,
"expected expression in 'repeat-while' condition", ())
-ERROR(missing_condition_after_repeat_while,stmt_parsing,none,
- "missing condition in a 'repeat-while' statement", ())
-ERROR(do_while_now_repeat_while,stmt_parsing,none,
+ERROR(do_while_now_repeat_while,none,
"'do-while' statement is not allowed; use 'repeat-while' instead", ())
// Do/Catch Statement
-ERROR(expected_lbrace_after_do,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_do,PointsToFirstBadToken,
"expected '{' after 'do'", ())
-ERROR(expected_lbrace_after_catch,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_catch,PointsToFirstBadToken,
"expected '{' after 'catch' pattern", ())
-ERROR(expected_catch_where_expr,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_catch_where_expr,PointsToFirstBadToken,
"expected expression for 'where' guard of 'catch'", ())
+ERROR(docatch_not_trycatch,PointsToFirstBadToken,
+ "the 'do' keyword is used to specify a 'catch' region",
+ ())
+
+
// C-Style For Stmt
-ERROR(expected_init_for_stmt,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_init_for_stmt,PointsToFirstBadToken,
"expected initialization in a 'for' statement", ())
-ERROR(missing_init_for_stmt,stmt_parsing,none,
+ERROR(missing_init_for_stmt,none,
"missing initialization in a 'for' statement", ())
-ERROR(expected_semi_for_stmt,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_semi_for_stmt,PointsToFirstBadToken,
"expected ';' in 'for' statement", ())
-ERROR(expected_cond_for_stmt,stmt_parsing,none,
+ERROR(expected_cond_for_stmt,none,
"expected condition in 'for' statement", ())
-ERROR(expected_rparen_for_stmt,stmt_parsing,none,
+ERROR(expected_rparen_for_stmt,none,
"expected ')' in 'for' statement", ())
-ERROR(expected_lbrace_after_for,stmt_parsing,none,
+ERROR(expected_lbrace_after_for,none,
"expected '{' in 'for' statement", ())
-ERROR(expected_var_decl_for_stmt,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_var_decl_for_stmt,PointsToFirstBadToken,
"expected var declaration in a 'for' statement", ())
// For-each Stmt
-ERROR(expected_foreach_in,stmt_parsing,none,
+ERROR(expected_foreach_in,none,
"expected 'in' after for-each pattern", ())
-ERROR(expected_foreach_container,stmt_parsing,none,
+ERROR(expected_foreach_container,none,
"expected SequenceType expression for for-each loop", ())
-ERROR(expected_foreach_lbrace,stmt_parsing,none,
+ERROR(expected_foreach_lbrace,none,
"expected '{' to start the body of for-each loop", ())
-ERROR(expected_foreach_where_expr,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_foreach_where_expr,PointsToFirstBadToken,
"expected expression in 'where' guard of 'for/in'", ())
// Switch Stmt
-ERROR(expected_switch_expr,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_switch_expr,PointsToFirstBadToken,
"expected expression in 'switch' statement", ())
-ERROR(expected_lbrace_after_switch,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_lbrace_after_switch,PointsToFirstBadToken,
"expected '{' after 'switch' subject expression", ())
-ERROR(expected_rbrace_switch,stmt_parsing,none,
+ERROR(expected_rbrace_switch,none,
"expected '}' at end of 'switch' statement", ())
-ERROR(case_outside_of_switch,stmt_parsing,none,
+ERROR(case_outside_of_switch,none,
"'%0' label can only appear inside a 'switch' statement", (StringRef))
-ERROR(stmt_in_switch_not_covered_by_case,stmt_parsing,none,
+ERROR(stmt_in_switch_not_covered_by_case,none,
"all statements inside a switch must be covered by a 'case' or 'default'",
())
-ERROR(case_after_default,stmt_parsing,none,
+ERROR(case_after_default,none,
"additional 'case' blocks cannot appear after the 'default' block of a 'switch'",
())
-ERROR(empty_switch_stmt,stmt_parsing,none,
+ERROR(empty_switch_stmt,none,
"'switch' statement body must have at least one 'case' or 'default' block",
())
// Case Stmt
-ERROR(expected_case_where_expr,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_case_where_expr,PointsToFirstBadToken,
"expected expression for 'where' guard of 'case'", ())
-ERROR(expected_case_colon,stmt_parsing,PointsToFirstBadToken,
+ERROR(expected_case_colon,PointsToFirstBadToken,
"expected ':' after '%0'", (StringRef))
-ERROR(default_with_where,stmt_parsing,none,
+ERROR(default_with_where,none,
"'default' cannot be used with a 'where' guard expression",
())
-ERROR(var_binding_with_multiple_case_patterns,stmt_parsing,none,
+ERROR(var_binding_with_multiple_case_patterns,none,
"'case' labels with multiple patterns cannot declare variables",
())
-ERROR(case_stmt_without_body,stmt_parsing,none,
+ERROR(case_stmt_without_body,none,
"%select{'case'|'default'}0 label in a 'switch' should have at least one "
"executable statement", (bool))
// 'try' on statements
-ERROR(try_on_stmt,stmt_parsing,none,
+ERROR(try_on_stmt,none,
"'try' cannot be used with '%0'", (StringRef))
-ERROR(try_on_return_throw,stmt_parsing,none,
+ERROR(try_on_return_throw,none,
"'try' must be placed on the %select{returned|thrown}0 expression",
(bool))
-ERROR(try_on_var_let,stmt_parsing,none,
+ERROR(try_on_var_let,none,
"'try' must be placed on the initial value expression", ())
//------------------------------------------------------------------------------
// Expression parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(expected_expr,expr_parsing,none,
+ERROR(expected_expr,none,
"expected expression", ())
-ERROR(expected_separator,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_separator,PointsToFirstBadToken,
"expected '%0' separator", (StringRef))
-ERROR(unexpected_separator,expr_parsing,none,
+ERROR(unexpected_separator,none,
"unexpected '%0' separator", (StringRef))
-ERROR(expected_expr_after_operator,expr_parsing,none,
+ERROR(expected_expr_after_operator,none,
"expected expression after operator", ())
-ERROR(expected_expr_after_unary_operator,expr_parsing,none,
+ERROR(expected_expr_after_unary_operator,none,
"expected expression after unary operator", ())
-ERROR(expected_prefix_operator,expr_parsing,none,
+ERROR(expected_prefix_operator,none,
"unary operator cannot be separated from its operand", ())
-ERROR(expected_operator_ref,expr_parsing,none,
+ERROR(expected_operator_ref,none,
"expected operator name in operator reference", ())
-ERROR(invalid_postfix_operator,expr_parsing,none,
+ERROR(invalid_postfix_operator,none,
"operator with postfix spacing cannot start a subexpression", ())
-ERROR(expected_member_name,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_member_name,PointsToFirstBadToken,
"expected member name following '.'", ())
-ERROR(expected_dollar_numeric,expr_parsing,none,
+ERROR(expected_dollar_numeric,none,
"expected numeric value following '$'", ())
-ERROR(dollar_numeric_too_large,expr_parsing,none,
+ERROR(dollar_numeric_too_large,none,
"numeric value following '$' is too large", ())
-ERROR(numeric_literal_numeric_member,expr_parsing,none,
+ERROR(numeric_literal_numeric_member,none,
"expected named member of numeric literal", ())
-ERROR(anon_closure_arg_not_in_closure,expr_parsing,none,
+ERROR(anon_closure_arg_not_in_closure,none,
"anonymous closure argument not contained in a closure", ())
-ERROR(anon_closure_arg_in_closure_with_args,expr_parsing,none,
+ERROR(anon_closure_arg_in_closure_with_args,none,
"anonymous closure arguments cannot be used inside a closure that has "
"explicit arguments", ())
-ERROR(expected_closure_parameter_name,expr_parsing,none,
+ERROR(expected_closure_parameter_name,none,
"expected the name of a closure parameter", ())
-ERROR(expected_capture_specifier,expr_parsing,none,
+ERROR(expected_capture_specifier,none,
"expected 'weak', 'unowned', or no specifier in capture list", ())
-ERROR(expected_capture_specifier_name,attribute_parsing,none,
+ERROR(expected_capture_specifier_name,none,
"expected name of in closure capture list", ())
-ERROR(expected_init_capture_specifier,attribute_parsing,none,
+ERROR(expected_init_capture_specifier,none,
"expected initializer for closure capture specifier", ())
-ERROR(expected_capture_list_end_rsquare,attribute_parsing,none,
+ERROR(expected_capture_list_end_rsquare,none,
"expected ']' at end of capture list", ())
-ERROR(cannot_capture_fields,attribute_parsing,none,
+ERROR(cannot_capture_fields,none,
"fields may only be captured by assigning to a specific name", ())
-ERROR(expected_closure_result_type,expr_parsing,none,
+ERROR(expected_closure_result_type,none,
"expected closure result type after '->'", ())
-ERROR(expected_closure_in,expr_parsing,none,
+ERROR(expected_closure_in,none,
"expected 'in' after the closure signature", ())
-ERROR(unexpected_tokens_before_closure_in,expr_parsing,none,
+ERROR(unexpected_tokens_before_closure_in,none,
"unexpected tokens prior to 'in'", ())
-ERROR(expected_closure_rbrace,expr_parsing,none,
+ERROR(expected_closure_rbrace,none,
"expected '}' at end of closure", ())
-WARNING(trailing_closure_excess_newlines,expr_parsing,none,
+WARNING(trailing_closure_excess_newlines,none,
"trailing closure is separated from call site by multiple newlines", ())
-NOTE(trailing_closure_call_here,expr_parsing,none,
+NOTE(trailing_closure_call_here,none,
"parsing trailing closure for this call", ())
-ERROR(string_literal_no_atsign,expr_parsing,none,
+ERROR(string_literal_no_atsign,none,
"string literals in Swift are not preceded by an '@' sign", ())
-ERROR(invalid_float_literal_missing_leading_zero,expr_parsing,none,
+ERROR(invalid_float_literal_missing_leading_zero,none,
"'.%0' is not a valid floating point literal; it must be written '0.%0'",
(StringRef))
-ERROR(availability_query_outside_if_stmt_guard, expr_parsing, none,
+ERROR(availability_query_outside_if_stmt_guard, none,
"#available may only be used as condition of an 'if', 'guard'"
" or 'while' statement", ())
-ERROR(expected_identifier_after_dot_expr,expr_parsing,none,
+ERROR(empty_arg_label_underscore, none,
+ "an empty argument label is spelled with '_'", ())
+
+ERROR(expected_identifier_after_dot_expr,none,
"expected identifier after '.' expression", ())
-ERROR(expected_field_spec_name_tuple_expr,expr_parsing,none,
- "expected field specifier name in tuple expression", ())
-ERROR(expected_identifier_after_super_dot_expr,expr_parsing,
+ERROR(expected_identifier_after_super_dot_expr,
PointsToFirstBadToken,
"expected identifier or 'init' after super '.' expression", ())
-ERROR(expected_dot_or_subscript_after_super,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_dot_or_subscript_after_super,PointsToFirstBadToken,
"expected '.' or '[' after 'super'", ())
-ERROR(super_in_closure_with_capture,expr_parsing,none,
+ERROR(super_in_closure_with_capture,none,
"using 'super' in a closure where 'self' is explicitly captured is "
"not yet supported", ())
-NOTE(super_in_closure_with_capture_here,expr_parsing,none,
+NOTE(super_in_closure_with_capture_here,none,
"'self' explicitly captured here", ())
// Tuples and parenthesized expressions
-ERROR(expected_expr_in_expr_list,expr_parsing,none,
+ERROR(expected_expr_in_expr_list,none,
"expected expression in list of expressions", ())
-ERROR(expected_expr_in_collection_literal,expr_parsing,none,
+ERROR(expected_expr_in_collection_literal,none,
"expected expression in container literal", ())
-ERROR(expected_key_in_dictionary_literal,expr_parsing,none,
+ERROR(expected_key_in_dictionary_literal,none,
"expected key expression in dictionary literal", ())
-ERROR(expected_value_in_dictionary_literal,expr_parsing,none,
+ERROR(expected_value_in_dictionary_literal,none,
"expected value in dictionary literal", ())
-ERROR(expected_colon_in_dictionary_literal,expr_parsing,none,
+ERROR(expected_colon_in_dictionary_literal,none,
"expected ':' in dictionary literal", ())
-ERROR(expected_rparen_expr_list,expr_parsing,none,
+ERROR(expected_rparen_expr_list,none,
"expected ')' in expression list", ())
-ERROR(expected_rsquare_expr_list,expr_parsing,none,
+ERROR(expected_rsquare_expr_list,none,
"expected ']' in expression list", ())
// Array literal expressions
-ERROR(expected_rsquare_array_expr,expr_parsing,PointsToFirstBadToken,
+ERROR(expected_rsquare_array_expr,PointsToFirstBadToken,
"expected ']' in container literal expression", ())
// Object literal expressions
-ERROR(expected_identifier_after_l_square_lit,expr_parsing,none,
+ERROR(expected_identifier_after_l_square_lit,none,
"expected identifier after '[#' in object literal expression", ())
-ERROR(expected_arg_list_in_object_literal,expr_parsing,none,
+ERROR(expected_arg_list_in_object_literal,none,
"expected argument list in object literal", ())
-ERROR(expected_r_square_lit_after_object_literal,expr_parsing,none,
+ERROR(expected_r_square_lit_after_object_literal,none,
"expected '#]' at end of object literal expression", ())
// If expressions
-ERROR(expected_expr_after_if_question,expr_parsing,none,
+ERROR(expected_expr_after_if_question,none,
"expected expression after '?' in ternary expression", ())
-ERROR(expected_colon_after_if_question,expr_parsing,none,
+ERROR(expected_colon_after_if_question,none,
"expected ':' after '? ...' in ternary expression", ())
-ERROR(expected_expr_after_if_colon,expr_parsing,none,
+ERROR(expected_expr_after_if_colon,none,
"expected expression after '? ... :' in ternary expression", ())
// Cast expressions
-ERROR(expected_type_after_is,expr_parsing,none,
+ERROR(expected_type_after_is,none,
"expected type after 'is'", ())
-ERROR(expected_type_after_as,expr_parsing,none,
+ERROR(expected_type_after_as,none,
"expected type after 'as'", ())
// Extra tokens in string interpolation like in " >> \( $0 } ) << "
-ERROR(string_interpolation_extra,expr_parsing,none,
+ERROR(string_interpolation_extra,none,
"extra tokens after interpolated string expression", ())
+// Selector expressions.
+ERROR(expr_selector_expected_lparen,PointsToFirstBadToken,
+ "expected '(' following '#selector'", ())
+ERROR(expr_selector_expected_expr,PointsToFirstBadToken,
+ "expected expression naming a method within '#selector(...)'", ())
+ERROR(expr_selector_expected_rparen,PointsToFirstBadToken,
+ "expected ')' to complete '#selector' expression", ())
+
//------------------------------------------------------------------------------
// Attribute-parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(expected_attribute_name,attribute_parsing,none,
+ERROR(expected_attribute_name,none,
"expected an attribute name", ())
-ERROR(unknown_attribute,attribute_parsing,none,
+ERROR(unknown_attribute,none,
"unknown attribute '%0'", (StringRef))
-ERROR(duplicate_attribute,attribute_parsing,none,
+ERROR(duplicate_attribute,none,
"duplicate %select{attribute|modifier}0", (bool))
-NOTE(previous_attribute,parsing,none,
+NOTE(previous_attribute,none,
"%select{attribute|modifier}0 already specified here", (bool))
-ERROR(cannot_combine_attribute,attribute_parsing,none,
+ERROR(cannot_combine_attribute,none,
"attribute '%0' cannot be combined with this attribute", (StringRef))
-ERROR(expected_in_attribute_list,attribute_parsing,none,
+ERROR(expected_in_attribute_list,none,
"expected ']' or ',' in attribute list", ())
-ERROR(type_attribute_applied_to_decl,attribute_parsing,none,
+ERROR(type_attribute_applied_to_decl,none,
"attribute can only be applied to types, not declarations", ())
-ERROR(decl_attribute_applied_to_type,attribute_parsing,none,
+ERROR(decl_attribute_applied_to_type,none,
"attribute can only be applied to declarations, not types", ())
-ERROR(attr_expected_lparen,attribute_parsing,none,
+ERROR(attr_expected_lparen,none,
"expected '(' in '%0' %select{attribute|modifier}1", (StringRef, bool))
-ERROR(attr_expected_rparen,attribute_parsing,none,
+ERROR(attr_expected_rparen,none,
"expected ')' in '%0' %select{attribute|modifier}1", (StringRef, bool))
-ERROR(attr_expected_comma,attribute_parsing,none,
+ERROR(attr_expected_comma,none,
"expected ',' in '%0' %select{attribute|modifier}1", (StringRef, bool))
-ERROR(attr_expected_string_literal,attribute_parsing,none,
+ERROR(attr_expected_string_literal,none,
"expected string literal in '%0' attribute", (StringRef))
-ERROR(alignment_must_be_positive_integer,attribute_parsing,none,
+ERROR(alignment_must_be_positive_integer,none,
"alignment value must be a positive integer literal", ())
-ERROR(swift_native_objc_runtime_base_must_be_identifier,attribute_parsing,none,
+ERROR(swift_native_objc_runtime_base_must_be_identifier,none,
"@_swift_native_objc_runtime_base class name must be an identifier", ())
-ERROR(attr_interpolated_string,attribute_parsing,none,
+ERROR(attr_interpolated_string,none,
"%0 cannot be an interpolated string literal", (StringRef))
-ERROR(attr_only_at_non_local_scope, attribute_parsing, none,
+ERROR(attr_only_at_non_local_scope, none,
"attribute '%0' can only be used in a non-local scope", (StringRef))
+ERROR(attr_expected_equal_separator,none,
+ "expected '=' following '%0' argument of '%1'",
+ (StringRef, StringRef))
+
+ERROR(attr_expected_string_literal_arg,none,
+ "expected string literal for '%0' argument of '%1'",
+ (StringRef, StringRef))
+
+ERROR(attr_duplicate_argument,none,
+ "duplicate '%0' argument", (StringRef))
+
// accessibility
-ERROR(attr_accessibility_expected_set,attribute_parsing,none,
+ERROR(attr_accessibility_expected_set,none,
"expected 'set' as subject of '%0' modifier", (StringRef))
// availability
-ERROR(attr_availability_platform,attribute_parsing,none,
+ERROR(attr_availability_platform,none,
"expected platform name or '*' for '%0' attribute", (StringRef))
-ERROR(attr_availability_unavailable_deprecated,attribute_parsing,none,
+ERROR(attr_availability_unavailable_deprecated,none,
"'%0' attribute cannot be both unconditionally 'unavailable' and "
"'deprecated'", (StringRef))
-WARNING(attr_availability_unknown_platform,attribute_parsing,none,
+WARNING(attr_availability_unknown_platform,none,
"unknown platform '%0' for attribute '%1'", (StringRef, StringRef))
-ERROR(attr_availability_expected_option,attribute_parsing,none,
+ERROR(attr_availability_expected_option,none,
"expected '%0' option such as 'unavailable', 'introduced', 'deprecated', "
"'obsoleted', 'message', or 'renamed'", (StringRef))
-ERROR(attr_availability_expected_equal,attribute_parsing,none,
-"expected '=' after '%1' in '%0' attribute", (StringRef, StringRef))
+ERROR(attr_availability_expected_equal,none,
+ "expected '=' after '%1' in '%0' attribute", (StringRef, StringRef))
-ERROR(attr_availability_expected_version,attribute_parsing,none,
+ERROR(attr_availability_expected_version,none,
"expected version number in '%0' attribute", (StringRef))
-ERROR(attr_availability_renamed, attribute_parsing, none,
+ERROR(attr_availability_renamed, none,
"@availability has been renamed to @available", ())
// autoclosure
-ERROR(attr_autoclosure_expected_r_paren,attribute_parsing,PointsToFirstBadToken,
+ERROR(attr_autoclosure_expected_r_paren,PointsToFirstBadToken,
"expected ')' in @autoclosure", ())
-// cc
-ERROR(cc_attribute_expected_lparen,attribute_parsing,none,
- "expected '(' after 'cc' attribute", ())
-ERROR(cc_attribute_expected_name,attribute_parsing,none,
- "expected calling convention name identifier in 'cc' attribute", ())
-ERROR(cc_attribute_expected_rparen,attribute_parsing,none,
- "expected ')' after calling convention name for 'cc' attribute", ())
-
// convention
-ERROR(convention_attribute_expected_lparen,attribute_parsing,none,
+ERROR(convention_attribute_expected_lparen,none,
"expected '(' after 'convention' attribute", ())
-ERROR(convention_attribute_expected_name,attribute_parsing,none,
+ERROR(convention_attribute_expected_name,none,
"expected convention name identifier in 'convention' attribute", ())
-ERROR(convention_attribute_expected_rparen,attribute_parsing,none,
+ERROR(convention_attribute_expected_rparen,none,
"expected ')' after convention name for 'convention' attribute", ())
// objc
-ERROR(attr_objc_missing_colon,attribute_parsing,none,
+ERROR(attr_objc_missing_colon,none,
"missing ':' after selector piece in @objc attribute", ())
-ERROR(attr_objc_expected_rparen,attribute_parsing,none,
+ERROR(attr_objc_expected_rparen,none,
"expected ')' after name for @objc", ())
-ERROR(attr_objc_empty_name,attribute_parsing,none,
+ERROR(attr_objc_empty_name,none,
"expected name within parentheses of @objc attribute", ())
// opened
-ERROR(opened_attribute_expected_lparen,attribute_parsing,none,
+ERROR(opened_attribute_expected_lparen,none,
"expected '(' after 'opened' attribute", ())
-ERROR(opened_attribute_id_value,attribute_parsing,none,
+ERROR(opened_attribute_id_value,none,
"known id for 'opened' attribute must be a UUID string", ())
-ERROR(opened_attribute_expected_rparen,attribute_parsing,none,
+ERROR(opened_attribute_expected_rparen,none,
"expected ')' after id value for 'opened' attribute", ())
// inline
-ERROR(inline_attribute_expect_option,attribute_parsing,none,
+ERROR(inline_attribute_expect_option,none,
"expected '%0' option such as 'never'", (StringRef))
-ERROR(inline_attribute_unknown_option,attribute_parsing,none,
+ERROR(inline_attribute_unknown_option,none,
"unknown option '%0' for attribute '%1'", (StringRef, StringRef))
// effects
-ERROR(effects_attribute_expect_option,attribute_parsing,none,
+ERROR(effects_attribute_expect_option,none,
"expected '%0' option (readnone, readonly, readwrite)", (StringRef))
-ERROR(effects_attribute_unknown_option,attribute_parsing,none,
+ERROR(effects_attribute_unknown_option,none,
"unknown option '%0' for attribute '%1'", (StringRef, StringRef))
+// swift3_migration
+ERROR(attr_swift3_migration_label,none,
+ "expected 'renamed' or 'message' in 'swift3_migration' attribute", ())
+WARNING(warn_attr_swift3_migration_unknown_label,none,
+ "expected 'renamed' or 'message' in 'swift3_migration' attribute", ())
+ERROR(attr_swift3_migration_expected_rparen,none,
+ "expected ')' after name for 'swift3_migration' attribute", ())
+ERROR(attr_bad_swift_name,none,
+ "ill-formed Swift name '%0'", (StringRef))
+
+
// unowned
-ERROR(attr_unowned_invalid_specifier,attribute_parsing,none,
+ERROR(attr_unowned_invalid_specifier,none,
"expected 'safe' or 'unsafe'", ())
-ERROR(attr_unowned_expected_rparen,attribute_parsing,none,
+ERROR(attr_unowned_expected_rparen,none,
"expected ')' after specifier for 'unowned'", ())
// warn_unused_result
-WARNING(attr_warn_unused_result_expected_name,attribute_parsing,none,
+WARNING(attr_warn_unused_result_expected_name,none,
"expected parameter 'message' or 'mutable_variant'", ())
-WARNING(attr_warn_unused_result_duplicate_parameter,attribute_parsing,none,
+WARNING(attr_warn_unused_result_duplicate_parameter,none,
"duplicate '%0' parameter; previous value will be ignored", (StringRef))
-ERROR(attr_warn_unused_result_expected_eq,attribute_parsing,none,
+ERROR(attr_warn_unused_result_expected_eq,none,
"expected '=' following '%0' parameter", (StringRef))
-ERROR(attr_warn_unused_result_expected_string,attribute_parsing,none,
+ERROR(attr_warn_unused_result_expected_string,none,
"expected a string following '=' for '%0' parameter", (StringRef))
-WARNING(attr_warn_unused_result_unknown_parameter,attribute_parsing,none,
+WARNING(attr_warn_unused_result_unknown_parameter,none,
"unknown parameter '%0' in 'warn_unused_result' attribute", (StringRef))
-ERROR(attr_warn_unused_result_expected_rparen,attribute_parsing,none,
+ERROR(attr_warn_unused_result_expected_rparen,none,
"expected ')' after 'warn_unused_result' attribute", ())
//------------------------------------------------------------------------------
// Generics parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(expected_rangle_generics_param,parsing,PointsToFirstBadToken,
+ERROR(expected_rangle_generics_param,PointsToFirstBadToken,
"expected '>' to complete generic parameter list", ())
-ERROR(expected_generics_parameter_name,parsing,PointsToFirstBadToken,
+ERROR(expected_generics_parameter_name,PointsToFirstBadToken,
"expected an identifier to name generic parameter", ())
-ERROR(expected_generics_type_restriction,parsing,none,
+ERROR(expected_generics_type_restriction,none,
"expected a type name or protocol composition restricting %0",
(Identifier))
-ERROR(requires_single_equal,parsing,none,
+ERROR(requires_single_equal,none,
"use '==' for same-type requirements rather than '='", ())
-ERROR(expected_requirement_delim,parsing,none,
+ERROR(expected_requirement_delim,none,
"expected ':' or '==' to indicate a conformance or same-type requirement",
())
-ERROR(invalid_class_requirement,decl_parsing,none,
+ERROR(invalid_class_requirement,none,
"'class' requirement only applies to protocols", ())
-ERROR(redundant_class_requirement,decl_parsing,none,
+ERROR(redundant_class_requirement,none,
"redundant 'class' requirement", ())
-ERROR(late_class_requirement,decl_parsing,none,
+ERROR(late_class_requirement,none,
"'class' must come first in the requirement list", ())
//------------------------------------------------------------------------------
// Build configuration parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(unsupported_build_config_binary_expression,parsing,none,
+ERROR(unsupported_build_config_binary_expression,none,
"expected '&&' or '||' expression", ())
-ERROR(unsupported_build_config_unary_expression,parsing,none,
+ERROR(unsupported_build_config_unary_expression,none,
"expected unary '!' expression", ())
-ERROR(unsupported_target_config_expression,parsing,none,
- "unexpected target configuration expression (expected 'os' or 'arch')",())
-ERROR(unsupported_target_config_runtime_argument,parsing,none,
+ERROR(unsupported_target_config_expression,none,
+ "unexpected target configuration expression (expected 'os', 'arch', or 'swift')",
+ ())
+ERROR(target_config_expected_one_argument,none,
+ "expected only one argument to target configuration expression",
+ ())
+ERROR(unsupported_target_config_runtime_argument,none,
"unexpected argument for the '_runtime' target configuration, "
"expected '_Native' or '_ObjC'", ())
-ERROR(unsupported_target_config_argument,parsing,none,
- "unexpected target configuration expression argument: expected %0",
+ERROR(unsupported_target_config_argument,none,
+ "unexpected target configuration argument: expected %0",
(StringRef))
-ERROR(unsupported_config_conditional_expression_type,parsing,none,
+ERROR(unexpected_version_comparison_operator,none,
+ "expected '>=' prefix operator on a version requirement",
+ ())
+ERROR(unsupported_config_conditional_expression_type,none,
"unexpected configuration expression type", ())
-ERROR(unsupported_config_integer,parsing,none,
+ERROR(unsupported_config_integer,none,
"'%0' is not a valid configuration option, use '%1'",
(StringRef, StringRef))
-ERROR(compiler_version_component_not_number,parsing,none,
- "compiler version component is not a number", ())
-ERROR(compiler_version_too_many_components,parsing,none,
+ERROR(version_component_not_number,none,
+ "version component contains non-numeric characters", ())
+ERROR(compiler_version_too_many_components,none,
"compiler version must not have more than five components", ())
-WARNING(unused_compiler_version_component,parsing,none,
+WARNING(unused_compiler_version_component,none,
"the second version component is not used for comparison", ())
-ERROR(empty_compiler_version_component,parsing,none,
- "found empty compiler version component", ())
-ERROR(compiler_version_component_out_of_range,parsing,none,
+ERROR(empty_version_component,none,
+ "found empty version component", ())
+ERROR(compiler_version_component_out_of_range,none,
"compiler version component out of range: must be in [0, %0]",
(unsigned))
-ERROR(empty_compiler_version_string,parsing,none,
- "compiler version requirement is empty", ())
-ERROR(cannot_combine_compiler_version,parsing,none,
- "cannot combine _compiler_version with binary operators", ())
-WARNING(unknown_build_config,parsing,none,
+ERROR(empty_version_string,none,
+ "version requirement is empty", ())
+WARNING(unknown_build_config,none,
"unknown %0 for build configuration '%1'",
(StringRef, StringRef))
//------------------------------------------------------------------------------
// Availability query parsing diagnostics
//------------------------------------------------------------------------------
-ERROR(avail_query_not_enabled,parsing,Fatal,
- "experimental availability checking not enabled", ())
-
-ERROR(avail_query_expected_condition,parsing,PointsToFirstBadToken,
+ERROR(avail_query_expected_condition,PointsToFirstBadToken,
"expected availability condition", ())
-ERROR(avail_query_expected_platform_name,parsing,PointsToFirstBadToken,
+ERROR(avail_query_expected_platform_name,PointsToFirstBadToken,
"expected platform name", ())
-ERROR(avail_query_expected_version_number,parsing,PointsToFirstBadToken,
+ERROR(avail_query_expected_version_number,PointsToFirstBadToken,
"expected version number", ())
-ERROR(avail_query_expected_rparen,parsing,PointsToFirstBadToken,
+ERROR(avail_query_expected_rparen,PointsToFirstBadToken,
"expected ')' in availability query", ())
-ERROR(avail_query_unrecognized_platform_name,parsing,
+ERROR(avail_query_unrecognized_platform_name,
PointsToFirstBadToken, "unrecognized platform name %0", (Identifier))
-ERROR(avail_query_disallowed_operator,parsing, PointsToFirstBadToken,
+ERROR(avail_query_disallowed_operator, PointsToFirstBadToken,
"'%0' cannot be used in an availability condition", (StringRef))
-ERROR(avail_query_version_comparison_not_needed,parsing,
+ERROR(avail_query_version_comparison_not_needed,
none,"version comparison not needed", ())
-ERROR(availability_query_wildcard_required, parsing, none,
+ERROR(availability_query_wildcard_required, none,
"must handle potential future platforms with '*'", ())
-ERROR(availability_query_repeated_platform, parsing, none,
+ERROR(availability_query_repeated_platform, none,
"version for '%0' already specified", (StringRef))
#ifndef DIAG_NO_UNDEF
diff --git a/include/swift/AST/DiagnosticsParse.h b/include/swift/AST/DiagnosticsParse.h
index e50840cfb8fd1..8108431f693c9 100644
--- a/include/swift/AST/DiagnosticsParse.h
+++ b/include/swift/AST/DiagnosticsParse.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsParse.h - Diagnostic Definitions --------------*- C++ -*-===//
+//===--- DiagnosticsParse.h - Diagnostic Definitions ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
namespace diag {
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsParse.def"
}
diff --git a/include/swift/AST/DiagnosticsSIL.def b/include/swift/AST/DiagnosticsSIL.def
index a75690c391399..36bd41c2699d6 100644
--- a/include/swift/AST/DiagnosticsSIL.def
+++ b/include/swift/AST/DiagnosticsSIL.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsSILAnalysis.def - Diagnostics Text ------------*- C++ -*-===//
+//===--- DiagnosticsSIL.def - Diagnostics Text ------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -22,230 +22,236 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
// SILGen issues.
-ERROR(bridging_module_missing,sil_gen,none,
+ERROR(bridging_module_missing,none,
"unable to find module '%0' for implicit conversion function '%0.%1'",
(StringRef, StringRef))
-ERROR(bridging_function_missing,sil_gen,none,
+ERROR(bridging_function_missing,none,
"unable to find implicit conversion function '%0.%1'",
(StringRef, StringRef))
-ERROR(bridging_function_overloaded,sil_gen,none,
+ERROR(bridging_function_overloaded,none,
"multiple definitions of implicit conversion function '%0.%1'",
(StringRef, StringRef))
-ERROR(bridging_function_not_function,sil_gen,none,
+ERROR(bridging_function_not_function,none,
"definition of implicit conversion function '%0.%1' is not a function",
(StringRef, StringRef))
-ERROR(bridging_function_not_correct_type,sil_gen,none,
+ERROR(bridging_function_not_correct_type,none,
"definition of implicit conversion function '%0.%1' is not of the correct"
" type",
(StringRef, StringRef))
-ERROR(invalid_sil_builtin,sil_gen,none,
+ERROR(invalid_sil_builtin,none,
"INTERNAL ERROR: invalid use of builtin: %0",
(StringRef))
-ERROR(could_not_find_bridge_type,sil_gen,none,
+ERROR(could_not_find_bridge_type,none,
"could not find Objective-C bridge type for type %0; "
"did you forget to import Foundation?", (Type))
-ERROR(could_not_find_pointer_memory_property,sil_gen,none,
+ERROR(could_not_find_pointer_memory_property,none,
"could not find 'memory' property of pointer type %0", (Type))
-ERROR(writeback_overlap_property,sil_gen,none,
+ERROR(writeback_overlap_property,none,
"inout writeback to computed property %0 occurs in multiple arguments to"
" call, introducing invalid aliasing", (Identifier))
-ERROR(writeback_overlap_subscript,sil_gen,none,
+ERROR(writeback_overlap_subscript,none,
"inout writeback through subscript occurs in multiple arguments to call,"
" introducing invalid aliasing",
())
-NOTE(writebackoverlap_note,sil_gen,none,
+NOTE(writebackoverlap_note,none,
"concurrent writeback occurred here", ())
-ERROR(inout_argument_alias,sil_gen,none,
+ERROR(inout_argument_alias,none,
"inout arguments are not allowed to alias each other", ())
-NOTE(previous_inout_alias,sil_gen,none,
+NOTE(previous_inout_alias,none,
"previous aliasing argument", ())
-ERROR(unsupported_recursive_type,sil_gen,none,
+ERROR(unsupported_recursive_type,none,
"recursive value type %0 is not allowed", (Type))
-ERROR(recursive_enum_not_indirect,sil_gen,none,
+ERROR(recursive_enum_not_indirect,none,
"recursive enum %0 is not marked 'indirect'", (Type))
-ERROR(unsupported_c_function_pointer_conversion,sil_gen,none,
+ERROR(unsupported_c_function_pointer_conversion,none,
"C function pointer signature %0 is not compatible with expected type %1",
(Type, Type))
+ERROR(objc_selector_malformed,none,"the type ObjectiveC.Selector is malformed",
+ ())
+
// Definite initialization diagnostics.
-NOTE(variable_defined_here,sil_analysis,none,
+NOTE(variable_defined_here,none,
"%select{variable|constant}0 defined here", (bool))
-ERROR(variable_used_before_initialized,sil_analysis,none,
+ERROR(variable_used_before_initialized,none,
"%select{variable|constant}1 '%0' used before being initialized",
(StringRef, bool))
-ERROR(variable_inout_before_initialized,sil_analysis,none,
+ERROR(variable_inout_before_initialized,none,
"%select{variable|constant}1 '%0' passed by reference before being"
" initialized", (StringRef, bool))
-ERROR(variable_closure_use_uninit,sil_analysis,none,
+ERROR(variable_closure_use_uninit,none,
"%select{variable|constant}1 '%0' captured by a closure before being"
" initialized", (StringRef, bool))
+ERROR(self_closure_use_uninit,none,
+ "'self' captured by a closure before all members were initialized", ())
+
-ERROR(variable_addrtaken_before_initialized,sil_analysis,none,
+ERROR(variable_addrtaken_before_initialized,none,
"address of %select{variable|constant}1 '%0' taken before it is"
" initialized", (StringRef, bool))
-ERROR(ivar_not_initialized_at_superinit,sil_analysis,none,
+ERROR(ivar_not_initialized_at_superinit,none,
"property '%0' not initialized at super.init call", (StringRef, bool))
-ERROR(ivar_not_initialized_at_implicit_superinit,sil_analysis,none,
+ERROR(ivar_not_initialized_at_implicit_superinit,none,
"property '%0' not initialized at implicitly generated super.init call",
(StringRef, bool))
-ERROR(self_use_before_fully_init,sil_analysis,none,
+ERROR(self_use_before_fully_init,none,
"use of 'self' in %select{method call|property access}1 %0 before "
"%select{all stored properties are initialized|"
"super.init initializes self|"
"self.init initializes self}2", (Identifier, bool, unsigned))
-ERROR(use_of_self_before_fully_init,sil_analysis,none,
+ERROR(use_of_self_before_fully_init,none,
"'self' used before all stored properties are initialized", ())
-ERROR(use_of_self_before_fully_init_protocol,sil_analysis,none,
+ERROR(use_of_self_before_fully_init_protocol,none,
"'self' used before chaining to another self.init requirement", ())
-NOTE(stored_property_not_initialized,sil_analysis,none,
+NOTE(stored_property_not_initialized,none,
"'%0' not initialized", (StringRef))
-ERROR(selfinit_multiple_times,sil_analysis,none,
+ERROR(selfinit_multiple_times,none,
"%select{super|self}0.init called multiple times in initializer",
(unsigned))
-ERROR(superselfinit_not_called_before_return,sil_analysis,none,
+ERROR(superselfinit_not_called_before_return,none,
"%select{super|self}0.init isn't called on all paths before returning "
"from initializer", (unsigned))
-ERROR(self_before_superselfinit,sil_analysis,none,
+ERROR(self_before_superselfinit,none,
"'self' used before %select{super|self}0.init call",
(unsigned))
-ERROR(self_inside_catch_superselfinit,sil_analysis,none,
+ERROR(self_inside_catch_superselfinit,none,
"'self' used inside 'catch' block reachable from "
"%select{super|self}0.init call",
(unsigned))
-ERROR(return_from_init_without_initing_self,sil_analysis,none,
+ERROR(return_from_init_without_initing_self,none,
"return from enum initializer method without storing to 'self'", ())
-ERROR(return_from_protocol_init_without_initing_self,sil_analysis,none,
+ERROR(return_from_protocol_init_without_initing_self,none,
"protocol extension initializer never chained to 'self.init'", ())
-ERROR(return_from_init_without_initing_stored_properties,sil_analysis,none,
+ERROR(return_from_init_without_initing_stored_properties,none,
"return from initializer without initializing all"
" stored properties", ())
-ERROR(variable_function_use_uninit,sil_analysis,none,
+ERROR(variable_function_use_uninit,none,
"%select{variable|constant}1 '%0' used by function definition before"
" being initialized",
(StringRef, bool))
-ERROR(struct_not_fully_initialized,sil_analysis,none,
+ERROR(struct_not_fully_initialized,none,
"struct '%0' must be completely initialized before a member is stored to",
(StringRef, bool))
-ERROR(immutable_property_already_initialized,sil_analysis,none,
+ERROR(immutable_property_already_initialized,none,
"immutable value '%0' may only be initialized once",
(StringRef))
-NOTE(initial_value_provided_in_let_decl,sil_analysis,none,
+NOTE(initial_value_provided_in_let_decl,none,
"initial value already provided in 'let' declaration", ())
-ERROR(mutating_method_called_on_immutable_value,sil_analysis,none,
+ERROR(mutating_method_called_on_immutable_value,none,
"mutating %select{method|property access|subscript|operator}1 %0 may not"
" be used on immutable value '%2'",
(Identifier, unsigned, StringRef))
-ERROR(immutable_value_passed_inout,sil_analysis,none,
+ERROR(immutable_value_passed_inout,none,
"immutable value '%0' may not be passed inout",
(StringRef))
-ERROR(assignment_to_immutable_value,sil_analysis,none,
+ERROR(assignment_to_immutable_value,none,
"immutable value '%0' may not be assigned to",
(StringRef))
// Control flow diagnostics.
-ERROR(missing_return,sil_analysis,none,
+ERROR(missing_return,none,
"missing return in a %select{function|closure}1 expected to return %0",
(Type, unsigned))
-ERROR(return_from_noreturn,sil_analysis,none,
+ERROR(return_from_noreturn,none,
"return from a 'noreturn' function", ())
-ERROR(non_exhaustive_switch,sil_analysis,none,
+ERROR(non_exhaustive_switch,none,
"switch must be exhaustive, consider adding a default clause", ())
-ERROR(guard_body_must_not_fallthrough,sil_analysis,none,
+ERROR(guard_body_must_not_fallthrough,none,
"'guard' body may not fall through, consider using 'return' or 'break'"
" to exit the scope", ())
-WARNING(unreachable_code,sil_analysis,none, "will never be executed", ())
-NOTE(unreachable_code_branch,sil_analysis,none,
+WARNING(unreachable_code,none, "will never be executed", ())
+NOTE(unreachable_code_branch,none,
"condition always evaluates to %select{false|true}0", (bool))
-NOTE(call_to_noreturn_note,sil_analysis,none,
+NOTE(call_to_noreturn_note,none,
"a call to a noreturn function", ())
-WARNING(unreachable_code_after_stmt,sil_analysis,none,
+WARNING(unreachable_code_after_stmt,none,
"code after '%select{return|break|continue|throw}0' will never "
"be executed", (unsigned))
-WARNING(unreachable_case,sil_analysis,none,
+WARNING(unreachable_case,none,
"%select{case|default}0 will never be executed", (bool))
-WARNING(switch_on_a_constant,sil_analysis,none,
+WARNING(switch_on_a_constant,none,
"switch condition evaluates to a constant", ())
-NOTE(unreachable_code_note,sil_analysis,none, "will never be executed", ())
+NOTE(unreachable_code_note,none, "will never be executed", ())
// 'transparent' diagnostics
-ERROR(circular_transparent,sil_analysis,none,
+ERROR(circular_transparent,none,
"inlining 'transparent' functions forms circular loop", ())
-NOTE(note_while_inlining,sil_analysis,none,
+NOTE(note_while_inlining,none,
"while inlining here", ())
// Arithmetic diagnostics.
-ERROR(integer_conversion_overflow,sil_analysis,none,
+ERROR(integer_conversion_overflow,none,
"integer overflows when converted from %0 to %1",
(Type, Type))
-ERROR(integer_conversion_overflow_builtin_types,sil_analysis,none,
+ERROR(integer_conversion_overflow_builtin_types,none,
"integer overflows when converted from %select{unsigned|signed}0 "
"%1 to %select{unsigned|signed}2 %3",
(bool, Type, bool, Type))
-WARNING(integer_conversion_overflow_warn,sil_analysis,none,
+WARNING(integer_conversion_overflow_warn,none,
"integer overflows when converted from %0 to %1",
(Type, Type))
-ERROR(integer_conversion_sign_error,sil_analysis,none,
+ERROR(integer_conversion_sign_error,none,
"negative integer cannot be converted to unsigned type %0",
(Type))
-ERROR(negative_integer_literal_overflow_unsigned,sil_analysis,none,
+ERROR(negative_integer_literal_overflow_unsigned,none,
"negative integer '%1' overflows when stored into unsigned type %0",
(Type, StringRef))
-ERROR(integer_literal_overflow,sil_analysis,none,
+ERROR(integer_literal_overflow,none,
"integer literal '%1' overflows when stored into %0",
(Type, StringRef))
-ERROR(integer_literal_overflow_builtin_types,sil_analysis,none,
+ERROR(integer_literal_overflow_builtin_types,none,
"integer literal '%2' overflows when stored into "
"%select{unsigned|signed}0 %1", (bool, Type, StringRef))
-WARNING(integer_literal_overflow_warn,sil_analysis,none,
+WARNING(integer_literal_overflow_warn,none,
"integer literal overflows when stored into %0",
(Type))
-ERROR(arithmetic_operation_overflow,sil_analysis,none,
+ERROR(arithmetic_operation_overflow,none,
"arithmetic operation '%0 %1 %2' (on type %3) results in an overflow",
(StringRef, StringRef, StringRef, Type))
-ERROR(arithmetic_operation_overflow_generic_type,sil_analysis,none,
+ERROR(arithmetic_operation_overflow_generic_type,none,
"arithmetic operation '%0 %1 %2' (on %select{unsigned|signed}3 "
"%4-bit integer type) results in an overflow",
(StringRef, StringRef, StringRef, bool, unsigned))
-ERROR(division_overflow,sil_analysis,none,
+ERROR(division_overflow,none,
"division '%0 %1 %2' results in an overflow",
(StringRef, StringRef, StringRef))
-ERROR(division_by_zero,sil_analysis,none, "division by zero", ())
-ERROR(wrong_non_negative_assumption,sil_analysis,none,
+ERROR(division_by_zero,none, "division by zero", ())
+ERROR(wrong_non_negative_assumption,none,
"assumed non-negative value '%0' is negative", (StringRef))
-ERROR(shifting_all_significant_bits,sil_analysis,none,
+ERROR(shifting_all_significant_bits,none,
"shift amount is greater than or equal to type size in bits", ())
// FIXME: We won't need this as it will be replaced with user-generated strings.
// staticReport diagnostics.
-ERROR(static_report_error, sil_analysis, none,
+ERROR(static_report_error, none,
"static report error", ())
diff --git a/include/swift/AST/DiagnosticsSIL.h b/include/swift/AST/DiagnosticsSIL.h
index 7c9e24d2c11a7..bc9b47164baea 100644
--- a/include/swift/AST/DiagnosticsSIL.h
+++ b/include/swift/AST/DiagnosticsSIL.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsSIL.h - Diagnostic Definitions ----------------*- C++ -*-===//
+//===--- DiagnosticsSIL.h - Diagnostic Definitions --------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
namespace diag {
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsSIL.def"
}
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index ba12db1bc9f72..2977008b5a04a 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -1,8 +1,8 @@
-//===- DiagnosticsSema.def - Diagnostics Text -------------------*- C++ -*-===//
+//===--- DiagnosticsSema.def - Diagnostics Text -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,888 +23,970 @@
#endif
#ifndef ERROR
-# define ERROR(ID,Category,Options,Text,Signature) \
- DIAG(ERROR,ID,Category,Options,Text,Signature)
+# define ERROR(ID,Options,Text,Signature) \
+ DIAG(ERROR,ID,Options,Text,Signature)
#endif
#ifndef WARNING
-# define WARNING(ID,Category,Options,Text,Signature) \
- DIAG(WARNING,ID,Category,Options,Text,Signature)
+# define WARNING(ID,Options,Text,Signature) \
+ DIAG(WARNING,ID,Options,Text,Signature)
#endif
#ifndef NOTE
-# define NOTE(ID,Category,Options,Text,Signature) \
- DIAG(NOTE,ID,Category,Options,Text,Signature)
+# define NOTE(ID,Options,Text,Signature) \
+ DIAG(NOTE,ID,Options,Text,Signature)
#endif
-NOTE(type_declared_here,sema,none,
+NOTE(type_declared_here,none,
"type declared here", ())
-NOTE(decl_declared_here,sema,none,
- "%0 declared here", (Identifier))
-NOTE(extended_type_declared_here,sema,none,
+NOTE(decl_declared_here,none,
+ "%0 declared here", (DeclName))
+NOTE(extended_type_declared_here,none,
"extended type declared here", ())
-NOTE(while_converting_default_tuple_value,sema,none,
+NOTE(while_converting_default_tuple_value,none,
"while converting default tuple value to element type %0", (Type))
-NOTE(while_converting_subscript_index,sema,none,
+NOTE(while_converting_subscript_index,none,
"while converting subscript index to expected type %0", (Type))
//------------------------------------------------------------------------------
// Constraint solver diagnostics
//------------------------------------------------------------------------------
-ERROR(ambiguous_member_overload_set,sema,none,
- "ambiguous reference to member '%0'", (StringRef))
+ERROR(ambiguous_member_overload_set,none,
+ "ambiguous reference to member %0", (DeclName))
-ERROR(ambiguous_subscript,sema,none,
+ERROR(ambiguous_subscript,none,
"ambiguous subscript with base type %0 and index type %1",
(Type, Type))
-ERROR(type_not_subscriptable,sema,none,
+ERROR(type_not_subscriptable,none,
"type %0 has no subscript members",
(Type))
-ERROR(could_not_find_tuple_member,sema,none,
+ERROR(could_not_find_tuple_member,none,
"value of tuple type %0 has no member %1", (Type, DeclName))
-ERROR(could_not_find_value_member,sema,none,
+ERROR(could_not_find_value_member,none,
"value of type %0 has no member %1", (Type, DeclName))
-ERROR(could_not_find_type_member,sema,none,
+ERROR(could_not_find_type_member,none,
"type %0 has no member %1", (Type, DeclName))
-ERROR(expected_argument_in_contextual_member,sema,none,
- "contextual member %0 expects argument of type %1", (Identifier, Type))
-ERROR(unexpected_argument_in_contextual_member,sema,none,
- "contextual member %0 has no associated value", (Identifier))
+NOTE(did_you_mean_raw_type,none,
+ "did you mean to specify a raw type on the enum declaration?", ())
+
+ERROR(expected_argument_in_contextual_member,none,
+ "contextual member %0 expects argument of type %1", (DeclName, Type))
+
+ERROR(expected_result_in_contextual_member,none,
+ "member %0 in %2 produces result of type %1, but context expects %2",
+ (DeclName, Type, Type))
-ERROR(could_not_use_value_member,sema,none,
+ERROR(unexpected_argument_in_contextual_member,none,
+ "contextual member %0 has no associated value", (DeclName))
+
+ERROR(could_not_use_value_member,none,
"member %1 cannot be used on value of type %0", (Type, DeclName))
-ERROR(could_not_use_type_member,sema,none,
+ERROR(could_not_use_type_member,none,
"member %1 cannot be used on type %0", (Type, DeclName))
-ERROR(could_not_use_type_member_on_instance,sema,none,
+ERROR(could_not_use_type_member_on_instance,none,
"static member %1 cannot be used on instance of type %0",
(Type, DeclName))
-ERROR(could_not_use_instance_member_on_type,sema,none,
+ERROR(could_not_use_instance_member_on_type,none,
"instance member %1 cannot be used on type %0",
(Type, DeclName))
-ERROR(could_not_use_member_on_existential,sema,none,
+ERROR(could_not_use_member_on_existential,none,
"member %1 cannot be used on value of protocol type %0; use a generic"
" constraint instead",
(Type, DeclName))
+ERROR(candidate_inaccessible,none,
+ "%0 is inaccessible due to '%select{private|internal|PUBLIC}1' "
+ "protection level", (DeclName, Accessibility))
+
+ERROR(init_candidate_inaccessible,none,
+ "%0 initializer is inaccessible due to '%select{private|internal|PUBLIC}1' "
+ "protection level", (Type, Accessibility))
+
-ERROR(cannot_pass_rvalue_mutating_subelement,sema_tcs,none,
+ERROR(cannot_pass_rvalue_mutating_subelement,none,
"cannot use mutating member on immutable value: %0",
(StringRef))
-ERROR(cannot_pass_rvalue_mutating,sema_tcs,none,
+ERROR(cannot_pass_rvalue_mutating,none,
"cannot use mutating member on immutable value of type %0",
(Type))
-ERROR(cannot_pass_rvalue_mutating_getter_subelement,sema_tcs,none,
+ERROR(cannot_pass_rvalue_mutating_getter_subelement,none,
"cannot use mutating getter on immutable value: %0",
(StringRef))
-ERROR(cannot_pass_rvalue_mutating_getter,sema_tcs,none,
+ERROR(cannot_pass_rvalue_mutating_getter,none,
"cannot use mutating getter on immutable value of type %0",
(Type))
-ERROR(expression_too_complex,sema,none,
+ERROR(expression_too_complex,none,
"expression was too complex to be solved in reasonable time; "
"consider breaking up the expression into distinct sub-expressions", ())
-ERROR(comparison_with_nil_illegal,sema,none,
+ERROR(comparison_with_nil_illegal,none,
"value of type %0 can never be nil, comparison isn't allowed",
(Type))
-ERROR(cannot_match_expr_pattern_with_value,sema,none,
+ERROR(cannot_match_expr_pattern_with_value,none,
"expression pattern of type %0 cannot match values of type %1",
(Type, Type))
-ERROR(cannot_apply_binop_to_args,sema,none,
+ERROR(cannot_apply_binop_to_args,none,
"binary operator '%0' cannot be applied to operands of type "
"%1 and %2",
(StringRef, Type, Type))
-ERROR(cannot_apply_binop_to_same_args,sema,none,
+ERROR(cannot_apply_binop_to_same_args,none,
"binary operator '%0' cannot be applied to two %1 operands",
(StringRef, Type))
-ERROR(cannot_apply_unop_to_arg,sema,none,
+ERROR(cannot_apply_unop_to_arg,none,
"unary operator '%0' cannot be applied to an operand of type %1",
(StringRef, Type))
-ERROR(cannot_apply_lvalue_unop_to_subelement,sema_tcs,none,
+ERROR(cannot_apply_lvalue_unop_to_subelement,none,
"cannot pass immutable value to mutating operator: %0",
(StringRef))
-ERROR(cannot_apply_lvalue_unop_to_rvalue,sema,none,
+ERROR(cannot_apply_lvalue_unop_to_rvalue,none,
"cannot pass immutable value of type %0 to mutating operator",
(Type))
-ERROR(cannot_apply_lvalue_binop_to_subelement,sema_tcs,none,
+ERROR(cannot_apply_lvalue_binop_to_subelement,none,
"left side of mutating operator isn't mutable: %0", (StringRef))
-ERROR(cannot_apply_lvalue_binop_to_rvalue,sema,none,
+ERROR(cannot_apply_lvalue_binop_to_rvalue,none,
"left side of mutating operator has immutable type %0", (Type))
-ERROR(cannot_subscript_with_index,sema,none,
+ERROR(cannot_subscript_with_index,none,
"cannot subscript a value of type %0 with an index of type %1",
(Type, Type))
-ERROR(cannot_subscript_base,sema,none,
+ERROR(cannot_subscript_base,none,
"cannot subscript a value of type %0",
(Type))
-ERROR(cannot_pass_rvalue_inout_subelement,sema_tcs,none,
+ERROR(cannot_pass_rvalue_inout_subelement,none,
"cannot pass immutable value as inout argument: %0",
(StringRef))
-ERROR(cannot_pass_rvalue_inout,sema_tcs,none,
+ERROR(cannot_pass_rvalue_inout,none,
"cannot pass immutable value of type %0 as inout argument",
(Type))
-ERROR(cannot_assign_to_literal,sema,none,
+ERROR(cannot_assign_to_literal,none,
"cannot assign to a literal value", ())
-ERROR(cannot_call_with_no_params,sema,none,
+ERROR(cannot_call_with_no_params,none,
"cannot invoke %select{|initializer for type }1'%0' with no arguments",
(StringRef, bool))
-ERROR(cannot_call_with_params, sema, none,
+ERROR(cannot_call_with_params, none,
"cannot invoke %select{|initializer for type }2'%0' with an argument list"
" of type '%1'", (StringRef, StringRef, bool))
-ERROR(expected_do_in_statement,sema,none,
+ERROR(expected_do_in_statement,none,
"expected 'do' keyword to designate a block of statements", ())
-ERROR(cannot_call_non_function_value,sema,none,
+ERROR(cannot_call_non_function_value,none,
"cannot call value of non-function type %0", (Type))
-ERROR(wrong_argument_labels_overload,sema,none,
+ERROR(wrong_argument_labels_overload,none,
"argument labels '%0' do not match any available overloads", (StringRef))
-ERROR(no_candidates_match_result_type,sema,none,
+ERROR(no_candidates_match_result_type,none,
"no '%0' candidates produce the expected contextual result type %1",
(StringRef, Type))
-ERROR(candidates_no_match_result_type,sema,none,
+ERROR(candidates_no_match_result_type,none,
"'%0' produces %1, not the expected contextual result type %2",
(StringRef, Type, Type))
-ERROR(invalid_callee_result_type,sema,none,
+ERROR(invalid_callee_result_type,none,
"cannot convert call result type %0 to expected type %1",
(Type, Type))
-ERROR(cannot_invoke_closure,sema,none,
+ERROR(cannot_invoke_closure,none,
"cannot invoke closure expression with an argument list of type '%0'",
(StringRef))
-ERROR(cannot_invoke_closure_type,sema,none,
+ERROR(cannot_invoke_closure_type,none,
"cannot invoke closure of type %0 with an argument list of type '%1'",
(Type, StringRef))
-ERROR(cannot_infer_closure_type,sema,none,
+ERROR(cannot_infer_closure_type,none,
"unable to infer closure type in the current context", ())
-ERROR(cannot_infer_closure_result_type,sema,none,
+ERROR(cannot_infer_closure_result_type,none,
"unable to infer closure return type in current context", ())
-ERROR(incorrect_explicit_closure_result,sema,none,
+ERROR(incorrect_explicit_closure_result,none,
"declared closure result %0 is incompatible with contextual type %1",
(Type, Type))
-ERROR(cannot_call_function_value,sema,none,
+ERROR(cannot_call_function_value,none,
"cannot invoke value of function type with argument list '%0'",
(StringRef))
-ERROR(cannot_call_value_of_function_type,sema,none,
+ERROR(cannot_call_value_of_function_type,none,
"cannot invoke value of type %0 with argument list '%1'",
(Type, StringRef))
-NOTE(suggest_expected_match,sema,none,
+NOTE(suggest_expected_match,none,
"%select{expected an argument list|produces result}0 of type '%1'",
(bool, StringRef))
-NOTE(suggest_partial_overloads,sema,none,
+NOTE(suggest_partial_overloads,none,
"overloads for '%1' exist with these %select{"
"partially matching parameter lists|result types}0: %2",
(bool, StringRef, StringRef))
-ERROR(cannot_convert_initializer_value,sema,none,
+ERROR(cannot_convert_initializer_value,none,
"cannot convert value of type %0 to specified type %1", (Type,Type))
-ERROR(cannot_convert_initializer_value_protocol,sema,none,
+ERROR(cannot_convert_initializer_value_protocol,none,
"value of type %0 does not conform to specified type %1", (Type,Type))
-ERROR(cannot_convert_initializer_value_nil,sema_tcd,none,
+ERROR(cannot_convert_initializer_value_nil,none,
"nil cannot initialize specified type %0", (Type))
-ERROR(cannot_convert_to_return_type,sema,none,
+ERROR(cannot_convert_to_return_type,none,
"cannot convert return expression of type %0 to return type %1",
(Type,Type))
-ERROR(cannot_convert_to_return_type_protocol,sema,none,
+ERROR(cannot_convert_to_return_type_protocol,none,
"return expression of type %0 does not conform to %1", (Type,Type))
-ERROR(cannot_convert_to_return_type_nil,sema,none,
+ERROR(cannot_convert_to_return_type_nil,none,
"nil is incompatible with return type %0", (Type))
-ERROR(cannot_convert_thrown_type,sema,none,
+ERROR(cannot_convert_thrown_type,none,
"thrown expression type %0 does not conform to 'ErrorType'", (Type))
-ERROR(cannot_throw_nil,sema,none,
+ERROR(cannot_throw_nil,none,
"cannot infer concrete ErrorType for thrown 'nil' value", ())
-ERROR(cannot_convert_raw_initializer_value,sema,none,
+ERROR(cannot_convert_raw_initializer_value,none,
"cannot convert value of type %0 to raw type %1", (Type,Type))
-ERROR(cannot_convert_raw_initializer_value_nil,sema,none,
- "cannot convert nil to raw type %1", (Type))
+ERROR(cannot_convert_raw_initializer_value_nil,none,
+ "cannot convert nil to raw type %0", (Type))
-ERROR(cannot_convert_default_arg_value,sema,none,
+ERROR(cannot_convert_default_arg_value,none,
"default argument value of type %0 cannot be converted to type %1",
(Type,Type))
-ERROR(cannot_convert_default_arg_value_protocol,sema,none,
+ERROR(cannot_convert_default_arg_value_protocol,none,
"default argument value of type %0 does not conform to %1", (Type,Type))
-ERROR(cannot_convert_default_arg_value_nil,sema,none,
+ERROR(cannot_convert_default_arg_value_nil,none,
"nil default argument value of cannot be converted to type %0", (Type))
-ERROR(cannot_convert_argument_value,sema,none,
+ERROR(cannot_convert_argument_value,none,
"cannot convert value of type %0 to expected argument type %1",
(Type,Type))
-ERROR(cannot_convert_argument_value_protocol,sema_tcd,none,
+ERROR(cannot_convert_argument_value_protocol,none,
"argument type %0 does not conform to expected type %1", (Type, Type))
-ERROR(cannot_convert_argument_value_nil,sema,none,
+ERROR(cannot_convert_argument_value_nil,none,
"nil is not compatible with expected argument type %0", (Type))
-ERROR(cannot_convert_closure_result,sema,none,
+ERROR(cannot_convert_closure_result,none,
"cannot convert value of type %0 to closure result type %1",
(Type,Type))
-ERROR(cannot_convert_closure_result_protocol,sema_tcd,none,
+ERROR(cannot_convert_closure_result_protocol,none,
"result value of type %0 does not conform to closure result type %1",
(Type, Type))
-ERROR(cannot_convert_closure_result_nil,sema,none,
+ERROR(cannot_convert_closure_result_nil,none,
"nil is not compatible with closure result type %0", (Type))
// Array Element
-ERROR(cannot_convert_array_element,sema,none,
+ERROR(cannot_convert_array_element,none,
"cannot convert value of type %0 to expected element type %1",
(Type,Type))
-ERROR(cannot_convert_array_element_protocol,sema_tcd,none,
+ERROR(cannot_convert_array_element_protocol,none,
"value of type %0 does not conform to expected element type %1",
(Type, Type))
-ERROR(cannot_convert_array_element_nil,sema,none,
+ERROR(cannot_convert_array_element_nil,none,
"nil is not compatible with expected element type %0", (Type))
// Dictionary Key
-ERROR(cannot_convert_dict_key,sema,none,
+ERROR(cannot_convert_dict_key,none,
"cannot convert value of type %0 to expected dictionary key type %1",
(Type,Type))
-ERROR(cannot_convert_dict_key_protocol,sema_tcd,none,
+ERROR(cannot_convert_dict_key_protocol,none,
"value of type %0 does not conform to expected dictionary key type %1",
(Type, Type))
-ERROR(cannot_convert_dict_key_nil,sema,none,
+ERROR(cannot_convert_dict_key_nil,none,
"nil is not compatible with expected dictionary key type %0", (Type))
// Dictionary Value
-ERROR(cannot_convert_dict_value,sema,none,
+ERROR(cannot_convert_dict_value,none,
"cannot convert value of type %0 to expected dictionary value type %1",
(Type,Type))
-ERROR(cannot_convert_dict_value_protocol,sema_tcd,none,
+ERROR(cannot_convert_dict_value_protocol,none,
"value of type %0 does not conform to expected dictionary value type %1",
(Type, Type))
-ERROR(cannot_convert_dict_value_nil,sema,none,
+ERROR(cannot_convert_dict_value_nil,none,
"nil is not compatible with expected dictionary value type %0", (Type))
// Coerce Expr
-ERROR(cannot_convert_coerce,sema,none,
+ERROR(cannot_convert_coerce,none,
"cannot convert value of type %0 to type %1 in coercion",
(Type,Type))
-ERROR(cannot_convert_coerce_protocol,sema_tcd,none,
+ERROR(cannot_convert_coerce_protocol,none,
"value of type %0 does not conform to %1 in coercion",
(Type, Type))
-ERROR(cannot_convert_coerce_nil,sema,none,
+ERROR(cannot_convert_coerce_nil,none,
"nil is not compatible with type %0 in coercion", (Type))
// Assign Expr
-ERROR(cannot_convert_assign,sema,none,
+ERROR(cannot_convert_assign,none,
"cannot assign value of type %0 to type %1",
(Type,Type))
-ERROR(cannot_convert_assign_protocol,sema_tcd,none,
+ERROR(cannot_convert_assign_protocol,none,
"value of type %0 does not conform to %1 in assignment",
(Type, Type))
-ERROR(cannot_convert_assign_nil,sema,none,
+ERROR(cannot_convert_assign_nil,none,
"nil cannot be assigned to type %0", (Type))
-ERROR(throws_functiontype_mismatch,sema_tcc,none,
+ERROR(throws_functiontype_mismatch,none,
"invalid conversion from throwing function of type %0 to "
"non-throwing function type %1", (Type, Type))
-ERROR(noescape_functiontype_mismatch,sema_tcc,none,
+ERROR(noescape_functiontype_mismatch,none,
"invalid conversion from non-escaping function of type %0 to "
"potentially escaping function type %1", (Type, Type))
+// Selector expressions.
+ERROR(expr_selector_no_objc_runtime,none,
+ "'#selector' can only be used with the Objective-C runtime", ())
+ERROR(expr_selector_module_missing,none,
+ "import the 'ObjectiveC' module to use '#selector'", ())
+ERROR(expr_selector_no_declaration,none,
+ "argument of '#selector' does not refer to an initializer or method", ())
+ERROR(expr_selector_property,none,
+ "argument of '#selector' cannot refer to a property", ())
+ERROR(expr_selector_not_method_or_init,none,
+ "argument of '#selector' does not refer to a method or initializer", ())
+ERROR(expr_selector_not_objc,none,
+ "argument of '#selector' refers to %select{a method|an initializer}0 "
+ "that is not exposed to Objective-C",
+ (bool))
+NOTE(expr_selector_make_objc,none,
+ "add '@objc' to expose this %select{method|initializer}0 to Objective-C",
+ (bool))
-
-
-ERROR(cannot_return_value_from_void_func,sema,none,
+// Selectors-as-string-literals.
+WARNING(selector_literal_invalid,none,
+ "string literal is not a valid Objective-C selector", ())
+WARNING(selector_literal_undeclared,none,
+ "no method declared with Objective-C selector %0", (ObjCSelector))
+WARNING(selector_literal_deprecated,none,
+ "use of string literal for Objective-C selectors is deprecated; "
+ "use '#selector' or explicitly construct a 'Selector'", ())
+WARNING(selector_literal_deprecated_suggest,none,
+ "use of string literal for Objective-C selectors is deprecated; "
+ "use '#selector' instead", ())
+WARNING(selector_construction_suggest,none,
+ "use '#selector' instead of explicitly constructing a 'Selector'", ())
+
+ERROR(cannot_return_value_from_void_func,none,
"unexpected non-void return value in void function", ())
//------------------------------------------------------------------------------
// Name Binding
//------------------------------------------------------------------------------
-ERROR(sema_no_import,sema_nb,Fatal,
+ERROR(sema_no_import,Fatal,
"no such module '%0'", (StringRef))
-ERROR(sema_no_import_repl,sema_nb,none,
+ERROR(sema_no_import_repl,none,
"no such module '%0'", (StringRef))
-NOTE(sema_no_import_no_sdk,sema_nb,none,
+NOTE(sema_no_import_no_sdk,none,
"did you forget to set an SDK using -sdk or SDKROOT?", ())
-NOTE(sema_no_import_no_sdk_xcrun,sema_nb,none,
+NOTE(sema_no_import_no_sdk_xcrun,none,
"use \"xcrun -sdk macosx swiftc\" to select the default OS X SDK "
"installed with Xcode", ())
-WARNING(sema_import_current_module,sema_nb,none,
+WARNING(sema_import_current_module,none,
"this file is part of module %0; ignoring import", (Identifier))
-WARNING(sema_import_current_module_with_file,sema_nb,none,
+WARNING(sema_import_current_module_with_file,none,
"file '%0' is part of module %1; ignoring import",
(StringRef, Identifier))
-ERROR(sema_opening_import,sema_nb,Fatal,
+ERROR(sema_opening_import,Fatal,
"opening import file for module %0: %1", (Identifier, StringRef))
-ERROR(serialization_load_failed,sema,Fatal,
+ERROR(serialization_load_failed,Fatal,
"failed to load module %0", (Identifier))
-ERROR(serialization_malformed_module,sema,Fatal,
+ERROR(serialization_malformed_module,Fatal,
"malformed module file: %0", (StringRef))
-ERROR(serialization_module_too_new,sema,Fatal,
+ERROR(serialization_module_too_new,Fatal,
"module file was created by a newer version of the compiler: %0",
(StringRef))
-ERROR(serialization_module_too_old,sema,Fatal,
+ERROR(serialization_module_too_old,Fatal,
"module file was created by an older version of the compiler; "
"rebuild %0 and try again: %1",
(Identifier, StringRef))
-ERROR(serialization_missing_single_dependency,sema,Fatal,
+ERROR(serialization_missing_single_dependency,Fatal,
"missing required module '%0'", (StringRef))
-ERROR(serialization_missing_dependencies,sema,Fatal,
+ERROR(serialization_missing_dependencies,Fatal,
"missing required modules: %0", (StringRef))
-ERROR(serialization_missing_shadowed_module,sema,Fatal,
+ERROR(serialization_missing_shadowed_module,Fatal,
"cannot load underlying module for %0", (Identifier))
-ERROR(serialization_name_mismatch,sema,Fatal,
+ERROR(serialization_name_mismatch,Fatal,
"cannot load module '%0' as %1", (StringRef, Identifier))
-ERROR(serialization_name_mismatch_repl,sema,none,
+ERROR(serialization_name_mismatch_repl,none,
"cannot load module '%0' as %1", (StringRef, Identifier))
-ERROR(serialization_target_incompatible,sema,Fatal,
+ERROR(serialization_target_incompatible,Fatal,
"module file was created for incompatible target %0: %1",
(StringRef, StringRef))
-ERROR(serialization_target_incompatible_repl,sema,none,
+ERROR(serialization_target_incompatible_repl,none,
"module file was created for incompatible target %0: %1",
(StringRef, StringRef))
-ERROR(serialization_target_too_new,sema,Fatal,
+ERROR(serialization_target_too_new,Fatal,
"module file's minimum deployment target is %0 v%1.%2%select{|.%3}3: %4",
(StringRef, unsigned, unsigned, unsigned, StringRef))
-ERROR(serialization_target_too_new_repl,sema,none,
+ERROR(serialization_target_too_new_repl,none,
"module file's minimum deployment target is %0 v%1.%2%select{|.%3}3: %4",
(StringRef, unsigned, unsigned, unsigned, StringRef))
-ERROR(unknown_name_in_type,sema_nb,none,
- "use of unknown scope %0 in type reference", (Identifier))
+ERROR(reserved_member_name,none,
+ "type member may not be named %0, since it would conflict with the"
+ " 'foo.%1' expression", (DeclName, StringRef))
+NOTE(backticks_to_escape,none,
+ "backticks can escape this name if it is important to use", ())
-ERROR(invalid_redecl,sema_nb,none,"invalid redeclaration of %0", (DeclName))
-NOTE(invalid_redecl_prev,sema_nb,none,
+ERROR(invalid_redecl,none,"invalid redeclaration of %0", (DeclName))
+NOTE(invalid_redecl_prev,none,
"%0 previously declared here", (DeclName))
-ERROR(ambiguous_type_base,sema_nb,none,
+ERROR(ambiguous_type_base,none,
"%0 is ambiguous for type lookup in this context", (Identifier))
-ERROR(invalid_member_type,sema_nb,none,
+ERROR(invalid_member_type,none,
"%0 is not a member type of %1", (Identifier, Type))
-ERROR(invalid_member_type_suggest,sema_nb,none,
+ERROR(invalid_member_type_suggest,none,
"%0 does not have a member type named %1; did you mean %2?",
(Type, Identifier, Identifier))
-ERROR(ambiguous_member_type,sema_nb,none,
+ERROR(ambiguous_member_type,none,
"ambiguous type name %0 in %1", (Identifier, Type))
-ERROR(no_module_type,sema_nb,none,
+ERROR(no_module_type,none,
"no type named %0 in module %1", (Identifier, Identifier))
-ERROR(ambiguous_module_type,sema_nb,none,
+ERROR(ambiguous_module_type,none,
"ambiguous type name %0 in module %1", (Identifier, Identifier))
-ERROR(use_nonmatching_operator,sema_nb,none,
+ERROR(use_nonmatching_operator,none,
"%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
(Identifier, unsigned))
-ERROR(use_unresolved_identifier,sema_nb,none,
- "use of unresolved identifier %0", (Identifier))
-ERROR(use_undeclared_type,sema_nb,none,
+
+ERROR(unspaced_binary_operator_fixit,none,
+ "missing whitespace between %0 and %1 operators",
+ (Identifier, Identifier, bool))
+ERROR(unspaced_binary_operator,none,
+ "ambiguous missing whitespace between unary and binary operators", ())
+NOTE(unspaced_binary_operators_candidate,none,
+ "could be %select{binary|postfix}2 %0 and %select{prefix|binary}2 %1",
+ (Identifier, Identifier, bool))
+ERROR(unspaced_unary_operator,none,
+ "unary operators may not be juxtaposed; parenthesize inner expression",
+ ())
+
+
+ERROR(use_unresolved_identifier,none,
+ "use of unresolved %select{identifier|operator}1 %0", (DeclName, bool))
+ERROR(use_undeclared_type,none,
"use of undeclared type %0", (Identifier))
-ERROR(use_undeclared_type_did_you_mean,sema_nb,none,
-"use of undeclared type %0; did you mean to use '%1'?", (Identifier, StringRef))
-NOTE(note_remapped_type,sema_nb,none,
- "did you mean to use '%0'?", (StringRef))
-ERROR(identifier_init_failure,sema_nb,none,
- "could not infer type for %0", (Identifier))
-ERROR(pattern_used_in_type,sema_nb,none,
+ERROR(use_undeclared_type_did_you_mean,none,
+ "use of undeclared type %0; did you mean to use '%1'?", (Identifier, StringRef))
+NOTE(note_remapped_type,none,
+ "did you mean to use '%0'?", (StringRef))
+ERROR(identifier_init_failure,none,
+ "could not infer type for %0", (Identifier))
+ERROR(pattern_used_in_type,none,
"%0 used within its own type", (Identifier))
-NOTE(note_module_as_type,sema_nb,none,
+NOTE(note_module_as_type,none,
"cannot use module %0 as a type", (Identifier))
-ERROR(use_unknown_object_literal,sema_nb,none,
+ERROR(use_unknown_object_literal,none,
"use of unknown object literal name %0", (Identifier))
+ERROR(object_literal_default_type_missing,none,
+ "could not infer type of %0 literal", (StringRef))
+NOTE(object_literal_resolve_import,none,
+ "import %0 to use '%1' as the default %2 literal type",
+ (StringRef, StringRef, StringRef))
-ERROR(use_non_type_value,sema_nb,none,
+ERROR(use_non_type_value,none,
"%0 is not a type", (Identifier))
-NOTE(use_non_type_value_prev,sema_nb,none,
+NOTE(use_non_type_value_prev,none,
"%0 declared here", (Identifier))
-ERROR(use_local_before_declaration,sema_nb,none,
- "use of local variable %0 before its declaration", (Identifier))
-ERROR(unsupported_existential_type,sema_nb,none,
+ERROR(use_local_before_declaration,none,
+ "use of local variable %0 before its declaration", (DeclName))
+ERROR(unsupported_existential_type,none,
"protocol %0 can only be used as a generic constraint because it has "
"Self or associated type requirements", (Identifier))
-ERROR(no_decl_in_module,sema_nb,none,
+ERROR(no_decl_in_module,none,
"no such decl in module", ())
-ERROR(imported_decl_is_wrong_kind,sema_nb,none,
+ERROR(imported_decl_is_wrong_kind,none,
"%0 was imported as '%1', but is a "
"%select{**MODULE**|type|struct|class|enum|protocol|variable|function}2",
(Identifier, StringRef, /*ImportKind*/ unsigned))
-ERROR(ambiguous_decl_in_module,sema_nb,none,
+ERROR(ambiguous_decl_in_module,none,
"ambiguous name %0 in module %1", (Identifier, Identifier))
-ERROR(module_not_testable,sema_nb,none,
+ERROR(module_not_testable,none,
"module %0 was not compiled for testing", (Identifier))
// Operator decls
-ERROR(ambiguous_operator_decls,sema_nb,none,
+ERROR(ambiguous_operator_decls,none,
"ambiguous operator declarations found for operator", ())
-NOTE(found_this_operator_decl,sema_nb,none,
+NOTE(found_this_operator_decl,none,
"found this matching operator declaration", ())
-ERROR(operator_redeclared,sema_nb,none,
+ERROR(operator_redeclared,none,
"operator redeclared", ())
-NOTE(previous_operator_decl,sema_nb,none,
+NOTE(previous_operator_decl,none,
"previous operator declaration here", ())
-ERROR(declared_operator_without_operator_decl,sema_nb,none,
+ERROR(declared_operator_without_operator_decl,none,
"operator implementation without matching operator declaration", ())
-ERROR(declared_unary_op_without_attribute,sema_nb,none,
+ERROR(declared_unary_op_without_attribute,none,
"unary operator implementation must have a 'prefix' or 'postfix' modifier", ())
-ERROR(unary_op_missing_prepos_attribute,sema_nb,none,
+ERROR(unary_op_missing_prepos_attribute,none,
"%select{prefix|postfix}0 unary operator missing "
"'%select{prefix|postfix}0' modifier", (bool))
-NOTE(unary_operator_declaration_here,sema_nb,none,
+NOTE(unary_operator_declaration_here,none,
"%select{prefix|postfix}0 operator found here", (bool))
-ERROR(invalid_arg_count_for_operator,sema_nb,none,
+ERROR(invalid_arg_count_for_operator,none,
"operators must have one or two arguments", ())
//------------------------------------------------------------------------------
// Type Check Coercions
//------------------------------------------------------------------------------
-ERROR(tuple_conversion_not_expressible,sema_tcc,none,
+ERROR(tuple_conversion_not_expressible,none,
"cannot express tuple conversion %0 to %1", (Type, Type))
-ERROR(load_of_explicit_lvalue,sema_tcc,none,
+ERROR(load_of_explicit_lvalue,none,
"%0 variable is not being passed by reference", (Type))
//------------------------------------------------------------------------------
// Expression Type Checking Errors
//------------------------------------------------------------------------------
-ERROR(types_not_convertible,sema_tcc,none,
+ERROR(types_not_convertible,none,
"%1 is not %select{convertible to|a subtype of}0 %2",
(bool, Type, Type))
-NOTE(in_cast_expr_types,sema_tcc,none,
+NOTE(in_cast_expr_types,none,
"in cast from type %0 to %1",
(Type, Type))
-ERROR(tuple_types_not_convertible,sema_tcc,none,
+ERROR(tuple_types_not_convertible_nelts,none,
"%0 is not convertible to %1, "
"tuples have a different number of elements", (Type, Type))
-ERROR(invalid_force_unwrap,sema_tcc,none,
+ERROR(tuple_types_not_convertible,none,
+ "tuple type %0 is not convertible to tuple %1", (Type, Type))
+
+ERROR(invalid_force_unwrap,none,
"cannot force unwrap value of non-optional type %0", (Type))
-ERROR(invalid_optional_chain,sema_tcc,none,
+ERROR(invalid_optional_chain,none,
"cannot use optional chaining on non-optional value of type %0",
(Type))
-ERROR(if_expr_cases_mismatch,sema_tcc,none,
+ERROR(if_expr_cases_mismatch,none,
"result values in '? :' expression have mismatching types %0 and %1",
(Type, Type))
-ERROR(did_not_call_function_value,sema_tcc,none,
+ERROR(did_not_call_function_value,none,
"function value was used as a property; add () to call it",
())
-ERROR(did_not_call_function,sema_tcc,none,
+ERROR(did_not_call_function,none,
"function %0 was used as a property; add () to call it",
(Identifier))
-ERROR(did_not_call_method,sema_tcc,none,
+ERROR(did_not_call_method,none,
"method %0 was used as a property; add () to call it",
(Identifier))
-ERROR(init_not_instance_member,sema_tcc,none,
+ERROR(init_not_instance_member,none,
"'init' is a member of the type; insert '.dynamicType' to initialize "
"a new object of the same dynamic type", ())
-ERROR(super_initializer_not_in_initializer,sema_tcc,none,
+ERROR(super_initializer_not_in_initializer,none,
"'super.init' cannot be called outside of an initializer", ())
-WARNING(isa_is_always_true,sema_tcc,none, "'%0' test is always true",
+WARNING(isa_is_always_true,none, "'%0' test is always true",
(StringRef))
-WARNING(conditional_downcast_coercion,sema_tcc,none,
+WARNING(conditional_downcast_coercion,none,
"conditional cast from %0 to %1 always succeeds",
(Type, Type))
-WARNING(forced_downcast_noop,sema_tcc,none,
+WARNING(forced_downcast_noop,none,
"forced cast of %0 to same type has no effect", (Type))
-WARNING(forced_downcast_coercion,sema_tcc,none,
+WARNING(forced_downcast_coercion,none,
"forced cast from %0 to %1 always succeeds; did you mean to use 'as'?",
(Type, Type))
-ERROR(downcast_same_type,sema_tcc,none,
+ERROR(downcast_same_type,none,
"downcast from %0 to %1 only unwraps optionals; did you mean to use "
"'%2'?",
(Type, Type, StringRef))
-WARNING(downcast_to_unrelated,sema_tcc,none,
+WARNING(downcast_to_unrelated,none,
"cast from %0 to unrelated type %1 always fails", (Type, Type))
-ERROR(downcast_from_existential_to_unrelated,sema_tcc,none,
- "cannot cast from protocol type %0 to non-conforming type %1",
- (Type, Type))
-ERROR(downcast_to_more_optional,sema_tcc,none,
+ERROR(downcast_to_more_optional,none,
"cannot downcast from %0 to a more optional type %1",
(Type, Type))
-ERROR(optional_chain_noop,sema_tcc,none,
+ERROR(optional_chain_noop,none,
"optional chain has no effect, expression already produces %0",
(Type))
-ERROR(optional_chain_isnt_chaining,sema_tcc,none,
+ERROR(optional_chain_isnt_chaining,none,
"'?' must be followed by a call, member lookup, or subscript",
())
-ERROR(pattern_in_expr,sema_tcc,none,
+ERROR(pattern_in_expr,none,
"%0 cannot appear in an expression", (PatternKind))
-NOTE(note_call_to_operator,sema_tcc,none,
+NOTE(note_call_to_operator,none,
"in call to operator %0", (Identifier))
-NOTE(note_call_to_func,sema_tcc,none,
+NOTE(note_call_to_func,none,
"in call to function %0", (Identifier))
-NOTE(note_call_to_initializer,sema_tcc,none,
+NOTE(note_call_to_initializer,none,
"in call to initializer", ())
-NOTE(note_init_parameter,sema_tcc,none,
+NOTE(note_init_parameter,none,
"in initialization of parameter %0", (Identifier))
-ERROR(missing_nullary_call,sema_tcc,none,
+
+
+ERROR(missing_nullary_call,none,
"function produces expected type %0; did you mean to call it with '()'?",
(Type))
-ERROR(missing_unwrap_optional,sema_tcc,none,
+ERROR(missing_unwrap_optional,none,
"value of optional type %0 not unwrapped; did you mean to use '!' "
"or '?'?",
(Type))
-ERROR(missing_unwrap_optional_try,sema_tcc,none,
+ERROR(missing_unwrap_optional_try,none,
"value of optional type %0 not unwrapped; did you mean to use 'try!' "
"or chain with '?'?",
(Type))
-ERROR(missing_forced_downcast,sema_tcc,none,
+ERROR(missing_forced_downcast,none,
"%0 is not convertible to %1; "
"did you mean to use 'as!' to force downcast?", (Type, Type))
-ERROR(missing_explicit_conversion,sema_tcc,none,
+ERROR(missing_explicit_conversion,none,
"%0 is not implicitly convertible to %1; "
"did you mean to use 'as' to explicitly convert?", (Type, Type))
-ERROR(missing_address_of,sema_tcc,none,
+ERROR(missing_address_of,none,
"passing value of type %0 to an inout parameter requires explicit '&'",
(Type))
-ERROR(extra_address_of,sema_tcc,none,
+ERROR(extra_address_of,none,
"'&' used with non-inout argument of type %0",
(Type))
-ERROR(extra_address_of_unsafepointer,sema_tcc,none,
+ERROR(extra_address_of_unsafepointer,none,
"'&' is not allowed passing array value as %0 argument",
(Type))
-ERROR(missing_init_on_metatype_initialization,sema_tcc,none,
+ERROR(missing_init_on_metatype_initialization,none,
"initializing from a metatype value must reference 'init' explicitly",
())
-ERROR(extra_call_nonfunction,sema_tcc,none,
+ERROR(extra_call_nonfunction,none,
"invalid use of '()' to call a value of non-function type %0",
(Type))
-ERROR(extra_argument_labels,sema_tcc,none,
+ERROR(extra_argument_labels,none,
"extraneous argument label%select{|s}0 '%1' in %select{call|subscript}2",
(bool, StringRef, bool))
-ERROR(missing_argument_labels,sema_tcc,none,
+ERROR(missing_argument_labels,none,
"missing argument label%select{|s}0 '%1' in %select{call|subscript}2",
(bool, StringRef, bool))
-ERROR(wrong_argument_labels,sema_tcc,none,
+ERROR(wrong_argument_labels,none,
"incorrect argument label%select{|s}0 in %select{call|subscript}3 "
"(have '%1', expected '%2')",
(bool, StringRef, StringRef, bool))
-ERROR(extra_named_single_element_tuple,sema_tcc,none,
+ERROR(extra_named_single_element_tuple,none,
"cannot treat single-element named tuple as a scalar; use '.%0' to "
"access its element", (StringRef))
-ERROR(argument_out_of_order,sema_tcc,none,
+ERROR(argument_out_of_order,none,
"argument %0 must precede argument %1", (Identifier, Identifier))
-ERROR(argument_out_of_order_named_unnamed,sema_tcc,none,
+ERROR(argument_out_of_order_named_unnamed,none,
"argument %0 must precede unnamed parameter #%1", (Identifier, unsigned))
-ERROR(instance_member_use_on_type,sema_tcc,none,
+ERROR(instance_member_use_on_type,none,
"use of instance member %1 on type %0; "
- "did you mean to use a value of type %0 instead?", (Type, Identifier))
+ "did you mean to use a value of type %0 instead?", (Type, DeclName))
+ERROR(instance_member_in_initializer,none,
+ "cannot use instance member %0 within property initializer; "
+ "property initializers run before 'self' is available", (DeclName))
-ERROR(missing_argument_named,sema_tcc,none,
+ERROR(missing_argument_named,none,
"missing argument for parameter %0 in call", (Identifier))
-ERROR(missing_argument_positional,sema_tcc,none,
+ERROR(missing_argument_positional,none,
"missing argument for parameter #%0 in call", (unsigned))
-ERROR(extra_argument_named,sema_tcc,none,
+ERROR(extra_argument_named,none,
"extra argument %0 in call", (Identifier))
-ERROR(extra_argument_positional,sema_tcc,none,
+ERROR(extra_argument_positional,none,
"extra argument in call", ())
-ERROR(extra_argument_to_nullary_call,sema_tcc,none,
+ERROR(extra_argument_to_nullary_call,none,
"argument passed to call that takes no arguments", ())
-ERROR(extra_trailing_closure_in_call,sema_tcc,none,
+ERROR(extra_trailing_closure_in_call,none,
"extra trailing closure passed in call", ())
-ERROR(no_accessible_initializers,sema_tcc,none,
+ERROR(no_accessible_initializers,none,
"%0 cannot be constructed because it has no accessible initializers",
(Type))
-ERROR(unbound_generic_parameter,sema_tcc,none,
+ERROR(unbound_generic_parameter,none,
"generic parameter %0 could not be inferred", (Type))
-ERROR(cannot_bind_generic_parameter_to_type,sema_tcc,none,
- "cannot bind generic parameter to type %0",
+ERROR(unbound_generic_parameter_cast,none,
+ "generic parameter %0 could not be inferred in cast to %1", (Type, Type))
+NOTE(archetype_declared_in_type,none,
+ "%0 declared as parameter to type %1", (Type, Type))
+
+
+ERROR(string_index_not_integer,none,
+ "String may not be indexed with %0, it has variable size elements",
(Type))
+NOTE(string_index_not_integer_note,none,
+ "consider using an existing high level algorithm, "
+ "str.startIndex.advancedBy(n), or a projection like str.utf8", ())
-ERROR(invalid_c_function_pointer_conversion_expr,sema_tcc,none,
+ERROR(invalid_c_function_pointer_conversion_expr,none,
"a C function pointer can only be formed from a reference to a 'func' or "
"a literal closure", ())
-ERROR(c_function_pointer_from_method,sema_tcc,none,
+ERROR(c_function_pointer_from_method,none,
"a C function pointer cannot be formed from a method", ())
-ERROR(c_function_pointer_from_generic_function,sema_tcc,none,
+ERROR(c_function_pointer_from_generic_function,none,
"a C function pointer cannot be formed from a reference to a generic "
"function", ())
-ERROR(c_function_pointer_from_function_with_context,sema_tcc,none,
+ERROR(c_function_pointer_from_function_with_context,none,
"a C function pointer cannot be formed from a "
"%select{local function|closure}0 that captures "
"%select{context|generic parameters}1", (bool, bool))
-NOTE(c_function_pointer_captures_here,sema_tcc,none,
+NOTE(c_function_pointer_captures_here,none,
"%0 captured here", (Identifier))
//------------------------------------------------------------------------------
// Type Check Declarations
//------------------------------------------------------------------------------
-ERROR(var_type_not_materializable,sema_tcd,none,
+ERROR(var_type_not_materializable,none,
"type %0 of variable is not materializable", (Type))
-ERROR(enum_element_not_materializable,sema_tcd,none,
+ERROR(enum_element_not_materializable,none,
"type of enum case is not materializable", ())
-ERROR(missing_initializer_def,decl_parsing,PointsToFirstBadToken,
+ERROR(missing_initializer_def,PointsToFirstBadToken,
"initializer requires a body", ())
// Attributes
-ERROR(operator_not_func,sema_tcd,none,
+ERROR(operator_not_func,none,
"operators must be declared with 'func'", ())
-ERROR(redefining_builtin_operator,sema_tcd,none,
+ERROR(redefining_builtin_operator,none,
"cannot declare a custom %0 '%1' operator", (StringRef, StringRef))
-ERROR(invalid_infix_on_func,sema_tcd,none,
+ERROR(invalid_infix_on_func,none,
"'infix' modifier is not required or allowed on func declarations", ())
-ERROR(attribute_requires_operator_identifier,sema_tcd,none,
+ERROR(attribute_requires_operator_identifier,none,
"'%0' requires a function with an operator identifier", (StringRef))
-ERROR(attribute_requires_single_argument,sema_tcd,none,
+ERROR(attribute_requires_single_argument,none,
"'%0' requires a function with one argument", (StringRef))
-ERROR(inout_cant_be_variadic,sema_tce,none,
+ERROR(inout_cant_be_variadic,none,
"inout arguments cannot be variadic", ())
-ERROR(inout_only_parameter,sema_tce,none,
+ERROR(inout_only_parameter,none,
"'inout' is only valid in parameter lists", ())
-ERROR(mutating_invalid_global_scope,sema_tcd,none,
+ERROR(mutating_invalid_global_scope,none,
"'mutating' is only valid on methods", ())
-ERROR(mutating_invalid_classes,sema_tcd,none,
+ERROR(mutating_invalid_classes,none,
"'mutating' isn't valid on methods in classes or class-bound protocols",
())
-ERROR(functions_mutating_and_not,sema_tcd,none,
+ERROR(functions_mutating_and_not,none,
"method may not be declared both mutating and nonmutating", ())
-ERROR(static_functions_not_mutating,sema_tcd,none,
+ERROR(static_functions_not_mutating,none,
"static functions may not be declared mutating", ())
-ERROR(transparent_stored_property,sema_tcd,none,
+ERROR(transparent_stored_property,none,
"@_transparent cannot be applied to stored properties", ())
-ERROR(transparent_on_invalid_extension,sema_tcd,none,
+ERROR(transparent_on_invalid_extension,none,
"@_transparent is only supported on struct and enum extensions", ())
-ERROR(transparent_in_protocols_not_supported,sema_tcd,none,
+ERROR(transparent_in_protocols_not_supported,none,
"@_transparent is not supported on declarations within protocols", ())
-ERROR(transparent_in_classes_not_supported,sema_tcd,none,
+ERROR(transparent_in_classes_not_supported,none,
"@_transparent is not supported on declarations within classes", ())
-ERROR(invalid_iboutlet,sema_tcd,none,
+ERROR(invalid_iboutlet,none,
"only instance properties can be declared @IBOutlet", ())
-ERROR(iboutlet_nonobjc_class,sema_tcd,none,
+ERROR(iboutlet_nonobjc_class,none,
"@IBOutlet property cannot %select{have|be an array of}0 "
"non-'@objc' class type %1", (bool, Type))
-ERROR(iboutlet_nonobjc_protocol,sema_tcd,none,
+ERROR(iboutlet_nonobjc_protocol,none,
"@IBOutlet property cannot %select{have|be an array of}0 "
"non-'@objc' protocol type %1", (bool, Type))
-ERROR(iboutlet_nonobject_type,sema_tcd,none,
+ERROR(iboutlet_nonobject_type,none,
"@IBOutlet property cannot %select{have|be an array of}0 "
"non-object type %1", (bool, Type))
-ERROR(iboutlet_only_mutable,sema_tcd,none,
+ERROR(iboutlet_only_mutable,none,
"@IBOutlet attribute requires property to be mutable", ())
-ERROR(iboutlet_non_optional,sema_tcd,none,
+ERROR(iboutlet_non_optional,none,
"@IBOutlet property has non-optional type %0", (Type))
-NOTE(note_make_optional,sema_tcd,none,
+NOTE(note_make_optional,none,
"add '?' to form the optional type %0", (Type))
-NOTE(note_make_implicitly_unwrapped_optional,sema_tcd,none,
+NOTE(note_make_implicitly_unwrapped_optional,none,
"add '!' to form the implicitly unwrapped optional type %0", (Type))
-ERROR(invalid_ibdesignable_extension,sema_tcd,none,
+ERROR(invalid_ibdesignable_extension,none,
"@IBDesignable can only be applied to classes and extensions "
"of classes", ())
-ERROR(invalid_ibinspectable,sema_tcd,none,
+ERROR(invalid_ibinspectable,none,
"only instance properties can be declared @IBInspectable", ())
-ERROR(invalid_ibaction_decl,sema_tcd,none,
+ERROR(invalid_ibaction_decl,none,
"only instance methods can be declared @IBAction", ())
-ERROR(invalid_ibaction_result,sema_tcd,none,
+ERROR(invalid_ibaction_result,none,
"methods declared @IBAction must return 'Void' (not %0)", (Type))
-ERROR(invalid_ibaction_argument_count,sema_tcd,none,
+ERROR(invalid_ibaction_argument_count,none,
"@IBAction methods %select{must have a single argument"
"|can only have up to 2 arguments}0", (bool))
-ERROR(ibaction_nonobjc_class_argument,sema_tcd,none,
+ERROR(ibaction_nonobjc_class_argument,none,
"argument to @IBAction method cannot have non-'@objc' class type %0",
(Type))
-ERROR(ibaction_nonobject_argument,sema_tcd,none,
+ERROR(ibaction_nonobject_argument,none,
"argument to @IBAction method cannot have non-object type %0", (Type))
-ERROR(no_objc_tagged_pointer_not_class_protocol,sema_tcd,none,
+ERROR(no_objc_tagged_pointer_not_class_protocol,none,
"@unsafe_no_objc_tagged_pointer can only be applied to class protocols",
())
-ERROR(swift_native_objc_runtime_base_not_on_root_class,sema_tcd,none,
+ERROR(swift_native_objc_runtime_base_not_on_root_class,none,
"@_swift_native_objc_runtime_base_not_on_root_class can only be applied "
"to root classes", ())
-ERROR(attr_methods_only,sema_tcd,none,
+ERROR(attr_methods_only,none,
"only methods can be declared %0", (DeclAttribute))
-ERROR(access_control_in_protocol,sema_tcd,none,
+ERROR(access_control_in_protocol,none,
"%0 modifier cannot be used in protocols", (DeclAttribute))
-ERROR(access_control_setter,sema_tcd,none,
+ERROR(access_control_setter,none,
"'%select{private|internal|public}0(set)' modifier can only be applied "
"to variables and subscripts",
(Accessibility))
-ERROR(access_control_setter_read_only,sema_tcd,none,
+ERROR(access_control_setter_read_only,none,
"'%select{private|internal|public}0(set)' modifier cannot be applied to "
"%select{constants|read-only variables|read-only properties"
"|read-only subscripts}1",
(Accessibility, unsigned))
-ERROR(access_control_setter_more,sema_tcd,none,
+ERROR(access_control_setter_more,none,
"%select{private|internal|PUBLIC}0 "
"%select{variable|property|subscript}1 cannot have "
"%select{PRIVATE|an internal|a public}2 setter",
(Accessibility, unsigned, Accessibility))
-WARNING(access_control_member_more,sema_tcd,none,
+WARNING(access_control_member_more,none,
"declaring %select{PRIVATE|an internal|a public}0 %1 for "
"%select{a private|an internal|PUBLIC}2 %3",
(Accessibility, DescriptiveDeclKind, Accessibility, DescriptiveDeclKind))
-WARNING(access_control_ext_member_more,sema_tcd,none,
+WARNING(access_control_ext_member_more,none,
"declaring %select{PRIVATE|an internal|a public}0 %1 in "
"%select{a private|an internal|PUBLIC}2 extension",
(Accessibility, DescriptiveDeclKind, Accessibility))
-ERROR(access_control_ext_requirement_member_more,sema_tcd,none,
+ERROR(access_control_ext_requirement_member_more,none,
"cannot declare %select{PRIVATE|an internal|a public}0 %1 in "
"an extension with %select{private|internal|PUBLIC}2 requirements",
(Accessibility, DescriptiveDeclKind, Accessibility))
-ERROR(access_control_extension_more,sema_tcd,none,
+ERROR(access_control_extension_more,none,
"extension of %select{private|internal|PUBLIC}0 %1 cannot be "
"declared %select{PRIVATE|internal|public}2",
(Accessibility, DescriptiveDeclKind, Accessibility))
-ERROR(invalid_decl_attribute_simple,sema_tcd,none,
+ERROR(invalid_decl_attribute_simple,none,
"attribute cannot be applied to declaration", ())
-ERROR(invalid_decl_attribute,sema_tcd,none,
+ERROR(invalid_decl_attribute,none,
"%0 cannot be applied to this declaration", (DeclAttribute))
-ERROR(invalid_decl_modifier,sema_tcd,none,
+ERROR(invalid_decl_modifier,none,
"%0 modifier cannot be applied to this declaration", (DeclAttribute))
-ERROR(attribute_does_not_apply_to_type,type_parsing,none,
+ERROR(attribute_does_not_apply_to_type,none,
"attribute does not apply to type", ())
-ERROR(optional_attribute_non_protocol,sema_tcd,none,
+ERROR(optional_attribute_non_protocol,none,
"'optional' can only be applied to protocol members", ())
-ERROR(optional_attribute_non_objc_protocol,sema_tcd,none,
+ERROR(optional_attribute_non_objc_protocol,none,
"'optional' can only be applied to members of an @objc protocol",
())
-ERROR(optional_attribute_initializer,sema_tcd,none,
+ERROR(optional_attribute_initializer,none,
"'optional' cannot be applied to an initializer", ())
-ERROR(unavailable_method_non_objc_protocol,sema_tcd,none,
+ERROR(unavailable_method_non_objc_protocol,none,
"protocol members can only be marked unavailable in an @objc protocol",
())
-ERROR(missing_in_class_init_1,sema_tcd,none,
+ERROR(missing_in_class_init_1,none,
"stored property %0 requires an initial value%select{| or should be "
"@NSManaged}1", (Identifier, bool))
-ERROR(missing_in_class_init_2,sema_tcd,none,
+ERROR(missing_in_class_init_2,none,
"stored properties %0 and %1 require initial values%select{| or should "
"be @NSManaged}2",
(Identifier, Identifier, bool))
-ERROR(missing_in_class_init_3plus,sema_tcd,none,
+ERROR(missing_in_class_init_3plus,none,
"stored properties %0, %1, %select{and %2|%2, and others}3 "
"require initial values%select{| or should be @NSManaged}4",
(Identifier, Identifier, Identifier, bool, bool))
-NOTE(requires_stored_property_inits_here,sema_tcd,none,
+NOTE(requires_stored_property_inits_here,none,
"%select{superclass|class}1 %0 requires all stored properties to have "
"initial values%select{| or use @NSManaged}2", (Type, bool, bool))
-ERROR(class_without_init,sema_tcd,none,
+ERROR(class_without_init,none,
"class %0 has no initializers", (Type))
-NOTE(note_no_in_class_init_1,sema_tcd,none,
+NOTE(note_no_in_class_init_1,none,
"stored property %0 without initial value prevents synthesized "
"initializers",
(Identifier))
-NOTE(note_no_in_class_init_2,sema_tcd,none,
+NOTE(note_no_in_class_init_2,none,
"stored properties %0 and %1 without initial values prevent synthesized "
"initializers",
(Identifier, Identifier))
-NOTE(note_no_in_class_init_3plus,sema_tcd,none,
+NOTE(note_no_in_class_init_3plus,none,
"stored properties %0, %1, %select{and %2|%2, and others}3 "
"without initial values prevent synthesized initializers",
(Identifier, Identifier, Identifier, bool))
-ERROR(missing_unimplemented_init_runtime,sema_tcd,none,
+ERROR(missing_unimplemented_init_runtime,none,
"standard library error: missing _unimplemented_initializer", ())
-ERROR(missing_undefined_runtime,sema_tcd,none,
+ERROR(missing_undefined_runtime,none,
"standard library error: missing _undefined", ())
-WARNING(unsupported_synthesize_init_variadic,sema_tcd,none,
+WARNING(unsupported_synthesize_init_variadic,none,
"synthesizing a variadic inherited initializer for subclass %0 is "
"unsupported",
(Type))
-NOTE(variadic_superclass_init_here,sema_tcd,none,
+NOTE(variadic_superclass_init_here,none,
"variadic superclass initializer defined here", ())
// Alignment attribute
-ERROR(alignment_not_power_of_two,sema_tcd,none,
+ERROR(alignment_not_power_of_two,none,
"alignment value must be a power of two", ())
// Indirect enums
-ERROR(indirect_case_without_payload,sema_tcd,none,
+ERROR(indirect_case_without_payload,none,
"enum case %0 without associated value cannot be 'indirect'", (Identifier))
-ERROR(indirect_case_in_indirect_enum,sema_tcd,none,
+ERROR(indirect_case_in_indirect_enum,none,
"enum case in 'indirect' enum cannot also be 'indirect'", ())
// Variables (var and let).
-ERROR(unimplemented_type_var,decl_parsing,none,
+ERROR(unimplemented_type_var,none,
"%select{ERROR|static|class}1 stored properties not yet supported"
"%select{ in this context| in generic types| in classes}0"
"%select{|; did you mean 'static'?}2",
(unsigned, StaticSpellingKind, unsigned))
-ERROR(observingprop_requires_initializer,decl_parsing,none,
+ERROR(observingprop_requires_initializer,none,
"non-member observing properties require an initializer", ())
-ERROR(global_requires_initializer,decl_parsing,none,
+ERROR(global_requires_initializer,none,
"global '%select{var|let}0' declaration requires an initializer expression"
"%select{ or getter/setter specifier}0", (bool))
-ERROR(static_requires_initializer,decl_parsing,none,
+ERROR(static_requires_initializer,none,
"%select{ERROR|'static var'|'class var'|}0 declaration requires an initializer "
"expression or getter/setter specifier", (StaticSpellingKind))
-ERROR(pattern_type_access,sema_tcd,none,
+ERROR(pattern_type_access,none,
"%select{%select{variable|constant}0|property}1 "
"%select{must be declared %select{private|internal|PUBLIC}4"
"|cannot be declared %select{PRIVATE|internal|public}3}2 because its "
"type uses %select{a private|an internal|PUBLIC}4 type",
(bool, bool, bool, Accessibility, Accessibility))
-ERROR(pattern_type_access_inferred,sema_tcd,none,
+ERROR(pattern_type_access_inferred,none,
"%select{%select{variable|constant}0|property}1 "
"%select{must be declared %select{private|internal|PUBLIC}4"
"|cannot be declared %select{PRIVATE|internal|public}3}2 because its "
"type %5 uses %select{a private|an internal|PUBLIC}4 type",
(bool, bool, bool, Accessibility, Accessibility, Type))
-ERROR(pattern_binds_no_variables,sema_tcd,none,
+ERROR(pattern_binds_no_variables,none,
"%select{property|global variable}0 declaration does not bind any "
"variables",
(unsigned))
// Generic types
-ERROR(unsupported_generic_nested_in_type,sema_tcd,none,
+ERROR(unsupported_generic_nested_in_type,none,
"generic type %0 nested in type %1 is not allowed",
(Identifier, Type))
-ERROR(unsupported_type_nested_in_generic_type,sema_tcd,none,
+ERROR(unsupported_type_nested_in_generic_type,none,
"type %0 nested in generic type %1 is not allowed",
(Identifier, Type))
-ERROR(unsupported_type_nested_in_generic_function,sema_tcd,none,
+ERROR(unsupported_type_nested_in_generic_function,none,
"type %0 nested in generic function %1 is not allowed",
(Identifier, Identifier))
// Type aliases
-ERROR(circular_type_alias,sema_tct,none,
+ERROR(circular_type_alias,none,
"type alias %0 circularly references itself", (Identifier))
-ERROR(type_alias_underlying_type_access,sema_tcd,none,
+ERROR(type_alias_underlying_type_access,none,
"type alias %select{must be declared %select{private|internal|PUBLIC}2"
"|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
"underlying type uses %select{a private|an internal|PUBLIC}2 type",
(bool, Accessibility, Accessibility))
// Subscripts
-ERROR(subscript_type_access,sema_tcd,none,
+ERROR(subscript_type_access,none,
"subscript %select{must be declared %select{private|internal|PUBLIC}2"
"|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
"%select{index|element type}3 uses "
@@ -912,615 +994,606 @@ ERROR(subscript_type_access,sema_tcd,none,
(bool, Accessibility, Accessibility, bool))
// Functions
-ERROR(function_type_access,sema_tcd,none,
+ERROR(function_type_access,none,
"%select{function|method|initializer}3 "
"%select{must be declared %select{private|internal|PUBLIC}2"
"|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
"%select{parameter|result}4 uses "
"%select{a private|an internal|PUBLIC}2 type",
(bool, Accessibility, Accessibility, unsigned, bool))
-WARNING(non_trailing_closure_before_default_args,sema_tcd,none,
+WARNING(non_trailing_closure_before_default_args,none,
"closure parameter prior to parameters with default arguments will "
"not be treated as a trailing closure", ())
// Extensions
-ERROR(non_nominal_extension,sema_tcd,none,
+ERROR(non_nominal_extension,none,
"non-nominal type %0 cannot be extended", (Type))
-ERROR(extension_access_with_conformances,sema_tcd,none,
+ERROR(extension_access_with_conformances,none,
"%0 modifier cannot be used with extensions that declare "
"protocol conformances", (DeclAttribute))
-ERROR(extension_metatype,sema_tcd,none,
+ERROR(extension_metatype,none,
"cannot extend a metatype %0", (Type))
-ERROR(extension_specialization,decl_parsing,none,
+ERROR(extension_specialization,none,
"constrained extension must be declared on the unspecialized generic "
"type %0 with constraints specified by a 'where' clause", (Identifier))
-ERROR(extension_stored_property,sema_tcd,none,
+ERROR(extension_stored_property,none,
"extensions may not contain stored properties", ())
-ERROR(extension_nongeneric_trailing_where,sema_tcd,none,
+ERROR(extension_nongeneric_trailing_where,none,
"trailing 'where' clause for extension of non-generic type %0", (Type))
-ERROR(extension_constrained_inheritance,sema_tcd,none,
+ERROR(extension_constrained_inheritance,none,
"extension of type %0 with constraints cannot have an "
"inheritance clause", (Type))
-ERROR(extension_protocol_inheritance,sema_tcd,none,
+ERROR(extension_protocol_inheritance,none,
"extension of protocol %0 cannot have an inheritance clause", (Type))
-ERROR(extension_protocol_type_definition,sema_tcd,none,
+ERROR(extension_protocol_type_definition,none,
"type %0 cannot be defined within a protocol extension", (DeclName))
-ERROR(extension_protocol_via_typealias,sema_tcd,none,
+ERROR(extension_protocol_via_typealias,none,
"protocol %0 in the module being compiled cannot be extended via a "
"typealias", (Type))
-ERROR(extension_anyobject,sema_tcd,none,
+ERROR(extension_anyobject,none,
"'AnyObject' protocol cannot be extended", ())
// Protocols
-ERROR(type_does_not_conform,sema_tcd,none,
+ERROR(type_does_not_conform,none,
"type %0 does not conform to protocol %1", (Type, Type))
-ERROR(cannot_use_nil_with_this_type,sema_tcd,none,
+ERROR(cannot_use_nil_with_this_type,none,
"nil cannot be used in context expecting type %0", (Type))
-ERROR(use_of_equal_instead_of_equality,sema_tcd,none,
+ERROR(use_of_equal_instead_of_equality,none,
"use of '=' in a boolean context, did you mean '=='?", ())
-ERROR(protocol_does_not_conform_objc,sema_tcc,none,
+ERROR(protocol_does_not_conform_objc,none,
"using %0 as a concrete type conforming to protocol %1 is not supported",
(Type, Type))
-ERROR(protocol_does_not_conform_static,sema_tcc,none,
+ERROR(protocol_does_not_conform_static,none,
"%0 cannot be used as a type conforming to protocol %1 because %1 "
"has static requirements",
(Type, Type))
-ERROR(protocol_derivation_is_broken,sema_tcd,none,
+ERROR(protocol_derivation_is_broken,none,
"protocol %0 is broken; cannot derive conformance for type %1", (Type, Type))
-ERROR(type_does_not_inherit,sema_tcd,none,
+ERROR(type_does_not_inherit,none,
"%0 requires that %1 inherit from %2", (Type, Type, Type))
-NOTE(type_does_not_inherit_requirement,sema_tcd,none,
+NOTE(type_does_not_inherit_requirement,none,
"requirement specified as %0 : %1%2", (Type, Type, StringRef))
-ERROR(types_not_equal,sema_tcd,none,
+ERROR(types_not_equal,none,
"%0 requires the types %1 and %2 be equivalent",
(Type, Type, Type))
-NOTE(types_not_equal_requirement,sema_tcd,none,
+NOTE(types_not_equal_requirement,none,
"requirement specified as %0 == %1%2", (Type, Type, StringRef))
-ERROR(non_class_cannot_conform_to_class_protocol,sema_tcd,none,
+ERROR(non_class_cannot_conform_to_class_protocol,none,
"non-class type %0 cannot conform to class protocol %1",
(Type, Type))
-ERROR(foreign_class_cannot_conform_to_objc_protocol,sema_tcd,none,
+ERROR(foreign_class_cannot_conform_to_objc_protocol,none,
"Core Foundation class %0 cannot conform to @objc protocol %1 because "
"Core Foundation types are not classes in Objective-C",
(Type, Type))
-ERROR(protocol_has_missing_requirements,sema_tcd,none,
+ERROR(protocol_has_missing_requirements,none,
"type %0 cannot conform to protocol %1 because it has requirements that "
"cannot be satisfied", (Type, Type))
-ERROR(witness_argument_name_mismatch,sema_tcd,none,
+ERROR(witness_argument_name_mismatch,none,
"%select{method|initializer}0 %1 has different argument names from those "
"required by protocol %2 (%3)", (bool, DeclName, Type, DeclName))
-ERROR(witness_initializer_not_required,sema_tcd,none,
+ERROR(witness_initializer_not_required,none,
"initializer requirement %0 can only be satisfied by a `required` "
"initializer in%select{| the definition of}1 non-final class %2",
(DeclName, bool, Type))
-ERROR(witness_initializer_failability,sema_tcd,none,
+ERROR(witness_initializer_failability,none,
"non-failable initializer requirement %0"
"%select{| in Objective-C protocol}1 cannot be satisfied by a "
"failable initializer ('init%select{?|!}1')",
(DeclName, bool))
-ERROR(witness_self_non_subtype,sema_tcd,none,
+ERROR(witness_self_non_subtype,none,
"protocol %0 requirement %1 cannot be satisfied by a non-final class "
"(%2) because it uses 'Self' in a non-parameter, non-result type "
"position",
(Type, DeclName, Type))
-ERROR(witness_requires_dynamic_self,sema_tcd,none,
+ERROR(witness_requires_dynamic_self,none,
"method %0 in non-final class %1 must return `Self` to conform to "
"protocol %2",
(DeclName, Type, Type))
-ERROR(witness_not_accessible_proto,sema_tcd,none,
+ERROR(witness_not_accessible_proto,none,
"%select{initializer %1|method %1|%select{|setter for }2property %1"
"|subscript%select{| setter}2}0 must be declared "
"%select{PRIVATE|internal|public}3 because it matches a requirement "
"in %select{PRIVATE|internal|public}3 protocol %4",
(RequirementKind, DeclName, bool, Accessibility, DeclName))
-ERROR(witness_not_accessible_type,sema_tcd,none,
+ERROR(witness_not_accessible_type,none,
"%select{initializer %1|method %1|%select{|setter for }2property %1"
"|subscript%select{| setter}2}0 must be as accessible as its enclosing "
"type because it matches a requirement in protocol %4",
(RequirementKind, DeclName, bool, Accessibility, DeclName))
-ERROR(type_witness_not_accessible_proto,sema_tcd,none,
+ERROR(type_witness_not_accessible_proto,none,
"%0 %1 must be declared %select{PRIVATE|internal|public}2 because it "
"matches a requirement in %select{PRIVATE|internal|public}2 protocol %3",
(DescriptiveDeclKind, DeclName, Accessibility, DeclName))
-ERROR(type_witness_not_accessible_type,sema_tcd,none,
+ERROR(type_witness_not_accessible_type,none,
"%0 %1 must be as accessible as its enclosing type because it "
"matches a requirement in protocol %3",
(DescriptiveDeclKind, DeclName, Accessibility, DeclName))
-ERROR(protocol_refine_access,sema_tcd,none,
+ERROR(protocol_refine_access,none,
"%select{protocol must be declared %select{private|internal|PUBLIC}2 "
"because it refines"
"|%select{PRIVATE|internal|public}1 protocol cannot refine}0 "
"%select{a private|an internal|PUBLIC}2 protocol",
(bool, Accessibility, Accessibility))
-ERROR(protocol_property_must_be_computed_var,sema_tcd,none,
+ERROR(protocol_property_must_be_computed_var,none,
"immutable property requirement must be declared as 'var' with a "
"'{ get }' specifier", ())
-ERROR(protocol_property_must_be_computed,sema_tcd,none,
+ERROR(protocol_property_must_be_computed,none,
"property in protocol must have explicit { get } or { get set } specifier",
())
-NOTE(inherited_protocol_does_not_conform,sema_tcd,none,
+NOTE(inherited_protocol_does_not_conform,none,
"type %0 does not conform to inherited protocol %1", (Type, Type))
-NOTE(no_witnesses,sema_tcd,none,
+NOTE(no_witnesses,none,
"protocol requires %select{initializer %1|function %1|property %1|"
"subscript}0 with type %2", (RequirementKind, DeclName, Type))
-NOTE(ambiguous_witnesses,sema_tcd,none,
+NOTE(ambiguous_witnesses,none,
"multiple matching "
"%select{initializers named %1|functions named %1|properties named %1|"
"subscript operators}0 with type %2", (RequirementKind, DeclName, Type))
-NOTE(ambiguous_witnesses_wrong_name,sema_tcd,none,
+NOTE(ambiguous_witnesses_wrong_name,none,
"multiple matching "
"%select{initializers named %1|functions named %1|properties named %1|"
"subscript operators}0 with type %2", (RequirementKind, DeclName, Type))
-NOTE(no_witnesses_type,sema_tcd,none,
+NOTE(no_witnesses_type,none,
"protocol requires nested type %0", (Identifier))
-NOTE(default_associated_type_req_fail,sema_tcd,none,
+NOTE(default_associated_type_req_fail,none,
"default type %0 for associated type %1 (from protocol %2) "
"does not conform to %3",
(Type, DeclName, Type, Type))
-ERROR(associated_type_access,sema_tcd,none,
+ERROR(associated_type_access,none,
"associated type in %select{PRIVATE|an internal|a public}0 protocol "
"uses %select{a private|an internal|PUBLIC}1 type in its "
"%select{default definition|requirement}2 ",
(Accessibility, Accessibility, unsigned))
-NOTE(bad_associated_type_deduction,sema_tcd,none,
+NOTE(bad_associated_type_deduction,none,
"unable to infer associated type %0 for protocol %1",
(DeclName, DeclName))
-NOTE(associated_type_deduction_witness_failed,sema_tcd,none,
+NOTE(associated_type_deduction_witness_failed,none,
"inferred type %1 (by matching requirement %0) is invalid: "
"does not conform to %2",
(DeclName, Type, DeclName))
-NOTE(ambiguous_associated_type_deduction,sema_tcd,none,
+NOTE(ambiguous_associated_type_deduction,none,
"ambiguous inference of associated type %0: %1 vs. %2",
(DeclName, Type, Type))
-NOTE(associated_type_deduction_witness,sema_tcd,none,
+NOTE(associated_type_deduction_witness,none,
"matching requirement %0 to this declaration inferred associated type to "
"%1",
(DeclName, Type))
-NOTE(associated_type_deduction_default,sema_tcd,none,
+NOTE(associated_type_deduction_default,none,
"using associated type default %0", (Type))
-NOTE(ambiguous_witnesses_type,sema_tcd,none,
+NOTE(ambiguous_witnesses_type,none,
"multiple matching types named %0", (Identifier))
-NOTE(protocol_witness_exact_match,sema_tcd,none,
+NOTE(protocol_witness_exact_match,none,
"candidate exactly matches%0", (StringRef))
-NOTE(protocol_witness_renamed,sema_tcd,none,
+NOTE(protocol_witness_renamed,none,
"candidate matches (with renaming)%0", (StringRef))
-NOTE(protocol_witness_kind_conflict,sema_tcd,none,
+NOTE(protocol_witness_kind_conflict,none,
"candidate is not %select{an initializer|a function|a variable|"
"a subscript}0", (RequirementKind))
-NOTE(protocol_witness_type_conflict,sema_tcd,none,
+NOTE(protocol_witness_type_conflict,none,
"candidate has non-matching type %0%1", (Type, StringRef))
-NOTE(protocol_witness_optionality_conflict,sema_tcd,none,
+NOTE(protocol_witness_optionality_conflict,none,
"candidate %select{type has|result type has|parameter type has|"
"parameter types have|result and parameter types have}0 incorrect "
"optionality%1",
(unsigned, StringRef))
-ERROR(err_protocol_witness_optionality,sema_tcd,none,
+ERROR(err_protocol_witness_optionality,none,
"%select{type|result|parameter|parameters|"
"result and parameters}0 of %1 %select{has|has|has|have|have|}0"
" different optionality than required by protocol %2",
(unsigned, DeclName, DeclName))
-WARNING(warn_protocol_witness_optionality,sema_tcd,none,
+WARNING(warn_protocol_witness_optionality,none,
"%select{type|result|parameter|parameters|"
"result and parameters}0 of %1 %select{has|has|has|have|have|}0"
" different optionality than expected by protocol %2",
(unsigned, DeclName, DeclName))
-NOTE(protocol_witness_static_conflict,sema_tcd,none,
+NOTE(protocol_witness_static_conflict,none,
"candidate operates on %select{a type|an instance}0, not "
"%select{an instance|a type}0 as required", (bool))
-NOTE(protocol_witness_prefix_postfix_conflict,sema_tcd,none,
+NOTE(protocol_witness_prefix_postfix_conflict,none,
"candidate is %select{|prefix, |postfix, }1not "
"%select{prefix|postfix}0 as required", (bool, unsigned))
-NOTE(protocol_witness_mutating_conflict,sema_tcd,none,
+NOTE(protocol_witness_mutating_conflict,none,
"candidate is marked 'mutating' but protocol does not allow it", ())
-NOTE(protocol_witness_settable_conflict,sema_tcd,none,
+NOTE(protocol_witness_settable_conflict,none,
"candidate is not settable, but protocol requires it", ())
-NOTE(protocol_witness_noreturn_conflict,sema_tcd,none,
+NOTE(protocol_witness_noreturn_conflict,none,
"candidate is not @noreturn, but protocol requires it", ())
-NOTE(protocol_witness_rethrows_conflict,sema_tcd,none,
+NOTE(protocol_witness_rethrows_conflict,none,
"candidate is not 'rethrows', but protocol requires it", ())
-NOTE(protocol_witness_throws_conflict,sema_tcd,none,
+NOTE(protocol_witness_throws_conflict,none,
"candidate throws, but protocol does not allow it", ())
-NOTE(protocol_witness_not_objc,sema_tcd,none,
+NOTE(protocol_witness_not_objc,none,
"candidate is not '@objc', but protocol requires it", ())
-NOTE(protocol_witness_type,sema_tcd,none,
+NOTE(protocol_witness_type,none,
"possibly intended match", ())
-NOTE(protocol_witness_nonconform_type,sema_tcd,none,
+NOTE(protocol_witness_nonconform_type,none,
"possibly intended match %0 does not conform to %1", (Type, Type))
-NOTE(protocol_requirement_here,sema_tcd,none,
+NOTE(protocol_requirement_here,none,
"requirement %0 declared here", (DeclName))
-NOTE(protocol_conformance_here,sema_tcd,none,
+NOTE(protocol_conformance_here,none,
"%select{|class }0%1 declares conformance to protocol %2 here",
(bool, DeclName, DeclName))
-NOTE(declared_protocol_conformance_here,sema_tcd,none,
+NOTE(declared_protocol_conformance_here,none,
"%select{%0 inherits conformance to protocol %2 from superclass|"
"%0 declares conformance to protocol %2|"
"%0 implicitly conforms to protocol %2 (via conformance to %3)|"
"%0 implicitly conforms to protocol %2}1 here",
(Type, unsigned, DeclName, DeclName))
-ERROR(redundant_conformance,sema_tcd,none,
+ERROR(redundant_conformance,none,
"redundant conformance of %0 to protocol %1", (Type, DeclName))
-NOTE(protocol_conformance_implied_here,sema_tcd,none,
+NOTE(protocol_conformance_implied_here,none,
"implied protocol conformance %0 here can be made explicit", (Identifier))
-WARNING(optional_req_nonobjc_near_match,sema_tcd,none,
+WARNING(optional_req_nonobjc_near_match,none,
"non-@objc %select{initializer %1|method %1|property %1|subscript}0 "
"cannot satisfy optional requirement of @objc protocol %2",
(RequirementKind, DeclName, DeclName))
// Protocols and existentials
-ERROR(assoc_type_outside_of_protocol,sema_nb,none,
+ERROR(assoc_type_outside_of_protocol,none,
"cannot use associated type %0 outside of its protocol", (Identifier))
-ERROR(circular_protocol_def,sema_tcd,none,
+ERROR(circular_protocol_def,none,
"circular protocol inheritance %0", (StringRef))
-NOTE(protocol_here,sema_tcd,none,
+NOTE(protocol_here,none,
"protocol %0 declared here", (Identifier))
-ERROR(protocol_composition_not_protocol,sema_tcd,none,
+ERROR(protocol_composition_not_protocol,none,
"non-protocol type %0 cannot be used within 'protocol<...>'", (Type))
-ERROR(objc_protocol_inherits_non_objc_protocol,sema_tcd,none,
+ERROR(objc_protocol_inherits_non_objc_protocol,none,
"@objc protocol %0 cannot refine non-@objc protocol %1", (Type, Type))
-ERROR(requires_conformance_nonprotocol,sema_tcd,none,
+ERROR(requires_conformance_nonprotocol,none,
"type %0 constrained to non-protocol type %1", (TypeLoc, TypeLoc))
-ERROR(requires_not_suitable_archetype,sema_tcd,none,
+ERROR(requires_not_suitable_archetype,none,
"%select{|first |second }0type %1 in %select{conformance|same-type}2 "
"requirement does not refer to a generic parameter or associated type",
(int, TypeLoc, int))
-ERROR(requires_no_same_type_archetype,sema_tcd,none,
+ERROR(requires_no_same_type_archetype,none,
"neither type in same-type refers to a generic parameter or "
"associated type",
())
-ERROR(requires_generic_params_made_equal,sema_tcd,none,
+ERROR(requires_generic_params_made_equal,none,
"same-type requirement makes generic parameters %0 and %1 equivalent",
(Identifier, Identifier))
-ERROR(requires_generic_param_made_equal_to_concrete,sema_tcd,none,
+ERROR(requires_generic_param_made_equal_to_concrete,none,
"same-type requirement makes generic parameter %0 non-generic",
(Identifier))
-ERROR(requires_superclass_conflict,sema_tcd,none,
+ERROR(requires_superclass_conflict,none,
"generic parameter %0 cannot be a subclass of both %1 and %2",
(Identifier, Type, Type))
-ERROR(recursive_requirement_reference,sema_tcd,none,
+ERROR(recursive_requirement_reference,none,
"type may not reference itself as a requirement",())
-ERROR(recursive_same_type_constraint,sema_tcd,none,
+ERROR(recursive_same_type_constraint,none,
"same-type constraint %0 == %1 is recursive", (Type, Type))
-ERROR(requires_same_type_conflict,sema_tcd,none,
+ERROR(requires_same_type_conflict,none,
"generic parameter %0 cannot be equal to both %1 and %2",
(Identifier, Type, Type))
-ERROR(requires_generic_param_same_type_does_not_conform,sema_tcd,none,
+ERROR(requires_generic_param_same_type_does_not_conform,none,
"same-type constraint type %0 does not conform to required protocol %1",
(Type, Identifier))
-ERROR(dependent_superclass_constraint,sema_tcd,none,
+ERROR(dependent_superclass_constraint,none,
"superclass constraint %0 cannot depend on a type parameter",
(Type))
-ERROR(generic_param_access,sema_tcd,none,
+ERROR(generic_param_access,none,
"%0 %select{must be declared %select{private|internal|PUBLIC}3"
"|cannot be declared %select{PRIVATE|internal|public}2}1 because its "
"generic %select{parameter|requirement}4 uses "
"%select{a private|an internal|PUBLIC}3 type",
(DescriptiveDeclKind, bool, Accessibility, Accessibility, bool))
-ERROR(override_multiple_decls_base,sema_tcd,none,
+ERROR(override_multiple_decls_base,none,
"declaration %0 cannot override more than one superclass declaration",
(DeclName))
-ERROR(override_multiple_decls_arg_mismatch,sema_tcd,none,
+ERROR(override_multiple_decls_arg_mismatch,none,
"declaration %0 has different argument names from any potential "
"overrides", (DeclName))
-ERROR(override_multiple_decls_derived,sema_tcd,none,
- "declaration cannot be overridden by more than one subclass "
- "declaration", ())
-NOTE(overridden_near_match_here,sema_tcd,none,
+NOTE(overridden_near_match_here,none,
"potential overridden %select{method|initializer}0 %1 here",
(bool, DeclName))
-ERROR(override_decl_extension,sema_tcd,none,
+ERROR(override_decl_extension,none,
"declarations %select{in extensions|from extensions}0 cannot "
"%select{override|be overridden}0 yet", (bool))
-NOTE(overridden_here,sema_tcd,none,
+NOTE(overridden_here,none,
"overridden declaration is here", ())
-ERROR(override_objc_type_mismatch_method,sema_tcd,none,
+ERROR(override_objc_type_mismatch_method,none,
"overriding method with selector %0 has incompatible type %1",
(ObjCSelector, Type))
-ERROR(override_objc_type_mismatch_subscript,sema_tcd,none,
+ERROR(override_objc_type_mismatch_subscript,none,
"overriding %select{|indexed |keyed }0subscript with incompatible type "
"%1",
(unsigned, Type))
-NOTE(overridden_here_with_type,sema_tcd,none,
+NOTE(overridden_here_with_type,none,
"overridden declaration here has type %0", (Type))
-ERROR(missing_override,sema_tcd,none,
+ERROR(missing_override,none,
"overriding declaration requires an 'override' keyword", ())
-ERROR(override_unavailable,sema_tcd,none,
+ERROR(override_unavailable,none,
"cannot override %0 which has been marked unavailable", (Identifier))
-ERROR(override_less_available,sema_tcd,none,
+ERROR(override_less_available,none,
"overriding %0 must be as available as declaration it overrides",
(Identifier))
-ERROR(override_accessor_less_available,sema_tcd,none,
+ERROR(override_accessor_less_available,none,
"overriding %0 for %1 must be as available as declaration it overrides",
(DescriptiveDeclKind, Identifier))
-ERROR(override_let_property,sema_tcd,none,
+ERROR(override_let_property,none,
"cannot override immutable 'let' property %0 with the getter of a 'var'",
(Identifier))
-ERROR(override_not_accessible,sema_tcd,none,
+ERROR(override_not_accessible,none,
"%select{|setter of }0overriding %1 must be as accessible as "
"%select{its enclosing type|the declaration it overrides}2",
(bool, DescriptiveDeclKind, bool))
-ERROR(method_does_not_override,sema_tcd,none,
+ERROR(method_does_not_override,none,
"method does not override any method from its superclass", ())
-ERROR(property_does_not_override,sema_tcd,none,
+ERROR(property_does_not_override,none,
"property does not override any property from its superclass", ())
-ERROR(subscript_does_not_override,sema_tcd,none,
+ERROR(subscript_does_not_override,none,
"subscript does not override any subscript from its superclass", ())
-ERROR(initializer_does_not_override,sema_tcd,none,
+ERROR(initializer_does_not_override,none,
"initializer does not override a designated initializer from its "
"superclass", ())
-ERROR(failable_initializer_override,sema_tcd,none,
+ERROR(failable_initializer_override,none,
"failable initializer %0 cannot override a non-failable initializer",
(DeclName))
-NOTE(nonfailable_initializer_override_here,sema_tcd,none,
+NOTE(nonfailable_initializer_override_here,none,
"non-failable initializer %0 overridden here", (DeclName))
-NOTE(property_override_here,sema_tcd,none,
+NOTE(property_override_here,none,
"attempt to override property here", ())
-NOTE(subscript_override_here,sema_tcd,none,
+NOTE(subscript_override_here,none,
"attempt to override subscript here", ())
-NOTE(convenience_init_override_here,sema_tcd,none,
+NOTE(convenience_init_override_here,none,
"attempt to override convenience initializer here", ())
-ERROR(override_nonclass_decl,sema_tcd,none,
+ERROR(override_nonclass_decl,none,
"'override' can only be specified on class members", ())
-ERROR(override_property_type_mismatch,sema_tcd,none,
+ERROR(override_property_type_mismatch,none,
"property %0 with type %1 cannot override a property with type %2",
(Identifier, Type, Type))
-ERROR(override_with_stored_property,sema_tcd,none,
+ERROR(override_with_stored_property,none,
"cannot override with a stored property %0", (Identifier))
-ERROR(observing_readonly_property,sema_tcd,none,
+ERROR(observing_readonly_property,none,
"cannot observe read-only property %0; it can't change", (Identifier))
-ERROR(override_mutable_with_readonly_property,sema_tcd,none,
+ERROR(override_mutable_with_readonly_property,none,
"cannot override mutable property with read-only property %0",
(Identifier))
-ERROR(override_argument_name_mismatch,sema_tcd,none,
+ERROR(override_argument_name_mismatch,none,
"argument names for %select{method|initializer}0 %1 do not match those "
"of overridden %select{method|initializer}0 %2",
(bool, DeclName, DeclName))
-ERROR(override_ownership_mismatch,sema_tcd,none,
+ERROR(override_ownership_mismatch,none,
"cannot override %select{strong|weak|unowned|unowned(unsafe)}0 property "
"with %select{strong|weak|unowned|unowned(unsafe)}1 property",
(/*Ownership*/unsigned, /*Ownership*/unsigned))
-ERROR(override_throws,sema_tcd,none,
+ERROR(override_throws,none,
"cannot override non-throwing %select{method|initializer}0 with "
"throwing %select{method|initializer}0", (bool))
-ERROR(override_throws_objc,sema_tcd,none,
+ERROR(override_throws_objc,none,
"overriding a throwing @objc %select{method|initializer}0 with "
"a non-throwing %select{method|initializer}0 is not supported", (bool))
-WARNING(override_unnecessary_IUO,sema_tcd,none,
+WARNING(override_unnecessary_IUO,none,
"overriding %0 parameter of type %1 with implicitly unwrapped optional "
"type %2",
(DescriptiveDeclKind, Type, Type))
-WARNING(override_unnecessary_result_IUO,sema_tcd,none,
+WARNING(override_unnecessary_result_IUO,none,
"overriding %0 optional result type %1 with implicitly unwrapped "
"optional type %2",
(DescriptiveDeclKind, Type, Type))
-NOTE(override_unnecessary_IUO_remove,sema_tcd,none,
+NOTE(override_unnecessary_IUO_remove,none,
"remove '!' to make the parameter required", ())
-NOTE(override_unnecessary_IUO_use_strict,sema_tcd,none,
+NOTE(override_unnecessary_IUO_use_strict,none,
"use '?' to make the result optional", ())
-NOTE(override_unnecessary_IUO_silence,sema_tcd,none,
+NOTE(override_unnecessary_IUO_silence,none,
"add parentheses to silence this warning", ())
-ERROR(override_mutable_covariant_property,sema_tcd,none,
+ERROR(override_mutable_covariant_property,none,
"cannot override mutable property %0 of type %1 with covariant type %2",
(Identifier, Type, Type))
-ERROR(override_mutable_covariant_subscript,sema_tcd,none,
+ERROR(override_mutable_covariant_subscript,none,
"cannot override mutable subscript of type %0 with covariant type %1",
(Type, Type))
-ERROR(decl_already_final,sema_tcd,none,
+ERROR(decl_already_final,none,
"static declarations are already final", ())
-ERROR(decl_no_default_init,sema_tcd,none,
- "cannot default-initialize variable of type %0", (Type))
-ERROR(decl_no_default_init_ivar_hole,sema_tcd,none,
- "cannot use initial value when one of the variables is '_'", ())
-NOTE(decl_init_here,sema_tcd,none,
+NOTE(decl_init_here,none,
"initial value is here", ())
// Inheritance
-ERROR(duplicate_inheritance,sema_tcd,none,
+ERROR(duplicate_inheritance,none,
"duplicate inheritance from %0", (Type))
-ERROR(multiple_inheritance,sema_tcd,none,
+ERROR(multiple_inheritance,none,
"multiple inheritance from classes %0 and %1", (Type, Type))
-ERROR(non_class_inheritance,sema_tcd,none,
+ERROR(non_class_inheritance,none,
"non-class type %0 cannot inherit from class %1", (Type, Type))
-ERROR(extension_class_inheritance,sema_tcd,none,
+ERROR(extension_class_inheritance,none,
"extension of type %0 cannot inherit from class %1", (Type, Type))
-ERROR(inheritance_from_non_protocol_or_class,sema_tcd,none,
+ERROR(inheritance_from_non_protocol_or_class,none,
"inheritance from non-protocol, non-class type %0", (Type))
-ERROR(inheritance_from_non_protocol,sema_tcd,none,
+ERROR(inheritance_from_non_protocol,none,
"inheritance from non-protocol type %0", (Type))
-ERROR(superclass_not_first,sema_tcd,none,
+ERROR(superclass_not_first,none,
"superclass %0 must appear first in the inheritance clause", (Type))
-ERROR(circular_class_inheritance,sema_tcd,none,
+ERROR(circular_class_inheritance,none,
"circular class inheritance %0", (StringRef))
-NOTE(class_here,sema_tcd,none,
+NOTE(class_here,none,
"class %0 declared here", (Identifier))
-ERROR(inheritance_from_final_class,sema_tcd,none,
+ERROR(inheritance_from_final_class,none,
"inheritance from a final class %0", (Identifier))
// Enums
-ERROR(enum_case_access,sema_tcd,none,
+ERROR(enum_case_access,none,
"enum case in %select{PRIVATE|an internal|a public}0 enum uses "
"%select{a private|an internal|PUBLIC}1 type",
(Accessibility, Accessibility))
-ERROR(enum_stored_property,sema_tcd,none,
+ERROR(enum_stored_property,none,
"enums may not contain stored properties", ())
// Enum raw types
-ERROR(multiple_enum_raw_types,sema_tcd,none,
+ERROR(multiple_enum_raw_types,none,
"multiple enum raw types %0 and %1", (Type, Type))
-ERROR(circular_enum_inheritance,sema_tcd,none,
+ERROR(circular_enum_inheritance,none,
"circular enum raw types %0", (StringRef))
-ERROR(raw_type_not_first,sema_tcd,none,
+ERROR(raw_type_not_first,none,
"raw type %0 must appear first in the enum inheritance clause", (Type))
-ERROR(raw_type_not_literal_convertible,sema_tcd,none,
+ERROR(raw_type_not_literal_convertible,none,
"raw type %0 is not convertible from any literal",
(Type))
-ERROR(enum_raw_type_not_equatable,sema_tcd,none,
+ERROR(enum_raw_type_not_equatable,none,
"RawRepresentable 'init' cannot be synthesized because raw type %0 is not "
"Equatable", (Type))
-ERROR(enum_raw_type_access,sema_tcd,none,
+ERROR(enum_raw_type_access,none,
"enum %select{must be declared %select{private|internal|PUBLIC}2"
"|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
"raw type uses %select{a private|an internal|PUBLIC}2 type",
(bool, Accessibility, Accessibility))
-NOTE(enum_here,sema_tcd,none,
+NOTE(enum_here,none,
"enum %0 declared here", (Identifier))
-ERROR(empty_enum_raw_type,sema_tcd,none,
+ERROR(empty_enum_raw_type,none,
"an enum with no cases cannot declare a raw type", ())
-ERROR(enum_raw_value_without_raw_type,sema_tcd,none,
+ERROR(enum_raw_value_without_raw_type,none,
"enum case cannot have a raw value if the enum does not have a raw type", ())
-ERROR(enum_with_raw_type_case_with_argument,sema_tcd,none,
+ERROR(enum_with_raw_type_case_with_argument,none,
"enum with raw type cannot have cases with arguments", ())
-NOTE(enum_raw_type_here,sema_tcd,none,
+NOTE(enum_raw_type_here,none,
"declared raw type %0 here", (Type))
-ERROR(objc_enum_no_raw_type,sema_tcd,none,
+ERROR(objc_enum_no_raw_type,none,
"'@objc' enum must declare an integer raw type", ())
-ERROR(objc_enum_raw_type_not_integer,sema_tcd,none,
+ERROR(objc_enum_raw_type_not_integer,none,
"'@objc' enum raw type %0 is not an integer type", (Type))
-ERROR(enum_non_integer_raw_value_auto_increment,sema_tcd,none,
+ERROR(enum_non_integer_raw_value_auto_increment,none,
"enum case must declare a raw value when the preceding raw value is not an integer", ())
-ERROR(enum_non_integer_convertible_raw_type_no_value,sema_tcd,none,
+ERROR(enum_non_integer_convertible_raw_type_no_value,none,
"enum cases require explicit raw values when the raw type is not integer "
"or string literal convertible", ())
-ERROR(enum_raw_value_not_unique,sema_tcd,none,
+ERROR(enum_raw_value_not_unique,none,
"raw value for enum case is not unique", ())
-NOTE(enum_raw_value_used_here,sema_tcd,none,
+NOTE(enum_raw_value_used_here,none,
"raw value previously used here", ())
-NOTE(enum_raw_value_incrementing_from_here,sema_tcd,none,
+NOTE(enum_raw_value_incrementing_from_here,none,
"raw value auto-incremented from here",())
-NOTE(enum_raw_value_incrementing_from_zero,sema_tcd,none,
+NOTE(enum_raw_value_incrementing_from_zero,none,
"raw value implicitly auto-incremented from zero",())
// Derived conformances
-ERROR(broken_raw_representable_requirement,sema_tcd,none,
+ERROR(broken_raw_representable_requirement,none,
"RawRepresentable protocol is broken: unexpected requirement", ())
-ERROR(broken_equatable_requirement,sema_tcd,none,
+ERROR(broken_equatable_requirement,none,
"Equatable protocol is broken: unexpected requirement", ())
-ERROR(broken_hashable_requirement,sema_tcd,none,
+ERROR(broken_hashable_requirement,none,
"Hashable protocol is broken: unexpected requirement", ())
-ERROR(broken_errortype_requirement,sema_tcd,none,
+ERROR(broken_errortype_requirement,none,
"ErrorType protocol is broken: unexpected requirement", ())
-ERROR(broken_int_hashable_conformance,sema_tcd,none,
+ERROR(broken_int_hashable_conformance,none,
"Int type is broken: does not conform to Hashable", ())
-ERROR(broken_int_integer_literal_convertible_conformance,sema_tcd,none,
+ERROR(broken_int_integer_literal_convertible_conformance,none,
"Int type is broken: does not conform to IntegerLiteralConvertible", ())
-ERROR(broken_equatable_eq_operator,sema_tcd,none,
+ERROR(broken_equatable_eq_operator,none,
"Equatable protocol is broken: no infix operator declaration for '=='", ())
-ERROR(no_equal_overload_for_int,sema_tcd,none,
+ERROR(no_equal_overload_for_int,none,
"no overload of '==' for Int", ())
// Dynamic Self
-ERROR(dynamic_self_non_method,sema_tcd,none,
+ERROR(dynamic_self_non_method,none,
"%select{global|local}0 function cannot return 'Self'", (bool))
-ERROR(dynamic_self_struct_enum,sema_tcd,none,
+ERROR(dynamic_self_struct_enum,none,
"%select{struct|enum}0 method cannot return 'Self'; "
"did you mean to use the %select{struct|enum}0 type %1?",
(int, Identifier))
// Duplicate declarations
-ERROR(duplicate_enum_element,sema_tcd,none,
+ERROR(duplicate_enum_element,none,
"duplicate definition of enum element",())
//------------------------------------------------------------------------------
// Type Check Attributes
//------------------------------------------------------------------------------
-ERROR(attr_only_only_one_decl_kind,sema_tcd,none,
+ERROR(attr_only_only_one_decl_kind,none,
"%0 may only be used on '%1' declarations", (DeclAttribute,StringRef))
-ERROR(override_final,sema_tcd,none,
+ERROR(override_final,none,
"%0 overrides a 'final' %0", (DescriptiveDeclKind))
-ERROR(member_cannot_be_final,sema_tcd,none,
+ERROR(member_cannot_be_final,none,
"only classes and class members may be marked with 'final'",
())
-ERROR(final_not_allowed_here,sema_tcd,none,
+ERROR(final_not_allowed_here,none,
"'final' may only be applied to classes, properties, methods, and "
"subscripts", ())
-ERROR(final_not_on_accessors,sema_tcd,none,
+ERROR(final_not_on_accessors,none,
"'final' cannot be applied to accessors, it must be put on the "
"%select{var|let|subscript}0", (unsigned))
-ERROR(override_noreturn_with_return,sema_tcd,none,
+ERROR(override_noreturn_with_return,none,
"an override of a @noreturn method should also be @noreturn", ())
-ERROR(override_rethrows_with_non_rethrows,sema_tcd,none,
+ERROR(override_rethrows_with_non_rethrows,none,
"override of 'rethrows' %select{method|initializer}0 should also "
"be 'rethrows'", (bool))
-ERROR(rethrows_without_throwing_parameter,sema_tcd,none,
+ERROR(rethrows_without_throwing_parameter,none,
"'rethrows' function must take a throwing function argument", ())
-ERROR(inconsistent_attribute_override,sema_tcd,none,
- "@%0 must be consistent between a method and its override", (StringRef))
-ERROR(autoclosure_function_type,attribute_parsing,none,
+ERROR(autoclosure_function_type,none,
"@autoclosure may only be applied to values of function type",
())
-ERROR(autoclosure_function_input_nonunit,attribute_parsing,none,
+ERROR(autoclosure_function_input_nonunit,none,
"autoclosure argument type must be '()'", ())
-ERROR(noescape_function_type,attribute_parsing,none,
+ERROR(noescape_function_type,none,
"@noescape may only be applied to parameters of function type",
())
-ERROR(noescape_implied_by_autoclosure,attribute_parsing,none,
+ERROR(noescape_implied_by_autoclosure,none,
"@noescape is implied by @autoclosure and should not be "
"redundantly specified", ())
-ERROR(noescape_conflicts_escaping_autoclosure,attribute_parsing,none,
+ERROR(noescape_conflicts_escaping_autoclosure,none,
"@noescape conflicts with @autoclosure(escaping)", ())
// NSManaged attribute
-ERROR(attr_NSManaged_not_instance_member,sema_tcd,none,
+ERROR(attr_NSManaged_not_instance_member,none,
"@NSManaged only allowed on an instance property or method", ())
-ERROR(attr_NSManaged_not_stored,sema_tcd,none,
+ERROR(attr_NSManaged_not_stored,none,
"@NSManaged not allowed on %select{computed|observing|addressed}0 "
"properties", (unsigned))
-ERROR(attr_NSManaged_let_property,sema_tcd,none,
+ERROR(attr_NSManaged_let_property,none,
"@NSManaged not allowed on a 'let' property", ())
-ERROR(attr_NSManaged_initial_value,sema_tcd,none,
+ERROR(attr_NSManaged_initial_value,none,
"@NSManaged property cannot have an initial value", ())
-ERROR(attr_NSManaged_NSCopying,sema_tcd,none,
+ERROR(attr_NSManaged_NSCopying,none,
"@NSManaged property cannot also be marked @NSCopying", ())
-ERROR(attr_NSManaged_method_body,sema_tcd,none,
+ERROR(attr_NSManaged_method_body,none,
"@NSManaged method cannot have a body; it must be provided at runtime",())
// NSCopying attribute
-ERROR(nscopying_only_on_class_properties,sema_tcd,none,
+ERROR(nscopying_only_on_class_properties,none,
"@NSCopying may only be used on properties in classes",
())
-ERROR(nscopying_only_mutable,sema_tcd,none,
+ERROR(nscopying_only_mutable,none,
"@NSCopying requires property to be mutable", ())
-ERROR(nscopying_only_stored_property,sema_tcd,none,
+ERROR(nscopying_only_stored_property,none,
"@NSCopying is only valid on stored properties", ())
-ERROR(nscopying_doesnt_conform,sema_tcd,none,
+ERROR(nscopying_doesnt_conform,none,
"@NSCopying is only valid with types that conform to"
" the NSCopying protocol", ())
@@ -1528,23 +1601,23 @@ ERROR(nscopying_doesnt_conform,sema_tcd,none,
#define SELECT_APPLICATION_MAIN "select{'UIApplicationMain'|'NSApplicationMain'}"
#define SELECT_APPLICATION_DELEGATE "select{'UIApplicationDelegate'|'NSApplicationDelegate'}"
-ERROR(attr_ApplicationMain_not_class,sema_tcd,none,
+ERROR(attr_ApplicationMain_not_class,none,
"%" SELECT_APPLICATION_MAIN "0 attribute may only be used on classes",
(unsigned))
-ERROR(attr_ApplicationMain_not_ApplicationDelegate,sema_tcd,none,
+ERROR(attr_ApplicationMain_not_ApplicationDelegate,none,
"%" SELECT_APPLICATION_MAIN "0 class must conform to the %" SELECT_APPLICATION_DELEGATE "0 protocol",
(unsigned))
-ERROR(attr_generic_ApplicationMain_not_supported,sema_tcd,none,
+ERROR(attr_generic_ApplicationMain_not_supported,none,
"generic %" SELECT_APPLICATION_MAIN "0 classes are not supported",
(unsigned))
-ERROR(attr_ApplicationMain_multiple,sema_tcd,none,
+ERROR(attr_ApplicationMain_multiple,none,
"%" SELECT_APPLICATION_MAIN "0 attribute can only apply to one class in a module",
(unsigned))
-ERROR(attr_ApplicationMain_with_script,sema_tcd,none,
+ERROR(attr_ApplicationMain_with_script,none,
"%" SELECT_APPLICATION_MAIN "0 attribute cannot be used in a module that contains "
"top-level code",
(unsigned))
-NOTE(attr_ApplicationMain_script_here,sema_tcd,none,
+NOTE(attr_ApplicationMain_script_here,none,
"top-level code defined in this source file",
())
@@ -1552,32 +1625,32 @@ NOTE(attr_ApplicationMain_script_here,sema_tcd,none,
#undef SELECT_APPLICATION_DELEGATE
// lazy
-ERROR(lazy_not_on_let,sema_tcd,none,
+ERROR(lazy_not_on_let,none,
"'lazy' cannot be used on a let", ())
-ERROR(lazy_not_on_computed,sema_tcd,none,
+ERROR(lazy_not_on_computed,none,
"'lazy' may not be used on a computed property", ())
-ERROR(lazy_on_already_lazy_global,sema_tcd,none,
+ERROR(lazy_on_already_lazy_global,none,
"'lazy' may not be used on an already-lazy global", ())
-ERROR(lazy_not_in_protocol,sema_tcd,none,
+ERROR(lazy_not_in_protocol,none,
"'lazy' isn't allowed on a protocol requirement", ())
-ERROR(lazy_requires_initializer,sema_tcd,none,
+ERROR(lazy_requires_initializer,none,
"lazy properties must have an initializer", ())
-ERROR(lazy_requires_single_var,sema_tcd,none,
+ERROR(lazy_requires_single_var,none,
"'lazy' cannot destructure an initializer", ())
-ERROR(lazy_must_be_property,sema_tcd,none,
+ERROR(lazy_must_be_property,none,
"lazy is only valid for members of a struct or class", ())
-ERROR(lazy_not_observable,sema_tcd,none,
+ERROR(lazy_not_observable,none,
"lazy properties may not have observers", ())
// Debugger function attribute.
-ERROR(attr_for_debugger_support_only,sema_tcd,none,
+ERROR(attr_for_debugger_support_only,none,
"@LLDBDebuggerSupport may only be used when debugger support is on", ())
// warn_unused_result
-ERROR(attr_warn_unused_result_mutable_variable,sema_tcd,none,
+ERROR(attr_warn_unused_result_mutable_variable,none,
"'mutable_variant' parameter of 'warn_unused_result' attribute does not "
"make sense on a %select{non-function|non-method|non-instance method|"
"method of a class|mutating method}0", (unsigned))
@@ -1586,268 +1659,268 @@ ERROR(attr_warn_unused_result_mutable_variable,sema_tcd,none,
// Type Check Expressions
//------------------------------------------------------------------------------
-NOTE(found_candidate,sema_tce,none,
+NOTE(found_candidate,none,
"found this candidate", ())
-NOTE(found_candidate_type,sema_tce,none,
+NOTE(found_candidate_type,none,
"found candidate with type %0", (Type))
-NOTE(first_declaration,sema_tce,none,
+NOTE(first_declaration,none,
"first declaration", ())
-NOTE(second_declaration,sema_tce,none,
+NOTE(second_declaration,none,
"second declaration", ())
-ERROR(no_IntegerLiteralType_found,sema_tce,none,
+ERROR(no_IntegerLiteralType_found,none,
"standard library error: IntegerLiteralType not defined", ())
-ERROR(no_FloatLiteralType_found,sema_tce,none,
+ERROR(no_FloatLiteralType_found,none,
"standard library error: FloatLiteralType not defined", ())
-ERROR(no_StringLiteralType_found,sema_tce,none,
+ERROR(no_StringLiteralType_found,none,
"standard library error: StringLiteralType not defined", ())
-ERROR(no_MaxBuiltinIntegerType_found,sema_tce,none,
+ERROR(no_MaxBuiltinIntegerType_found,none,
"standard library error: _MaxBuiltinIntegerType is not properly defined", ())
-ERROR(no_MaxBuiltinFloatType_found,sema_tce,none,
+ERROR(no_MaxBuiltinFloatType_found,none,
"standard library error: _MaxBuiltinFloatType is not properly defined", ())
-ERROR(no_member_of_module,sema_tce,none,
+ERROR(no_member_of_module,none,
"module %0 has no member named %1", (Identifier, DeclName))
-ERROR(super_with_no_base_class,sema_tce,none,
+ERROR(super_with_no_base_class,none,
"'super' members cannot be referenced in a root class", ())
-ERROR(bad_init_ref_base,sema_tce, none,
+ERROR(bad_init_ref_base, none,
"'init' can only refer to the initializers of "
"'self'%select{| or 'super'}0", (bool))
-ERROR(init_delegation_outside_initializer,sema_tce,none,
+ERROR(init_delegation_outside_initializer,none,
"initializer delegation can only occur within an initializer", ())
-ERROR(init_delegates_and_chains,sema_tce,none,
+ERROR(init_delegates_and_chains,none,
"initializer cannot both delegate ('self.init') and chain to a "
"superclass initializer ('super.init')", ())
-NOTE(init_delegation_or_chain,sema_tce,none,
+NOTE(init_delegation_or_chain,none,
"previous %select{delegation|chaining}0 call is here", (bool))
-ERROR(delegating_convenience_super_init,sema_tce,none,
+ERROR(delegating_convenience_super_init,none,
"convenience initializer for %0 must delegate (with 'self.init') rather "
"than chaining to a superclass initializer (with 'super.init')",
(Type))
-ERROR(delegating_designated_init,sema_tce,none,
+ERROR(delegating_designated_init,none,
"designated initializer for %0 cannot delegate (with 'self.init'); "
"did you mean this to be a convenience initializer?",
(Type))
-NOTE(delegation_here,sema_tce,none, "delegation occurs here", ())
-ERROR(chain_convenience_init,sema_tce,none,
+NOTE(delegation_here,none, "delegation occurs here", ())
+ERROR(chain_convenience_init,none,
"must call a designated initializer of the superclass %0",
(Type))
-ERROR(delegate_chain_nonoptional_to_optional,sema_tce,none,
+ERROR(delegate_chain_nonoptional_to_optional,none,
"a non-failable initializer cannot %select{delegate|chain}0 to "
"failable initializer %1 written with 'init?'", (bool, DeclName))
-NOTE(init_force_unwrap,sema_tce,none,
+NOTE(init_force_unwrap,none,
"force potentially-failing result with '!'", ())
-NOTE(init_propagate_failure,sema_tce,none,
+NOTE(init_propagate_failure,none,
"propagate the failure with 'init?'", ())
-ERROR(delegate_chain_nonoptional_to_optional_try,sema_tce,none,
+ERROR(delegate_chain_nonoptional_to_optional_try,none,
"a non-failable initializer cannot use 'try?' to "
"%select{delegate|chain}0 to another initializer", (bool))
-NOTE(init_delegate_force_try,sema_tce,none,
+NOTE(init_delegate_force_try,none,
"force potentially-failing result with 'try!'", ())
-ERROR(init_delegation_nested,sema_tce,none,
+ERROR(init_delegation_nested,none,
"%select{initializer delegation ('self.init')|"
"initializer chaining ('super.init')}0 cannot be nested in another "
"%select{expression|statement}1", (bool, bool))
-NOTE(convenience_init_here,sema_tce,none,
+NOTE(convenience_init_here,none,
"convenience initializer is declared here", ())
-ERROR(designated_init_in_extension,sema_tcd,none,
+ERROR(designated_init_in_extension,none,
"designated initializer cannot be declared in an extension of %0; "
"did you mean this to be a convenience initializer?",
(Type))
-ERROR(enumstruct_convenience_init,sema_tce,none,
+ERROR(enumstruct_convenience_init,none,
"delegating initializers in %0 are not marked with 'convenience'",
(StringRef))
-ERROR(nonclass_convenience_init,sema_tce,none,
+ERROR(nonclass_convenience_init,none,
"convenience initializer not allowed in non-class type %0",
(Type))
-ERROR(dynamic_construct_class,sema_tce,none,
+ERROR(dynamic_construct_class,none,
"constructing an object of class type %0 with a metatype value must use "
"a 'required' initializer", (Type))
-NOTE(note_nonrequired_initializer,sema_tce,none,
+NOTE(note_nonrequired_initializer,none,
"selected %select{non-required|implicit}0 initializer %1",
(bool, DeclName))
-ERROR(construct_protocol_value,sema_tce,none,
+ERROR(construct_protocol_value,none,
"value of type %0 is a protocol; it cannot be instantiated",
(Type))
-ERROR(construct_protocol_by_name,sema_tce,none,
+ERROR(construct_protocol_by_name,none,
"protocol type %0 cannot be instantiated",
(Type))
// Operators
-ERROR(unknown_binop,sema_tce,none,
+ERROR(unknown_binop,none,
"operator is not a known binary operator", ())
-ERROR(non_assoc_adjacent,sema_tce,none,
+ERROR(non_assoc_adjacent,none,
"non-associative operator is adjacent to operator of same precedence", ())
-ERROR(incompatible_assoc,sema_tce,none,
+ERROR(incompatible_assoc,none,
"operator is adjacent to operator of same precedence"
" but incompatible associativity", ())
// If you change this, also change enum TryKindForDiagnostics.
#define TRY_KIND_SELECT(SUB) "%select{try|try!|try?}" #SUB
-ERROR(try_rhs,sema_tce,none,
+ERROR(try_rhs,none,
"'" TRY_KIND_SELECT(0) "' cannot appear to the right of a "
"non-assignment operator", (unsigned))
-ERROR(try_if_rhs_noncovering,sema_tce,none,
+ERROR(try_if_rhs_noncovering,none,
"'" TRY_KIND_SELECT(0) "' following conditional operator does not cover "
"everything to its right", (unsigned))
-ERROR(try_assign_rhs_noncovering,sema_tce,none,
+ERROR(try_assign_rhs_noncovering,none,
"'" TRY_KIND_SELECT(0) "' following assignment operator does not cover "
"everything to its right", (unsigned))
-ERROR(reference_non_inout,sema_tce,none,
- "reference to %0 not used to initialize a inout parameter", (Type))
-NOTE(subscript_decl_here,sema_tca,none,
+NOTE(subscript_decl_here,none,
"subscript operator declared here", ())
-ERROR(condition_broken_proto,sema_tce,none,
+ERROR(condition_broken_proto,none,
"protocol 'BooleanType' is broken", ())
-ERROR(option_type_broken,sema_tce,none,
- "type 'Optional' is broken", ())
-ERROR(broken_bool,sema_tce,none, "type 'Bool' is broken", ())
-ERROR(binding_explicit_downcast,sema_tce,none,
- "operand of postfix '?' is a forced downcast to type %0; use 'as?' to "
- "perform a conditional downcast", (Type))
+ERROR(broken_bool,none, "type 'Bool' is broken", ())
-WARNING(inject_forced_downcast,sema_tce,none,
+WARNING(inject_forced_downcast,none,
"treating a forced downcast to %0 as optional will never produce 'nil'",
(Type))
-NOTE(forced_to_conditional_downcast,sema_tce,none,
+NOTE(forced_to_conditional_downcast,none,
"use 'as?' to perform a conditional downcast to %0", (Type))
-NOTE(silence_inject_forced_downcast,sema_tce,none,
+NOTE(silence_inject_forced_downcast,none,
"add parentheses around the cast to silence this warning", ())
-ERROR(conditional_downcast_foreign,sema_tce,none,
+ERROR(conditional_downcast_foreign,none,
"conditional downcast to CoreFoundation type %0 will always succeed",
(Type))
-ERROR(optional_used_as_boolean,sema_tce,none,
+ERROR(optional_used_as_boolean,none,
"optional type %0 cannot be used as a boolean; "
"test for '!= nil' instead", (Type))
-ERROR(optional_used_as_true_boolean,sema_tce,none,
+ERROR(optional_used_as_true_boolean,none,
"optional type %0 cannot be used as a boolean; "
"test for '== nil' instead", (Type))
-ERROR(migrate_from_raw_to_init,sema_tce,none,
+ERROR(migrate_from_raw_to_init,none,
"static method 'fromRaw' has been replaced with a failable initializer "
"'init(rawValue:)'", ())
-ERROR(migrate_from_allZeros,sema_tce,none,
+ERROR(migrate_from_allZeros,none,
"static method 'allZeros' has been replaced with the default initializer",
())
-ERROR(migrate_to_raw_to_raw_value,sema_tce,none,
+ERROR(migrate_to_raw_to_raw_value,none,
"method 'fromRaw' has been replaced with a property 'rawValue'", ())
-ERROR(new_array_bound_zero,sema_tce,none,
- "array type cannot have zero length", ())
-ERROR(non_constant_array,type_parsing,none,
- "array has non-constant size", ())
-
-ERROR(interpolation_missing_proto,sema_tce,none,
+ERROR(interpolation_missing_proto,none,
"string interpolation requires the protocol 'StringInterpolationConvertible' to be defined",
())
-ERROR(interpolation_broken_proto,sema_tce,none,
+ERROR(interpolation_broken_proto,none,
"protocol 'StringInterpolationConvertible' is broken",
())
-ERROR(object_literal_broken_proto,sema_tce,none,
+ERROR(object_literal_broken_proto,none,
"object literal protocol is broken", ())
-ERROR(discard_expr_outside_of_assignment,sema_tce,none,
+ERROR(discard_expr_outside_of_assignment,none,
"'_' can only appear in a pattern or on the left side of an assignment",
())
-ERROR(inout_expr_outside_of_call,sema_tce,none,
+ERROR(inout_expr_outside_of_call,none,
"'&' can only appear immediately in a call argument list", ())
-ERROR(type_of_expression_is_ambiguous,sema_tce,none,
+
+ERROR(unresolved_member_no_inference,none,
+ "reference to member %0 cannot be resolved without a contextual type",
+ (DeclName))
+ERROR(unresolved_collection_literal,none,
+ "cannot infer type for empty collection literal without a "
+ "contextual type", ())
+ERROR(unresolved_nil_literal,none,
+ "'nil' requires a contextual type", ())
+
+ERROR(type_of_expression_is_ambiguous,none,
"type of expression is ambiguous without more context", ())
-ERROR(specific_type_of_expression_is_ambiguous,sema_tce,none,
+ERROR(specific_type_of_expression_is_ambiguous,none,
"expression type %0 is ambiguous without more context", (Type))
-ERROR(missing_protocol,sema_tce,none,
+ERROR(missing_protocol,none,
"missing protocol %0", (Identifier))
-ERROR(nil_literal_broken_proto,sema_tce,none,
+ERROR(nil_literal_broken_proto,none,
"protocol 'NilLiteralConvertible' is broken", ())
-ERROR(builtin_integer_literal_broken_proto,sema_tce,none,
+ERROR(builtin_integer_literal_broken_proto,none,
"protocol '_BuiltinIntegerLiteralConvertible' is broken", ())
-ERROR(integer_literal_broken_proto,sema_tce,none,
+ERROR(integer_literal_broken_proto,none,
"protocol 'IntegerLiteralConvertible' is broken", ())
-ERROR(builtin_float_literal_broken_proto,sema_tce,none,
+ERROR(builtin_float_literal_broken_proto,none,
"protocol '_BuiltinFloatLiteralConvertible' is broken", ())
-ERROR(float_literal_broken_proto,sema_tce,none,
+ERROR(float_literal_broken_proto,none,
"protocol 'FloatLiteralConvertible' is broken", ())
-ERROR(builtin_boolean_literal_broken_proto,sema_tce,none,
+ERROR(builtin_boolean_literal_broken_proto,none,
"protocol '_BuiltinBooleanLiteralConvertible' is broken", ())
-ERROR(boolean_literal_broken_proto,sema_tce,none,
+ERROR(boolean_literal_broken_proto,none,
"protocol 'BooleanLiteralConvertible' is broken", ())
-ERROR(builtin_unicode_scalar_literal_broken_proto,sema_tce,none,
+ERROR(builtin_unicode_scalar_literal_broken_proto,none,
"protocol '_BuiltinUnicodeScalarLiteralConvertible' is broken", ())
-ERROR(unicode_scalar_literal_broken_proto,sema_tce,none,
+ERROR(unicode_scalar_literal_broken_proto,none,
"protocol 'UnicodeScalarLiteralConvertible' is broken", ())
-ERROR(builtin_extended_grapheme_cluster_literal_broken_proto,sema_tce,none,
+ERROR(builtin_extended_grapheme_cluster_literal_broken_proto,none,
"protocol '_BuiltinExtendedGraphemeClusterLiteralConvertible' is broken", ())
-ERROR(extended_grapheme_cluster_literal_broken_proto,sema_tce,none,
+ERROR(extended_grapheme_cluster_literal_broken_proto,none,
"protocol 'ExtendedGraphemeClusterLiteralConvertible' is broken", ())
-ERROR(builtin_string_literal_broken_proto,sema_tce,none,
+ERROR(builtin_string_literal_broken_proto,none,
"protocol '_BuiltinStringLiteralConvertible' is broken", ())
-ERROR(string_literal_broken_proto,sema_tce,none,
+ERROR(string_literal_broken_proto,none,
"protocol 'StringLiteralConvertible' is broken", ())
-ERROR(bool_type_broken,sema_tce,none,
+ERROR(bool_type_broken,none,
"could not find a Bool type defined for 'is'", ())
// Array literals
-ERROR(array_protocol_broken,sema_tce,none,
+ERROR(array_protocol_broken,none,
"ArrayLiteralConvertible protocol definition is broken", ())
-ERROR(type_is_not_array,sema_tce,none,
+ERROR(type_is_not_array,none,
"contextual type %0 cannot be used with array literal", (Type))
-NOTE(meant_dictionary_lit, sema_tce,none,
+NOTE(meant_dictionary_lit,none,
"did you mean to use a dictionary literal instead?", ())
+ERROR(should_use_empty_dictionary_literal,none,
+ "use [:] to get an empty dictionary literal", ())
// Dictionary literals
-ERROR(dictionary_protocol_broken,sema_tce,none,
+ERROR(dictionary_protocol_broken,none,
"DictionaryLiteralConvertible protocol definition is broken", ())
-ERROR(type_is_not_dictionary,sema_tce,none,
+ERROR(type_is_not_dictionary,none,
"contextual type %0 cannot be used with dictionary literal", (Type))
// Generic specializations
-ERROR(cannot_explicitly_specialize_generic_function,tce_sema,none,
+ERROR(cannot_explicitly_specialize_generic_function,none,
"cannot explicitly specialize a generic function", ())
-ERROR(not_a_generic_definition,tce_sema,none,
+ERROR(not_a_generic_definition,none,
"cannot specialize a non-generic definition", ())
-ERROR(not_a_generic_type,tce_sema,none,
+ERROR(not_a_generic_type,none,
"cannot specialize non-generic type %0", (Type))
-ERROR(type_parameter_count_mismatch,tce_sema,none,
+ERROR(type_parameter_count_mismatch,none,
"generic type %0 specialized with %select{too many|too few}3 type "
"parameters (got %2, but expected %1)",
(Identifier, unsigned, unsigned, bool))
-ERROR(generic_type_requires_arguments,tce_sema,none,
+ERROR(generic_type_requires_arguments,none,
"reference to generic type %0 requires arguments in <...>", (Type))
-NOTE(generic_type_declared_here,tce_sema,none,
+NOTE(generic_type_declared_here,none,
"generic type %0 declared here", (Identifier))
// Ambiguities
-ERROR(ambiguous_decl_ref,tce_sema,none,
+ERROR(ambiguous_decl_ref,none,
"ambiguous use of %0", (DeclName))
-ERROR(ambiguous_operator_ref,tce_sema,none,
+ERROR(ambiguous_operator_ref,none,
"ambiguous use of operator %0", (DeclName))
// Cannot capture inout-ness of a parameter
// Partial application of foreign functions not supported
-ERROR(partial_application_of_function_invalid,tce_sema,none,
+ERROR(partial_application_of_function_invalid,none,
"partial application of %select{"
"function with 'inout' parameters|"
"'mutating' method|"
@@ -1856,81 +1929,76 @@ ERROR(partial_application_of_function_invalid,tce_sema,none,
"}0 is not allowed",
(unsigned))
-ERROR(self_assignment_var,tce_sema,none,
+ERROR(self_assignment_var,none,
"assigning a variable to itself", ())
-ERROR(self_assignment_prop,tce_sema,none,
+ERROR(self_assignment_prop,none,
"assigning a property to itself", ())
-ERROR(property_use_in_closure_without_explicit_self,tce_sema,none,
+ERROR(property_use_in_closure_without_explicit_self,none,
"reference to property %0 in closure requires explicit 'self.' to make"
" capture semantics explicit", (Identifier))
-ERROR(method_call_in_closure_without_explicit_self,tce_sema,none,
+ERROR(method_call_in_closure_without_explicit_self,none,
"call to method %0 in closure requires explicit 'self.' to make"
" capture semantics explicit", (Identifier))
-ERROR(implicit_use_of_self_in_closure,tce_sema,none,
+ERROR(implicit_use_of_self_in_closure,none,
"implicit use of 'self' in closure; use 'self.' to make"
" capture semantics explicit", ())
-ERROR(capture_before_declaration,tce_sema,none,
+ERROR(capture_before_declaration,none,
"cannot capture %0 before it is declared", (Identifier))
-ERROR(transitive_capture_before_declaration,tce_sema,none,
+ERROR(transitive_capture_before_declaration,none,
"cannot capture %0, which would use %1 before it is declared",
(Identifier, Identifier))
-NOTE(transitive_capture_through_here,tce_sema,none,
+NOTE(transitive_capture_through_here,none,
"%0, declared here, captures %1",
(Identifier, Identifier))
-ERROR(unsupported_local_function_reference,tce_sema,none,
- "cannot reference a local function with captures from another local "
- "function", ())
-ERROR(unsupported_recursive_local_function,tce_sema,none,
- "local functions cannot reference themselves", ())
-WARNING(recursive_accessor_reference,tce_sema,none,
+WARNING(recursive_accessor_reference,none,
"attempting to %select{access|modify}1 %0 within its own "
"%select{getter|setter}1", (Identifier, bool))
-NOTE(recursive_accessor_reference_silence,tce_sema,none,
+NOTE(recursive_accessor_reference_silence,none,
"access 'self' explicitly to silence this warning", ())
-WARNING(store_in_willset,tce_sema,none,
+WARNING(store_in_willset,none,
"attempting to store to property %0 within its own willSet, which is "
"about to be overwritten by the new value", (Identifier))
-ERROR(value_of_module_type,tce_sema,none,
+ERROR(value_of_module_type,none,
"expected module member name after module name", ())
-ERROR(value_of_metatype_type,tce_sema,none,
+ERROR(value_of_metatype_type,none,
"expected member name or constructor call after type name", ())
-NOTE(add_parens_to_type,tce_sema,none,
+NOTE(add_parens_to_type,none,
"add arguments after the type to construct a value of the type", ())
-NOTE(add_self_to_type,tce_sema,none,
+NOTE(add_self_to_type,none,
"use '.self' to reference the type object", ())
-WARNING(warn_unqualified_access,tce_sema,none,
+WARNING(warn_unqualified_access,none,
"use of %0 treated as a reference to %1 in %2 %3",
(Identifier, DescriptiveDeclKind, DescriptiveDeclKind, DeclName))
-NOTE(fix_unqualified_access_member,tce_sema,none,
+NOTE(fix_unqualified_access_member,none,
"use 'self.' to silence this warning", ())
-NOTE(fix_unqualified_access_top_level,tce_sema,none,
+NOTE(fix_unqualified_access_top_level,none,
"use '%0' to reference the %1",
(StringRef, DescriptiveDeclKind, Identifier))
-NOTE(fix_unqualified_access_top_level_multi,tce_sema,none,
+NOTE(fix_unqualified_access_top_level_multi,none,
"use '%0' to reference the %1 in module %2",
(StringRef, DescriptiveDeclKind, Identifier))
-ERROR(type_of_metatype,tce_sema,none,
+ERROR(type_of_metatype,none,
"'.dynamicType' is not allowed after a type name", ())
-ERROR(invalid_noescape_use,tce_sema,none,
+ERROR(invalid_noescape_use,none,
"@noescape parameter %0 may only be called", (Identifier))
-NOTE(noescape_autoclosure,tce_sema,none,
+NOTE(noescape_autoclosure,none,
"parameter %0 is implicitly @noescape because it was declared @autoclosure",
(Identifier))
-ERROR(closure_noescape_use,tce_sema,none,
+ERROR(closure_noescape_use,none,
"closure use of @noescape parameter %0 may allow it to escape",
(Identifier))
-ERROR(decl_closure_noescape_use,tce_sema,none,
+ERROR(decl_closure_noescape_use,none,
"declaration closing over @noescape parameter %0 may allow it to escape",
(Identifier))
-ERROR(capture_across_type_decl,tce_sema,none,
+ERROR(capture_across_type_decl,none,
"%0 declaration cannot close over value %1 defined in outer scope",
(DescriptiveDeclKind, Identifier))
@@ -1938,174 +2006,172 @@ ERROR(capture_across_type_decl,tce_sema,none,
// Type Check Statements
//------------------------------------------------------------------------------
-ERROR(jump_out_of_defer,sema_tcs,none,
+ERROR(jump_out_of_defer,none,
"'%0' cannot transfer control out of a defer statement",
(StringRef))
-ERROR(return_invalid_outside_func,sema_tcs,none,
+ERROR(return_invalid_outside_func,none,
"return invalid outside of a func", ())
-ERROR(return_expr_missing,sema_tcs,none,
+ERROR(return_expr_missing,none,
"non-void function should return a value", ())
-ERROR(return_non_failable_init,sema_tcs,none,
+ERROR(return_non_failable_init,none,
"only a failable initializer can return 'nil'", ())
-NOTE(make_init_failable,sema_tcs,none,
+NOTE(make_init_failable,none,
"use 'init?' to make the initializer %0 failable", (DeclName))
-ERROR(return_init_non_nil,sema_tcs,none,
+ERROR(return_init_non_nil,none,
"'nil' is the only return value permitted in an initializer",
())
-WARNING(if_always_true,sema_tcd,none,
+WARNING(if_always_true,none,
"'if' condition is always true", ())
-WARNING(while_always_true,sema_tcd,none,
+WARNING(while_always_true,none,
"'while' condition is always true", ())
-WARNING(guard_always_succeeds,sema_tcd,none,
+WARNING(guard_always_succeeds,none,
"'guard' condition is always true, body is unreachable", ())
-ERROR(expression_unused_function,sema_tcs,none,
+ERROR(expression_unused_function,none,
"expression resolves to an unused function", ())
-ERROR(expression_unused_lvalue,sema_tcs,none,
+ERROR(expression_unused_lvalue,none,
"expression resolves to an unused l-value", ())
-WARNING(expression_unused_result,sema_tcs,none,
+WARNING(expression_unused_result,none,
"result of call to %0 is unused", (DeclName))
-WARNING(expression_unused_init_result,sema_tcs,none,
+WARNING(expression_unused_init_result,none,
"result of initializer is unused", ())
-WARNING(expression_unused_result_message,sema_tcs,none,
+WARNING(expression_unused_result_message,none,
"result of call to %0 is unused: %1", (DeclName, StringRef))
-WARNING(expression_unused_result_nonmutating,sema_tcs,none,
+WARNING(expression_unused_result_nonmutating,none,
"result of call to non-mutating function %0 is unused; "
"use %1 to mutate in-place", (DeclName, DeclName))
-WARNING(expression_unused_optional_try,sema_tcs,none,
+WARNING(expression_unused_optional_try,none,
"result of 'try?' is unused", ())
-ERROR(assignment_lhs_not_lvalue,sema_tcs,none,
+ERROR(assignment_lhs_not_lvalue,none,
"cannot assign to immutable expression of type %0", (Type))
-ERROR(assignment_lhs_is_immutable_variable,sema_tcs,none,
+ERROR(assignment_lhs_is_immutable_variable,none,
"cannot assign to value: %0", (StringRef))
-ERROR(assignment_lhs_is_immutable_property,sema_tcs,none,
+ERROR(assignment_lhs_is_immutable_property,none,
"cannot assign to property: %0", (StringRef))
-ERROR(assignment_subscript_has_immutable_base,sema_tcs,none,
+ERROR(assignment_subscript_has_immutable_base,none,
"cannot assign through subscript: %0", (StringRef))
-ERROR(assignment_bang_has_immutable_subcomponent,sema_tcs,none,
+ERROR(assignment_bang_has_immutable_subcomponent,none,
"cannot assign through '!': %0", (StringRef))
-NOTE(change_to_mutating,sema_tcs,none,
+NOTE(change_to_mutating,none,
"mark %select{method|accessor}0 'mutating' to make 'self' mutable",
(bool))
+// For Stmt
+WARNING(deprecated_c_style_for_stmt,none,
+"C-style for statement is deprecated and will be removed in a future version of Swift", ())
+NOTE(cant_fix_c_style_for_stmt,none,
+"C-style for statement can't be automatically fixed to for-in, because the loop variable is modified inside the loop", ())
+
// ForEach Stmt
-ERROR(sequence_protocol_broken,sema_tcs,none,
+ERROR(sequence_protocol_broken,none,
"SequenceType protocol definition is broken", ())
-ERROR(generator_protocol_broken,sema_tcs,none,
+ERROR(generator_protocol_broken,none,
"GeneratorType protocol definition is broken", ())
-ERROR(label_shadowed,sema_tcs, none,
+ERROR(label_shadowed, none,
"label %0 cannot be reused on an inner statement", (Identifier))
-ERROR(break_outside_loop,sema_tcs,none,
+ERROR(break_outside_loop,none,
"'break' is only allowed inside a loop, if, do, or switch", ())
-ERROR(unlabeled_break_outside_loop,sema_tcs,none,
+ERROR(unlabeled_break_outside_loop,none,
"unlabeled 'break' is only allowed inside a loop or switch, a"
" labeled break is required to exit an if or do", ())
-ERROR(continue_outside_loop,sema_tcs,none,
+ERROR(continue_outside_loop,none,
"'continue' is only allowed inside a loop", ())
-ERROR(continue_not_in_this_stmt,sema_tcs,none,
+ERROR(continue_not_in_this_stmt,none,
"'continue' cannot be used with %0 statements", (StringRef))
// Switch Stmt
-ERROR(no_match_operator,sema_tcs,none,
+ERROR(no_match_operator,none,
"no binary '~=' operator available for 'switch' statement", ())
-ERROR(fallthrough_outside_switch,sema_tcs,none,
+ERROR(fallthrough_outside_switch,none,
"'fallthrough' is only allowed inside a switch", ())
-ERROR(fallthrough_from_last_case,sema_tcs,none,
+ERROR(fallthrough_from_last_case,none,
"'fallthrough' without a following 'case' or 'default' block", ())
-ERROR(fallthrough_into_case_with_var_binding,sema_tcs,none,
+ERROR(fallthrough_into_case_with_var_binding,none,
"'fallthrough' cannot transfer control to a case label that declares variables",
())
-ERROR(unnecessary_cast_over_optionset,sema_tcs,none,
+ERROR(unnecessary_cast_over_optionset,none,
"unnecessary cast over raw value of %0", (Type))
//------------------------------------------------------------------------------
// Type Check Patterns
//------------------------------------------------------------------------------
-ERROR(cannot_infer_type_for_pattern,sema_tcp,none,
+ERROR(cannot_infer_type_for_pattern,none,
"type annotation missing in pattern", ())
-ERROR(refutable_pattern_requires_initializer,sema_tcd,none,
+ERROR(refutable_pattern_requires_initializer,none,
"pattern matching requires an initializer value to match against", ())
-ERROR(invalid_pattern,sema_tcd,none,
+ERROR(invalid_pattern,none,
"invalid pattern", ())
-WARNING(var_pattern_didnt_bind_variables, sema_tcp,none,
+WARNING(var_pattern_didnt_bind_variables,none,
"'%0' pattern has no effect; sub-pattern didn't bind any variables",
(StringRef))
-ERROR(iflet_pattern_matching,sema_tcp,none,
+ERROR(iflet_pattern_matching,none,
"pattern matching in a condition requires the 'case' keyword", ())
-ERROR(iflet_implicitly_unwraps,sema_tcp,none,
+ERROR(iflet_implicitly_unwraps,none,
"pattern matching in a condition implicitly unwraps optionals", ())
-ERROR(type_pattern_missing_is,sema_tcp,none,
+ERROR(type_pattern_missing_is,none,
"'is' keyword required to pattern match against type name", ())
-ERROR(pattern_type_mismatch_context,sema_tcp,none,
+ERROR(pattern_type_mismatch_context,none,
"type annotation does not match contextual type %0", (Type))
-ERROR(label_single_entry_tuple,sema_tcp,none,
- "label is not allowed on single element tuple pattern", ())
-NOTE(remove_parens_for_type_annotation,sema_tcp,none,
- "remove the parentheses to make this a type annotation", ())
-NOTE(remove_label_for_tuple_pattern,sema_tcp,none,
- "remove the label to make this a tuple pattern", ())
-
-ERROR(tuple_pattern_in_non_tuple_context,sema_tcp,none,
+
+ERROR(tuple_pattern_in_non_tuple_context,none,
"tuple pattern cannot match values of the non-tuple type %0", (Type))
-ERROR(closure_argument_list_tuple,sema_tcp,none,
+ERROR(closure_argument_list_tuple,none,
"contextual closure type %0 expects %1 argument%s1, "
"but %2 were used in closure body", (Type, unsigned, unsigned))
-ERROR(closure_argument_list_missing,sema_tcp,none,
+ERROR(closure_argument_list_missing,none,
"contextual type for closure argument list expects %0 argument%s0, "
"which cannot be implicitly ignored", (unsigned))
-ERROR(tuple_pattern_length_mismatch,sema_tcp,none,
+ERROR(tuple_pattern_length_mismatch,none,
"tuple pattern has the wrong length for tuple type %0", (Type))
-ERROR(tuple_pattern_label_mismatch,sema_tcp,none,
+ERROR(tuple_pattern_label_mismatch,none,
"tuple pattern element label %0 must be %1", (Identifier, Identifier))
-ERROR(enum_element_pattern_member_not_found,sema_tcp,none,
+ERROR(enum_element_pattern_member_not_found,none,
"enum case '%0' not found in type %1", (StringRef, Type))
-ERROR(enum_element_pattern_not_enum,sema_tcp,none,
- "enum case pattern cannot match values of the non-enum type %0", (Type))
-ERROR(optional_element_pattern_not_valid_type,sema_tcp,none,
+ERROR(optional_element_pattern_not_valid_type,none,
"'?' pattern cannot match values of type %0", (Type))
-ERROR(condition_optional_element_pattern_not_valid_type,sema_tcp,none,
+ERROR(condition_optional_element_pattern_not_valid_type,none,
"initializer for conditional binding must have Optional type, not %0",
(Type))
-ERROR(enum_element_pattern_not_member_of_enum,sema_tcp,none,
+ERROR(enum_element_pattern_not_member_of_enum,none,
"enum case '%0' is not a member of type %1", (StringRef, Type))
-ERROR(nominal_type_pattern_not_nominal_type,sema_tcp,none,
+ERROR(nominal_type_pattern_not_nominal_type,none,
"non-nominal type %0 cannot be used with property pattern syntax", (Type))
-ERROR(nominal_type_pattern_type_mismatch,sema_tcp,none,
+ERROR(nominal_type_pattern_type_mismatch,none,
"type %0 of pattern does not match deduced type %1", (Type, Type))
-ERROR(nominal_type_pattern_property_not_found,sema_tcp,none,
+ERROR(nominal_type_pattern_property_not_found,none,
"property '%0' not found in type %1", (StringRef, Type))
-ERROR(nominal_type_pattern_property_ambiguous,sema_tcp,none,
+ERROR(nominal_type_pattern_property_ambiguous,none,
"property name '%0' in type %1 is ambiguous", (StringRef, Type))
-ERROR(nominal_type_pattern_not_property,sema_tcp,none,
+ERROR(nominal_type_pattern_not_property,none,
"member '%0' of type %1 is not a property", (StringRef, Type))
-ERROR(nominal_type_pattern_static_property,sema_tcp,none,
+ERROR(nominal_type_pattern_static_property,none,
"cannot match type property '%0' of type %1 in a 'case' pattern",
(StringRef, Type))
-ERROR(nominal_type_subpattern_without_property_name,pattern_parsing,none,
+ERROR(nominal_type_subpattern_without_property_name,none,
"subpattern of a struct or class pattern must have a keyword name", ())
-ERROR(ambiguous_enum_pattern_type,sema_tcp,none,
+ERROR(ambiguous_enum_pattern_type,none,
"generic enum type %0 is ambiguous without explicit generic parameters "
"when matching value of type %1", (Type, Type))
-WARNING(type_inferred_to_undesirable_type,sema_tcp,none,
+WARNING(type_inferred_to_undesirable_type,none,
"%select{variable|constant}2 %0 inferred to have type %1, "
"which may be unexpected", (Identifier, Type, bool))
-NOTE(add_explicit_type_annotation_to_silence,sema_tcp,none,
+NOTE(add_explicit_type_annotation_to_silence,none,
"add an explicit type annotation to silence this warning", ())
-ERROR(isa_pattern_value,sema_tcp,none,
+ERROR(isa_pattern_value,none,
"downcast pattern value of type %0 cannot be used", (Type))
//------------------------------------------------------------------------------
@@ -2114,190 +2180,184 @@ ERROR(isa_pattern_value,sema_tcp,none,
-ERROR(try_unhandled,sema,none,
+ERROR(try_unhandled,none,
"errors thrown from here are not handled", ())
-ERROR(throwing_call_unhandled,sema,none,
+ERROR(throwing_call_unhandled,none,
"call can throw, but the error is not handled", ())
-ERROR(tryless_throwing_call_unhandled,sema,none,
+ERROR(tryless_throwing_call_unhandled,none,
"call can throw, but it is not marked with 'try' and "
"the error is not handled", ())
-ERROR(throw_in_nonthrowing_function,sema,none,
+ERROR(throw_in_nonthrowing_function,none,
"error is not handled because the enclosing function "
"is not declared 'throws'", ())
-ERROR(throwing_call_in_rethrows_function,sema,none,
+ERROR(throwing_call_in_rethrows_function,none,
"call can throw, but the error is not handled; a function declared "
"'rethrows' may only throw if its parameter does", ())
-ERROR(tryless_throwing_call_in_rethrows_function,sema,none,
+ERROR(tryless_throwing_call_in_rethrows_function,none,
"call can throw, but it is not marked with 'try' and "
"the error is not handled; a function declared "
"'rethrows' may only throw if its parameter does", ())
-ERROR(throw_in_rethrows_function,sema,none,
+ERROR(throw_in_rethrows_function,none,
"a function declared 'rethrows' may only throw if its parameter does", ())
-NOTE(because_rethrows_argument_throws,sema,none,
+NOTE(because_rethrows_argument_throws,none,
"call is to 'rethrows' function, but argument function can throw", ())
-NOTE(because_rethrows_default_argument_throws,sema,none,
+NOTE(because_rethrows_default_argument_throws,none,
"call is to 'rethrows' function, but a defaulted argument function"
" can throw", ())
-ERROR(throwing_call_in_nonthrowing_autoclosure,sema,none,
+ERROR(throwing_call_in_nonthrowing_autoclosure,none,
"call can throw, but it is executed in a non-throwing "
"autoclosure",())
-ERROR(tryless_throwing_call_in_nonthrowing_autoclosure,sema,none,
+ERROR(tryless_throwing_call_in_nonthrowing_autoclosure,none,
"call can throw, but it is not marked with 'try' and "
"it is executed in a non-throwing autoclosure",())
-ERROR(throw_in_nonthrowing_autoclosure,sema,none,
+ERROR(throw_in_nonthrowing_autoclosure,none,
"error is not handled because it is thrown in a non-throwing "
"autoclosure", ())
-ERROR(try_unhandled_in_nonexhaustive_catch,sema,none,
+ERROR(try_unhandled_in_nonexhaustive_catch,none,
"errors thrown from here are not handled because the "
"enclosing catch is not exhaustive", ())
-ERROR(throwing_call_in_nonexhaustive_catch,sema,none,
+ERROR(throwing_call_in_nonexhaustive_catch,none,
"call can throw, but the enclosing catch is not exhaustive", ())
-ERROR(tryless_throwing_call_in_nonexhaustive_catch,sema,none,
+ERROR(tryless_throwing_call_in_nonexhaustive_catch,none,
"call can throw, but it is not marked with 'try' and "
"the enclosing catch is not exhaustive", ())
-ERROR(throw_in_nonexhaustive_catch,sema,none,
+ERROR(throw_in_nonexhaustive_catch,none,
"error is not handled because the enclosing catch is not exhaustive", ())
-ERROR(throwing_call_in_illegal_context,sema,none,
+ERROR(throwing_call_in_illegal_context,none,
"call can throw, but errors cannot be thrown out of %0",
(StringRef))
-ERROR(throw_in_illegal_context,sema,none,
+ERROR(throw_in_illegal_context,none,
"errors cannot be thrown out of %0", (StringRef))
-ERROR(throwing_operator_without_try,sema,none,
+ERROR(throwing_operator_without_try,none,
"operator can throw but expression is not marked with 'try'", ())
-ERROR(throwing_call_without_try,sema,none,
+ERROR(throwing_call_without_try,none,
"call can throw but is not marked with 'try'", ())
-WARNING(no_throw_in_try,sema,none,
+WARNING(no_throw_in_try,none,
"no calls to throwing functions occur within 'try' expression", ())
-WARNING(no_throw_in_do_with_catch,sema,none,
+WARNING(no_throw_in_do_with_catch,none,
"'catch' block is unreachable because no errors are thrown in 'do' block", ())
//------------------------------------------------------------------------------
// Type Check Types
//------------------------------------------------------------------------------
-ERROR(sugar_type_not_found,sema_tct,none,
+ERROR(sugar_type_not_found,none,
"broken standard library: cannot find "
"%select{Array|Optional|ImplicitlyUnwrappedOptional|Dictionary|"
"ErrorType}0 type", (unsigned))
-ERROR(optional_intrinsics_not_found,sema_tct,none,
+ERROR(optional_intrinsics_not_found,none,
"broken standard library: cannot find intrinsic operations on "
"Optional", ())
-ERROR(pointer_argument_intrinsics_not_found,sema_tct,none,
+ERROR(pointer_argument_intrinsics_not_found,none,
"broken standard library: cannot find intrinsic operations on "
"UnsafeMutablePointer", ())
-ERROR(array_literal_intrinsics_not_found,sema_tct,none,
+ERROR(array_literal_intrinsics_not_found,none,
"broken standard library: cannot find intrinsic operations on "
"Array", ())
-ERROR(bool_intrinsics_not_found,sema_tct,none,
+ERROR(bool_intrinsics_not_found,none,
"broken standard library: cannot find intrinsic operations on Bool", ())
-ERROR(self_in_nominal,sema_tct,none,
+ERROR(self_in_nominal,none,
"'Self' is only available in a protocol or as the result of a "
"method in a class; did you mean %0?", (Identifier))
-ERROR(class_super_access,sema_tcd,none,
+ERROR(class_super_access,none,
"class %select{must be declared %select{private|internal|PUBLIC}2"
"|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
"superclass is %select{private|internal|PUBLIC}2",
(bool, Accessibility, Accessibility))
-ERROR(dot_protocol_on_non_existential,sema_tct,none,
+ERROR(dot_protocol_on_non_existential,none,
"cannot use 'Protocol' with non-protocol type %0", (Type))
-ERROR(tuple_single_element,sema_tcd,none,
+ERROR(tuple_single_element,none,
"cannot create a single-element tuple with an element label", ())
-ERROR(tuple_ellipsis,sema_tcd,none,
+ERROR(tuple_ellipsis,none,
"cannot create a variadic tuple", ())
// Ownership
-ERROR(invalid_ownership_type,attribute_parsing,none,
+ERROR(invalid_ownership_type,none,
"'%select{strong|weak|unowned|unowned}0' may only be applied to "
"class and class-bound protocol types, not %1",
(/*Ownership*/unsigned, Type))
-ERROR(invalid_ownership_protocol_type,attribute_parsing,none,
+ERROR(invalid_ownership_protocol_type,none,
"'%select{strong|weak|unowned|unowned}0' may not be applied to "
"non-class-bound protocol %1; consider adding a class bound",
(/*Ownership*/unsigned, Type))
-ERROR(invalid_weak_ownership_not_optional,attribute_parsing,none,
+ERROR(invalid_weak_ownership_not_optional,none,
"'weak' variable should have optional type %0", (Type))
-ERROR(invalid_weak_let,attribute_parsing,none,
+ERROR(invalid_weak_let,none,
"'weak' must be a mutable variable, because it may change at runtime", ())
// required
-ERROR(required_initializer_nonclass,attribute_parsing,none,
+ERROR(required_initializer_nonclass,none,
"'required' initializer in non-class type %0", (Type))
-ERROR(required_initializer_in_extension,attribute_parsing,none,
+ERROR(required_initializer_in_extension,none,
"'required' initializer must be declared directly in class %0"
" (not in an extension)", (Type))
-ERROR(required_initializer_missing,attribute_parsing,none,
+ERROR(required_initializer_missing,none,
"'required' initializer %0 must be provided by subclass of %1",
(DeclName, Type))
-NOTE(required_initializer_here,sema_tcd,none,
+NOTE(required_initializer_here,none,
"'required' initializer is declared in superclass here", ())
-ERROR(required_initializer_not_accessible,sema_tcd,none,
+ERROR(required_initializer_not_accessible,none,
"'required' initializer must be as accessible as its enclosing type", ())
-ERROR(required_initializer_missing_keyword,sema_tcd,none,
+ERROR(required_initializer_missing_keyword,none,
"'required' modifier must be present on all overrides of a required "
"initializer", ())
-ERROR(required_initializer_override_wrong_keyword,sema_tcd,none,
+ERROR(required_initializer_override_wrong_keyword,none,
"use the 'required' modifier to override a required initializer", ())
-WARNING(required_initializer_override_keyword,sema_tcd,none,
+WARNING(required_initializer_override_keyword,none,
"'override' is implied when overriding a required initializer", ())
-NOTE(overridden_required_initializer_here,sema_tcd,none,
+NOTE(overridden_required_initializer_here,none,
"overridden required initializer is here", ())
// Functions
-ERROR(attribute_requires_function_type,attribute_parsing,none,
+ERROR(attribute_requires_function_type,none,
"attribute only applies to syntactic function types", ())
-ERROR(first_class_generic_function,type_parsing,PointsToFirstBadToken,
- "generic types cannot be used as first-class types", ())
-ERROR(objc_block_cannot_be_thin,attribute_parsing,none,
+ERROR(objc_block_cannot_be_thin,none,
"@objc_block function type cannot be @thin", ())
-ERROR(attribute_not_supported,attribute_parsing,none,
+ERROR(attribute_not_supported,none,
"this attribute is not supported", ())
-ERROR(convention_with_deprecated_representation_attribute,attribute_parsing,none,
+ERROR(convention_with_deprecated_representation_attribute,none,
"@convention attribute cannot be used with deprecated @%0 attribute",
(StringRef))
-ERROR(unsupported_convention,type_parsing,none,
+ERROR(unsupported_convention,none,
"convention '%0' not supported", (StringRef))
-ERROR(unreferenced_generic_parameter,type_parsing,none,
+ERROR(unreferenced_generic_parameter,none,
"generic parameter '%0' is not used in function signature", (StringRef))
-WARNING(deprecated_convention_attribute,type_parsing,none,
+WARNING(deprecated_convention_attribute,none,
"'@%0' attribute is deprecated; '@convention(%1)' should be used "
"instead", (StringRef, StringRef))
// SIL
-ERROR(sil_local_storage_nested, decl_parsing,none,
- "local storage types cannot be in nested positions", ())
-ERROR(opened_non_protocol, decl_parsing,none,
+ERROR(opened_non_protocol,none,
"@opened cannot be applied to non-protocol type %0", (Type))
-ERROR(sil_function_ellipsis,type_parsing,PointsToFirstBadToken,
+ERROR(sil_function_ellipsis,PointsToFirstBadToken,
"SIL function types cannot be variadic", ())
-ERROR(sil_function_label,type_parsing,PointsToFirstBadToken,
+ERROR(sil_function_label,PointsToFirstBadToken,
"SIL function types cannot have labeled inputs", ())
-ERROR(sil_function_repeat_convention,type_parsing,PointsToFirstBadToken,
+ERROR(sil_function_repeat_convention,PointsToFirstBadToken,
"repeated %select{parameter|result|callee}0 convention attribute",
(unsigned))
-ERROR(sil_function_multiple_results,type_parsing,PointsToFirstBadToken,
+ERROR(sil_function_multiple_results,PointsToFirstBadToken,
"SIL function types cannot have multiple results", ())
-ERROR(sil_function_multiple_error_results,type_parsing,PointsToFirstBadToken,
+ERROR(sil_function_multiple_error_results,PointsToFirstBadToken,
"SIL function types cannot have multiple @error results", ())
-ERROR(unsupported_cc_representation_combo,type_parsing,none,
- "cc unsupported with this sil representation", ())
-ERROR(unsupported_sil_convention,type_parsing,none,
+ERROR(unsupported_sil_convention,none,
"convention '%0' not supported in SIL", (StringRef))
-ERROR(sil_deprecated_convention_attribute,type_parsing,none,
+ERROR(sil_deprecated_convention_attribute,none,
"'@%0' attribute is deprecated; '@convention(%1)' must be used instead",
(StringRef, StringRef))
// SIL Metatypes
-ERROR(sil_metatype_without_repr,type_parsing,none,
+ERROR(sil_metatype_without_repr,none,
"metatypes in SIL must have @thin, @thick, or @objc_metatype attribute",
())
-ERROR(sil_metatype_multiple_reprs,type_parsing,none,
+ERROR(sil_metatype_multiple_reprs,none,
"metatypes in SIL can only be one of @thin, @thick, or @objc_metatype",
())
@@ -2305,192 +2365,195 @@ ERROR(sil_metatype_multiple_reprs,type_parsing,none,
// @objc and @nonobjc
//------------------------------------------------------------------------------
-ERROR(attr_used_without_required_module, sema_tcd, none,
+ERROR(attr_used_without_required_module, none,
"%0 attribute used without importing module %1",
(DeclAttribute, Identifier))
-ERROR(invalid_objc_decl_context,sema_tcd,none,
+ERROR(invalid_objc_decl_context,none,
"@objc can only be used with members of classes, @objc protocols, and "
"concrete extensions of classes", ())
-ERROR(invalid_objc_decl,sema_tcd,none,
+ERROR(invalid_objc_decl,none,
"only classes, protocols, methods, initializers, properties, and "
"subscript declarations can be declared @objc", ())
-ERROR(invalid_objc_swift_rooted_class,sema_tcd,none,
+ERROR(invalid_objc_swift_rooted_class,none,
"only classes that inherit from NSObject can be declared @objc", ())
-ERROR(invalid_nonobjc_decl,sema_tcd,none,
+ERROR(invalid_nonobjc_decl,none,
"only methods, initializers, properties and subscript declarations can "
"be declared @nonobjc", ())
-ERROR(objc_in_extension_context,sema_objc,none,
+ERROR(objc_in_extension_context,none,
"members of constrained extensions cannot be declared @objc", ())
-ERROR(objc_in_generic_extension,sema_objc,none,
+ERROR(objc_in_generic_extension,none,
"@objc is not supported within extensions of generic classes", ())
-ERROR(objc_for_generic_class,sema_objc,none,
+ERROR(objc_for_generic_class,none,
"generic subclasses of '@objc' classes cannot have an explicit '@objc' "
"attribute because they are not directly visible from Objective-C", ())
-ERROR(objc_getter_for_nonobjc_property,sema_tcd,none,
+ERROR(objc_getter_for_nonobjc_property,none,
"'@objc' getter for non-'@objc' property", ())
-ERROR(objc_getter_for_nonobjc_subscript,sema_tcd,none,
+ERROR(objc_getter_for_nonobjc_subscript,none,
"'@objc' getter for non-'@objc' subscript", ())
-ERROR(objc_setter_for_nonobjc_property,sema_tcd,none,
+ERROR(objc_setter_for_nonobjc_property,none,
"'@objc' setter for non-'@objc' property", ())
-ERROR(objc_setter_for_nonobjc_subscript,sema_tcd,none,
+ERROR(objc_setter_for_nonobjc_subscript,none,
"'@objc' setter for non-'@objc' subscript", ())
-ERROR(objc_enum_generic,sema_tcd,none,
+ERROR(objc_enum_generic,none,
"'@objc' enum cannot be generic", ())
-ERROR(objc_name_req_nullary,sema_objc,none,
- "'@objc' %select{class|protocol|property}0 must have a simple name", (int))
-ERROR(objc_name_enum,sema_objc,none,
- "'@objc' enum cannot have a name", ())
-ERROR(objc_name_subscript,sema_objc,none,
+ERROR(objc_name_req_nullary,none,
+ "'@objc' %select{class|protocol|enum|enum case|property}0 must have a simple name", (int))
+ERROR(objc_name_subscript,none,
"'@objc' subscript cannot have a name; did you mean to put "
"the name on the getter or setter?", ())
-ERROR(objc_name_func_mismatch,sema_objc,none,
+ERROR(objc_name_func_mismatch,none,
"'@objc' %select{initializer|method}0 name provides "
"%select{one argument name|names for %1 arguments}2, but "
"%select{initializer|method}0 has %select{one parameter|%3 parameters}4"
"%select{| (%select{|including }4the error parameter)}5",
(bool, unsigned, bool, unsigned, bool, bool))
+ERROR(objc_enum_case_req_name,none,
+ "attribute has no effect; cases within an '@objc' enum are already "
+ "exposed to Objective-C", ())
+ERROR(objc_enum_case_req_objc_enum,none,
+ "'@objc' enum case is not allowed outside of an '@objc' enum", ())
+ERROR(objc_enum_case_multi,none,
+ "'@objc' enum case declaration defines multiple enum cases with the same Objective-C name", ())
// If you change this, also change enum ObjCReason
#define OBJC_ATTR_SELECT "select{marked dynamic|marked @objc|marked @IBOutlet|marked @NSManaged|a member of an @objc protocol|implicitly @objc|an @objc override}"
-ERROR(objc_invalid_on_var,sema_objc,none,
+ERROR(objc_invalid_on_var,none,
"property cannot be %" OBJC_ATTR_SELECT "0 "
"because its type cannot be represented in Objective-C", (unsigned))
-ERROR(objc_invalid_subscript_key_type,sema_objc,none,
+ERROR(objc_invalid_subscript_key_type,none,
"subscript cannot be %" OBJC_ATTR_SELECT "0 because its key "
"type %1 is neither an integer nor an object", (unsigned, Type))
-ERROR(objc_invalid_on_subscript,sema_objc,none,
+ERROR(objc_invalid_on_subscript,none,
"subscript cannot be %" OBJC_ATTR_SELECT "0 because its type "
"cannot be represented in Objective-C", (unsigned))
-ERROR(objc_invalid_with_generic_params,sema_objc,none,
+ERROR(objc_invalid_with_generic_params,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because it has generic "
"parameters", (unsigned))
-ERROR(objc_convention_invalid,sema_objc,none,
+ERROR(objc_convention_invalid,none,
"%0 is not representable in Objective-C, so it cannot be used"
" with '@convention(%1)'", (Type, StringRef))
-NOTE(not_objc_empty_protocol_composition,sema_objc,none,
+NOTE(not_objc_empty_protocol_composition,none,
"'protocol<>' is not considered '@objc'; use 'AnyObject' instead", ())
-NOTE(not_objc_protocol,sema_objc,none,
+NOTE(not_objc_protocol,none,
"protocol %0 is not '@objc'", (Type))
-NOTE(not_objc_empty_tuple,sema_objc,none,
+NOTE(not_objc_empty_tuple,none,
"empty tuple type cannot be represented in Objective-C", ())
-NOTE(not_objc_tuple,sema_objc,none,
+NOTE(not_objc_tuple,none,
"tuples cannot be represented in Objective-C", ())
-NOTE(not_objc_swift_class,sema_objc,none,
+NOTE(not_objc_swift_class,none,
"classes not annotated with @objc cannot be represented "
"in Objective-C", ())
-NOTE(not_objc_swift_struct,sema_objc,none,
+NOTE(not_objc_swift_struct,none,
"Swift structs cannot be represented in Objective-C", ())
-NOTE(not_objc_swift_enum,sema_objc,none,
+NOTE(not_objc_swift_enum,none,
"non-'@objc' enums cannot be represented in Objective-C", ())
-NOTE(not_objc_generic_type_param,sema_objc,none,
+NOTE(not_objc_generic_type_param,none,
"generic type parameters cannot be represented in Objective-C", ())
-NOTE(not_objc_function_type_param,sema_objc,none,
+NOTE(not_objc_function_type_param,none,
"function types cannot be represented in Objective-C unless their "
"parameters and returns can be", ())
-NOTE(not_objc_function_type_throwing,sema_objc,none,
+NOTE(not_objc_function_type_throwing,none,
"throwing function types cannot be represented in Objective-C", ())
-NOTE(objc_inferring_on_objc_protocol_member,sema_objc,none,
+NOTE(objc_inferring_on_objc_protocol_member,none,
"inferring '@objc' because the declaration is a member of "
"an '@objc' protocol", ())
-NOTE(objc_overriding_objc_decl,sema_objc,none,
+NOTE(objc_overriding_objc_decl,none,
"overriding '@objc' %select{property|subscript|initializer|method}0 %1 "
"here", (unsigned, DeclName))
-ERROR(objc_invalid_on_func_curried,sema_objc,none,
+ERROR(objc_invalid_on_func_curried,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because curried functions "
"cannot be represented in Objective-C", (unsigned))
-ERROR(objc_observing_accessor,sema_objc, none,
+ERROR(objc_observing_accessor, none,
"observing accessors are not allowed to be marked @objc", ())
-ERROR(objc_invalid_on_func_variadic,sema_objc,none,
+ERROR(objc_invalid_on_func_variadic,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because it has a variadic "
"parameter", (unsigned))
-ERROR(objc_invalid_on_func_param_type,sema_objc,none,
+ERROR(objc_invalid_on_func_param_type,none,
"method cannot be %" OBJC_ATTR_SELECT "1 because the type of the "
"parameter %0 cannot be represented in Objective-C", (unsigned, unsigned))
-ERROR(objc_invalid_on_func_single_param_type,sema_objc,none,
+ERROR(objc_invalid_on_func_single_param_type,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because the type of the "
"parameter cannot be represented in Objective-C", (unsigned))
-ERROR(objc_invalid_on_func_result_type,sema_objc,none,
+ERROR(objc_invalid_on_func_result_type,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because its result type "
"cannot be represented in Objective-C", (unsigned))
-ERROR(objc_invalid_on_foreign_class,sema_objc,none,
+ERROR(objc_invalid_on_foreign_class,none,
"method cannot be %" OBJC_ATTR_SELECT "0 because Core Foundation "
"types are not classes in Objective-C", (unsigned))
-ERROR(objc_invalid_on_throwing_optional_result,sema_objc,none,
+ERROR(objc_invalid_on_throwing_optional_result,none,
"throwing method cannot be %" OBJC_ATTR_SELECT "0 because "
"it returns a value of optional type %1; 'nil' indicates failure to "
"Objective-C",
(unsigned, Type))
-ERROR(objc_invalid_on_throwing_result,sema_objc,none,
+ERROR(objc_invalid_on_throwing_result,none,
"throwing method cannot be %" OBJC_ATTR_SELECT "0 because "
"it returns a value of type %1; return 'Void' or a type that bridges "
"to an Objective-C class",
(unsigned, Type))
-ERROR(objc_invalid_on_failing_init,sema_objc,none,
+ERROR(objc_invalid_on_failing_init,none,
"a failable and throwing initializer cannot be "
"%" OBJC_ATTR_SELECT "0 because 'nil' indicates failure to Objective-C",
(unsigned))
-ERROR(objc_override_method_selector_mismatch,sema_objc,none,
+ERROR(objc_override_method_selector_mismatch,none,
"Objective-C method has a different selector from the "
"method it overrides (%0 vs. %1)", (ObjCSelector, ObjCSelector))
-ERROR(objc_override_property_name_mismatch,sema_objc,none,
+ERROR(objc_override_property_name_mismatch,none,
"Objective-C property has a different name from the "
"property it overrides (%0 vs. %1)", (Identifier, Identifier))
-ERROR(broken_bridged_to_objc_protocol,sema_tcd,none,
+ERROR(broken_bridged_to_objc_protocol,none,
"_BridgedToObjectiveC protocol is broken", ())
-ERROR(type_not_bridged,sema_objc,none,
- "%0 is not bridged to Objective-C", (Type))
-ERROR(missing_bridging_function,sema_objc,Fatal,
+ERROR(missing_bridging_function,Fatal,
"missing '%select{_forceBridgeFromObjectiveC|"
"_conditionallyBridgeFromObjectiveC}0'", (bool))
-ERROR(missing_nserror_bridging_function,sema_objc,none,
+ERROR(missing_nserror_bridging_function,none,
"missing _bridgeNSError", ())
#define OBJC_DIAG_SELECT "%select{initializer %1|implicit initializer %1|deinitializer|implicit deinitializer|method %1|getter for %1|subscript getter|setter for %1|subscript setter}0"
#define OBJC_DIAG_SELECT_2 "%select{initializer %3|implicit initializer %3|deinitializer|implicit deinitializer|method %3|getter for %3|subscript getter|setter for %3|subscript setter}2"
-ERROR(objc_redecl,sema_objc,none,
+ERROR(objc_redecl,none,
OBJC_DIAG_SELECT " with Objective-C selector %4 conflicts with "
OBJC_DIAG_SELECT_2 " with the same Objective-C selector",
(unsigned, DeclName, unsigned, DeclName, ObjCSelector))
-NOTE(objc_declared_here,sema_objc,none,
+NOTE(objc_declared_here,none,
OBJC_DIAG_SELECT " declared here",
(unsigned, DeclName))
-ERROR(objc_redecl_same,sema_objc,none,
+ERROR(objc_redecl_same,none,
OBJC_DIAG_SELECT " with Objective-C selector %2 conflicts with "
"previous declaration with the same Objective-C selector",
(unsigned, DeclName, ObjCSelector))
-ERROR(objc_override_other,sema_objc,none,
+ERROR(objc_override_other,none,
OBJC_DIAG_SELECT " with Objective-C selector %4 conflicts with "
OBJC_DIAG_SELECT_2 " from superclass %5 with the same Objective-C "
"selector",
(unsigned, DeclName, unsigned, DeclName, ObjCSelector, Type))
-ERROR(objc_class_method_not_permitted,sema_objc,none,
+ERROR(objc_class_method_not_permitted,none,
OBJC_DIAG_SELECT " defines Objective-C class method %2, which is "
"not permitted by Swift", (unsigned, DeclName, ObjCSelector))
-NOTE(objc_witness_selector_mismatch,sema_objc,none,
+NOTE(objc_witness_selector_mismatch,none,
"Objective-C method %2 provided by " OBJC_DIAG_SELECT
" does not match the requirement's selector (%3)",
(unsigned, DeclName, ObjCSelector, ObjCSelector))
-ERROR(objc_optional_requirement_conflict,sema_objc,none,
+ERROR(objc_optional_requirement_conflict,none,
"Objective-C method %4 provided by " OBJC_DIAG_SELECT
" conflicts with optional requirement " OBJC_DIAG_SELECT_2
" in protocol %5",
(unsigned, DeclName, unsigned, DeclName, ObjCSelector, DeclName))
-ERROR(nonobjc_not_allowed,sema_objc,none,
+ERROR(nonobjc_not_allowed,none,
"declaration is %" OBJC_ATTR_SELECT "0, and cannot be marked @nonobjc",
(unsigned))
@@ -2502,9 +2565,9 @@ ERROR(nonobjc_not_allowed,sema_objc,none,
// dynamic
//------------------------------------------------------------------------------
-ERROR(dynamic_not_in_class,sema_dynamic,none,
+ERROR(dynamic_not_in_class,none,
"only members of classes may be dynamic", ())
-ERROR(dynamic_with_final,sema_dynamic,none,
+ERROR(dynamic_with_final,none,
"a declaration cannot be both 'final' and 'dynamic'",
())
@@ -2512,154 +2575,154 @@ ERROR(dynamic_with_final,sema_dynamic,none,
// @available
//------------------------------------------------------------------------------
-ERROR(availability_decl_unavailable, sema_avail, none,
+ERROR(availability_decl_unavailable, none,
"%0 is unavailable", (DeclName))
-ERROR(availability_decl_unavailable_rename, sema_avail, none,
+ERROR(availability_decl_unavailable_rename, none,
"%0 has been renamed to '%1'", (DeclName, StringRef))
-ERROR(availability_decl_unavailable_rename_msg, sema_avail, none,
+ERROR(availability_decl_unavailable_rename_msg, none,
"%0 has been renamed to '%1': %2", (DeclName, StringRef, StringRef))
-ERROR(availability_decl_unavailable_msg, sema_avail, none,
+ERROR(availability_decl_unavailable_msg, none,
"%0 is unavailable: %1", (DeclName, StringRef))
-ERROR(availability_decl_unavailable_in_swift, sema_avail, none,
+ERROR(availability_decl_unavailable_in_swift, none,
"%0 is unavailable in Swift", (DeclName))
-ERROR(availability_decl_unavailable_in_swift_msg, sema_avail, none,
+ERROR(availability_decl_unavailable_in_swift_msg, none,
"%0 is unavailable in Swift: %1", (DeclName, StringRef))
-NOTE(availability_marked_unavailable, sema_avail, none,
+NOTE(availability_marked_unavailable, none,
"%0 has been explicitly marked unavailable here", (DeclName))
-NOTE(availability_obsoleted, sema_avail, none,
+NOTE(availability_obsoleted, none,
"%0 was obsoleted in %1 %2",
(DeclName, StringRef, clang::VersionTuple))
-WARNING(availability_deprecated, sema_avail, none,
+WARNING(availability_deprecated, none,
"%0 %select{is|%select{is|was}3}1 deprecated"
"%select{| %select{on|in}3 %2%select{| %4}3}1",
(DeclName, bool, StringRef, bool, clang::VersionTuple))
-WARNING(availability_deprecated_msg, sema_avail, none,
+WARNING(availability_deprecated_msg, none,
"%0 %select{is|%select{is|was}3}1 deprecated"
"%select{| %select{on|in}3 %2%select{| %4}3}1: %5",
(DeclName, bool, StringRef, bool, clang::VersionTuple, StringRef))
-WARNING(availability_deprecated_rename, sema_avail, none,
+WARNING(availability_deprecated_rename, none,
"%0 %select{is|%select{is|was}3}1 deprecated"
"%select{| %select{on|in}3 %2%select{| %4}3}1: renamed to '%5'",
(DeclName, bool, StringRef, bool, clang::VersionTuple, StringRef))
-NOTE(note_deprecated_rename, sema_avail, none,
+NOTE(note_deprecated_rename, none,
"use '%0' instead", (StringRef))
-ERROR(availability_decl_more_than_enclosing, sema_avail, none,
+ERROR(availability_decl_more_than_enclosing, none,
"declaration cannot be more available than enclosing scope", ())
-NOTE(availability_decl_more_than_enclosing_enclosing_here, sema_avail, none,
+NOTE(availability_decl_more_than_enclosing_enclosing_here, none,
"enclosing scope here", ())
-ERROR(availability_decl_only_version_newer, sema_avail, none,
+ERROR(availability_decl_only_version_newer, none,
"%0 is only available on %1 %2 or newer",
(DeclName, StringRef, clang::VersionTuple))
-NOTE(availability_guard_with_version_check, sema_avail, none,
+NOTE(availability_guard_with_version_check, none,
"add 'if #available' version check", ())
-NOTE(availability_add_attribute, sema_avail, none,
+NOTE(availability_add_attribute, none,
"add @available attribute to enclosing %0", (DescriptiveDeclKind))
-ERROR(availability_accessor_only_version_newer, sema_avail, none,
+ERROR(availability_accessor_only_version_newer, none,
"%select{getter|setter}0 for %1 is only available on %2 %3"
" or newer",
(/*AccessorKind*/unsigned, DeclName, StringRef, clang::VersionTuple))
-ERROR(availability_inout_accessor_only_version_newer, sema_avail, none,
+ERROR(availability_inout_accessor_only_version_newer, none,
"cannot pass as inout because %select{getter|setter}0 for %1 is only "
"available on %2 %3 or newer",
(/*AccessorKind*/unsigned, DeclName, StringRef, clang::VersionTuple))
-ERROR(availability_query_required_for_platform, sema_avail, none,
+ERROR(availability_query_required_for_platform, none,
"condition required for target platform '%0'", (StringRef))
-WARNING(availability_query_useless_min_deployment, sema_avail, none,
+WARNING(availability_query_useless_min_deployment, none,
"unnecessary check for '%0'; minimum deployment target ensures guard "
"will always be true", (StringRef))
-WARNING(availability_query_useless_enclosing_scope, sema_avail, none,
+WARNING(availability_query_useless_enclosing_scope, none,
"unnecessary check for '%0'; enclosing scope ensures guard "
"will always be true", (StringRef))
-NOTE(availability_query_useless_enclosing_scope_here, sema_avail, none,
+NOTE(availability_query_useless_enclosing_scope_here, none,
"enclosing scope here", ())
-ERROR(availability_global_script_no_potential, sema_avail,
+ERROR(availability_global_script_no_potential,
none, "global variable cannot be marked potentially "
"unavailable with '@available' in script mode", ())
-ERROR(availability_stored_property_no_potential, sema_avail,
+ERROR(availability_stored_property_no_potential,
none, "stored properties cannot be marked potentially unavailable with "
"'@available'", ())
-ERROR(availability_protocol_requires_version, sema_avail,
+ERROR(availability_protocol_requires_version,
none, "protocol %0 requires %1 to be available on %2 %3 and newer",
(DeclName, DeclName, StringRef, clang::VersionTuple))
-NOTE(availability_protocol_requirement_here, sema_avail, none,
+NOTE(availability_protocol_requirement_here, none,
"protocol requirement here", ())
-NOTE(availability_conformance_introduced_here, sema_avail, none,
+NOTE(availability_conformance_introduced_here, none,
"conformance introduced here", ())
//------------------------------------------------------------------------------
// Variable usage diagnostics
//------------------------------------------------------------------------------
-WARNING(pbd_never_used_stmtcond, sema_varusage, none,
+WARNING(pbd_never_used_stmtcond, none,
"value %0 was defined but never used; consider replacing "
"with boolean test",
(Identifier))
-WARNING(pbd_never_used, sema_varusage, none,
+WARNING(pbd_never_used, none,
"initialization of %select{variable|immutable value}1 %0 was never used"
"; consider replacing with assignment to '_' or removing it",
(Identifier, unsigned))
-WARNING(capture_never_used, sema_varusage, none,
+WARNING(capture_never_used, none,
"capture %0 was never used",
(Identifier))
-WARNING(variable_never_used, sema_varusage, none,
+WARNING(variable_never_used, none,
"%select{variable|immutable value}1 %0 was never used; "
"consider replacing with '_' or removing it",
(Identifier, unsigned))
-WARNING(variable_never_mutated, sema_varusage, none,
+WARNING(variable_never_mutated, none,
"%select{variable|parameter}1 %0 was never mutated; "
"consider changing to 'let' constant",
(Identifier, unsigned))
-WARNING(variable_never_read, sema_varusage, none,
+WARNING(variable_never_read, none,
"%select{variable|parameter}1 %0 was written to, but never read",
(Identifier, unsigned))
//------------------------------------------------------------------------------
// Naming convention diagnostics
//------------------------------------------------------------------------------
-WARNING(omit_needless_words, sema_tcd, none,
+WARNING(omit_needless_words, none,
"%0 could be named %1 [-Womit-needless-words]", (DeclName, DeclName))
-WARNING(extraneous_default_args_in_call, sema_tcd, none,
+WARNING(extraneous_default_args_in_call, none,
"call to %0 has extraneous arguments that could use defaults",
(DeclName))
//------------------------------------------------------------------------------
// Circular reference diagnostics
//------------------------------------------------------------------------------
-ERROR(circular_reference, sema_tcd, none,
+ERROR(circular_reference, none,
"circular reference", ())
-NOTE(circular_reference_through, sema_tcd, none,
+NOTE(circular_reference_through, none,
"through reference here", ())
#ifndef DIAG_NO_UNDEF
diff --git a/include/swift/AST/DiagnosticsSema.h b/include/swift/AST/DiagnosticsSema.h
index 1177807691734..d2cac6e713308 100644
--- a/include/swift/AST/DiagnosticsSema.h
+++ b/include/swift/AST/DiagnosticsSema.h
@@ -1,8 +1,8 @@
-//===- DiagnosticsSema.h - Diagnostic Definitions ---------------*- C++ -*-===//
+//===--- DiagnosticsSema.h - Diagnostic Definitions -------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
namespace diag {
- /// Describes the kind of requirement in a protocl.
+ /// Describes the kind of requirement in a protocol.
enum class RequirementKind : uint8_t {
Constructor,
Func,
@@ -32,7 +32,7 @@ namespace swift {
};
// Declare common diagnostics objects with their appropriate types.
-#define DIAG(KIND,ID,Category,Options,Text,Signature) \
+#define DIAG(KIND,ID,Options,Text,Signature) \
extern detail::DiagWithArguments::type ID;
#include "DiagnosticsSema.def"
}
diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h
index 4bc2a2f06980c..c7b0bfee6cf82 100644
--- a/include/swift/AST/Expr.h
+++ b/include/swift/AST/Expr.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -19,15 +19,10 @@
#include "swift/AST/CaptureInfo.h"
#include "swift/AST/ConcreteDeclRef.h"
-#include "swift/AST/DeclContext.h"
-#include "swift/AST/Identifier.h"
-#include "swift/AST/Substitution.h"
+#include "swift/AST/DeclNameLoc.h"
+#include "swift/AST/ProtocolConformanceRef.h"
#include "swift/AST/TypeLoc.h"
#include "swift/AST/Availability.h"
-#include "swift/Basic/SourceLoc.h"
-#include "swift/Config.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
namespace llvm {
struct fltSemantics;
@@ -49,11 +44,11 @@ namespace swift {
class Initializer;
class VarDecl;
class OpaqueValueExpr;
- class ProtocolConformance;
class FuncDecl;
class ConstructorDecl;
class TypeDecl;
class PatternBindingDecl;
+ class ParameterList;
enum class ExprKind : uint8_t {
#define EXPR(Id, Parent) Id,
@@ -758,7 +753,7 @@ class InterpolatedStringLiteralExpr : public LiteralExpr {
return Segments.front()->getStartLoc();
}
SourceLoc getEndLoc() const {
- return Segments.front()->getEndLoc();
+ return Segments.back()->getEndLoc();
}
static bool classof(const Expr *E) {
@@ -899,14 +894,14 @@ class DeclRefExpr : public Expr {
/// \brief The declaration pointer or SpecializeInfo pointer if it was
/// explicitly specialized with <...>.
llvm::PointerUnion DOrSpecialized;
- SourceLoc Loc;
+ DeclNameLoc Loc;
SpecializeInfo *getSpecInfo() const {
return DOrSpecialized.dyn_cast();
}
public:
- DeclRefExpr(ConcreteDeclRef D, SourceLoc Loc, bool Implicit,
+ DeclRefExpr(ConcreteDeclRef D, DeclNameLoc Loc, bool Implicit,
AccessSemantics semantics = AccessSemantics::Ordinary,
Type Ty = Type())
: Expr(ExprKind::DeclRef, Implicit, Ty), DOrSpecialized(D), Loc(Loc) {
@@ -949,8 +944,10 @@ class DeclRefExpr : public Expr {
return Spec->GenericArgs;
return ArrayRef();
}
- SourceRange getSourceRange() const { return Loc; }
-
+ SourceRange getSourceRange() const { return Loc.getSourceRange(); }
+ SourceLoc getLoc() const { return Loc.getBaseNameLoc(); }
+ DeclNameLoc getNameLoc() const { return Loc; }
+
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::DeclRef;
}
@@ -987,6 +984,10 @@ class TypeExpr : public Expr {
// Create a TypeExpr with location information.
TypeExpr(TypeLoc Ty);
+ // The type of a TypeExpr is always a metatype type. Return the instance
+ // type, ErrorType if an error, or null if not set yet.
+ Type getInstanceType() const;
+
// Create an implicit TypeExpr, which has no location information.
static TypeExpr *createImplicit(Type Ty, ASTContext &C) {
return new (C) TypeExpr(Ty);
@@ -999,7 +1000,8 @@ class TypeExpr : public Expr {
/// Return a TypeExpr for a TypeDecl and the specified location.
- static TypeExpr *createForDecl(SourceLoc Loc, TypeDecl *D);
+ static TypeExpr *createForDecl(SourceLoc Loc, TypeDecl *D,
+ bool isImplicit);
static TypeExpr *createForSpecializedDecl(SourceLoc Loc, TypeDecl *D,
ArrayRef args,
SourceRange angleLocs);
@@ -1026,10 +1028,10 @@ class TypeExpr : public Expr {
/// constructor' entry point referenced by a 'new' expression.
class OtherConstructorDeclRefExpr : public Expr {
ConcreteDeclRef Ctor;
- SourceLoc Loc;
+ DeclNameLoc Loc;
public:
- OtherConstructorDeclRefExpr(ConcreteDeclRef Ctor, SourceLoc Loc,
+ OtherConstructorDeclRefExpr(ConcreteDeclRef Ctor, DeclNameLoc Loc,
bool Implicit, Type Ty = {})
: Expr(ExprKind::OtherConstructorDeclRef, Implicit, Ty),
Ctor(Ctor), Loc(Loc)
@@ -1038,42 +1040,15 @@ class OtherConstructorDeclRefExpr : public Expr {
ConstructorDecl *getDecl() const;
ConcreteDeclRef getDeclRef() const { return Ctor; }
- SourceLoc getConstructorLoc() const { return Loc; }
- SourceRange getSourceRange() const { return Loc; }
+ SourceLoc getLoc() const { return Loc.getBaseNameLoc(); }
+ DeclNameLoc getConstructorLoc() const { return Loc; }
+ SourceRange getSourceRange() const { return Loc.getSourceRange(); }
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::OtherConstructorDeclRef;
}
};
-/// An unresolved reference to a constructor member of a value. Resolves to a
-/// DotSyntaxCall involving the value and the resolved constructor.
-class UnresolvedConstructorExpr : public Expr {
- Expr *SubExpr;
- SourceLoc DotLoc;
- SourceLoc ConstructorLoc;
-public:
- UnresolvedConstructorExpr(Expr *SubExpr, SourceLoc DotLoc,
- SourceLoc ConstructorLoc, bool Implicit)
- : Expr(ExprKind::UnresolvedConstructor, Implicit),
- SubExpr(SubExpr), DotLoc(DotLoc), ConstructorLoc(ConstructorLoc)
- {}
-
- Expr *getSubExpr() const { return SubExpr; }
- void setSubExpr(Expr *e) { SubExpr = e; }
-
- SourceLoc getLoc() const { return ConstructorLoc; }
- SourceLoc getConstructorLoc() const { return ConstructorLoc; }
- SourceLoc getDotLoc() const { return DotLoc; }
-
- SourceLoc getStartLoc() const { return SubExpr->getStartLoc(); }
- SourceLoc getEndLoc() const { return ConstructorLoc; }
-
- static bool classof(const Expr *E) {
- return E->getKind() == ExprKind::UnresolvedConstructor;
- }
-};
-
/// OverloadSetRefExpr - A reference to an overloaded set of values with a
/// single name.
///
@@ -1108,18 +1083,19 @@ class OverloadSetRefExpr : public Expr {
/// OverloadedDeclRefExpr - A reference to an overloaded name that should
/// eventually be resolved (by overload resolution) to a value reference.
class OverloadedDeclRefExpr : public OverloadSetRefExpr {
- SourceLoc Loc;
+ DeclNameLoc Loc;
bool IsSpecialized = false;
bool IsPotentiallyDelayedGlobalOperator = false;
public:
- OverloadedDeclRefExpr(ArrayRef Decls, SourceLoc Loc,
+ OverloadedDeclRefExpr(ArrayRef Decls, DeclNameLoc Loc,
bool Implicit, Type Ty = Type())
: OverloadSetRefExpr(ExprKind::OverloadedDeclRef, Decls, Implicit, Ty),
Loc(Loc) { }
- SourceLoc getLoc() const { return Loc; }
- SourceRange getSourceRange() const { return Loc; }
+ DeclNameLoc getNameLoc() const { return Loc; }
+ SourceLoc getLoc() const { return Loc.getBaseNameLoc(); }
+ SourceRange getSourceRange() const { return Loc.getSourceRange(); }
void setSpecialized(bool specialized) { IsSpecialized = specialized; }
@@ -1145,11 +1121,11 @@ class OverloadedDeclRefExpr : public OverloadSetRefExpr {
class OverloadedMemberRefExpr : public OverloadSetRefExpr {
Expr *SubExpr;
SourceLoc DotLoc;
- SourceLoc MemberLoc;
+ DeclNameLoc MemberLoc;
public:
OverloadedMemberRefExpr(Expr *SubExpr, SourceLoc DotLoc,
- ArrayRef Decls, SourceLoc MemberLoc,
+ ArrayRef Decls, DeclNameLoc MemberLoc,
bool Implicit, Type Ty = Type(),
AccessSemantics semantics = AccessSemantics::Ordinary)
: OverloadSetRefExpr(ExprKind::OverloadedMemberRef, Decls, Implicit, Ty),
@@ -1158,15 +1134,16 @@ class OverloadedMemberRefExpr : public OverloadSetRefExpr {
}
SourceLoc getDotLoc() const { return DotLoc; }
- SourceLoc getMemberLoc() const { return MemberLoc; }
+ DeclNameLoc getMemberLoc() const { return MemberLoc; }
Expr *getBase() const { return SubExpr; }
void setBase(Expr *E) { SubExpr = E; }
- SourceLoc getLoc() const { return MemberLoc; }
+ SourceLoc getLoc() const { return MemberLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const {
- return DotLoc.isValid()? SubExpr->getStartLoc() : MemberLoc;
+ return DotLoc.isValid()? SubExpr->getStartLoc()
+ : MemberLoc.getBaseNameLoc();
}
- SourceLoc getEndLoc() const { return MemberLoc; }
+ SourceLoc getEndLoc() const { return MemberLoc.getSourceRange().End; }
AccessSemantics getAccessSemantics() const {
return AccessSemantics(OverloadedMemberRefExprBits.Semantics);
@@ -1176,26 +1153,26 @@ class OverloadedMemberRefExpr : public OverloadSetRefExpr {
return E->getKind() == ExprKind::OverloadedMemberRef;
}
};
-
+
/// UnresolvedDeclRefExpr - This represents use of an undeclared identifier,
/// which may ultimately be a use of something that hasn't been defined yet, it
/// may be a use of something that got imported (which will be resolved during
/// sema), or may just be a use of an unknown identifier.
///
class UnresolvedDeclRefExpr : public Expr {
- Identifier Name;
- SourceLoc Loc;
+ DeclName Name;
+ DeclNameLoc Loc;
DeclRefKind RefKind;
bool IsSpecialized = false;
public:
- UnresolvedDeclRefExpr(Identifier name, DeclRefKind refKind, SourceLoc loc)
+ UnresolvedDeclRefExpr(DeclName name, DeclRefKind refKind, DeclNameLoc loc)
: Expr(ExprKind::UnresolvedDeclRef, /*Implicit=*/loc.isInvalid()),
Name(name), Loc(loc), RefKind(refKind) {
}
- bool hasName() const { return !Name.empty(); }
- Identifier getName() const { return Name; }
+ bool hasName() const { return static_cast(Name); }
+ DeclName getName() const { return Name; }
DeclRefKind getRefKind() const { return RefKind; }
void setSpecialized(bool specialized) { IsSpecialized = specialized; }
@@ -1204,7 +1181,9 @@ class UnresolvedDeclRefExpr : public Expr {
/// specialized by <...>.
bool isSpecialized() const { return IsSpecialized; }
- SourceRange getSourceRange() const { return Loc; }
+ DeclNameLoc getNameLoc() const { return Loc; }
+
+ SourceRange getSourceRange() const { return Loc.getSourceRange(); }
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::UnresolvedDeclRef;
@@ -1221,15 +1200,15 @@ class MemberRefExpr : public Expr {
Expr *Base;
ConcreteDeclRef Member;
SourceLoc DotLoc;
- SourceRange NameRange;
+ DeclNameLoc NameLoc;
public:
MemberRefExpr(Expr *base, SourceLoc dotLoc, ConcreteDeclRef member,
- SourceRange nameRange, bool Implicit,
+ DeclNameLoc loc, bool Implicit,
AccessSemantics semantics = AccessSemantics::Ordinary);
Expr *getBase() const { return Base; }
ConcreteDeclRef getMember() const { return Member; }
- SourceLoc getNameLoc() const { return NameRange.Start; }
+ DeclNameLoc getNameLoc() const { return NameLoc; }
SourceLoc getDotLoc() const { return DotLoc; }
void setBase(Expr *E) { Base = E; }
@@ -1248,17 +1227,17 @@ class MemberRefExpr : public Expr {
/// property.
void setIsSuper(bool isSuper) { MemberRefExprBits.IsSuper = isSuper; }
- SourceLoc getLoc() const { return NameRange.Start; }
+ SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const {
SourceLoc BaseStartLoc = Base->getStartLoc();
- if (BaseStartLoc.isInvalid() || NameRange.End.isInvalid()) {
- return NameRange.Start;
+ if (BaseStartLoc.isInvalid() || NameLoc.isInvalid()) {
+ return NameLoc.getBaseNameLoc();
} else {
return BaseStartLoc;
}
}
SourceLoc getEndLoc() const {
- return NameRange.End;
+ return NameLoc.getSourceRange().End;
}
static bool classof(const Expr *E) {
@@ -1299,12 +1278,12 @@ class DynamicMemberRefExpr : public DynamicLookupExpr {
Expr *Base;
ConcreteDeclRef Member;
SourceLoc DotLoc;
- SourceLoc NameLoc;
+ DeclNameLoc NameLoc;
public:
DynamicMemberRefExpr(Expr *base, SourceLoc dotLoc,
ConcreteDeclRef member,
- SourceLoc nameLoc)
+ DeclNameLoc nameLoc)
: DynamicLookupExpr(ExprKind::DynamicMemberRef),
Base(base), Member(member), DotLoc(dotLoc), NameLoc(nameLoc) {
}
@@ -1319,22 +1298,22 @@ class DynamicMemberRefExpr : public DynamicLookupExpr {
ConcreteDeclRef getMember() const { return Member; }
/// Retrieve the location of the member name.
- SourceLoc getNameLoc() const { return NameLoc; }
+ DeclNameLoc getNameLoc() const { return NameLoc; }
/// Retrieve the location of the '.'.
SourceLoc getDotLoc() const { return DotLoc; }
- SourceLoc getLoc() const { return NameLoc; }
+ SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const {
SourceLoc BaseStartLoc = Base->getStartLoc();
if (BaseStartLoc.isInvalid() || NameLoc.isInvalid()) {
- return NameLoc;
+ return NameLoc.getBaseNameLoc();
} else {
return BaseStartLoc;
}
}
- SourceLoc getEndLoc() const { return NameLoc; }
+ SourceLoc getEndLoc() const { return NameLoc.getSourceRange().End; }
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::DynamicMemberRef;
@@ -1401,28 +1380,28 @@ class DynamicSubscriptExpr : public DynamicLookupExpr {
/// bar.foo. These always have unresolved type.
class UnresolvedMemberExpr : public Expr {
SourceLoc DotLoc;
- SourceLoc NameLoc;
- Identifier Name;
+ DeclNameLoc NameLoc;
+ DeclName Name;
Expr *Argument;
public:
- UnresolvedMemberExpr(SourceLoc dotLoc, SourceLoc nameLoc,
- Identifier name, Expr *argument)
+ UnresolvedMemberExpr(SourceLoc dotLoc, DeclNameLoc nameLoc,
+ DeclName name, Expr *argument)
: Expr(ExprKind::UnresolvedMember, /*Implicit=*/false),
DotLoc(dotLoc), NameLoc(nameLoc), Name(name), Argument(argument) {
}
- Identifier getName() const { return Name; }
- SourceLoc getNameLoc() const { return NameLoc; }
+ DeclName getName() const { return Name; }
+ DeclNameLoc getNameLoc() const { return NameLoc; }
SourceLoc getDotLoc() const { return DotLoc; }
Expr *getArgument() const { return Argument; }
void setArgument(Expr *argument) { Argument = argument; }
- SourceLoc getLoc() const { return NameLoc; }
+ SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const { return DotLoc; }
SourceLoc getEndLoc() const {
- return (Argument ? Argument->getEndLoc() : NameLoc);
+ return (Argument ? Argument->getEndLoc() : NameLoc.getSourceRange().End);
}
static bool classof(const Expr *E) {
@@ -1898,91 +1877,35 @@ class SubscriptExpr : public Expr {
class UnresolvedDotExpr : public Expr {
Expr *SubExpr;
SourceLoc DotLoc;
- SourceLoc NameLoc;
- Identifier Name;
+ DeclNameLoc NameLoc;
+ DeclName Name;
public:
- UnresolvedDotExpr(Expr *subexpr, SourceLoc dotloc, Identifier name,
- SourceLoc nameloc, bool Implicit)
+ UnresolvedDotExpr(Expr *subexpr, SourceLoc dotloc, DeclName name,
+ DeclNameLoc nameloc, bool Implicit)
: Expr(ExprKind::UnresolvedDot, Implicit), SubExpr(subexpr), DotLoc(dotloc),
NameLoc(nameloc), Name(name) {}
- SourceLoc getLoc() const { return NameLoc; }
+ SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }
SourceLoc getStartLoc() const {
- return (DotLoc.isInvalid() ? NameLoc : SubExpr->getStartLoc());
+ return (DotLoc.isInvalid() ? NameLoc.getSourceRange().End
+ : SubExpr->getStartLoc());
+ }
+ SourceLoc getEndLoc() const {
+ return NameLoc.getSourceRange().End ;
}
- SourceLoc getEndLoc() const { return NameLoc; }
SourceLoc getDotLoc() const { return DotLoc; }
Expr *getBase() const { return SubExpr; }
void setBase(Expr *e) { SubExpr = e; }
- Identifier getName() const { return Name; }
- SourceLoc getNameLoc() const { return NameLoc; }
+ DeclName getName() const { return Name; }
+ DeclNameLoc getNameLoc() const { return NameLoc; }
static bool classof(const Expr *E) {
return E->getKind() == ExprKind::UnresolvedDot;
}
};
-
-/// A selector-style member access (foo.bar:bas:) on an expression with
-/// unresolved type.
-class UnresolvedSelectorExpr : public Expr {
-public:
- // A selector component.
- struct ComponentLoc {
- SourceLoc NameLoc;
- SourceLoc ColonLoc;
- };
-
-private:
- Expr *SubExpr;
- SourceLoc DotLoc;
- DeclName Name;
-
- MutableArrayRef getComponentsBuf() {
- return {reinterpret_cast(this+1),
- Name.getArgumentNames().size() + 1};
- }
-
- UnresolvedSelectorExpr(Expr *subExpr, SourceLoc dotLoc,
- DeclName name,
- ArrayRef components);
-
-public:
- static UnresolvedSelectorExpr *create(ASTContext &C,
- Expr *subExpr,
- SourceLoc dotLoc,
- DeclName name,
- ArrayRef components);
-
- ArrayRef getComponentLocs() const {
- return {reinterpret_cast(this+1),
- Name.getArgumentNames().size() + 1};
- }
-
- SourceLoc getLoc() const {
- return getComponentLocs().front().NameLoc;
- }
-
- SourceLoc getStartLoc() const { return SubExpr->getStartLoc(); }
- SourceLoc getEndLoc() const { return getComponentLocs().back().ColonLoc; }
-
- SourceLoc getDotLoc() const { return DotLoc; }
- Expr *getBase() const { return SubExpr; }
- void setBase(Expr *e) { SubExpr = e; }
-
- SourceRange getNameRange() const {
- return {getComponentLocs().front().NameLoc,
- getComponentLocs().back().ColonLoc};
- }
-
- DeclName getName() const { return Name; }
-
- static bool classof(const Expr *E) {
- return E->getKind() == ExprKind::UnresolvedSelector;
- }
-};
/// TupleElementExpr - Refer to an element of a tuple,
/// e.g. "(1,field:2).field".
@@ -2561,11 +2484,11 @@ class CollectionUpcastConversionExpr : public ImplicitConversionExpr {
/// "Appropriate kind" means e.g. a concrete/existential metatype if the
/// result is an existential metatype.
class ErasureExpr : public ImplicitConversionExpr {
- ArrayRef Conformances;
+ ArrayRef Conformances;
public:
ErasureExpr(Expr *subExpr, Type type,
- ArrayRef conformances)
+ ArrayRef conformances)
: ImplicitConversionExpr(ExprKind::Erasure, subExpr, type),
Conformances(conformances) {}
@@ -2579,7 +2502,7 @@ class ErasureExpr : public ImplicitConversionExpr {
/// to the corresponding protocol is trivial (because the source
/// type is either an archetype or an existential type that conforms to
/// that corresponding protocol).
- ArrayRef getConformances() const {
+ ArrayRef getConformances() const {
return Conformances;
}
@@ -2775,14 +2698,14 @@ class AbstractClosureExpr : public Expr, public DeclContext {
CaptureInfo Captures;
/// \brief The set of parameters.
- Pattern *ParamPattern;
+ ParameterList *parameterList;
public:
AbstractClosureExpr(ExprKind Kind, Type FnType, bool Implicit,
unsigned Discriminator, DeclContext *Parent)
: Expr(Kind, Implicit, FnType),
DeclContext(DeclContextKind::AbstractClosureExpr, Parent),
- ParamPattern(nullptr) {
+ parameterList(nullptr) {
AbstractClosureExprBits.Discriminator = Discriminator;
}
@@ -2790,9 +2713,9 @@ class AbstractClosureExpr : public Expr, public DeclContext {
const CaptureInfo &getCaptureInfo() const { return Captures; }
/// \brief Retrieve the parameters of this closure.
- Pattern *getParams() { return ParamPattern; }
- const Pattern *getParams() const { return ParamPattern; }
- void setParams(Pattern *P);
+ ParameterList *getParameters() { return parameterList; }
+ const ParameterList *getParameters() const { return parameterList; }
+ void setParameterList(ParameterList *P);
// Expose this to users.
using DeclContext::setParent;
@@ -2825,11 +2748,12 @@ class AbstractClosureExpr : public Expr, public DeclContext {
decltype(AbstractClosureExprBits)::InvalidDiscriminator
};
- ArrayRef getParamPatterns() {
- return ParamPattern ? ParamPattern : ArrayRef ();
+ ArrayRef getParameterLists() {
+ return parameterList ? parameterList : ArrayRef();
}
- ArrayRef getParamPatterns() const {
- return ParamPattern ? ParamPattern : ArrayRef ();
+
+ ArrayRef getParameterLists() const {
+ return parameterList ? parameterList : ArrayRef();
}
unsigned getNaturalArgumentCount() const { return 1; }
@@ -2921,7 +2845,7 @@ class ClosureExpr : public AbstractClosureExpr {
llvm::PointerIntPair Body;
public:
- ClosureExpr(Pattern *params, SourceLoc throwsLoc, SourceLoc arrowLoc,
+ ClosureExpr(ParameterList *params, SourceLoc throwsLoc, SourceLoc arrowLoc,
SourceLoc inLoc, TypeLoc explicitResultType,
unsigned discriminator, DeclContext *parent)
: AbstractClosureExpr(ExprKind::Closure, Type(), /*Implicit=*/false,
@@ -2929,7 +2853,7 @@ class ClosureExpr : public AbstractClosureExpr {
ThrowsLoc(throwsLoc), ArrowLoc(arrowLoc), InLoc(inLoc),
ExplicitResultType(explicitResultType),
Body(nullptr) {
- setParams(params);
+ setParameterList(params);
ClosureExprBits.HasAnonymousClosureVars = false;
ClosureExprBits.IsVoidConversionClosure = false;
}
@@ -3048,7 +2972,7 @@ class ClosureExpr : public AbstractClosureExpr {
/// \brief This is a closure of the contained subexpression that is formed
-/// when an scalar expression is converted to @autoclosure function type.
+/// when a scalar expression is converted to @autoclosure function type.
/// For example:
/// \code
/// @autoclosure var x : () -> Int = 4
@@ -3094,7 +3018,7 @@ class AutoClosureExpr : public AbstractClosureExpr {
/// DynamicTypeExpr - "base.dynamicType" - Produces a metatype value.
///
-/// The metatype value can comes from a evaluating an expression and then
+/// The metatype value can comes from evaluating an expression and then
/// getting its metatype.
class DynamicTypeExpr : public Expr {
Expr *Base;
@@ -3771,6 +3695,44 @@ class EditorPlaceholderExpr : public Expr {
void setSemanticExpr(Expr *SE) { SemanticExpr = SE; }
};
+/// Produces the Objective-C selector of the referenced method.
+///
+/// \code
+/// #selector(UIView.insertSubview(_:aboveSubview:))
+/// \endcode
+class ObjCSelectorExpr : public Expr {
+ SourceLoc KeywordLoc;
+ SourceLoc LParenLoc;
+ Expr *SubExpr;
+ SourceLoc RParenLoc;
+ AbstractFunctionDecl *Method = nullptr;
+
+public:
+ ObjCSelectorExpr(SourceLoc keywordLoc, SourceLoc lParenLoc,
+ Expr *subExpr, SourceLoc rParenLoc)
+ : Expr(ExprKind::ObjCSelector, /*Implicit=*/false),
+ KeywordLoc(keywordLoc), LParenLoc(lParenLoc), SubExpr(subExpr),
+ RParenLoc(rParenLoc) { }
+
+ Expr *getSubExpr() const { return SubExpr; }
+ void setSubExpr(Expr *expr) { SubExpr = expr; }
+
+ /// Retrieve the Objective-C method to which this expression refers.
+ AbstractFunctionDecl *getMethod() const { return Method; }
+
+ /// Set the Objective-C method to which this expression refers.
+ void setMethod(AbstractFunctionDecl *method) { Method = method; }
+
+ SourceLoc getLoc() const { return KeywordLoc; }
+ SourceRange getSourceRange() const {
+ return SourceRange(KeywordLoc, RParenLoc);
+ }
+
+ static bool classof(const Expr *E) {
+ return E->getKind() == ExprKind::ObjCSelector;
+ }
+};
+
#undef SWIFT_FORWARD_SOURCE_LOCS_TO
} // end namespace swift
diff --git a/include/swift/AST/ExprHandle.h b/include/swift/AST/ExprHandle.h
index 3b3a1d7aa3aad..6c4b8930d25a6 100644
--- a/include/swift/AST/ExprHandle.h
+++ b/include/swift/AST/ExprHandle.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -26,7 +26,7 @@ namespace swift {
/// ExprHandle - Provides an indirection for expressions, so both a type and a
/// pattern can point at the same expression during type-checking.
-class ExprHandle {
+class alignas(8) ExprHandle {
/// \brief The expression along with a bit saying whether this expression
/// was already type-checked (or not).
llvm::PointerIntPair EAndChecked;
diff --git a/include/swift/AST/ExprNodes.def b/include/swift/AST/ExprNodes.def
index a76815e53a44b..66387b964003b 100644
--- a/include/swift/AST/ExprNodes.def
+++ b/include/swift/AST/ExprNodes.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -64,7 +64,6 @@ EXPR(DeclRef, Expr)
EXPR(SuperRef, Expr)
EXPR(Type, Expr)
EXPR(OtherConstructorDeclRef, Expr)
-UNCHECKED_EXPR(UnresolvedConstructor, Expr)
EXPR(DotSyntaxBaseIgnored, Expr)
ABSTRACT_EXPR(OverloadSetRef, Expr)
UNCHECKED_EXPR(OverloadedDeclRef, OverloadSetRefExpr)
@@ -79,7 +78,6 @@ ABSTRACT_EXPR(DynamicLookup, Expr)
UNCHECKED_EXPR(UnresolvedSpecialize, Expr)
UNCHECKED_EXPR(UnresolvedMember, Expr)
UNCHECKED_EXPR(UnresolvedDot, Expr)
-UNCHECKED_EXPR(UnresolvedSelector, Expr)
UNCHECKED_EXPR(Sequence, Expr)
ABSTRACT_EXPR(Identity, Expr)
EXPR(Paren, IdentityExpr)
@@ -157,6 +155,7 @@ EXPR(DefaultValue, Expr)
EXPR(CodeCompletion, Expr)
UNCHECKED_EXPR(UnresolvedPattern, Expr)
EXPR(EditorPlaceholder, Expr)
+EXPR(ObjCSelector, Expr)
#undef EXPR_RANGE
#undef UNCHECKED_EXPR
diff --git a/include/swift/AST/ForeignErrorConvention.h b/include/swift/AST/ForeignErrorConvention.h
index f50ad66b78015..c9023bc4f0137 100644
--- a/include/swift/AST/ForeignErrorConvention.h
+++ b/include/swift/AST/ForeignErrorConvention.h
@@ -1,8 +1,8 @@
-//===--- ForeignErrorConvention.h - Error conventions ----------*- C++ -*-===//
+//===--- ForeignErrorConvention.h - Error conventions -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/GenericSignature.h b/include/swift/AST/GenericSignature.h
index 4ba3fbd3a3a9f..6505f9c70de26 100644
--- a/include/swift/AST/GenericSignature.h
+++ b/include/swift/AST/GenericSignature.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -101,7 +101,7 @@ class GenericSignature : public llvm::FoldingSetNode {
NumGenericParams };
}
- /// Retrieve a mutable verison of the requirements.
+ /// Retrieve a mutable version of the requirements.
MutableArrayRef getRequirementsBuffer() {
void *genericParams = getGenericParamsBuffer().end();
return { reinterpret_cast(genericParams),
diff --git a/include/swift/AST/IRGenOptions.h b/include/swift/AST/IRGenOptions.h
index 2a8b536bcb861..2a6691ad2a9fb 100644
--- a/include/swift/AST/IRGenOptions.h
+++ b/include/swift/AST/IRGenOptions.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -126,8 +126,15 @@ class IRGenOptions {
/// Whether we should embed the bitcode file.
IRGenEmbedMode EmbedMode : 2;
- /// For resilient access to super's members for testing.
- unsigned ForceResilientSuperDispatch: 1;
+ /// Add names to LLVM values.
+ unsigned HasValueNamesSetting : 1;
+ unsigned ValueNames : 1;
+
+ /// Only strip the field names section from nominal type field metadata.
+ unsigned StripFieldNames : 1;
+
+ /// Strip all nominal type field metadata.
+ unsigned StripFieldMetadata : 1;
/// List of backend command-line options for -embed-bitcode.
std::vector CmdArgs;
@@ -139,9 +146,10 @@ class IRGenOptions {
DisableFPElim(true), Playground(false),
EmitStackPromotionChecks(false), GenerateProfile(false),
EmbedMode(IRGenEmbedMode::None),
- ForceResilientSuperDispatch(false)
+ HasValueNamesSetting(false), ValueNames(false),
+ StripFieldNames(false), StripFieldMetadata(false)
{}
-
+
/// Gets the name of the specified output filename.
/// If multiple files are specified, the last one is returned.
StringRef getSingleOutputFilename() const {
diff --git a/include/swift/AST/Identifier.h b/include/swift/AST/Identifier.h
index 7cdc01d263ed1..c6a7631e27555 100644
--- a/include/swift/AST/Identifier.h
+++ b/include/swift/AST/Identifier.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -18,12 +18,8 @@
#define SWIFT_AST_IDENTIFIER_H
#include "swift/Basic/LLVM.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/StringRef.h"
-#include
namespace llvm {
class raw_ostream;
@@ -31,6 +27,7 @@ namespace llvm {
namespace swift {
class ASTContext;
+ class ParameterList;
/// DeclRefKind - The kind of reference to an identifier.
enum class DeclRefKind {
@@ -109,9 +106,6 @@ class Identifier {
/// isOperatorContinuationCodePoint - Return true if the specified code point
/// is a valid operator code point.
static bool isOperatorContinuationCodePoint(uint32_t C) {
- // '.' is a special case. It can only appear in '..'.
- if (C == '.')
- return false;
if (isOperatorStartCodePoint(C))
return true;
@@ -124,8 +118,12 @@ class Identifier {
|| (C >= 0xE0100 && C <= 0xE01EF);
}
+ static bool isEditorPlaceholder(StringRef name) {
+ return name.startswith("<#");
+ }
+
bool isEditorPlaceholder() const {
- return !empty() && Pointer[0] == '<' && Pointer[1] == '#';
+ return !empty() && isEditorPlaceholder(str());
}
void *getAsOpaquePointer() const { return (void *)Pointer; }
@@ -246,6 +244,9 @@ class DeclName {
: SimpleOrCompound(decltype(SimpleOrCompound)::getFromOpaqueValue(Opaque))
{}
+ void initialize(ASTContext &C, Identifier baseName,
+ ArrayRef argumentNames);
+
public:
/// Build a null name.
DeclName() : SimpleOrCompound(IdentifierAndCompound()) {}
@@ -256,9 +257,15 @@ class DeclName {
/// Build a compound value name given a base name and a set of argument names.
DeclName(ASTContext &C, Identifier baseName,
- ArrayRef argumentNames);
+ ArrayRef argumentNames) {
+ initialize(C, baseName, argumentNames);
+ }
+
+ /// Build a compound value name given a base name and a set of argument names
+ /// extracted from a parameter list.
+ DeclName(ASTContext &C, Identifier baseName, ParameterList *paramList);
- /// Retrive the 'base' name, i.e., the name that follows the introducer,
+ /// Retrieve the 'base' name, i.e., the name that follows the introducer,
/// such as the 'foo' in 'func foo(x:Int, y:Int)' or the 'bar' in
/// 'var bar: Int'.
Identifier getBaseName() const {
@@ -374,6 +381,14 @@ class DeclName {
void *getOpaqueValue() const { return SimpleOrCompound.getOpaqueValue(); }
static DeclName getFromOpaqueValue(void *p) { return DeclName(p); }
+ /// Print the representation of this declaration name to the given
+ /// stream.
+ ///
+ /// \param skipEmptyArgumentNames When true, don't print the argument labels
+ /// if they are all empty.
+ llvm::raw_ostream &print(llvm::raw_ostream &os,
+ bool skipEmptyArgumentNames = false) const;
+
/// Print a "pretty" representation of this declaration name to the given
/// stream.
///
diff --git a/include/swift/AST/Initializer.h b/include/swift/AST/Initializer.h
index 29039412b36b6..f757c9525743f 100644
--- a/include/swift/AST/Initializer.h
+++ b/include/swift/AST/Initializer.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/KnownDecls.def b/include/swift/AST/KnownDecls.def
index a8483d202d7ce..524d0f1478ba4 100644
--- a/include/swift/AST/KnownDecls.def
+++ b/include/swift/AST/KnownDecls.def
@@ -1,8 +1,8 @@
-//===-- KnownDecl.def - Compiler declaration metaprogramming ----*- C++ -*-===//
+//===--- KnownDecls.def - Compiler declaration metaprogramming --*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/KnownFoundationEntities.def b/include/swift/AST/KnownFoundationEntities.def
new file mode 100644
index 0000000000000..c5f72d04fae98
--- /dev/null
+++ b/include/swift/AST/KnownFoundationEntities.def
@@ -0,0 +1,38 @@
+//===--- KnownFoundationEntities.def - Objective-C Foundation ---*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines macros used for macro-metaprogramming with
+// compiler-known entities in the Objective-C Foundation module (and
+// the ObjectiveC module it depends on).
+//
+//===----------------------------------------------------------------------===//
+#ifndef FOUNDATION_ENTITY
+# error define FOUNDATION_ENTITY(Name)
+#endif
+
+FOUNDATION_ENTITY(NSArray)
+FOUNDATION_ENTITY(NSCopying)
+FOUNDATION_ENTITY(NSDictionary)
+FOUNDATION_ENTITY(NSError)
+FOUNDATION_ENTITY(NSErrorPointer)
+FOUNDATION_ENTITY(NSInteger)
+FOUNDATION_ENTITY(NSNumber)
+FOUNDATION_ENTITY(NSObject)
+FOUNDATION_ENTITY(NSRange)
+FOUNDATION_ENTITY(NSSet)
+FOUNDATION_ENTITY(NSString)
+FOUNDATION_ENTITY(NSStringEncoding)
+FOUNDATION_ENTITY(NSUInteger)
+FOUNDATION_ENTITY(NSURL)
+FOUNDATION_ENTITY(NSZone)
+
+#undef FOUNDATION_ENTITY
diff --git a/include/swift/AST/KnownIdentifiers.def b/include/swift/AST/KnownIdentifiers.def
index 341249c1d6f88..419c3582016ef 100644
--- a/include/swift/AST/KnownIdentifiers.def
+++ b/include/swift/AST/KnownIdentifiers.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -24,6 +24,7 @@
IDENTIFIER(alloc)
IDENTIFIER(allocWithZone)
+IDENTIFIER(allZeros)
IDENTIFIER(atIndexedSubscript)
IDENTIFIER_(bridgeToObjectiveC)
IDENTIFIER_WITH_NAME(code_, "_code")
@@ -42,9 +43,7 @@ IDENTIFIER(hashValue)
IDENTIFIER(init)
IDENTIFIER(load)
IDENTIFIER(next)
-IDENTIFIER(NSError)
IDENTIFIER_(NSErrorDomain)
-IDENTIFIER(NSObject)
IDENTIFIER(objectAtIndexedSubscript)
IDENTIFIER(objectForKeyedSubscript)
IDENTIFIER(ObjectiveC)
@@ -52,6 +51,7 @@ IDENTIFIER_(OptionalNilComparisonType)
IDENTIFIER(Protocol)
IDENTIFIER(rawValue)
IDENTIFIER(RawValue)
+IDENTIFIER(Selector)
IDENTIFIER(self)
IDENTIFIER(Self)
IDENTIFIER(setObject)
diff --git a/include/swift/AST/KnownProtocols.def b/include/swift/AST/KnownProtocols.def
index 1669808d3bd86..615f9d6bd4c65 100644
--- a/include/swift/AST/KnownProtocols.def
+++ b/include/swift/AST/KnownProtocols.def
@@ -1,8 +1,8 @@
-//===-- KnownProtocols.def - Compiler protocol metaprogramming --*- C++ -*-===//
+//===--- KnownProtocols.def - Compiler protocol metaprogramming -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/KnownProtocols.h b/include/swift/AST/KnownProtocols.h
index a2554fcebf1df..18cd1cb85b0a7 100644
--- a/include/swift/AST/KnownProtocols.h
+++ b/include/swift/AST/KnownProtocols.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/LazyResolver.h b/include/swift/AST/LazyResolver.h
index 3320491f108fa..42ac0d8cc8821 100644
--- a/include/swift/AST/LazyResolver.h
+++ b/include/swift/AST/LazyResolver.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -129,12 +129,8 @@ class alignas(void*) LazyMemberLoader {
/// Populates the given vector with all member decls for \p D.
///
/// The implementation should add the members to D.
- ///
- /// \param[out] hasMissingRequiredMembers If present, set to true if any
- /// members failed to import and were non-optional protocol requirements.
virtual void
- loadAllMembers(Decl *D, uint64_t contextData,
- bool *hasMissingRequiredMembers = nullptr) {
+ loadAllMembers(Decl *D, uint64_t contextData) {
llvm_unreachable("unimplemented");
}
diff --git a/include/swift/AST/LinkLibrary.h b/include/swift/AST/LinkLibrary.h
index df359296a9441..62724a8dd3f1c 100644
--- a/include/swift/AST/LinkLibrary.h
+++ b/include/swift/AST/LinkLibrary.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/Mangle.h b/include/swift/AST/Mangle.h
index 35e01c711bb72..ad2868d83fa3a 100644
--- a/include/swift/AST/Mangle.h
+++ b/include/swift/AST/Mangle.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -17,7 +17,6 @@
#include "swift/AST/Types.h"
#include "swift/AST/Decl.h"
#include "swift/AST/GenericSignature.h"
-#include "swift/AST/ResilienceExpansion.h"
namespace swift {
@@ -34,17 +33,19 @@ enum class OperatorFixity {
Postfix
};
-/// Defined in include/swift/SIL/Mangle.h
-class SpecializationManglerBase;
-/// A class for mangling declarations.
+/// A class for mangling declarations. The Mangler accumulates name fragments
+/// with the mangleXXX methods, and the final string is constructed with the
+/// `finalize` method, after which the Mangler should not be used.
class Mangler {
struct ArchetypeInfo {
unsigned Depth;
unsigned Index;
};
- raw_ostream &Buffer;
+ llvm::SmallVector Storage;
+ llvm::raw_svector_ostream Buffer;
+
llvm::DenseMap Substitutions;
llvm::DenseMap Archetypes;
CanGenericSignature CurGenericSignature;
@@ -56,8 +57,6 @@ class Mangler {
/// If enabled, non-ASCII names are encoded in modified Punycode.
bool UsePunycode;
- friend class SpecializationManglerBase;
-
public:
enum BindGenerics : unsigned {
/// We don't intend to mangle any sort of type within this context
@@ -88,49 +87,48 @@ class Mangler {
~ContextStack() { M.ArchetypesDepth = OldDepth; }
};
+ /// Finish the mangling of the symbol and return the mangled name.
+ std::string finalize();
+
+ /// Finish the mangling of the symbol and write the mangled name into
+ /// \p stream.
+ void finalize(llvm::raw_ostream &stream);
+
void setModuleContext(ModuleDecl *M) { Mod = M; }
/// \param DWARFMangling - use the 'Qq' mangling format for
/// archetypes and the 'a' mangling for alias types.
/// \param usePunycode - emit modified Punycode instead of UTF-8.
- Mangler(raw_ostream &buffer, bool DWARFMangling = false,
+ Mangler(bool DWARFMangling = false,
bool usePunycode = true)
- : Buffer(buffer), DWARFMangling(DWARFMangling), UsePunycode(usePunycode) {}
+ : Buffer(Storage), DWARFMangling(DWARFMangling), UsePunycode(usePunycode) {}
void mangleContextOf(const ValueDecl *decl, BindGenerics shouldBind);
void mangleContext(const DeclContext *ctx, BindGenerics shouldBind);
void mangleModule(const ModuleDecl *module);
void mangleDeclName(const ValueDecl *decl);
- void mangleDeclType(const ValueDecl *decl, ResilienceExpansion expansion,
- unsigned uncurryingLevel);
+ void mangleDeclType(const ValueDecl *decl, unsigned uncurryingLevel);
- void mangleEntity(const ValueDecl *decl, ResilienceExpansion expansion,
- unsigned uncurryingLevel);
+ void mangleEntity(const ValueDecl *decl, unsigned uncurryingLevel);
void mangleConstructorEntity(const ConstructorDecl *ctor, bool isAllocating,
- ResilienceExpansion kind,
unsigned uncurryingLevel);
void mangleDestructorEntity(const DestructorDecl *decl, bool isDeallocating);
void mangleIVarInitDestroyEntity(const ClassDecl *decl, bool isDestroyer);
void mangleAccessorEntity(AccessorKind kind, AddressorKind addressorKind,
- const AbstractStorageDecl *decl,
- ResilienceExpansion expansion);
+ const AbstractStorageDecl *decl);
void mangleAddressorEntity(const ValueDecl *decl);
void mangleGlobalGetterEntity(ValueDecl *decl);
void mangleDefaultArgumentEntity(const DeclContext *ctx, unsigned index);
void mangleInitializerEntity(const VarDecl *var);
void mangleClosureEntity(const SerializedAbstractClosureExpr *closure,
- ResilienceExpansion explosion,
unsigned uncurryingLevel);
void mangleClosureEntity(const AbstractClosureExpr *closure,
- ResilienceExpansion explosion,
unsigned uncurryingLevel);
void mangleNominalType(const NominalTypeDecl *decl,
- ResilienceExpansion expansion,
BindGenerics shouldBind,
CanGenericSignature extGenericSig = nullptr,
const GenericParamList *extGenericParams = nullptr);
void mangleProtocolDecl(const ProtocolDecl *protocol);
- void mangleType(Type type, ResilienceExpansion expansion,
- unsigned uncurryingLevel);
+ void mangleType(Type type, unsigned uncurryingLevel);
void mangleDirectness(bool isIndirect);
void mangleProtocolName(const ProtocolDecl *protocol);
void mangleProtocolConformance(const ProtocolConformance *conformance);
@@ -140,14 +138,30 @@ class Mangler {
void mangleDeclTypeForDebugger(const ValueDecl *decl);
void mangleTypeForDebugger(Type decl, const DeclContext *DC);
- void mangleGenericSignature(const GenericSignature *sig,
- ResilienceExpansion expansion);
+ void mangleGenericSignature(const GenericSignature *sig);
void mangleFieldOffsetFull(const ValueDecl *decl, bool isIndirect);
void mangleTypeMetadataFull(CanType ty, bool isPattern);
void mangleTypeFullMetadataFull(CanType ty);
void mangleGlobalVariableFull(const VarDecl *decl);
-
+
+ /// Adds the string \p S into the mangled name.
+ void append(StringRef S);
+
+ /// Adds the char \p C into the mangled name.
+ void append(char C);
+
+ /// Add the already mangled symbol \p Name as an identifier. (using the
+ /// length prefix).
+ void mangleIdentifierSymbol(StringRef Name);
+
+ /// Add the already mangled symbol \p Name. This gives the mangler the
+ /// opportunity to decode \p Name before adding it to the mangled name.
+ void appendSymbol(StringRef Name);
+
+ /// Mangle the integer \p Nat into the name.
+ void mangleNatural(const APInt &Nat);
+
/// Mangles globalinit_token and globalinit_func, which are used to
/// initialize global variables.
/// \param decl The global variable or one of the global variables of a
@@ -162,8 +176,7 @@ class Mangler {
bool isOperator=false);
void resetArchetypesDepth() { ArchetypesDepth = 0; }
private:
- void mangleFunctionType(AnyFunctionType *fn, ResilienceExpansion expansion,
- unsigned uncurryingLevel);
+ void mangleFunctionType(AnyFunctionType *fn, unsigned uncurryingLevel);
void mangleProtocolList(ArrayRef protocols);
void mangleProtocolList(ArrayRef protocols);
void mangleIdentifier(Identifier ident,
@@ -181,13 +194,12 @@ class Mangler {
assert(DWARFMangling &&
"sugared types are only legal when mangling for the debugger");
auto *BlandTy = cast(type.getPointer())->getSinglyDesugaredType();
- mangleType(BlandTy, ResilienceExpansion::Minimal, 0);
+ mangleType(BlandTy, 0);
}
void mangleGenericSignatureParts(ArrayRef params,
unsigned initialParamDepth,
- ArrayRef requirements,
- ResilienceExpansion expansion);
+ ArrayRef requirements);
Type getDeclTypeForMangling(const ValueDecl *decl,
ArrayRef &genericParams,
unsigned &initialParamIndex,
@@ -197,8 +209,7 @@ class Mangler {
void mangleGenericParamIndex(GenericTypeParamType *paramTy);
void mangleAssociatedTypeName(DependentMemberType *dmt,
bool canAbbreviate);
- void mangleConstrainedType(CanType type,
- ResilienceExpansion expansion);
+ void mangleConstrainedType(CanType type);
CanGenericSignature getCanonicalSignatureOrNull(GenericSignature *sig,
ModuleDecl &M);
};
diff --git a/include/swift/AST/Module.h b/include/swift/AST/Module.h
index 5069e1e4cb08a..d7a80db592f7c 100644
--- a/include/swift/AST/Module.h
+++ b/include/swift/AST/Module.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -267,13 +267,14 @@ class ModuleDecl : public TypeDecl, public DeclContext {
/// \see EntryPointInfoTy
EntryPointInfoTy EntryPointInfo;
- enum class Flags {
- TestingEnabled = 1 << 0,
- FailedToLoad = 1 << 1
- };
+ struct {
+ unsigned TestingEnabled : 1;
+ unsigned FailedToLoad : 1;
+ unsigned ResilienceEnabled : 1;
+ } Flags;
/// The magic __dso_handle variable.
- llvm::PointerIntPair> DSOHandleAndFlags;
+ VarDecl *DSOHandle;
ModuleDecl(Identifier name, ASTContext &ctx);
@@ -315,18 +316,28 @@ class ModuleDecl : public TypeDecl, public DeclContext {
/// Returns true if this module was or is being compiled for testing.
bool isTestingEnabled() const {
- return DSOHandleAndFlags.getInt().contains(Flags::TestingEnabled);
+ return Flags.TestingEnabled;
}
void setTestingEnabled(bool enabled = true) {
- DSOHandleAndFlags.setInt(DSOHandleAndFlags.getInt()|Flags::TestingEnabled);
+ Flags.TestingEnabled = enabled;
}
/// Returns true if there was an error trying to load this module.
bool failedToLoad() const {
- return DSOHandleAndFlags.getInt().contains(Flags::FailedToLoad);
+ return Flags.FailedToLoad;
}
void setFailedToLoad(bool failed = true) {
- DSOHandleAndFlags.setInt(DSOHandleAndFlags.getInt() | Flags::FailedToLoad);
+ Flags.FailedToLoad = failed;
+ }
+
+ /// Returns true if this module is compiled for resilience enabled,
+ /// meaning the module is expected to evolve without recompiling
+ /// clients that link against it.
+ bool isResilienceEnabled() const {
+ return Flags.ResilienceEnabled;
+ }
+ void setResilienceEnabled(bool enabled = true) {
+ Flags.ResilienceEnabled = enabled;
}
/// Look up a (possibly overloaded) value set at top-level scope
@@ -409,6 +420,11 @@ class ModuleDecl : public TypeDecl, public DeclContext {
DeclContext *container, DeclName name,
Identifier privateDiscriminator) const;
+ /// Find all Objective-C methods with the given selector.
+ void lookupObjCMethods(
+ ObjCSelector selector,
+ SmallVectorImpl &results) const;
+
/// \sa getImportedModules
enum class ImportFilter {
All,
@@ -572,7 +588,7 @@ class ModuleDecl : public TypeDecl, public DeclContext {
public:
// Only allow allocation of Modules using the allocator in ASTContext
// or by doing a placement new.
- void *operator new(size_t Bytes, ASTContext &C,
+ void *operator new(size_t Bytes, const ASTContext &C,
unsigned Alignment = alignof(ModuleDecl));
};
@@ -639,6 +655,11 @@ class FileUnit : public DeclContext {
DeclName name,
SmallVectorImpl &results) const {}
+ /// Find all Objective-C methods with the given selector.
+ virtual void lookupObjCMethods(
+ ObjCSelector selector,
+ SmallVectorImpl &results) const = 0;
+
/// Returns the comment attached to the given declaration.
///
/// This function is an implementation detail for comment serialization.
@@ -804,6 +825,10 @@ class DerivedFileUnit final : public FileUnit {
void getTopLevelDecls(SmallVectorImpl &results) const override;
+ void lookupObjCMethods(
+ ObjCSelector selector,
+ SmallVectorImpl &results) const override;
+
Identifier
getDiscriminatorForPrivateValue(const ValueDecl *D) const override {
llvm_unreachable("no private decls in the derived file unit");
@@ -903,6 +928,11 @@ class SourceFile final : public FileUnit {
/// complete, we diagnose.
std::map AttrsRequiringFoundation;
+ /// A mapping from Objective-C selectors to the methods that have
+ /// those selectors.
+ llvm::DenseMap>
+ ObjCMethods;
+
template
using OperatorMap = llvm::DenseMap>;
@@ -959,6 +989,10 @@ class SourceFile final : public FileUnit {
lookupClassMember(ModuleDecl::AccessPathTy accessPath, DeclName name,
SmallVectorImpl &results) const override;
+ void lookupObjCMethods(
+ ObjCSelector selector,
+ SmallVectorImpl &results) const override;
+
virtual void getTopLevelDecls(SmallVectorImpl &results) const override;
virtual void
@@ -1120,6 +1154,11 @@ class BuiltinUnit final : public FileUnit {
NLKind lookupKind,
SmallVectorImpl &result) const override;
+ /// Find all Objective-C methods with the given selector.
+ void lookupObjCMethods(
+ ObjCSelector selector,
+ SmallVectorImpl &results) const override;
+
Identifier
getDiscriminatorForPrivateValue(const ValueDecl *D) const override {
llvm_unreachable("no private values in the Builtin module");
diff --git a/include/swift/AST/ModuleLoader.h b/include/swift/AST/ModuleLoader.h
index ae3e62490c95f..05bf1b247fa66 100644
--- a/include/swift/AST/ModuleLoader.h
+++ b/include/swift/AST/ModuleLoader.h
@@ -1,8 +1,8 @@
-//===--- ModuleLoader.h - Module Loader Interface ----------- -*- C++ -*- -===//
+//===--- ModuleLoader.h - Module Loader Interface ---------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -95,7 +95,7 @@ class ModuleLoader {
virtual void loadExtensions(NominalTypeDecl *nominal,
unsigned previousGeneration) { }
- /// \brief Load the methods within the given class that that produce
+ /// \brief Load the methods within the given class that produce
/// Objective-C class or instance methods with the given selector.
///
/// \param classDecl The class in which we are searching for @objc methods.
@@ -109,7 +109,7 @@ class ModuleLoader {
///
/// \param previousGeneration The previous generation with which this
/// callback was invoked. The list of methods will already contain all of
- /// the results from generations up and and including \c previousGeneration.
+ /// the results from generations up and including \c previousGeneration.
///
/// \param methods The list of @objc methods in this class that have this
/// selector and are instance/class methods as requested. This list will be
diff --git a/include/swift/AST/NameLookup.h b/include/swift/AST/NameLookup.h
index b1fdf59244411..97b94ab03d4c2 100644
--- a/include/swift/AST/NameLookup.h
+++ b/include/swift/AST/NameLookup.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -140,7 +140,7 @@ enum class DeclVisibilityKind {
MemberOfOutsideNominal,
/// Declaration is visible at the top level because it is declared in this
- /// module or in a imported module.
+ /// module or in an imported module.
VisibleAtTopLevel,
/// Declaration was found via \c AnyObject or \c AnyObject.Type.
diff --git a/include/swift/AST/Ownership.h b/include/swift/AST/Ownership.h
index b329a324201d4..44b976c12d1f3 100644
--- a/include/swift/AST/Ownership.h
+++ b/include/swift/AST/Ownership.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -19,12 +19,14 @@
#ifndef SWIFT_OWNERSHIP_H
#define SWIFT_OWNERSHIP_H
+#include
+
namespace swift {
/// Different kinds of reference ownership supported by Swift.
// This enum is used in diagnostics. If you add a case here, the diagnostics
// must be updated as well.
-enum class Ownership {
+enum class Ownership : uint8_t {
/// \brief a strong reference (the default semantics)
Strong,
diff --git a/include/swift/AST/ParameterList.h b/include/swift/AST/ParameterList.h
new file mode 100644
index 0000000000000..d228151b05a9e
--- /dev/null
+++ b/include/swift/AST/ParameterList.h
@@ -0,0 +1,153 @@
+//===--- ParameterList.h - Functions & closures parameter lists -*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ParameterList class and support logic.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SWIFT_AST_PARAMETERLIST_H
+#define SWIFT_AST_PARAMETERLIST_H
+
+#include "swift/AST/Decl.h"
+#include "swift/Basic/OptionSet.h"
+
+namespace swift {
+
+/// This describes a list of parameters. Each parameter descriptor is tail
+/// allocated onto this list.
+class alignas(alignof(ParamDecl*)) ParameterList {
+ void *operator new(size_t Bytes) throw() = delete;
+ void operator delete(void *Data) throw() = delete;
+ void *operator new(size_t Bytes, void *Mem) throw() = delete;
+ void *operator new(size_t Bytes, ASTContext &C,
+ unsigned Alignment = 8);
+
+ SourceLoc LParenLoc, RParenLoc;
+ size_t numParameters;
+
+ ParameterList(SourceLoc LParenLoc, size_t numParameters, SourceLoc RParenLoc)
+ : LParenLoc(LParenLoc), RParenLoc(RParenLoc), numParameters(numParameters){}
+ void operator=(const ParameterList&) = delete;
+public:
+ /// Create a parameter list with the specified parameters.
+ static ParameterList *create(const ASTContext &C, SourceLoc LParenLoc,
+ ArrayRef params,
+ SourceLoc RParenLoc);
+
+ /// Create a parameter list with the specified parameters, with no location
+ /// info for the parens.
+ static ParameterList *create(const ASTContext &C,
+ ArrayRef params) {
+ return create(C, SourceLoc(), params, SourceLoc());
+ }
+
+ /// Create an empty parameter list.
+ static ParameterList *createEmpty(const ASTContext &C,
+ SourceLoc LParenLoc = SourceLoc(),
+ SourceLoc RParenLoc = SourceLoc()) {
+ return create(C, LParenLoc, {}, RParenLoc);
+ }
+
+ /// Create a parameter list for a single parameter lacking location info.
+ static ParameterList *createWithoutLoc(ParamDecl *decl) {
+ return create(decl->getASTContext(), decl);
+ }
+
+ /// Create an implicit 'self' decl for a method in the specified decl context.
+ /// If 'static' is true, then this is self for a static method in the type.
+ ///
+ /// Note that this decl is created, but it is returned with an incorrect
+ /// DeclContext that needs to be set correctly. This is automatically handled
+ /// when a function is created with this as part of its argument list.
+ ///
+ static ParameterList *createSelf(SourceLoc loc, DeclContext *DC,
+ bool isStaticMethod = false,
+ bool isInOut = false);
+
+ SourceLoc getLParenLoc() const { return LParenLoc; }
+ SourceLoc getRParenLoc() const { return RParenLoc; }
+
+ typedef MutableArrayRef::iterator iterator;
+ typedef ArrayRef::iterator const_iterator;
+ iterator begin() { return getArray().begin(); }
+ iterator end() { return getArray().end(); }
+ const_iterator begin() const { return getArray().begin(); }
+ const_iterator end() const { return getArray().end(); }
+
+ MutableArrayRef getArray() {
+ auto Ptr = reinterpret_cast(this + 1);
+ return { Ptr, numParameters };
+ }
+ ArrayRef getArray() const {
+ auto Ptr = reinterpret_cast(this + 1);
+ return { Ptr, numParameters };
+ }
+
+ size_t size() const {
+ return numParameters;
+ }
+
+ const ParamDecl *get(unsigned i) const {
+ return getArray()[i];
+ }
+
+ ParamDecl *&get(unsigned i) {
+ return getArray()[i];
+ }
+
+ const ParamDecl *operator[](unsigned i) const { return get(i); }
+ ParamDecl *&operator[](unsigned i) { return get(i); }
+
+ /// Change the DeclContext of any contained parameters to the specified
+ /// DeclContext.
+ void setDeclContextOfParamDecls(DeclContext *DC);
+
+
+ /// Flags used to indicate how ParameterList cloning should operate.
+ enum CloneFlags {
+ /// The cloned ParamDecls should be marked implicit.
+ Implicit = 0x01,
+ /// The cloned pattern is for an inherited constructor; mark default
+ /// arguments as inherited, and mark unnamed arguments as named.
+ Inherited = 0x02
+ };
+
+ /// Make a duplicate copy of this parameter list. This allocates copies of
+ /// the ParamDecls, so they can be reparented into a new DeclContext.
+ ParameterList *clone(const ASTContext &C,
+ OptionSet options = None) const;
+
+ /// Return a TupleType or ParenType for this parameter list. This returns a
+ /// null type if one of the ParamDecls does not have a type set for it yet.
+ Type getType(const ASTContext &C) const;
+
+ /// Return the full function type for a set of curried parameter lists that
+ /// returns the specified result type. This returns a null type if one of the
+ /// ParamDecls does not have a type set for it yet.
+ ///
+ static Type getFullType(Type resultType, ArrayRef PL);
+
+
+ /// Return the full source range of this parameter.
+ SourceRange getSourceRange() const;
+ SourceLoc getStartLoc() const { return getSourceRange().Start; }
+ SourceLoc getEndLoc() const { return getSourceRange().End; }
+
+ void dump() const;
+ void dump(raw_ostream &OS, unsigned Indent = 0) const;
+
+ // void print(raw_ostream &OS) const;
+};
+
+} // end namespace swift.
+
+#endif
diff --git a/include/swift/AST/Pattern.h b/include/swift/AST/Pattern.h
index 393b8154936d2..e30f875d20be5 100644
--- a/include/swift/AST/Pattern.h
+++ b/include/swift/AST/Pattern.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -20,7 +20,6 @@
#include "swift/Basic/SourceLoc.h"
#include "swift/Basic/type_traits.h"
#include "swift/AST/Decl.h"
-#include "swift/AST/DefaultArgumentKind.h"
#include "swift/AST/Expr.h"
#include "swift/Basic/LLVM.h"
#include "swift/AST/Type.h"
@@ -30,7 +29,6 @@
namespace swift {
class ASTContext;
- class ExprHandle;
/// PatternKind - The classification of different kinds of
/// value-matching pattern.
@@ -120,11 +118,6 @@ class alignas(8) Pattern {
/// identifier if the pattern does not bind a name directly.
Identifier getBoundName() const;
- /// Returns the name directly bound by this pattern within the body of
- /// a function, or the null identifier if the pattern does not bind a name
- /// directly.
- Identifier getBodyName() const;
-
/// If this pattern binds a single variable without any
/// destructuring or conditionalizing, return that variable.
VarDecl *getSingleVar() const;
@@ -169,54 +162,12 @@ class alignas(8) Pattern {
VD->setParentPatternStmt(S);
});
}
-
- /// Return the number of "top-level" variables in the given pattern,
- /// which looks into one level of tuple pattern to determine the #
- /// of variables. If the pattern is not a tuple, the result is one.
- unsigned numTopLevelVariables() const;
-
- /// \brief Build an implicit 'self' parameter for the specified DeclContext.
- static Pattern *buildImplicitSelfParameter(SourceLoc Loc,
- TypeLoc TyLoc,
- DeclContext *CurDeclContext);
-
- /// \brief Build an implicit let parameter pattern for the specified
- /// DeclContext.
- static Pattern *buildImplicitLetParameter(SourceLoc loc, StringRef name,
- TypeLoc TyLoc,
- DeclContext *CurDeclContext);
-
- /// Flags used to indicate how pattern cloning should operate.
- enum CloneFlags {
- /// The cloned pattern should be implicit.
- Implicit = 0x01,
- /// The cloned pattern is for an inherited constructor; mark default
- /// arguments as inherited, and mark unnamed arguments as named.
- Inherited = 0x02,
- /// Whether the named patterns produced from a cloned 'any' pattern is
- /// are 'var'.
- IsVar = 0x04
- };
-
- Pattern *clone(ASTContext &context,
- OptionSet options = None) const;
-
- /// Given that this is a function-parameter pattern, clone it in a
- /// way that permits makeForwardingReference to be called on the
- /// result.
- Pattern *cloneForwardable(ASTContext &context, DeclContext *DC,
- OptionSet options = None) const;
- /// Form an un-typechecked reference to the variables bound by this
- /// pattern in a manner which perfectly forwards the values. Not
- /// all patterns can be forwarded.
- Expr *buildForwardingRefExpr(ASTContext &context) const;
-
static bool classof(const Pattern *P) { return true; }
//*** Allocation Routines ************************************************/
- void *operator new(size_t bytes, ASTContext &C);
+ void *operator new(size_t bytes, const ASTContext &C);
// Make placement new and vanilla new/delete illegal for Patterns.
void *operator new(size_t bytes) = delete;
@@ -271,23 +222,14 @@ class ParenPattern : public Pattern {
class TuplePatternElt {
Identifier Label;
SourceLoc LabelLoc;
- llvm::PointerIntPair ThePatternAndEllipsis;
- SourceLoc EllipsisLoc;
- ExprHandle *Init;
- DefaultArgumentKind DefArgKind;
+ Pattern *ThePattern;
public:
TuplePatternElt() = default;
- explicit TuplePatternElt(Pattern *P)
- : ThePatternAndEllipsis(P, false), Init(nullptr), DefArgKind(DefaultArgumentKind::None) {}
+ explicit TuplePatternElt(Pattern *P) : ThePattern(P) {}
- TuplePatternElt(Identifier Label, SourceLoc LabelLoc,
- Pattern *p, bool hasEllipsis,
- SourceLoc ellipsisLoc = SourceLoc(),
- ExprHandle *init = nullptr,
- DefaultArgumentKind defArgKind = DefaultArgumentKind::None)
- : Label(Label), LabelLoc(LabelLoc), ThePatternAndEllipsis(p, hasEllipsis),
- EllipsisLoc(ellipsisLoc), Init(init), DefArgKind(defArgKind) {}
+ TuplePatternElt(Identifier Label, SourceLoc LabelLoc, Pattern *p)
+ : Label(Label), LabelLoc(LabelLoc), ThePattern(p) {}
Identifier getLabel() const { return Label; }
SourceLoc getLabelLoc() const { return LabelLoc; }
@@ -296,20 +238,12 @@ class TuplePatternElt {
LabelLoc = Loc;
}
- Pattern *getPattern() { return ThePatternAndEllipsis.getPointer(); }
+ Pattern *getPattern() { return ThePattern; }
const Pattern *getPattern() const {
- return ThePatternAndEllipsis.getPointer();
+ return ThePattern;
}
- void setPattern(Pattern *p) { ThePatternAndEllipsis.setPointer(p); }
-
- bool hasEllipsis() const { return ThePatternAndEllipsis.getInt(); }
- SourceLoc getEllipsisLoc() const { return EllipsisLoc; }
-
- ExprHandle *getInit() const { return Init; }
-
- DefaultArgumentKind getDefaultArgKind() const { return DefArgKind; }
- void setDefaultArgKind(DefaultArgumentKind DAK) { DefArgKind = DAK; }
+ void setPattern(Pattern *p) { ThePattern = p; }
};
/// A pattern consisting of a tuple of patterns.
@@ -366,9 +300,6 @@ class TuplePattern : public Pattern {
SourceLoc getRParenLoc() const { return RPLoc; }
SourceRange getSourceRange() const;
- bool hasAnyEllipsis() const;
- SourceLoc getAnyEllipsisLoc() const;
-
static bool classof(const Pattern *P) {
return P->getKind() == PatternKind::Tuple;
}
@@ -387,7 +318,6 @@ class NamedPattern : public Pattern {
VarDecl *getDecl() const { return Var; }
Identifier getBoundName() const;
- Identifier getBodyName() const;
StringRef getNameStr() const { return Var->getNameStr(); }
SourceLoc getLoc() const { return Var->getLoc(); }
diff --git a/include/swift/AST/PatternNodes.def b/include/swift/AST/PatternNodes.def
index a35385bdd17d6..40dc5926a8f59 100644
--- a/include/swift/AST/PatternNodes.def
+++ b/include/swift/AST/PatternNodes.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/PlatformKind.h b/include/swift/AST/PlatformKind.h
index 4ac2580ac3aca..3da2fe800b45b 100644
--- a/include/swift/AST/PlatformKind.h
+++ b/include/swift/AST/PlatformKind.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -32,7 +32,7 @@ enum class PlatformKind {
#include "swift/AST/PlatformKinds.def"
};
-/// Returns the short string representating the platform, suitable for
+/// Returns the short string representing the platform, suitable for
/// use in availability specifications (e.g., "OSX").
StringRef platformString(PlatformKind platform);
@@ -40,7 +40,7 @@ StringRef platformString(PlatformKind platform);
/// or None if such a platform kind does not exist.
Optional platformFromString(StringRef Name);
-/// Returns a human-readiable version of the platform name as a string, suitable
+/// Returns a human-readable version of the platform name as a string, suitable
/// for emission in diagnostics (e.g., "OS X").
StringRef prettyPlatformString(PlatformKind platform);
diff --git a/include/swift/AST/PlatformKinds.def b/include/swift/AST/PlatformKinds.def
index 0a97d241d8907..3325258e5fd16 100644
--- a/include/swift/AST/PlatformKinds.def
+++ b/include/swift/AST/PlatformKinds.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/PrettyStackTrace.h b/include/swift/AST/PrettyStackTrace.h
index cfd634202664f..1456a773965c2 100644
--- a/include/swift/AST/PrettyStackTrace.h
+++ b/include/swift/AST/PrettyStackTrace.h
@@ -1,8 +1,8 @@
-//===- PrettyStackTrace.h - Crash trace information -------------*- C++ -*-===//
+//===--- PrettyStackTrace.h - Crash trace information -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/PrintOptions.h b/include/swift/AST/PrintOptions.h
index 22fe00cb924d8..4806fad4eea7c 100644
--- a/include/swift/AST/PrintOptions.h
+++ b/include/swift/AST/PrintOptions.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -229,6 +229,7 @@ struct PrintOptions {
result.ExcludeAttrList.push_back(DAK_Exported);
result.ExcludeAttrList.push_back(DAK_Inline);
result.ExcludeAttrList.push_back(DAK_Rethrows);
+ result.ExcludeAttrList.push_back(DAK_Swift3Migration);
result.PrintOverrideKeyword = false;
result.AccessibilityFilter = Accessibility::Public;
result.PrintIfConfig = false;
@@ -247,7 +248,7 @@ struct PrintOptions {
static PrintOptions printTypeInterface(Type T, DeclContext *DC);
- /// Retrive the print options that are suitable to print the testable interface.
+ /// Retrieve the print options that are suitable to print the testable interface.
static PrintOptions printTestableInterface() {
PrintOptions result = printInterface();
result.AccessibilityFilter = Accessibility::Internal;
@@ -270,6 +271,7 @@ struct PrintOptions {
result.PrintAccessibility = false;
result.SkipUnavailable = false;
result.ExcludeAttrList.push_back(DAK_Available);
+ result.ExcludeAttrList.push_back(DAK_Swift3Migration);
result.ArgAndParamPrinting =
PrintOptions::ArgAndParamPrintingMode::BothAlways;
result.PrintDocumentationComments = false;
@@ -312,6 +314,7 @@ struct PrintOptions {
PO.PrintFunctionRepresentationAttrs = false;
PO.PrintDocumentationComments = false;
PO.ExcludeAttrList.push_back(DAK_Available);
+ PO.ExcludeAttrList.push_back(DAK_Swift3Migration);
PO.SkipPrivateStdlibDecls = true;
return PO;
}
diff --git a/include/swift/AST/ProtocolConformance.h b/include/swift/AST/ProtocolConformance.h
index c60c6d74e93a6..e8891fdeb7a9a 100644
--- a/include/swift/AST/ProtocolConformance.h
+++ b/include/swift/AST/ProtocolConformance.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -18,6 +18,7 @@
#include "swift/AST/ConcreteDeclRef.h"
#include "swift/AST/Decl.h"
+#include "swift/AST/ProtocolConformanceRef.h"
#include "swift/AST/Substitution.h"
#include "swift/AST/Type.h"
#include "swift/AST/Types.h"
@@ -35,6 +36,7 @@ class GenericParamList;
class NormalProtocolConformance;
class ProtocolConformance;
class ModuleDecl;
+class SubstitutionIterator;
enum class AllocationArena;
/// \brief Type substitution mapping from substitutable types to their
@@ -87,7 +89,7 @@ enum class ProtocolConformanceState {
///
/// ProtocolConformance is an abstract base class, implemented by subclasses
/// for the various kinds of conformance (normal, specialized, inherited).
-class ProtocolConformance {
+class alignas(1 << DeclAlignInBits) ProtocolConformance {
/// The kind of protocol conformance.
ProtocolConformanceKind Kind;
@@ -187,7 +189,9 @@ class ProtocolConformance {
/// protocol conformance.
///
/// The function object should accept a \c ValueDecl* for the requirement
- /// followed by the \c ConcreteDeclRef for the witness.
+ /// followed by the \c ConcreteDeclRef for the witness. Note that a generic
+ /// witness will only be specialized if the conformance came from the current
+ /// file.
template
void forEachValueWitness(LazyResolver *resolver, F f) const {
const ProtocolDecl *protocol = getProtocol();
@@ -252,7 +256,7 @@ class ProtocolConformance {
return mem;
}
- /// Print a parsable and human-readable description of the identifying
+ /// Print a parseable and human-readable description of the identifying
/// information of the protocol conformance.
void printName(raw_ostream &os,
const PrintOptions &PO = PrintOptions()) const;
@@ -376,6 +380,9 @@ class NormalProtocolConformance : public ProtocolConformance,
TypeDecl *typeDecl) const;
/// Retrieve the value witness corresponding to the given requirement.
+ ///
+ /// Note that a generic witness will only be specialized if the conformance
+ /// came from the current file.
ConcreteDeclRef getWitness(ValueDecl *requirement,
LazyResolver *resolver) const;
@@ -496,6 +503,8 @@ class SpecializedProtocolConformance : public ProtocolConformance,
return GenericSubstitutions;
}
+ SubstitutionIterator getGenericSubstitutionIterator() const;
+
/// Get the protocol being conformed to.
ProtocolDecl *getProtocol() const {
return GenericConformance->getProtocol();
diff --git a/include/swift/AST/ProtocolConformanceRef.h b/include/swift/AST/ProtocolConformanceRef.h
new file mode 100644
index 0000000000000..4549642624e64
--- /dev/null
+++ b/include/swift/AST/ProtocolConformanceRef.h
@@ -0,0 +1,98 @@
+//===--- ProtocolConformanceRef.h - AST Protocol Conformance ----*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ProtocolConformanceRef type.
+//
+//===----------------------------------------------------------------------===//
+#ifndef SWIFT_AST_PROTOCOLCONFORMANCEREF_H
+#define SWIFT_AST_PROTOCOLCONFORMANCEREF_H
+
+#include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/PointerUnion.h"
+#include "swift/AST/TypeAlignments.h"
+
+namespace swift {
+
+/// A ProtocolConformanceRef is a handle to a protocol conformance which
+/// may be either concrete or abstract.
+///
+/// A concrete conformance is derived from a specific protocol conformance
+/// declaration.
+///
+/// An abstract conformance is derived from context: the conforming type
+/// is either existential or opaque (i.e. an archetype), and while the
+/// type-checker promises that the conformance exists, it is not known
+/// statically which concrete conformance it refers to.
+///
+/// ProtocolConformanceRef allows the efficient recovery of the protocol
+/// even when the conformance is abstract.
+class ProtocolConformanceRef {
+ using UnionType = llvm::PointerUnion;
+ UnionType Union;
+
+ explicit ProtocolConformanceRef(UnionType value) : Union(value) {
+ assert(value && "cannot construct ProtocolConformanceRef with null");
+ }
+public:
+ /// Create an abstract protocol conformance reference.
+ explicit ProtocolConformanceRef(ProtocolDecl *proto) : Union(proto) {
+ assert(proto != nullptr &&
+ "cannot construct ProtocolConformanceRef with null");
+ }
+
+ /// Create a concrete protocol conformance reference.
+ explicit ProtocolConformanceRef(ProtocolConformance *conf) : Union(conf) {
+ assert(conf != nullptr &&
+ "cannot construct ProtocolConformanceRef with null");
+ }
+
+ /// Create either a concrete or an abstract protocol conformance reference,
+ /// depending on whether ProtocolConformance is null.
+ explicit ProtocolConformanceRef(ProtocolDecl *protocol,
+ ProtocolConformance *conf);
+
+ bool isConcrete() const { return Union.is(); }
+ ProtocolConformance *getConcrete() const {
+ return Union.get();
+ }
+
+ bool isAbstract() const { return Union.is(); }
+ ProtocolDecl *getAbstract() const {
+ return Union.get();
+ }
+
+ using OpaqueValue = void*;
+ OpaqueValue getOpaqueValue() const { return Union.getOpaqueValue(); }
+ static ProtocolConformanceRef getFromOpaqueValue(OpaqueValue value) {
+ return ProtocolConformanceRef(UnionType::getFromOpaqueValue(value));
+ }
+
+ /// Return the protocol requirement.
+ ProtocolDecl *getRequirement() const;
+
+ void dump() const;
+
+ bool operator==(ProtocolConformanceRef other) const {
+ return Union == other.Union;
+ }
+ bool operator!=(ProtocolConformanceRef other) const {
+ return Union != other.Union;
+ }
+
+ friend llvm::hash_code hash_value(ProtocolConformanceRef conformance) {
+ return llvm::hash_value(conformance.Union.getOpaqueValue());
+ }
+};
+
+} // end namespace swift
+
+#endif // LLVM_SWIFT_AST_PROTOCOLCONFORMANCEREF_H
diff --git a/include/swift/AST/RawComment.h b/include/swift/AST/RawComment.h
index 3b83baef652cd..bf7be32bc82ed 100644
--- a/include/swift/AST/RawComment.h
+++ b/include/swift/AST/RawComment.h
@@ -1,8 +1,8 @@
-//===--- RawComment.h - Extraction of raw comments ------------------------===//
+//===--- RawComment.h - Extraction of raw comments --------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/ReferencedNameTracker.h b/include/swift/AST/ReferencedNameTracker.h
index a1738c6b58871..7864ae1f86486 100644
--- a/include/swift/AST/ReferencedNameTracker.h
+++ b/include/swift/AST/ReferencedNameTracker.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/Requirement.h b/include/swift/AST/Requirement.h
index 41d8a057fda71..e4135267a474c 100644
--- a/include/swift/AST/Requirement.h
+++ b/include/swift/AST/Requirement.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -28,6 +28,10 @@ enum class RequirementKind : unsigned int {
/// A conformance requirement T : P, where T is a type that depends
/// on a generic parameter and P is a protocol to which T must conform.
Conformance,
+ /// A superclass requirement T : C, where T is a type that depends
+ /// on a generic parameter and C is a concrete class type which T must
+ /// equal or be a subclass of.
+ Superclass,
/// A same-type requirement T == U, where T and U are types that shall be
/// equivalent.
SameType,
diff --git a/include/swift/AST/ResilienceExpansion.h b/include/swift/AST/ResilienceExpansion.h
index f861539a8fd38..a8059e86b0827 100644
--- a/include/swift/AST/ResilienceExpansion.h
+++ b/include/swift/AST/ResilienceExpansion.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/SILOptions.h b/include/swift/AST/SILOptions.h
index 235ff2284c281..df6811cc56cd4 100644
--- a/include/swift/AST/SILOptions.h
+++ b/include/swift/AST/SILOptions.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -51,7 +51,7 @@ class SILOptions {
OptimizeUnchecked
};
- /// Controls how perform SIL linking.
+ /// Controls how to perform SIL linking.
LinkingMode LinkMode = LinkNormal;
/// Remove all runtime assertions during optimizations.
@@ -97,9 +97,10 @@ class SILOptions {
/// Should we use a pass pipeline passed in via a json file? Null by default.
StringRef ExternalPassPipelineFilename;
-
- /// Use super_method for native super method calls instead of function_ref.
- bool UseNativeSuperMethod = false;
+
+ /// Emit captures and function contexts using +0 caller-guaranteed ARC
+ /// conventions.
+ bool EnableGuaranteedClosureContexts = false;
};
} // end namespace swift
diff --git a/include/swift/AST/SearchPathOptions.h b/include/swift/AST/SearchPathOptions.h
index 8f558dfbfdf48..e767946540c08 100644
--- a/include/swift/AST/SearchPathOptions.h
+++ b/include/swift/AST/SearchPathOptions.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/Stmt.h b/include/swift/AST/Stmt.h
index f6c50aef97a65..206b184ee7e79 100644
--- a/include/swift/AST/Stmt.h
+++ b/include/swift/AST/Stmt.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -217,7 +217,7 @@ class DeferStmt : public Stmt {
Expr *getCallExpr() const { return callExpr; }
void setCallExpr(Expr *E) { callExpr = E; }
- /// Dig the original users's body of the defer out for AST fidelity.
+ /// Dig the original user's body of the defer out for AST fidelity.
BraceStmt *getBodyAsWritten() const;
static bool classof(const Stmt *S) { return S->getKind() == StmtKind::Defer; }
@@ -800,6 +800,9 @@ class ForStmt : public LabeledStmt {
SourceLoc getStartLoc() const { return getLabelLocOrKeywordLoc(ForLoc); }
SourceLoc getEndLoc() const { return Body->getEndLoc(); }
+
+ SourceLoc getFirstSemicolonLoc() const { return Semi1Loc; }
+ SourceLoc getSecondSemicolonLoc() const { return Semi2Loc; }
NullablePtr getInitializer() const { return Initializer; }
void setInitializer(Expr *V) { Initializer = V; }
diff --git a/include/swift/AST/StmtNodes.def b/include/swift/AST/StmtNodes.def
index 87b8f9a2b0aa1..38676dcbd5903 100644
--- a/include/swift/AST/StmtNodes.def
+++ b/include/swift/AST/StmtNodes.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/SubstTypeVisitor.h b/include/swift/AST/SubstTypeVisitor.h
index 2abe6583a1d74..012dead8867c2 100644
--- a/include/swift/AST/SubstTypeVisitor.h
+++ b/include/swift/AST/SubstTypeVisitor.h
@@ -1,8 +1,8 @@
-//===-- SubstTypeVisitor.h - Visitor for substituted types ------*- C++ -*-===//
+//===--- SubstTypeVisitor.h - Visitor for substituted types -----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/Substitution.h b/include/swift/AST/Substitution.h
index f6754e520f759..a209b3a18977d 100644
--- a/include/swift/AST/Substitution.h
+++ b/include/swift/AST/Substitution.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -26,54 +26,31 @@ namespace llvm {
namespace swift {
class ArchetypeType;
- class ProtocolConformance;
+ class ProtocolConformanceRef;
/// DenseMap type used internally by Substitution::subst to track conformances
/// applied to archetypes.
using ArchetypeConformanceMap
- = llvm::DenseMap>;
-
+ = llvm::DenseMap>;
+
/// Substitution - A substitution into a generic specialization.
class Substitution {
- ArchetypeType * Archetype = nullptr;
Type Replacement;
- ArrayRef Conformance;
+ ArrayRef Conformance;
public:
- /// FIXME: An archetype that looks like the archetype or dependent generic
- /// parameter type that should be substituted by this substitution, but
- /// which is not guaranteed to map to any particular context. All that is
- /// guaranteed:
- ///
- /// - Archetype will conform to the same protocols as the substituted
- /// type.
- /// - Archetype will appear at the same point in the generic parameter
- /// hierarchy as the substituted type; that is, if the substituted type
- /// is a generic parameter, it will be a primary archetype, or if the
- /// substituted type is a dependent member type, it will be a nested
- /// archetype with the same name path--if T0.Foo.Bar is being substituted,
- /// this will be some archetype X.Foo.Bar.
- /// - If the substituted type represents a Self or associated type of a
- /// protocol requirement, this Archetype will be that archetype from the
- /// protocol context.
- ///
- /// You really shouldn't use the value of this field for anything new.
- ArchetypeType *getArchetype() const { return Archetype; }
-
/// The replacement type.
Type getReplacement() const { return Replacement; }
/// The protocol conformances for the replacement. These appear in the same
/// order as Archetype->getConformsTo() for the substituted archetype.
- const ArrayRef getConformances() const {
+ const ArrayRef getConformances() const {
return Conformance;
}
Substitution() {}
- Substitution(ArchetypeType *Archetype,
- Type Replacement,
- ArrayRef Conformance);
+ Substitution(Type Replacement, ArrayRef Conformance);
bool operator!=(const Substitution &other) const { return !(*this == other); }
bool operator==(const Substitution &other) const;
@@ -96,6 +73,60 @@ class Substitution {
ArchetypeConformanceMap &conformanceMap) const;
};
+/// An iterator over a list of archetypes and the substitutions
+/// applied to them.
+class SubstitutionIterator {
+ // TODO: this should use dependent types when getConformsTo() becomes
+ // efficient there.
+ ArrayRef Archetypes;
+ ArrayRef Subs;
+
+public:
+ SubstitutionIterator() = default;
+ explicit SubstitutionIterator(GenericParamList *params,
+ ArrayRef subs);
+
+ struct iterator {
+ ArchetypeType * const *NextArch = nullptr;
+ const Substitution *NextSub = nullptr;
+
+ iterator() = default;
+ iterator(ArchetypeType * const *nextArch, const Substitution *nextSub)
+ : NextArch(nextArch), NextSub(nextSub) {}
+
+ iterator &operator++() {
+ ++NextArch;
+ ++NextSub;
+ return *this;
+ }
+
+ iterator operator++(int) {
+ iterator copy = *this;
+ ++*this;
+ return copy;
+ }
+
+ std::pair operator*() const {
+ return { *NextArch, *NextSub };
+ }
+
+ bool operator==(const iterator &other) const {
+ assert((NextSub == other.NextSub) == (NextArch == other.NextArch));
+ return NextSub == other.NextSub;
+ }
+ bool operator!=(const iterator &other) const {
+ return !(*this == other);
+ }
+ };
+
+ ArrayRef getSubstitutions() const { return Subs; }
+
+ bool empty() const { return Archetypes.empty(); }
+
+ iterator begin() const { return { Archetypes.begin(), Subs.begin() }; }
+ iterator end() const { return { Archetypes.end(), Subs.end() }; }
+};
+
void dump(const ArrayRef &subs);
} // end namespace swift
diff --git a/include/swift/AST/Type.h b/include/swift/AST/Type.h
index 8548667d4bfb8..f8093ac08bf99 100644
--- a/include/swift/AST/Type.h
+++ b/include/swift/AST/Type.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -434,7 +434,7 @@ namespace llvm {
template<> struct DenseMapInfo
: public DenseMapInfo {
static swift::CanType getEmptyKey() {
- return swift::CanType(0);
+ return swift::CanType(nullptr);
}
static swift::CanType getTombstoneKey() {
return swift::CanType(llvm::DenseMapInfo class PointerLikeTypeTraits \
LLVM_DECLARE_TYPE_ALIGNMENT(swift::Decl, swift::DeclAlignInBits)
LLVM_DECLARE_TYPE_ALIGNMENT(swift::AbstractStorageDecl, swift::DeclAlignInBits)
LLVM_DECLARE_TYPE_ALIGNMENT(swift::OperatorDecl, swift::DeclAlignInBits)
+LLVM_DECLARE_TYPE_ALIGNMENT(swift::ProtocolDecl, swift::DeclAlignInBits)
+LLVM_DECLARE_TYPE_ALIGNMENT(swift::ProtocolConformance, swift::DeclAlignInBits)
LLVM_DECLARE_TYPE_ALIGNMENT(swift::DeclContext, swift::DeclContextAlignInBits)
LLVM_DECLARE_TYPE_ALIGNMENT(swift::TypeBase, swift::TypeAlignInBits)
LLVM_DECLARE_TYPE_ALIGNMENT(swift::ArchetypeType, swift::TypeAlignInBits)
diff --git a/include/swift/AST/TypeCheckerDebugConsumer.h b/include/swift/AST/TypeCheckerDebugConsumer.h
index b6133e4378af5..00a5d9ec2663b 100644
--- a/include/swift/AST/TypeCheckerDebugConsumer.h
+++ b/include/swift/AST/TypeCheckerDebugConsumer.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeLoc.h b/include/swift/AST/TypeLoc.h
index 8f2f7ef40f49e..a76585e453633 100644
--- a/include/swift/AST/TypeLoc.h
+++ b/include/swift/AST/TypeLoc.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeMatcher.h b/include/swift/AST/TypeMatcher.h
index 70461e6dbf6db..1cf6c940f176d 100644
--- a/include/swift/AST/TypeMatcher.h
+++ b/include/swift/AST/TypeMatcher.h
@@ -1,8 +1,8 @@
-//===-- TypeMatcher.h - Recursive Type Matcher------- -----------*- C++ -*-===//
+//===--- TypeMatcher.h - Recursive Type Matcher -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeMemberVisitor.h b/include/swift/AST/TypeMemberVisitor.h
index d6afd46a89bd3..6af30cfc3d8d9 100644
--- a/include/swift/AST/TypeMemberVisitor.h
+++ b/include/swift/AST/TypeMemberVisitor.h
@@ -1,8 +1,8 @@
-//===-- TypeMemberVisitor.h - ASTVisitor specialization ---------*- C++ -*-===//
+//===--- TypeMemberVisitor.h - ASTVisitor specialization --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeNodes.def b/include/swift/AST/TypeNodes.def
index ebfffbf3baaa6..f9093ca449938 100644
--- a/include/swift/AST/TypeNodes.def
+++ b/include/swift/AST/TypeNodes.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeRefinementContext.h b/include/swift/AST/TypeRefinementContext.h
index 14186ca77dd07..63844e750f10e 100644
--- a/include/swift/AST/TypeRefinementContext.h
+++ b/include/swift/AST/TypeRefinementContext.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeRepr.h b/include/swift/AST/TypeRepr.h
index 4f5d3678d0c32..1478ba255199e 100644
--- a/include/swift/AST/TypeRepr.h
+++ b/include/swift/AST/TypeRepr.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -85,7 +85,7 @@ class alignas(8) TypeRepr {
//*** Allocation Routines ************************************************/
- void *operator new(size_t bytes, ASTContext &C,
+ void *operator new(size_t bytes, const ASTContext &C,
unsigned Alignment = alignof(TypeRepr));
// Make placement new and vanilla new/delete illegal for TypeReprs.
@@ -98,7 +98,7 @@ class alignas(8) TypeRepr {
void dump() const;
/// Clone the given type representation.
- TypeRepr *clone(ASTContext &ctx) const;
+ TypeRepr *clone(const ASTContext &ctx) const;
/// Visit the top-level types in the given type representation,
/// which includes the types referenced by \c IdentTypeReprs either
@@ -392,44 +392,24 @@ class FunctionTypeRepr : public TypeRepr {
/// [Foo]
/// \endcode
class ArrayTypeRepr : public TypeRepr {
- // FIXME: Tail allocation. Use bits to determine whether Base/Size are
- // available.
TypeRepr *Base;
- llvm::PointerIntPair SizeAndOldSyntax;
SourceRange Brackets;
public:
- ArrayTypeRepr(TypeRepr *Base, ExprHandle *Size, SourceRange Brackets,
- bool OldSyntax)
- : TypeRepr(TypeReprKind::Array), Base(Base),
- SizeAndOldSyntax(Size, OldSyntax), Brackets(Brackets) { }
+ ArrayTypeRepr(TypeRepr *Base, SourceRange Brackets)
+ : TypeRepr(TypeReprKind::Array), Base(Base), Brackets(Brackets) { }
TypeRepr *getBase() const { return Base; }
- ExprHandle *getSize() const { return SizeAndOldSyntax.getPointer(); }
SourceRange getBrackets() const { return Brackets; }
- bool usesOldSyntax() const { return SizeAndOldSyntax.getInt(); }
-
static bool classof(const TypeRepr *T) {
return T->getKind() == TypeReprKind::Array;
}
static bool classof(const ArrayTypeRepr *T) { return true; }
private:
- SourceLoc getStartLocImpl() const {
- if (usesOldSyntax())
- return Base->getStartLoc();
-
- return Brackets.Start;
- }
- SourceLoc getEndLocImpl() const {
- // This test is necessary because the type Int[4][2] is represented as
- // ArrayTypeRepr(ArrayTypeRepr(Int, 2), 4), so the range needs to cover both
- // sets of brackets.
- if (usesOldSyntax() && isa(Base))
- return Base->getEndLoc();
- return Brackets.End;
- }
+ SourceLoc getStartLocImpl() const { return Brackets.Start; }
+ SourceLoc getEndLocImpl() const { return Brackets.End; }
void printImpl(ASTPrinter &Printer, const PrintOptions &Opts) const;
friend class TypeRepr;
};
@@ -781,10 +761,8 @@ inline bool TypeRepr::isSimple() const {
case TypeReprKind::ProtocolComposition:
case TypeReprKind::Tuple:
case TypeReprKind::Fixed:
- return true;
-
case TypeReprKind::Array:
- return !cast(this)->usesOldSyntax();
+ return true;
}
llvm_unreachable("bad TypeRepr kind");
}
diff --git a/include/swift/AST/TypeReprNodes.def b/include/swift/AST/TypeReprNodes.def
index 1ec3f7879fe30..50404fd9d9d94 100644
--- a/include/swift/AST/TypeReprNodes.def
+++ b/include/swift/AST/TypeReprNodes.def
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeVisitor.h b/include/swift/AST/TypeVisitor.h
index 15be7dc39b574..81f89c3b90639 100644
--- a/include/swift/AST/TypeVisitor.h
+++ b/include/swift/AST/TypeVisitor.h
@@ -1,8 +1,8 @@
-//===-- TypeVisitor.h - Type Visitor ----------------------------*- C++ -*-===//
+//===--- TypeVisitor.h - Type Visitor ---------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/AST/TypeWalker.h b/include/swift/AST/TypeWalker.h
index 1a3d4042babff..7b079c01e604f 100644
--- a/include/swift/AST/TypeWalker.h
+++ b/include/swift/AST/TypeWalker.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -26,11 +26,11 @@ class TypeWalker {
Stop
};
- /// This method is called when first visiting an type before walking into its
+ /// This method is called when first visiting a type before walking into its
/// children.
virtual Action walkToTypePre(Type ty) { return Action::Continue; }
- /// This method is called after visiting an type's children.
+ /// This method is called after visiting a type's children.
virtual Action walkToTypePost(Type ty) { return Action::Continue; }
/// Controls whether the original type of a SubstitutedType is visited.
diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h
index caa2896fa6d7f..8b181b29f3cc0 100644
--- a/include/swift/AST/Types.h
+++ b/include/swift/AST/Types.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -425,7 +425,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
return getRecursiveProperties().hasOpenedExistential();
}
- /// Determine whether the type involves the given opend existential
+ /// Determine whether the type involves the given opened existential
/// archetype.
bool hasOpenedExistential(ArchetypeType *opened);
@@ -672,10 +672,6 @@ class alignas(1 << TypeAlignInBits) TypeBase {
/// the result would be the (parenthesized) type ((int, int)).
Type getUnlabeledType(ASTContext &Context);
- /// Relabel the elements of the given type with the given new
- /// (top-level) labels.
- Type getRelabeledType(ASTContext &Context, ArrayRef labels);
-
/// \brief Retrieve the type without any default arguments.
Type getWithoutDefaultArgs(const ASTContext &Context);
@@ -839,17 +835,6 @@ class alignas(1 << TypeAlignInBits) TypeBase {
/// Retrieve the type declaration directly referenced by this type, if any.
TypeDecl *getDirectlyReferencedTypeDecl() const;
- /// Retrieve the default argument string that would be inferred for this type,
- /// assuming that we know it is inferred.
- ///
- /// This routine pre-supposes that we know that the given type is the type of
- /// a parameter that has a default, and all we need to figure out is which
- /// default argument should be print.
- ///
- /// FIXME: This should go away when/if inferred default arguments become
- /// "real".
- StringRef getInferredDefaultArgString();
-
private:
// Make vanilla new/delete illegal for Types.
void *operator new(size_t Bytes) throw() = delete;
@@ -1257,9 +1242,11 @@ class TupleTypeElt {
/// is variadic.
llvm::PointerIntPair NameAndVariadic;
- /// \brief This is the type of the field, which is mandatory, along with the
- /// kind of default argument.
- llvm::PointerIntPair TyAndDefaultArg;
+ /// \brief This is the type of the field.
+ Type ElementType;
+
+ /// The default argument,
+ DefaultArgumentKind DefaultArg;
friend class TupleType;
@@ -1273,12 +1260,12 @@ class TupleTypeElt {
/*implicit*/ TupleTypeElt(TypeBase *Ty)
: NameAndVariadic(Identifier(), false),
- TyAndDefaultArg(Ty, DefaultArgumentKind::None) { }
+ ElementType(Ty), DefaultArg(DefaultArgumentKind::None) { }
bool hasName() const { return !NameAndVariadic.getPointer().empty(); }
Identifier getName() const { return NameAndVariadic.getPointer(); }
- Type getType() const { return TyAndDefaultArg.getPointer(); }
+ Type getType() const { return ElementType.getPointer(); }
/// Determine whether this field is variadic.
bool isVararg() const {
@@ -1286,9 +1273,7 @@ class TupleTypeElt {
}
/// Retrieve the kind of default argument available on this field.
- DefaultArgumentKind getDefaultArgKind() const {
- return TyAndDefaultArg.getInt();
- }
+ DefaultArgumentKind getDefaultArgKind() const { return DefaultArg; }
/// Whether we have a default argument.
bool hasDefaultArg() const {
@@ -1308,11 +1293,6 @@ class TupleTypeElt {
TupleTypeElt getWithType(Type T) const {
return TupleTypeElt(T, getName(), getDefaultArgKind(), isVararg());
}
-
- /// Determine whether this tuple element has an initializer.
- bool hasInit() const {
- return getDefaultArgKind() != DefaultArgumentKind::None;
- }
};
inline Type getTupleEltType(const TupleTypeElt &elt) {
@@ -1358,7 +1338,7 @@ class TupleType : public TypeBase, public llvm::FoldingSetNode {
return TupleEltTypeArrayRef(getElements());
}
- /// getNamedElementId - If this tuple has a element with the specified name,
+ /// getNamedElementId - If this tuple has an element with the specified name,
/// return the element index, otherwise return -1.
int getNamedElementId(Identifier I) const;
@@ -1944,7 +1924,7 @@ class ModuleType : public TypeBase {
// Implement isa/cast/dyncast/etc.
static bool classof(const TypeBase *T) {
- return T->getKind() == TypeKind::Module;
+ return T->getKind() == TypeKind::Module;
}
private:
@@ -2575,6 +2555,42 @@ inline bool isConsumedParameter(ParameterConvention conv) {
llvm_unreachable("bad convention kind");
}
+enum class InoutAliasingAssumption {
+ /// Assume that an inout indirect parameter may alias other objects.
+ /// This is the safe assumption an optimizations should make if it may break
+ /// memory safety in case the inout aliasing rule is violation.
+ Aliasing,
+
+ /// Assume that an inout indirect parameter cannot alias other objects.
+ /// Optimizations should only use this if they can guarantee that they will
+ /// not break memory safety even if the inout aliasing rule is violated.
+ NotAliasing
+};
+
+/// Returns true if \p conv is a not-aliasing indirect parameter.
+/// The \p isInoutAliasing specifies what to assume about the inout convention.
+/// See InoutAliasingAssumption.
+inline bool isNotAliasedIndirectParameter(ParameterConvention conv,
+ InoutAliasingAssumption isInoutAliasing) {
+ switch (conv) {
+ case ParameterConvention::Indirect_In:
+ case ParameterConvention::Indirect_Out:
+ case ParameterConvention::Indirect_In_Guaranteed:
+ return true;
+
+ case ParameterConvention::Indirect_Inout:
+ return isInoutAliasing == InoutAliasingAssumption::NotAliasing;
+
+ case ParameterConvention::Indirect_InoutAliasable:
+ case ParameterConvention::Direct_Unowned:
+ case ParameterConvention::Direct_Guaranteed:
+ case ParameterConvention::Direct_Owned:
+ case ParameterConvention::Direct_Deallocating:
+ return false;
+ }
+ llvm_unreachable("covered switch isn't covered?!");
+}
+
/// Returns true if conv is a guaranteed parameter. This may look unnecessary
/// but this will allow code to generalize to handle Indirect_Guaranteed
/// parameters when they are added.
@@ -4100,12 +4116,7 @@ class TypeVariableType : public TypeBase {
class Implementation;
public:
-
- /// \brief Printing substitutions for type variables may result in recursive
- /// references to the type variable itself. This flag is used to short-circuit
- /// such operations.
- bool isPrinting = false;
-
+
/// \brief Create a new type variable whose implementation is constructed
/// with the given arguments.
template
@@ -4339,7 +4350,7 @@ inline TupleTypeElt::TupleTypeElt(Type ty,
DefaultArgumentKind defArg,
bool isVariadic)
: NameAndVariadic(name, isVariadic),
- TyAndDefaultArg(ty.getPointer(), defArg)
+ ElementType(ty), DefaultArg(defArg)
{
assert(!isVariadic ||
isa(ty.getPointer()) ||
diff --git a/include/swift/AST/USRGeneration.h b/include/swift/AST/USRGeneration.h
index 5eed154d0477b..808f50e71d7f8 100644
--- a/include/swift/AST/USRGeneration.h
+++ b/include/swift/AST/USRGeneration.h
@@ -1,8 +1,8 @@
-//===--- USRGeneration.h - Routines for USR generation --------------------===//
+//===--- USRGeneration.h - Routines for USR generation ----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/ASTSectionImporter/ASTSectionImporter.h b/include/swift/ASTSectionImporter/ASTSectionImporter.h
index 5cf16e56e2016..2820bb86494d7 100644
--- a/include/swift/ASTSectionImporter/ASTSectionImporter.h
+++ b/include/swift/ASTSectionImporter/ASTSectionImporter.h
@@ -1,8 +1,8 @@
-//===--- ASTSectionImporter.cpp - Import AST Section Modules ---*- C++ -*--===//
+//===--- ASTSectionImporter.h - Import AST Section Modules ------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,7 +23,7 @@
namespace swift {
class SerializedModuleLoader;
- /// \brief Povided a memory buffer with an entire Mach-O __apple_ast
+ /// \brief Provided a memory buffer with an entire Mach-O __apple_ast
/// section, this function makes memory buffer copies of all swift
/// modules found in it and registers them using
/// registerMemoryBuffer() so they can be found by loadModule(). The
diff --git a/include/swift/Basic/Algorithm.h b/include/swift/Basic/Algorithm.h
index a1134e802d7fa..c2cef45aff32a 100644
--- a/include/swift/Basic/Algorithm.h
+++ b/include/swift/Basic/Algorithm.h
@@ -1,8 +1,8 @@
-//===--- Algorithm.h - -------------------------------------------*- C++ -*-==//
+//===--- Algorithm.h - ------------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/ArrayRefView.h b/include/swift/Basic/ArrayRefView.h
index 6cddda4f9296e..f9181db6dc334 100644
--- a/include/swift/Basic/ArrayRefView.h
+++ b/include/swift/Basic/ArrayRefView.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/AssertImplements.h b/include/swift/Basic/AssertImplements.h
index 81894acb6ae5e..d4aa08b42ded1 100644
--- a/include/swift/Basic/AssertImplements.h
+++ b/include/swift/Basic/AssertImplements.h
@@ -1,8 +1,8 @@
-//===- AssertImplements.h - Assert that a class overrides a function ------===//
+//===--- AssertImplements.h - Assert that a class overrides a function ----===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/BlotMapVector.h b/include/swift/Basic/BlotMapVector.h
index 645c2ee1da441..a80be3093cfd6 100644
--- a/include/swift/Basic/BlotMapVector.h
+++ b/include/swift/Basic/BlotMapVector.h
@@ -1,8 +1,8 @@
-//===- BlotMapVector.h - Map vector with "blot" operation -----*- C++ -*--===//
+//===--- BlotMapVector.h - Map vector with "blot" operation ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/BlotSetVector.h b/include/swift/Basic/BlotSetVector.h
index 92ca3dfd4ad53..9cd5f806bc60c 100644
--- a/include/swift/Basic/BlotSetVector.h
+++ b/include/swift/Basic/BlotSetVector.h
@@ -1,8 +1,8 @@
-//===--- BlotSetVector.h --------------------------------------------------===//
+//===--- BlotSetVector.h ----------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -99,7 +99,7 @@ class BlotSetVector {
/// V1.
void replace(const ValueT &V1, const ValueT &V2) {
auto Iter1 = Map.find(V1);
- assert(Iter1 != Map.end() && "Can not replace value that is not in set");
+ assert(Iter1 != Map.end() && "Cannot replace value that is not in set");
unsigned V1Index = Iter1->second;
Map.erase(V1);
diff --git a/include/swift/Basic/Cache.h b/include/swift/Basic/Cache.h
index e3dfc995723d0..bcfd357e1eb2d 100644
--- a/include/swift/Basic/Cache.h
+++ b/include/swift/Basic/Cache.h
@@ -1,8 +1,8 @@
-//===--- Cache.h - Caching mechanism interface -------------------*- C++ -*-==//
+//===--- Cache.h - Caching mechanism interface ------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/ClusteredBitVector.h b/include/swift/Basic/ClusteredBitVector.h
index dcc5cfa31868a..99114d9c3e172 100644
--- a/include/swift/Basic/ClusteredBitVector.h
+++ b/include/swift/Basic/ClusteredBitVector.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Defer.h b/include/swift/Basic/Defer.h
index 367b624a16d20..95e46e7cb2064 100644
--- a/include/swift/Basic/Defer.h
+++ b/include/swift/Basic/Defer.h
@@ -1,8 +1,8 @@
-//===- Defer.h - 'defer' helper macro ---------------------------*- C++ -*-===//
+//===--- Defer.h - 'defer' helper macro -------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This filed defines a 'defer' macro for performing a cleanup on any exit out
+// This file defines a 'defer' macro for performing a cleanup on any exit out
// of a scope.
//
//===----------------------------------------------------------------------===//
diff --git a/include/swift/Basic/Demangle.h b/include/swift/Basic/Demangle.h
index 41bc7fa47392a..c9d1807a98de2 100644
--- a/include/swift/Basic/Demangle.h
+++ b/include/swift/Basic/Demangle.h
@@ -1,8 +1,8 @@
-//===--- Demangle.h - Interface to Swift symbol demangling -------*- C++ -*-==//
+//===--- Demangle.h - Interface to Swift symbol demangling ------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -90,7 +90,7 @@ enum class FunctionSigSpecializationParamKind : unsigned {
/// The pass that caused the specialization to occur. We use this to make sure
/// that two passes that generate similar changes do not yield the same
-/// mangling. This currently can not happen, so this is just a safety measure
+/// mangling. This currently cannot happen, so this is just a safety measure
/// that creates separate name spaces.
enum class SpecializationPass : uint8_t {
AllocBoxToStack,
@@ -102,7 +102,7 @@ enum class SpecializationPass : uint8_t {
};
static inline char encodeSpecializationPass(SpecializationPass Pass) {
- return char(uint8_t(Pass)) + 48;
+ return char(uint8_t(Pass)) + '0';
}
enum class ValueWitnessKind {
diff --git a/include/swift/Basic/DemangleNodes.def b/include/swift/Basic/DemangleNodes.def
index 58e5c5752d4d0..0c05714bfda3b 100644
--- a/include/swift/Basic/DemangleNodes.def
+++ b/include/swift/Basic/DemangleNodes.def
@@ -1,8 +1,8 @@
-//===-- DemangleNodes.def - Demangling Tree Metaprogramming -----*- C++ -*-===//
+//===--- DemangleNodes.def - Demangling Tree Metaprogramming ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -30,6 +30,8 @@ NODE(ArchetypeRef)
NODE(ArgumentTuple)
NODE(AssociatedType)
NODE(AssociatedTypeRef)
+NODE(AssociatedTypeMetadataAccessor)
+NODE(AssociatedTypeWitnessTableAccessor)
NODE(AutoClosureType)
NODE(BoundGenericClass)
NODE(BoundGenericEnum)
@@ -49,8 +51,6 @@ NODE(DependentGenericSameTypeRequirement)
NODE(DependentGenericType)
NODE(DependentMemberType)
NODE(DependentGenericParamType)
-NODE(DependentProtocolWitnessTableGenerator)
-NODE(DependentProtocolWitnessTableTemplate)
CONTEXT_NODE(Destructor)
CONTEXT_NODE(DidSet)
NODE(Directness)
@@ -71,6 +71,8 @@ NODE(FunctionSignatureSpecializationParamKind)
NODE(FunctionSignatureSpecializationParamPayload)
NODE(FunctionType)
NODE(Generics)
+NODE(GenericProtocolWitnessTable)
+NODE(GenericProtocolWitnessTableInstantiationFunction)
NODE(GenericSpecialization)
NODE(GenericSpecializationParam)
NODE(GenericType)
@@ -128,6 +130,7 @@ NODE(QualifiedArchetype)
NODE(ReabstractionThunk)
NODE(ReabstractionThunkHelper)
NODE(ReturnType)
+NODE(SILBoxType)
NODE(SelfTypeRef)
CONTEXT_NODE(Setter)
NODE(SpecializationPassID)
diff --git a/include/swift/Basic/DemangleWrappers.h b/include/swift/Basic/DemangleWrappers.h
index 080320d2c2467..07d121994f6bd 100644
--- a/include/swift/Basic/DemangleWrappers.h
+++ b/include/swift/Basic/DemangleWrappers.h
@@ -1,8 +1,8 @@
-//===--- DemangleWrappers.h --------------------------------------*- C++ -*-==//
+//===--- DemangleWrappers.h -------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/DiagnosticConsumer.h b/include/swift/Basic/DiagnosticConsumer.h
index 7a1860ea136b1..87f8db009a483 100644
--- a/include/swift/Basic/DiagnosticConsumer.h
+++ b/include/swift/Basic/DiagnosticConsumer.h
@@ -1,8 +1,8 @@
-//===- DiagnosticConsumer.h - Diagnostic Consumer Interface -----*- C++ -*-===//
+//===--- DiagnosticConsumer.h - Diagnostic Consumer Interface ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -19,12 +19,8 @@
#ifndef SWIFT_BASIC_DIAGNOSTIC_CONSUMER_H
#define SWIFT_BASIC_DIAGNOSTIC_CONSUMER_H
-#include "swift/Basic/LLVM.h"
#include "swift/Basic/SourceLoc.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SourceMgr.h"
-#include
namespace swift {
class SourceManager;
@@ -32,7 +28,7 @@ namespace swift {
/// \brief Describes the kind of diagnostic.
///
-enum class DiagnosticKind {
+enum class DiagnosticKind : uint8_t {
Error,
Warning,
Note
diff --git a/include/swift/Basic/DiagnosticOptions.h b/include/swift/Basic/DiagnosticOptions.h
index 20b232faf913e..19ac63bf7ea7e 100644
--- a/include/swift/Basic/DiagnosticOptions.h
+++ b/include/swift/Basic/DiagnosticOptions.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -35,6 +35,12 @@ class DiagnosticOptions {
/// When emitting fixits as code edits, apply all fixits from diagnostics
/// without any filtering.
bool FixitCodeForAllDiagnostics = false;
+
+ /// Suppress all warnings
+ bool SuppressWarnings = false;
+
+ /// Treat all warnings as errors
+ bool WarningsAsErrors = false;
};
}
diff --git a/include/swift/Basic/DiverseList.h b/include/swift/Basic/DiverseList.h
index eeb7b0183ffed..8a2169e35001c 100644
--- a/include/swift/Basic/DiverseList.h
+++ b/include/swift/Basic/DiverseList.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/DiverseStack.h b/include/swift/Basic/DiverseStack.h
index 3d8ebb9321efc..01351273cee65 100644
--- a/include/swift/Basic/DiverseStack.h
+++ b/include/swift/Basic/DiverseStack.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Dwarf.h b/include/swift/Basic/Dwarf.h
index cceb2088e9391..c568990d3e8a0 100644
--- a/include/swift/Basic/Dwarf.h
+++ b/include/swift/Basic/Dwarf.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/EditorPlaceholder.h b/include/swift/Basic/EditorPlaceholder.h
index ea28420b5706c..c9734fcf0c778 100644
--- a/include/swift/Basic/EditorPlaceholder.h
+++ b/include/swift/Basic/EditorPlaceholder.h
@@ -1,8 +1,8 @@
-//===--- EditorPlaceholder.h - Handling for editor placeholders -----------===//
+//===--- EditorPlaceholder.h - Handling for editor placeholders -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/EncodedSequence.h b/include/swift/Basic/EncodedSequence.h
index b4c0a8d099211..c0a8bfc342e14 100644
--- a/include/swift/Basic/EncodedSequence.h
+++ b/include/swift/Basic/EncodedSequence.h
@@ -1,8 +1,8 @@
-//===--- EncodedSequence.h - A byte-encoded sequence -----------*- C++ -*-===//
+//===--- EncodedSequence.h - A byte-encoded sequence ------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Fallthrough.h b/include/swift/Basic/Fallthrough.h
index 0e28731c6c0a6..c697722545fc9 100644
--- a/include/swift/Basic/Fallthrough.h
+++ b/include/swift/Basic/Fallthrough.h
@@ -1,8 +1,8 @@
-//===- Fallthrough.h - switch fallthrough annotation macro ------*- C++ -*-===//
+//===--- Fallthrough.h - switch fallthrough annotation macro ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This filed defines a SWIFT_FALLTHROUGH macro to annotate intentional
+// This file defines a SWIFT_FALLTHROUGH macro to annotate intentional
// fallthrough between switch cases. For compilers that support the
// "clang::fallthrough" attribute, it expands to an empty statement with the
// attribute applied; otherwise, it expands to just an empty statement.
diff --git a/include/swift/Basic/FileSystem.h b/include/swift/Basic/FileSystem.h
index 59d99df55c928..749818329f166 100644
--- a/include/swift/Basic/FileSystem.h
+++ b/include/swift/Basic/FileSystem.h
@@ -1,8 +1,8 @@
-//===--- FileSystem.cpp - Extra helpers for manipulating files --*- C++ -*-===//
+//===--- FileSystem.h - Extra helpers for manipulating files ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/FlaggedPointer.h b/include/swift/Basic/FlaggedPointer.h
index b70fb8c93d4be..c6d2c349a0b35 100644
--- a/include/swift/Basic/FlaggedPointer.h
+++ b/include/swift/Basic/FlaggedPointer.h
@@ -1,8 +1,8 @@
-//===- FlaggedPointer.h - Explicit pointer tagging container ----*- C++ -*-===//
+//===--- FlaggedPointer.h - Explicit pointer tagging container --*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/JSONSerialization.h b/include/swift/Basic/JSONSerialization.h
index 00946e705ff0a..478ecdf6111e5 100644
--- a/include/swift/Basic/JSONSerialization.h
+++ b/include/swift/Basic/JSONSerialization.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -398,7 +398,7 @@ class Output {
template
void processKeyWithDefault(const char *Key, Optional &Val,
const Optional &DefaultValue, bool Required) {
- assert(DefaultValue.hasValue() == false &&
+ assert(!DefaultValue.hasValue() &&
"Optional shouldn't have a value!");
void *SaveInfo;
bool UseDefault;
@@ -425,8 +425,7 @@ class Output {
SaveInfo) ) {
jsonize(*this, Val, Required);
this->postflightKey(SaveInfo);
- }
- else {
+ } else {
if ( UseDefault )
Val = DefaultValue;
}
@@ -614,7 +613,7 @@ operator<<(Output &yout, T &map) {
return yout;
}
-// Define non-member operator<< so that Output can stream out a array.
+// Define non-member operator<< so that Output can stream out an array.
template
inline
typename
diff --git a/include/swift/Basic/LLVM.h b/include/swift/Basic/LLVM.h
index 6537f52ad0037..2bfb5b33755b0 100644
--- a/include/swift/Basic/LLVM.h
+++ b/include/swift/Basic/LLVM.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/LLVMInitialize.h b/include/swift/Basic/LLVMInitialize.h
index 53365f86f5e60..8394b3d557073 100644
--- a/include/swift/Basic/LLVMInitialize.h
+++ b/include/swift/Basic/LLVMInitialize.h
@@ -1,8 +1,8 @@
-//===--- LLVMInitialize.h -------------------------------------------------===//
+//===--- LLVMInitialize.h ---------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h
index d7bdd65dea672..d8d50174f9dcc 100644
--- a/include/swift/Basic/LangOptions.h
+++ b/include/swift/Basic/LangOptions.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -41,10 +41,6 @@ namespace swift {
/// Language features
///
- /// \brief If true, all types are treated as resilient unless declared
- /// @_fixed_layout.
- bool EnableResilience = false;
-
/// \brief Disable API availability checking.
bool DisableAvailabilityChecking = false;
@@ -74,12 +70,6 @@ namespace swift {
// FIXME: This should probably be limited to the particular SourceFile.
bool Playground = false;
- /// Whether to delay adding enum protocol conformances during code
- /// completion. This isn't completely correct with multiple files but is
- /// currently necessary to get reasonable performance.
- // FIXME: remove this when rdar://20047340 is fixed.
- bool EnableCodeCompletionDelayedEnumConformanceHack = false;
-
/// \brief Keep comments during lexing and attach them to declarations.
bool AttachCommentsToDecls = false;
@@ -130,7 +120,7 @@ namespace swift {
/// This is for testing purposes.
std::string DebugForbidTypecheckPrefix;
- /// Number of paralellel processes performing AST verification.
+ /// Number of parallel processes performing AST verification.
unsigned ASTVerifierProcessCount = 1U;
/// ID of the current process for the purposes of AST verification.
@@ -150,10 +140,19 @@ namespace swift {
/// Should we check the target OSs of serialized modules to see that they're
/// new enough?
bool EnableTargetOSChecking = true;
-
- /// Don't mangle the Self type as part of declaration manglings.
- bool DisableSelfTypeMangling = true;
-
+
+ /// Whether we're omitting needless words when importing Objective-C APIs.
+ ///
+ /// The vast majority of the logic for omitting needless words is
+ /// centralized in the Clang importer. However, there are a few
+ /// places elsewhere in the compiler that specifically reference
+ /// Objective-C entities whose names are affected by
+ /// omit-needless-words.
+ bool OmitNeedlessWords = false;
+
+ /// Enable the Swift 3 migration via Fix-Its.
+ bool Swift3Migration = false;
+
/// Sets the target we are building for and updates configuration options
/// to match.
///
diff --git a/include/swift/Basic/Lazy.h b/include/swift/Basic/Lazy.h
index 95c3e5c7ad0a3..75a9e8643ca02 100644
--- a/include/swift/Basic/Lazy.h
+++ b/include/swift/Basic/Lazy.h
@@ -1,8 +1,8 @@
-//===--- Lazy.h - A lazily-initialized object -----------------------------===//
+//===--- Lazy.h - A lazily-initialized object -------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Malloc.h b/include/swift/Basic/Malloc.h
index 2ac42e6ef5a79..1f11c133251a0 100644
--- a/include/swift/Basic/Malloc.h
+++ b/include/swift/Basic/Malloc.h
@@ -1,8 +1,8 @@
-//===- Malloc.h - Aligned malloc interface ----------------------*- C++ -*-===//
+//===--- Malloc.h - Aligned malloc interface --------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/NullablePtr.h b/include/swift/Basic/NullablePtr.h
index c39071dc35ac6..8f827a4625f72 100644
--- a/include/swift/Basic/NullablePtr.h
+++ b/include/swift/Basic/NullablePtr.h
@@ -1,8 +1,8 @@
-//===- NullablePtr.h - A pointer that allows null ---------------*- C++ -*-===//
+//===--- NullablePtr.h - A pointer that allows null -------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/OptionSet.h b/include/swift/Basic/OptionSet.h
index 977527e9b19c6..c2763fdf7b600 100644
--- a/include/swift/Basic/OptionSet.h
+++ b/include/swift/Basic/OptionSet.h
@@ -1,8 +1,8 @@
-//===-- OptionSet.h - Sets of boolean options -------------------*- C++ -*-===//
+//===--- OptionSet.h - Sets of boolean options ------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/OptionalEnum.h b/include/swift/Basic/OptionalEnum.h
index cfcd34e9b4e90..3d594ab4d998e 100644
--- a/include/swift/Basic/OptionalEnum.h
+++ b/include/swift/Basic/OptionalEnum.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Platform.h b/include/swift/Basic/Platform.h
index c60444a42ebfe..4b151a7dbc4a4 100644
--- a/include/swift/Basic/Platform.h
+++ b/include/swift/Basic/Platform.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/PointerIntEnum.h b/include/swift/Basic/PointerIntEnum.h
new file mode 100644
index 0000000000000..ce8471cc070b6
--- /dev/null
+++ b/include/swift/Basic/PointerIntEnum.h
@@ -0,0 +1,225 @@
+//===--- PointerIntEnum.h ---------------------------------------*- C++ -*-===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+#include "swift/Basic/LLVM.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/PointerLikeTypeTraits.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace swift {
+
+/// A tiny meta function to compute the log2 of a compile time constant.
+///
+/// *NOTE* This will be in an updated version of LLVM so this should be removed
+/// at that point in time.
+template
+struct ConstantLog2
+ : std::integral_constant::value + 1> {};
+template <> struct ConstantLog2<1> : std::integral_constant {};
+
+/// A meta function for computing at compile time cleanly the value for an index
+/// kind's value without using cpp macros.
+template
+struct PointerIntEnumIndexKindValue
+ : std::integral_constant::value)) |
+ unsigned(EnumTy::FirstIndexKind)> {};
+
+/// A pointer sized ADT that is able to compactly represent a Swift like enum
+/// that can contain both Integer and Pointer payloads. It attempts to optimize
+/// for the case of being able to represent as many pointer cases as possible
+/// while allowing for indices to be stored as well. Without any loss of
+/// generality assume that T* is our stored pointer. Then this is done as
+/// follows:
+///
+/// 1. A PointerIntEnum for which bits [0, (num_tagged_bits(T*)-1)] are not all
+/// set to 1 represent an enum with a pointer case. This means that one can have
+/// at most ((1 << num_tagged_bits(T*)) - 2) enum cases associated with
+/// pointers.
+///
+/// 2. A PointerIntEnum for which bits [0, (num_tagged_bits(T*)-1)] are all set
+/// is either an invalid PointerIntEnum or an index.
+///
+/// 3. A PointerIntEnum with all bits set is an invalid PointerIntEnum.
+///
+/// 4. A PointerIntEnum for which bits [0, (num_tagged_bits(T*)-1)] are all set
+/// but for which the upper bits are not all set is an index enum. The case bits
+/// for the index PointerIntEnum are stored in bits [num_tagged_bits(T*),
+/// num_tagged_bits(T*) + num_index_case_bits]. Then the actual index is stored
+/// in the remaining top bits. For the case in which this is used in swift
+/// currently, we use 3 index bits meaning that on a 32 bit system we have 26
+/// bits for representing indices meaning we can represent indices up to
+/// 67_108_862. Any index larger than that will result in an invalid
+/// PointerIntEnum. On 64 bit we have many more bits than that.
+///
+/// By using this representation, we can make PointerIntEnum a true value type
+/// that is trivially constructible and destructible without needing to malloc
+/// memory.
+///
+/// In order for all of this to work, the user of this needs to construct an
+/// enum with the appropriate case structure that allows the data structure to
+/// determine what cases are pointer and which are indices. For instance the one
+/// used by Projection in swift is:
+///
+/// enum class NewProjectionKind : unsigned {
+/// // PointerProjectionKinds
+/// Upcast = 0,
+/// RefCast = 1,
+/// BitwiseCast = 2,
+/// FirstPointerKind = Upcast,
+/// LastPointerKind = BitwiseCast,
+///
+///
+/// // This needs to be set to ((1 << num_tagged_bits(T*)) - 1). It
+/// // represents the first NonPointerKind.
+/// FirstIndexKind = 7,
+///
+/// // Index Projection Kinds
+/// Struct = PointerIntEnumIndexKindValue<0, EnumTy>::value,
+/// Tuple = PointerIntEnumIndexKindValue<1, EnumTy>::value,
+/// Index = PointerIntEnumIndexKindValue<2, EnumTy>::value,
+/// Class = PointerIntEnumIndexKindValue<3, EnumTy>::value,
+/// Enum = PointerIntEnumIndexKindValue<4, EnumTy>::value,
+/// LastIndexKind = Enum,
+/// };
+///
+template >
+class PointerIntEnum {
+
+ // Make sure that the enum fits our requirements.
+ static_assert(unsigned(EnumTy::FirstIndexKind) ==
+ ((1U << NumPointerKindBits) - 1U),
+ "Invalid Enum");
+ static_assert(unsigned(EnumTy::FirstIndexKind) <=
+ unsigned(EnumTy::LastIndexKind),
+ "Invalid Enum");
+ static_assert(unsigned(EnumTy::FirstPointerKind) <=
+ unsigned(EnumTy::LastPointerKind),
+ "Invalid Enum");
+ static_assert(unsigned(EnumTy::LastPointerKind) <
+ unsigned(EnumTy::FirstIndexKind),
+ "Invalid Enum");
+
+ /// The offset in bits where an index would be stored.
+ static constexpr unsigned IndexShiftOffset =
+ NumIndexKindBits + NumPointerKindBits;
+
+ /// The number of bits in a PointerIntEnum that can be used to store indices.
+ static constexpr unsigned NumIndexBits =
+ sizeof(uintptr_t) * CHAR_BIT - IndexShiftOffset;
+
+ /// The maximum index that can be stored for an index PointerIntEnum case.
+ static constexpr uintptr_t MaxIndex = (uintptr_t(1) << NumIndexBits) - 2;
+
+ /// The bit representation of an Invalid PointerIntEnum's storage.
+ static constexpr uintptr_t InvalidStorage = uintptr_t(0) - 1;
+
+ /// The pointer sized type used for the actual storage.
+ uintptr_t Storage;
+
+public:
+ PointerIntEnum() : Storage(InvalidStorage) {}
+
+ /// Initialize this PointerIntEnum with the kind \p Kind and the Pointer \p
+ /// Ptr.
+ PointerIntEnum(EnumTy Kind, uintptr_t NewIndex) {
+ // If we can not represent this index, make the PointerIntEnum invalid.
+ if (NewIndex > MaxIndex) {
+ Storage = InvalidStorage;
+ return;
+ }
+
+ Storage = uintptr_t(Kind) | (NewIndex << IndexShiftOffset);
+ }
+
+ /// Initialize this PointerIntEnum with the kind \p Kind and the Pointer \p
+ /// Ptr.
+ PointerIntEnum(EnumTy Kind, PointerTy Ptr) {
+ void *VoidPtr = PtrTraits::getAsVoidPointer(Ptr);
+
+ // Make sure the pointer is at least aligned to NumPointerKindBits.
+ assert((uintptr_t(VoidPtr) & ((1 << NumPointerKindBits) - 1)) == 0);
+ // Make sure that Kind is a PointerKind.
+ assert(unsigned(Kind) >= unsigned(EnumTy::FirstPointerKind));
+ assert(unsigned(Kind) <= unsigned(EnumTy::LastPointerKind));
+
+ Storage = uintptr_t(VoidPtr) | uintptr_t(Kind);
+ }
+
+ PointerIntEnum(PointerIntEnum &&P) = default;
+ PointerIntEnum(const PointerIntEnum &P) = default;
+ ~PointerIntEnum() = default;
+ PointerIntEnum &operator=(const PointerIntEnum &P) = default;
+ PointerIntEnum &operator=(PointerIntEnum &&P) = default;
+
+ bool isValid() const { return Storage != InvalidStorage; }
+
+ bool operator==(const PointerIntEnum &Other) const {
+ // Just compare the raw storage.
+ return Other.Storage == Storage;
+ }
+
+ bool operator!=(const PointerIntEnum &Other) const {
+ return !(*this == Other);
+ }
+
+ /// \returns the kind of the enum if the enum is valid. Returns None if the
+ /// enum is invalid.
+ Optional getKind() const {
+ if (!isValid())
+ return None;
+
+ // Check if the bottom pointer bits are all not set. If that is true then we
+ // know that we have a pointer kind.
+ unsigned PointerBits = Storage & uintptr_t(EnumTy::FirstIndexKind);
+ if (PointerBits != unsigned(EnumTy::FirstIndexKind)) {
+ return EnumTy(PointerBits);
+ }
+
+ // Otherwise, we have an index kind. Just mask off the actual index bits and
+ // return the kind.
+ unsigned Mask = (1 << IndexShiftOffset) - 1;
+ unsigned MaskedStorage = Storage & Mask;
+ return EnumTy(MaskedStorage);
+ }
+
+ /// \returns the index stored in the enum if the enum has an index
+ /// payload. Asserts if the PointerIntEnum is invalid or has a pointer
+ /// payload.
+ uintptr_t getIndex() const {
+ assert(isValid());
+ assert(unsigned(*getKind()) >= unsigned(EnumTy::FirstIndexKind));
+ return Storage >> IndexShiftOffset;
+ }
+
+ /// \returns the pointer stored in the enum if the enum has a pointer
+ /// payload. Asserts if the PointerIntEnum is invalid or has an index payload.
+ PointerTy getPointer() const {
+ assert(isValid());
+ assert(unsigned(*getKind()) <= unsigned(EnumTy::LastPointerKind));
+ uintptr_t Value = Storage & ~(uintptr_t(EnumTy::FirstIndexKind));
+ return PtrTraits::getFromVoidPointer((void *)(Value));
+ }
+
+ /// Return the raw storage of the type. Used for testing purposes.
+ uintptr_t getStorage() const { return Storage; }
+};
+
+} // end swift namespace
diff --git a/include/swift/Basic/PrefixMap.h b/include/swift/Basic/PrefixMap.h
index 47e1a55100f73..7841f7267e0f0 100644
--- a/include/swift/Basic/PrefixMap.h
+++ b/include/swift/Basic/PrefixMap.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/PrettyStackTrace.h b/include/swift/Basic/PrettyStackTrace.h
index 536dc3abae0de..7d94fde0f5306 100644
--- a/include/swift/Basic/PrettyStackTrace.h
+++ b/include/swift/Basic/PrettyStackTrace.h
@@ -1,8 +1,8 @@
-//===--- PrettyStackTrace.h - Generic stack-trace prettifiers ----*- C++ -*-==//
+//===--- PrettyStackTrace.h - Generic stack-trace prettifiers ---*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/PrimitiveParsing.h b/include/swift/Basic/PrimitiveParsing.h
index 90ea9719b5465..bff1e59153e07 100644
--- a/include/swift/Basic/PrimitiveParsing.h
+++ b/include/swift/Basic/PrimitiveParsing.h
@@ -1,8 +1,8 @@
-//===--- PrimitiveParsing.h - Primitive parsing routines ------------------===//
+//===--- PrimitiveParsing.h - Primitive parsing routines --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Program.h b/include/swift/Basic/Program.h
index 3d98377e32289..061639afc602c 100644
--- a/include/swift/Basic/Program.h
+++ b/include/swift/Basic/Program.h
@@ -1,8 +1,8 @@
-//===- swift/Basic/Program.h ------------------------------------*- C++ -*-===//
+//===--- Program.h ----------------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Punycode.h b/include/swift/Basic/Punycode.h
index 3fbfcb09475ca..de7974160aadf 100644
--- a/include/swift/Basic/Punycode.h
+++ b/include/swift/Basic/Punycode.h
@@ -2,7 +2,7 @@
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/QuotedString.h b/include/swift/Basic/QuotedString.h
index 5fffc896da3c2..cee2a416b6d60 100644
--- a/include/swift/Basic/QuotedString.h
+++ b/include/swift/Basic/QuotedString.h
@@ -1,8 +1,8 @@
-//===- QuotedString.h - Print a string in double-quotes ---------*- C++ -*-===//
+//===--- QuotedString.h - Print a string in double-quotes -------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
diff --git a/include/swift/Basic/Range.h b/include/swift/Basic/Range.h
index 8aaf8a1601802..f27fc738e0428 100644
--- a/include/swift/Basic/Range.h
+++ b/include/swift/Basic/Range.h
@@ -1,8 +1,8 @@
-//===- Range.h - Classes for conveniently working with ranges ---*- C++ -*-===//
+//===--- Range.h - Classes for conveniently working with ranges -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -292,6 +292,11 @@ none_of(Range R, Predicate P) {
return std::none_of(R.begin(), R.end(), P);
}
+template
+inline unsigned count_if(Range R, Predicate P) {
+ return std::count_if(R.begin(), R.end(), P);
+}
+
} // namespace swift
#endif
diff --git a/include/swift/Basic/RelativePointer.h b/include/swift/Basic/RelativePointer.h
index 188ddf26d9505..13e23efdf6555 100644
--- a/include/swift/Basic/RelativePointer.h
+++ b/include/swift/Basic/RelativePointer.h
@@ -1,8 +1,8 @@
-//===-- RelativePointer.h - Relative Pointer Support ------------*- C++ -*-===//
+//===--- RelativePointer.h - Relative Pointer Support -----------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
-// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
@@ -23,16 +23,41 @@
namespace swift {
+namespace detail {
+
+/// Apply a relative offset to a base pointer. The offset is applied to the base
+/// pointer using sign-extended, wrapping arithmetic.
+template