Skip to content

Commit 46b7a58

Browse files
authored
Merge pull request #28344 from apple/tensorflow-merge
Merging swift-DEVELOPMENT-SNAPSHOT-2019-11-11-a into tensorflow.
2 parents bcbe65e + 9600858 commit 46b7a58

File tree

554 files changed

+14073
-8130
lines changed

Some content is hidden

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

554 files changed

+14073
-8130
lines changed

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,39 @@ CHANGELOG
2626
Swift 5.2
2727
---------
2828

29+
* [SR-2790][]:
30+
31+
The compiler will now emit a warning when attempting to pass a temporary
32+
pointer argument produced from an array, string, or inout argument to a
33+
parameter which is known to escape it. This includes the various initializers
34+
for the `UnsafePointer`/`UnsafeBufferPointer` family of types, as well as
35+
memberwise initializers.
36+
37+
```swift
38+
struct S {
39+
var ptr: UnsafePointer<Int8>
40+
}
41+
42+
func foo() {
43+
var i: Int8 = 0
44+
let ptr = UnsafePointer(&i)
45+
// warning: initialization of 'UnsafePointer<Int8>' results in a
46+
// dangling pointer
47+
48+
let s1 = S(ptr: [1, 2, 3])
49+
// warning: passing '[Int8]' to parameter, but argument 'ptr' should be a
50+
// pointer that outlives the call to 'init(ptr:)'
51+
52+
let s2 = S(ptr: "hello")
53+
// warning: passing 'String' to parameter, but argument 'ptr' should be a
54+
// pointer that outlives the call to 'init(ptr:)'
55+
}
56+
```
57+
58+
All 3 of the above examples are unsound because each argument produces a
59+
temporary pointer only valid for the duration of the call they are passed to.
60+
Therefore the returned value in each case references a dangling pointer.
61+
2962
* [SR-2189][]:
3063

3164
The compiler now supports local functions whose default arguments capture
@@ -7824,6 +7857,7 @@ Swift 1.0
78247857
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
78257858
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
78267859
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
7860+
[SR-2790]: <https://bugs.swift.org/browse/SR-2790>
78277861
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
78287862
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
78297863
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
472472
include(ClangClCompileRules)
473473
endif()
474474

475-
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
475+
if(CMAKE_C_COMPILER_ID MATCHES Clang)
476476
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
477477
endif()
478478

@@ -1151,6 +1151,8 @@ endif()
11511151

11521152
add_subdirectory(utils)
11531153

1154+
add_subdirectory(userdocs)
1155+
11541156
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
11551157
if(SWIFT_BUILD_PERF_TESTSUITE)
11561158
add_subdirectory(benchmark)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
3333

3434
#### macOS
3535

36-
To build for macOS, you need [Xcode 11 beta 6](https://developer.apple.com/xcode/downloads/).
36+
To build for macOS, you need [Xcode 11.2](https://developer.apple.com/xcode/downloads/).
3737
The required version of Xcode changes frequently, and is often a beta release.
3838
Check this document for the current required version.
3939

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,9 @@ function(add_swift_target_library name)
20242024
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS}"
20252025
GYB_SOURCES ${SWIFTLIB_GYB_SOURCES}
20262026
)
2027+
if(NOT SWIFT_BUILT_STANDALONE AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
2028+
add_dependencies(${VARIANT_NAME} clang)
2029+
endif()
20272030

20282031
if(sdk STREQUAL WINDOWS)
20292032
if(SWIFT_COMPILER_IS_MSVC_LIKE)

docs/DebuggingTheCompiler.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ debugging press <CTRL>-C on the LLDB prompt.
214214
Note that this only works in Xcode if the PATH variable in the scheme's
215215
environment setting contains the path to the dot tool.
216216

217+
swift/Basic/Debug.h includes macros to help contributors declare these methods
218+
with the proper attributes to ensure they'll be available in the debugger. In
219+
particular, if you see ``SWIFT_DEBUG_DUMP`` in a class declaration, that class
220+
has a ``dump()`` method you can call.
221+
217222
Debugging and Profiling on SIL level
218223
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219224

docs/Diagnostics.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,25 @@ The Swift compiler has a setting (under LangOptions) called `DiagnosticsEditorMo
9090

9191
Most diagnostics have no reason to change behavior under editor mode. An example of an exception is the "protocol requirements not satisfied diagnostic"; on the command line, it may be better to show all unsatisfied requirements, while in an IDE a single multi-line fix-it would be preferred.
9292

93+
### Educational Notes ###
94+
95+
**Note**: This feature is currently experimental. It can be enabled by passing the `-Xfrontend -enable-descriptive-diagnostics` flag.
96+
97+
Educational notes are small snippets of documentation attached to a diagnostic which explain relevant language concepts. They are intended to further Swift's goal of progressive disclosure by providing a learning resource at the point of use for users encountering a new error message for the first time. In very limited circumstances, they also allow the main diagnostic message to use more precise and correct terminology (e.g. nominal types) which would otherwise be too unfriendly for beginners.
98+
99+
When outputting diagnostics on the command line, educational notes will be printed after the main diagnostic body if descriptive diagnostics are enabled. When presented in an IDE, it's expected they will be collapsed under a disclosure arrow, info button, or similar to avoid cluttering output.
100+
101+
Generally speaking, a diagnostic should try to provide educational notes for any concepts/terminology which is difficult to understand from context or is especially subtle. Educational notes should:
102+
- Explain a single language concept. This makes them easy to reuse across diagnostics and helps keep them clear, concise, and easy to understand.
103+
- Be written in unabbreviated English. These are longer form messages compared to the main diagnostic, so there is no need to omit needless words and punctuation.
104+
- Not generally exceed 3-4 paragraphs. Educational notes should be clear and easily digestible. Messages which are too long also have the potential to create diagnostics UX issues in some contexts.
105+
- Be accessible. Educational notes should be beginner friendly and avoid assuming unnecesary prior knowledge. The goal is not only to help users understand what a diagnostic is telling them, but also to turn errors and warnings into "teachable moments".
106+
- Include references to relevant chapters of _The Swift Programming Language_ if applicable.
107+
- Be written in Markdown, but avoid excessive markup to avoid impacting the terminal UX.
108+
109+
To add a new educational note:
110+
1. Add a new Markdown file in the `userdocs/diagnostics/` directory containing the contents of the note.
111+
2. Associate the note with one or more diagnostics in EducationalNotes.def.
93112

94113
### Format Specifiers ###
95114

docs/WindowsBuild.md

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Building Swift on Windows
22

3-
Visual Studio 2017 or newer is needed to build swift on Windows.
3+
Visual Studio 2017 or newer is needed to build swift on Windows. The following must take place in the developer command prompt (provided by Visual Studio). This shows up as "x64 Native Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu.
44

55
## Install dependencies
66
- Install the latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
7-
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation.
7+
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The following components are required:
8+
9+
1. Microsoft.VisualStudio.Component.Windows10SDK
10+
1. Microsoft.VisualStudio.Component.Windows10SDK.17763
11+
1. Microsoft.VisualStudio.Component.VC.Tools.x86.x64
812

913
## Clone the repositories
1014
1. Clone `apple/llvm-project` into a directory for the toolchain
@@ -49,54 +53,29 @@ git clone https://github.com/compnerd/windows-swift windows-swift
4953
┕ usr/...
5054
```
5155

52-
## Get ready
53-
- From within a **NATIVE developer** command prompt (not PowerShell nor cmd, but the [Visual Studio Developer Command Prompt](https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx)), execute the following command if you have an x64 PC (The Native Developer command prompt is situated at "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2019.lnk").
54-
55-
Run this as administrator the first time, for setting up the symlinks below.
56-
57-
If instead you're compiling for a 32-bit Windows target, adapt the `arch` argument to `x86` and run
58-
59-
```cmd
60-
VsDevCmd -arch=x86
61-
```
62-
63-
- Decide whether you want to build a release or debug version of Swift on Windows and
64-
replace the `CMAKE_BUILD_TYPE` parameter in the build steps below with the correct value
65-
(`Debug`, `RelWithDebInfoAssert` or `Release`) to avoid conflicts between the debug and
66-
non-debug version of the MSCRT library.
67-
6856
## One-time Setup (re-run on Visual Studio upgrades)
6957
- Set up the `ucrt`, `visualc`, and `WinSDK` modules by copying `ucrt.modulemap` located at
7058
`swift/stdlib/public/Platform/ucrt.modulemap` into
7159
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt` as `module.modulemap`, copying `visualc.modulemap` located at `swift/stdlib/public/Platform/visualc.modulemap` into `${VCToolsInstallDir}/include` as `module.modulemap`, and copying `winsdk.modulemap` located at `swift/stdlib/public/Platform/winsdk.modulemap` into `${UniversalCRTSdkDir}/Include/${UCRTVersion}/um` and setup the `visualc.apinotes` located at `swift/stdlib/public/Platform/visualc.apinotes` into `${VCToolsInstallDir}/include` as `visualc.apinotes`
7260

7361
```cmd
74-
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" S:\swift\stdlib\public\Platform\ucrt.modulemap
75-
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" S:\swift\stdlib\public\Platform\winsdk.modulemap
76-
mklink "%VCToolsInstallDir%\include\module.modulemap" S:\swift\stdlib\public\Platform\visualc.modulemap
77-
mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\swift\stdlib\public\Platform\visualc.apinotes
62+
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" S:\toolchain\swift\stdlib\public\Platform\ucrt.modulemap
63+
mklink "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" S:\toolchain\swift\stdlib\public\Platform\winsdk.modulemap
64+
mklink "%VCToolsInstallDir%\include\module.modulemap" S:\toolchain\swift\stdlib\public\Platform\visualc.modulemap
65+
mklink "%VCToolsInstallDir%\include\visualc.apinotes" S:\toolchain\swift\stdlib\public\Platform\visualc.apinotes
7866
```
7967

8068
Warning: Creating the above links usually requires administrator privileges. The quick and easy way to do this is to open a second developer prompt by right clicking whatever shortcut you used to open the first one, choosing Run As Administrator, and pasting the above commands into the resulting window. You can then close the privileged prompt; this is the only step which requires elevation.
8169

8270
## Build the toolchain
83-
- This must be done from within a developer command prompt. Make sure that the build type for LLVM/Clang is compatible with the build type for Swift. That is, either build everything `Debug` or some variant of `Release` (e.g. `Release`, `RelWithDebInfo`).
8471

8572
```cmd
8673
md "S:\b\toolchain"
87-
cmake -B "S:\b\toolchain" -G Ninja -S S:\toolchain\llvm -C S:\windows-swift\cmake\caches\Windows-x86_64.cmake -C S:\windows-swift\cmake\caches\org.compnerd.dt.cmake -DLLVM_ENABLE_ASSERTIONS=YES -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;cmark;swift;lldb;lld" -DLLVM_EXTERNAL_PROJECTS="cmark;swift" -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\llvm-project\swift-corelibs-libdispatch -DLLVM_ENABLE_PDB=YES -DLLDB_DISABLE_PYTHON=YES -DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_UC="S:/Library/icu-64/usr/lib/icuuc64.lib" -DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/Library/icu-64/usr/lib/icuin64.lib" -DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr" -DPYTHON_EXECUTABLE=C:\Python27\python.exe -DSWIFT_BUILD_DYNAMIC_STDLIB=YES -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=YES
74+
cmake -B "S:\b\toolchain" -G Ninja -S S:\toolchain\llvm -C S:\windows-swift\cmake\caches\Windows-x86_64.cmake -C S:\windows-swift\cmake\caches\org.compnerd.dt.cmake -DLLVM_ENABLE_ASSERTIONS=YES -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;cmark;swift;lldb;lld" -DLLVM_EXTERNAL_PROJECTS="cmark;swift" -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\toolchain\swift-corelibs-libdispatch -DLLVM_ENABLE_PDB=YES -DLLDB_DISABLE_PYTHON=YES -DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_UC="S:/Library/icu-64/usr/lib/icuuc64.lib" -DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/Library/icu-64/usr/include" -DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/Library/icu-64/usr/lib/icuin64.lib" -DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr" -DPYTHON_EXECUTABLE=C:\Python27\python.exe -DSWIFT_BUILD_DYNAMIC_STDLIB=YES -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=YES
8875
ninja -C S:\b\toolchain
8976
```
9077

91-
- Update your path to include the toolchain.
92-
93-
```cmd
94-
path S:\b\toolchain\bin;%PATH%
95-
```
96-
97-
## Running tests on Windows
98-
99-
Running the testsuite on Windows has additional external dependencies.
78+
## Running Swift tests on Windows
10079

10180
```cmd
10281
path S:\Library\icu-64\usr\bin;S:\b\toolchain\bin;S:\b\toolchain\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
@@ -106,15 +85,10 @@ ninja -C S:\b\toolchain check-swift
10685
## Build swift-corelibs-libdispatch
10786

10887
```cmd
109-
cmake -B S:\b\libdispatch -G Ninja -S S:\toolchain\swift-corelibs-libdispatch -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_Swift_COMPILER=S:\b\toolchain\bin\swiftc.exe -DENABLE_SWIFT=YES
88+
cmake -B S:\b\libdispatch -G Ninja -S S:\toolchain\swift-corelibs-libdispatch -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_Swift_COMPILER=S:/b/toolchain/bin/swiftc.exe -DENABLE_SWIFT=YES
11089
ninja -C S:\b\libdispatch
11190
```
11291

113-
- Add libdispatch to your path:
114-
```cmd
115-
path S:\b\libdispatch;S:\b\libdispatch\src;%PATH%
116-
```
117-
11892
## Test swift-corelibs-libdispatch
11993

12094
```cmd
@@ -237,12 +211,12 @@ cd S:\b\spm
237211
C:\Python27\python.exe S:\swift-package-manager\Utilities\bootstrap --foundation S:\b\foundation --libdispatch-build-dir S:\b\libdispatch --libdispatch-source-dir S:\swift-corelibs-libdispatch --llbuild-build-dir S:\b\llbuild --llbuild-source-dir S:\llbuild --sqlite-build-dir S:\b\sqlite --sqlite-source-dir S:\sqlite-amalgamation-3270200
238212
```
239213

240-
## Install Swift on Windows
214+
## Install the Swift toolchain on Windows
241215

242216
- Run ninja install:
243217

244218
```cmd
245-
ninja -C S:\b\swift install
219+
ninja -C S:\b\toolchain install
246220
```
247221

248222
- Add the Swift on Windows binaries path (`C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin`) to the `PATH` environment variable.

docs/conf.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import sys
1515
from datetime import date
16+
from sphinx.highlighting import lexers
1617

1718
# If extensions (or modules to document with autodoc) are in another directory,
1819
# add these directories to sys.path here. If the directory is relative to the
@@ -263,9 +264,7 @@
263264
# Enable this if you want TODOs to show up in the generated documentation.
264265
todo_include_todos = True
265266

266-
#
267-
# Monkeypatch pygments so it will know about the Swift lexers
268-
#
267+
# -- Patch pygments so it will know about the Swift lexers ---------------
269268

270269
# Pull in the Swift lexers
271270
from os.path import abspath, dirname, join as join_paths # noqa (E402)
@@ -277,22 +276,6 @@
277276

278277
sys.path.pop(0)
279278

280-
# Monkeypatch pygments.lexers.get_lexer_by_name to return our lexers. The
281-
# ordering required to allow for monkeypatching causes the warning
282-
# "I100 Import statements are in the wrong order." when linting using
283-
# flake8-import-order. "noqa" is used to suppress this warning.
284-
from pygments.lexers import get_lexer_by_name as original_get_lexer_by_name # noqa (E402)
285-
286-
287-
def swift_get_lexer_by_name(_alias, *args, **kw):
288-
if _alias == 'swift':
289-
return swift_pygments_lexers.SwiftLexer()
290-
elif _alias == 'sil':
291-
return swift_pygments_lexers.SILLexer()
292-
elif _alias == 'swift-console':
293-
return swift_pygments_lexers.SwiftConsoleLexer()
294-
else:
295-
return original_get_lexer_by_name(_alias, *args, **kw)
296-
297-
import pygments.lexers # noqa (I100 Import statements are in the wrong order.)
298-
pygments.lexers.get_lexer_by_name = swift_get_lexer_by_name
279+
lexers['swift'] = swift_pygments_lexers.SwiftLexer()
280+
lexers['sil'] = swift_pygments_lexers.SILLexer()
281+
lexers['swift-console'] = swift_pygments_lexers.SwiftConsoleLexer()

include/swift/AST/ASTContext.h

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ namespace swift {
7070
class LazyContextData;
7171
class LazyIterableDeclContextData;
7272
class LazyMemberLoader;
73-
class LazyResolver;
7473
class PatternBindingDecl;
7574
class PatternBindingInitializer;
7675
class SourceFile;
@@ -102,6 +101,7 @@ namespace swift {
102101
class SourceManager;
103102
class ValueDecl;
104103
class DiagnosticEngine;
104+
class TypeChecker;
105105
class TypeCheckerDebugConsumer;
106106
struct RawComment;
107107
class DocComment;
@@ -273,6 +273,9 @@ class ASTContext final {
273273
/// Cache of remapped types (useful for diagnostics).
274274
llvm::StringMap<Type> RemappedTypes;
275275

276+
/// The # of times we have performed typo correction.
277+
unsigned NumTypoCorrections = 0;
278+
276279
/// Cache of autodiff-associated vector spaces.
277280
llvm::DenseMap<Type, Optional<VectorSpace>> AutoDiffVectorSpaces;
278281

@@ -415,28 +418,14 @@ class ASTContext final {
415418
/// Set a new stats reporter.
416419
void setStatsReporter(UnifiedStatsReporter *stats);
417420

418-
/// Creates a new lazy resolver by passing the ASTContext and the other
419-
/// given arguments to a newly-allocated instance of \c ResolverType.
420-
///
421-
/// \returns true if a new lazy resolver was created, false if there was
422-
/// already a lazy resolver registered.
423-
template<typename ResolverType, typename ... Args>
424-
bool createLazyResolverIfMissing(Args && ...args) {
425-
if (getLazyResolver())
426-
return false;
427-
428-
setLazyResolver(new ResolverType(*this, std::forward<Args>(args)...));
429-
return true;
430-
}
431-
432-
/// Retrieve the lazy resolver for this context.
433-
LazyResolver *getLazyResolver() const;
434-
435421
private:
436-
/// Set the lazy resolver for this context.
437-
void setLazyResolver(LazyResolver *resolver);
422+
friend class TypeChecker;
438423

424+
void installGlobalTypeChecker(TypeChecker *TC);
439425
public:
426+
/// Retrieve the global \c TypeChecker instance associated with this context.
427+
TypeChecker *getLegacyGlobalTypeChecker() const;
428+
440429
/// getIdentifier - Return the uniqued and AST-Context-owned version of the
441430
/// specified string.
442431
Identifier getIdentifier(StringRef Str) const;
@@ -498,17 +487,13 @@ class ASTContext final {
498487
/// Retrieve the type Swift.Never.
499488
CanType getNeverType() const;
500489

501-
/// Retrieve the declaration of ObjectiveC.ObjCBool.
502-
StructDecl *getObjCBoolDecl() const;
503-
504-
/// Retrieve the declaration of Foundation.NSCopying.
505-
ProtocolDecl *getNSCopyingDecl() const;
506-
/// Retrieve the declaration of Foundation.NSError.
507-
ClassDecl *getNSErrorDecl() const;
508-
/// Retrieve the declaration of Foundation.NSNumber.
509-
ClassDecl *getNSNumberDecl() const;
510-
/// Retrieve the declaration of Foundation.NSValue.
511-
ClassDecl *getNSValueDecl() const;
490+
#define KNOWN_OBJC_TYPE_DECL(MODULE, NAME, DECL_CLASS) \
491+
/** Retrieve the declaration of MODULE.NAME. */ \
492+
DECL_CLASS *get##NAME##Decl() const; \
493+
\
494+
/** Retrieve the type of MODULE.NAME. */ \
495+
Type get##NAME##Type() const;
496+
#include "swift/AST/KnownObjCTypes.def"
512497

513498
// Declare accessors for the known declarations.
514499
#define FUNC_DECL(Name, Id) \
@@ -894,6 +879,11 @@ class ASTContext final {
894879
/// This guarantees that resulted \p names doesn't have duplicated names.
895880
void getVisibleTopLevelModuleNames(SmallVectorImpl<Identifier> &names) const;
896881

882+
/// Whether to perform typo correction given the pre-configured correction limit.
883+
/// Increments \c NumTypoCorrections then checks this against the limit in
884+
/// the language options.
885+
bool shouldPerformTypoCorrection();
886+
897887
private:
898888
/// Register the given generic signature builder to be used as the canonical
899889
/// generic signature builder for the given signature, if we don't already

0 commit comments

Comments
 (0)