Commit Graph

9699 Commits

Author SHA1 Message Date
Brent Royal-Gordon
def1af6049 Merge pull request #23358 from brentdax/a-type-is-a-set-of-its-instances
Add static and class subscripts
2019-04-11 12:58:32 -07:00
Brent Royal-Gordon
473fe7027e Make sure we don’t support @objc class subscripts
Obj-C subscripts don’t work on class objects, but you can declare class methods with the appropriate names. We don’t want to half-support this. Emit an error if you try to write “@objc class subscript” and test that we don’t import the methods as subscripts.
2019-04-10 23:17:04 -07:00
Brent Royal-Gordon
0fcb09d9ce Fix description of static subscripts in errors 2019-04-10 23:17:04 -07:00
Brent Royal-Gordon
d9732a050f Allow the declaration of static subscripts
In this commit, MyStruct.self[0] parses and typechecks but the solution doesn’t apply correctly. MyStruct[0] gets diagnosed as an error.
2019-04-10 23:09:44 -07:00
Jordan Rose
5c27568738 Check assoc types for conformances from implementation-only imports
Okay, strictly we're checking the "signature conformances" of a newly-
declared conformance, but that wouldn't have fit on one line. This is
making sure that we don't have a requirement on an associated type (or
on the conforming type) that can only be satisfied using a conformance
in an implementation-only import.
2019-04-10 11:09:07 -07:00
Jordan Rose
519fa00adc Check signatures for conformances from implementation-only imports
These also create a dependency on the implementation module, even if
both the type and the protocol are public. As John puts it, a
conformance is basically a declaration that we name as part of another
declaration.

More rdar://problem/48991061
2019-04-10 11:09:07 -07:00
Slava Pestov
e2cb0572fe SILOptimizer: Re-implement NPCR diagnostics in SIL pass
This fixes a test involving transitive captures of local functions,
as well as an infinite recursion possible with the old code.

Fixes <rdar://problem/34496304>.
2019-04-09 16:44:50 -04:00
Slava Pestov
6a34ed0120 Sema: Remove NPCR diagnostics 2019-04-09 16:35:25 -04:00
Slava Pestov
ae1e5b1ede AST: Remove unused TypeBase::isAssignableType() 2019-04-09 15:02:14 -04:00
Slava Pestov
003a9a47b2 Parse: Remove obsolete @autoclosure(escaping) and @noescape type attributes
Some diagnostics got worse, but I think the reduction in compiler complexity
is worth it, and copy-and-pasting Swift 2 code is not likely to produce great
results anyway.

Also, this corrects an oversight where we did not reject @pseudogeneric on
function types in AST parsing.
2019-04-09 15:02:14 -04:00
Slava Pestov
9ac0dc3d6c SILOptimizer: Re-implement escaping capture diagnostics
The new pass is based on existing asserts in DiagnoseStaticExclusivity.
They were compiled out in release builds and only checked for captures of
inout parameters. This patch converts the assertions into diagnostics and
adds checks for captures of non-escaping function values.

Unlike the Sema-based checks that this replaces, the new code handles
transitive captures from recursive local functions, which means certain
invalid code that used to compile will now be rejected with an error.

The new analysis also looks at the ultimate usages of a local function
instead of just assuming all local functions are escaping, which fixes
issues where the compiler would reject valid code.

Fixes a bunch of related issues, including:

- <rdar://problem/29403178>
- <https://bugs.swift.org/browse/SR-8546> / <rdar://problem/43355341>
- <https://bugs.swift.org/browse/SR-9043> / <rdar://problem/45511834>
2019-04-09 15:02:14 -04:00
Slava Pestov
1c17ccfd3c AST: Add TypeBase::isNoEscape() 2019-04-09 15:02:14 -04:00
Slava Pestov
e214156abf Sema: Remove escaping capture diagnostics
I'm about to replace all of this with a SIL pass.
2019-04-09 15:02:14 -04:00
Jordan Rose
d96aebd147 [AST] Mark two more dump() methods as LLVM_ATTRIBUTE_USED (#23873)
...so that they don't get dead-code-stripped and become unusable from
the debugger.
2019-04-08 19:55:16 -07:00
Gogul Balakrishnan
1fa3846224 Add more hooks for overriding name lookup in the DebuggerClient (#23031) 2019-04-08 15:19:31 -07:00
Jordan Rose
a9b0a6661a Implementation-only import checking for types used in decls
Based on the existing access checker for types used in decls. There's
a common skeleton here but we can't seem to get it out, so for now
add a third DeclVisitor to this file. On the plus side, checking this
alongside access is an easy way to make sure everything gets checked.

Part of rdar://problem/48991061
2019-04-05 20:10:10 -07:00
Jordan Rose
6c0538988d Access checking: Separate TypeDecl-finding from access scope checking
...for planned reuse in implementation-only import logic.
No intended functionality change.
2019-04-05 20:10:10 -07:00
John McCall
6ef5fb57f0 Merge pull request #23702 from rjmccall/implementation-only-diagnostics
[WIP] implementation-only import checking
2019-04-05 22:07:45 -04:00
David Ungar
cf5d81c889 Merge pull request #23735 from davidungar/tracking-primary
[Batch mode] Cope with bugs that cause error  suppression.
2019-04-05 17:45:20 -07:00
John McCall
ae6561c32c Checks for implementation-only imports in @inlinable code.
Part of rdar://48991061
2019-04-05 16:30:25 -04:00
Arnold Schwaighofer
e50af98cc4 Merge pull request #23790 from aschwaighofer/dynamic_replacement_final
Allow final on dynamic members
2019-04-05 10:09:39 -07:00
Arnold Schwaighofer
90fe435f25 Don't constrain to swift-version 5 2019-04-05 07:09:57 -07:00
Pavel Yaskevich
16b65018b4 Merge pull request #23436 from xedin/keypath-dynamic-lookup
[SE-0252][TypeChecker] Keypath Dynamic Member Lookup
2019-04-05 00:10:53 -07:00
David Ungar
c8cd0f3bc0 Move location lookup to RAII object. 2019-04-04 22:41:53 -07:00
David Ungar
240b573966 WIP 2019-04-04 21:55:25 -07:00
David Ungar
bb131fb4b4 Expand parameter description. 2019-04-04 16:37:38 -07:00
Michael Gottesman
b6c3ca0cd8 Merge pull request #23801 from gottesmm/pr-56c61430037696146352efbfcedf418a94036015
[silgenpattern] Fix two ASAN errors.
2019-04-04 16:34:22 -07:00
David Ungar
9d99eb7f83 Fix typo 2019-04-04 16:22:39 -07:00
Michael Gottesman
564b4fc11a [silgenpattern] Fix some stack-use-after-free errors caused by iterating over an Optional<ArrayRef<T>>.
Specifically the bad pattern was:

```
   for (auto *vd : *caseStmt->getCaseBodyVariables()) { ... }
```

The problem is that the optional is not lifetime extended over the for loop. To
work around this, I changed the API of CaseStmt's getCaseBodyVariable methods to
never return the inner Optional<MutableArrayRef<T>>. Now we have the following 3
methods (ignoring const differences):

1. CaseStmt::hasCaseBodyVariables().

2. CaseStmt::getCaseBodyVariables(). Asserts if the case body variable array was
   never specified.

3. CaseStmt::getCaseBodyVariablesOrEmptyArray(). Returns either the case body
   variables array or an empty array if we were never given any case body
   variable array.

This should prevent anyone else in the future from hitting this type of bug.

radar://49609717
2019-04-04 13:34:36 -07:00
swift-ci
8fc305c03e Merge pull request #23779 from adrian-prantl/48827784 2019-04-04 11:09:11 -07:00
Azoy
7c75836d77 context cleanup part 1 2019-04-03 20:50:58 -05:00
David Ungar
d0330523d0 suppress non-primary errors if there is no responsible primary 2019-04-03 16:19:45 -07:00
Adrian Prantl
4a23512068 Add an option to disable DWARF skeleton CU breadcrumbs for Clang
module imports. This is useful when building redistributable static
archives, since any pointers into the CLang module cache won't be
portable.

When using this option the Clang type fallback path in LLDB will be
less useful since DWARF type information from those modules will not
be available unless another object file compiled without the option
imported the same modules.

rdar://problem/48827784
2019-04-03 15:45:11 -07:00
Michael Gottesman
ed94b13d3f [ast] Add a helper method for checking if a pattern contains a var decl and adopt it. 2019-04-03 13:38:03 -07:00
Michael Gottesman
8311f2b050 [ast] Add helpers for grabbing various case stmt corresponding var decls to a specific case stmt var decl. 2019-04-03 13:38:03 -07:00
David Ungar
44daa88ebd Format 2019-04-03 12:53:31 -07:00
David Ungar
9cc3a4a9d8 Rename defaultDiagnosticLoc to bufferIndirectlyCausingDiagnostic. 2019-04-03 12:52:49 -07:00
David Ungar
fd63a1ea73 Change strategy for non-primaries
No more vacuous subconsumers. Output into active primary or everywhere.
2019-04-03 11:38:58 -07:00
David Ungar
7ac4592419 Rm ForAnyKind 2019-04-03 11:01:57 -07:00
David Ungar
b112f73780 Typos 2019-04-02 22:52:14 -07:00
David Ungar
0baa668920 Format 2019-04-02 22:28:38 -07:00
David Ungar
c139c5909a Pass defaultDiagnosticLoc to handleDiagnostic, not currentPrimaryInput. 2019-04-02 22:27:55 -07:00
David Ungar
3b8b903807 Refactor handleDiagnostic 2019-04-02 21:41:40 -07:00
Slava Pestov
6bb36b5c01 Sema: Subscript default arguments
Fixes <https://bugs.swift.org/browse/SR-6118>.
2019-04-02 20:37:01 -04:00
Slava Pestov
8292cbe3b3 AST: Remove 'default argument resilience expansion'
This was a Swift 3 mode holdover.
2019-04-02 20:37:01 -04:00
Brent Royal-Gordon
dd95a63e5b Merge pull request #23724 from brentdax/static-start
[NFC] Correct assumptions about static AbstractStorageDecls
2019-04-02 17:16:27 -07:00
adrian-prantl
8437ee5df0 Merge pull request #23427 from adrian-prantl/remove-resilience-bypass
Remove the -resilience-bypass flag and functionality.
2019-04-02 16:43:09 -07:00
Xi Ge
dd8b405dfb Merge pull request #23731 from nkcsgexi/witness-table-entry
swift-api-digester: diagnose changing of the necessity of new witness table entry as ABI breakage
2019-04-02 14:39:48 -07:00
David Ungar
c90d9e69b6 Format 2019-04-02 00:43:59 -07:00
David Ungar
7a0e0ffc8a Store current primary in diagnostic engine, pass it down via handleDiagnostic. Unformmated. 2019-04-02 00:43:28 -07:00