Commit Graph

58361 Commits

Author SHA1 Message Date
Michael Gottesman
e320ee1cd8 [ownership] Convert a few small visitor methods to be const. 2020-03-18 22:59:00 -07:00
Michael Gottesman
dbe0cfa561 Merge pull request #30494 from gottesmm/pr-71e6912f769c828f0358528f1e46433cb7032362
[ownership] Rename BorrowScopeIntroducingValue -> BorrowedValue and BorrowScopeOperand -> BorrowingOperand.
2020-03-18 21:41:33 -07:00
Xi Ge
5fba4b3e4c Merge pull request #30484 from nkcsgexi/58563540
ModuleInterface: consider inherited protocols from super class when collecting handled protocols
2020-03-18 21:34:23 -07:00
Doug Gregor
3abea6be65 [Constraint system] Use the PatternBindingDecl context when possible.
Make sure that we're resolving types and patterns using the
PatternBindingDecl context, both for the type resolver context and the
contextual pattern used for pattern resolution.

Fixes a regression with implicitly-unwrapped options reported as
SR-11998 / rdar://problem/58455441.
2020-03-18 21:09:06 -07:00
Slava Pestov
10c9cb57f0 Merge pull request #30485 from slavapestov/silgen-cleanup-sr-75
Remove SILGen support code for curry thunks
2020-03-18 23:19:42 -04:00
Argyrios Kyrtzidis
08f7028446 Merge pull request #30482 from apple/syntax-incremental-parse-diagnostic
[Parse] Fix issue with incremental re-parsing for SwiftSyntax emitting bogus parsing error
2020-03-18 20:17:27 -07:00
Michael Gottesman
47e74473f1 [ownership] Rename BorrowScopeIntroducingValue -> BorrowedValue and BorrowScopeOperand -> BorrowingOperand.
Andy and I for some time have been discussing the right name for these two
"ownership concepts". What we realized is that the "ing" on
BorrowScopeIntroducingValue is very unfortunate since this value is the result
of a new borrow scope being introduced. So the name should be really:
BorrowScopeIntroducedValue. Given that is sort of unsatisfying, we settled on
the name BorrowedValue.

Once we found the name BorrowedValue, we naturally realized that
BorrowScopeOperand -> BorrowingOperand followed. This is because the operand is
the operand of the instruction that is creating the new borrow scope. So in a
sense the Operand is the "Use" that causes the original value to become
borrowed. So a BorrowingOperand is where the action is and is "active".
2020-03-18 19:43:30 -07:00
Andrew Trick
991a8dc31b Add getArraySemanticsKind API.
So that it's possible to determine the kind of Array semantic function
from its SILFunction decl only.
2020-03-18 18:19:10 -07:00
Nathan Hawes
fd82d87db0 Merge pull request #30402 from nathawes/cross-import-code-completion
[IDE/CodeCompletion] Add code completion support for cross import overlays.
2020-03-18 18:16:03 -07:00
Pavel Yaskevich
c72940f2c7 [ConstraintSystem] Default multi-statement closure result to Void only after resolving
Let's remove a side-effect from `ConstraintGenerator::inferClosureType`
and default result type to `Void` for multi-statement closures after
closure has been resolved.
2020-03-18 17:48:56 -07:00
Xi Ge
45d0eca9c7 ModuleInterface: consider inherited protocols from super class when collecting handled protocols
Protocol conformances can be implied by super classes. When collecting the list
of IncludedProtocols, we should traverse the class inheritance chain and collect
all protocols.

Without this change, these implied conformances will be printed again via a synthesized
extension at the end of the Swift interface file, leading to an error of redundant
conformances when building modules.

rdar://58563540
2020-03-18 17:21:13 -07:00
Pavel Yaskevich
2d6170b847 [TypeChecker] Requestify check to determine if closure has explicit result
Determine whether closure body has any explicit `return`
statements which could produce a non-void result.
2020-03-18 17:06:15 -07:00
Joe Groff
c90b8f7722 Swift 5.3 is always available for arm64e.
Nobody has shipped an ABI-stable arm64e platform yet, so anyone who does ought to deploy at least
Swift 5.3.
2020-03-18 16:49:47 -07:00
Joe Groff
b636a07070 IRGen: Use mangled names to access opaque type associated types in Swift >=5.2. 2020-03-18 16:43:09 -07:00
Slava Pestov
052309e045 SILGen: Remove CallSite::SubstResultType
There was a bunch of book-keeping here that became dead.
2020-03-18 19:26:29 -04:00
Slava Pestov
b5732d3a3a SILGen: Eliminate the notion of 'extra call sites'
Now that curry thunks are gone, we can do a bit more refactoring
to guarantee that an ApplyExpr always has the *exact* number of
call sites expected.

Extra call sites are handled by emitting the innermost ApplyExpr
as an indirect callee, eliminating a special code path.
2020-03-18 19:26:29 -04:00
Slava Pestov
4aa75163a6 SILGen: Remove curry thunks
Now that CSApply transforms partial applications into closures,
we never see AST with partially-applied method calls. So all the
machinery for emitting curry thunks is now gone.
2020-03-18 19:26:14 -04:00
Brent Royal-Gordon
cd7bc73a0a Merge pull request #30462 from brentdax/futures-end-part-two
Provide fallback SourceLoc for swiftinterface build errors
2020-03-18 16:23:49 -07:00
Slava Pestov
f6187e520a Sema: Don't devirtualize partially applied operator references 2020-03-18 19:23:18 -04:00
Argyrios Kyrtzidis
791309155d [Parse] Fix issue with incremental re-parsing for SwiftSyntax emitting bogus parsing error
rdar://60232712
2020-03-18 16:00:04 -07:00
Arnold Schwaighofer
71599b711c IRGen: Only use type layouts when we expect the generated IR to be faster
If there the layout is not dependent on archetypes and but has resilient types
using the new type layout based approach is not going to be faster.

rdar://59960653
2020-03-18 14:54:04 -07:00
Arnold Schwaighofer
13cd05cfb1 TypeLayout: Add containsResilient and containsArchetype
We'll use that in a follow-up commit.
2020-03-18 14:54:04 -07:00
Joe Groff
72b13e8c65 IRGen: Add a flag to disable mangled name type metadata accessors.
Useful as a workaround for runtime demangler bugs, or in rare cases where there are
performance problems with the demangler.
2020-03-18 13:55:01 -07:00
Andrew Trick
976a1d7c9b Merge pull request #30474 from atrick/add-inlining-diagnostics
Emit inlining diagnostics as debug messages.
2020-03-18 13:23:07 -07:00
Andrew Trick
d28ab085cc Merge pull request #30473 from atrick/fix-devirtualizer-invalidate
SILOptimizer: Fix analysis invalidation after devirtualization.
2020-03-18 13:21:19 -07:00
Ben Langmuir
c04a8a9076 Merge pull request #30011 from AnthonyLatsis/mutating_dup_quick_help
[ASTPrinter] Fix duplicate «mutating» modifiers when printing file interface
2020-03-18 13:17:05 -07:00
Andrew Trick
3462935808 Merge pull request #30466 from atrick/fix-fso-bailout
Move the FSO bailout to the beginning of the pass.
2020-03-18 13:01:38 -07:00
AG
a32ed1e48f Merge pull request #30461 from bitjammer/acgarland/rdar-60193675-filter-unavailable-obsoleted
[SymbolGraph] Completely filter unavailable/obsoleted symbols
2020-03-18 12:35:04 -07:00
Nathan Hawes
63636100be [IDE/CodeCompletion] Add code completion support for cross import overlays.
If a cross-import overlay shadows another module and has a name starting with
'_', don't present that overlay in places where module name completions are
offered and present symbols comining from that module as if they came from
the shadowed module instead.

Resolves rdar://problem/59445688
2020-03-18 12:02:20 -07:00
Ben Langmuir
a3cf3737d4 Merge pull request #30471 from benlangmuir/more-str
More explicit StringRef -> std::string conversions
2020-03-18 11:36:03 -07:00
Slava Pestov
6412581751 Merge pull request #28698 from slavapestov/sr-75
Sema: Rewrite partial applications into closures
2020-03-18 14:24:37 -04:00
Andrew Trick
ab14c432c3 Emit inlining diagnostics as debug messages.
So -debug-only=sil-inliner is useful.
2020-03-18 11:24:11 -07:00
Andrew Trick
70678ab856 SILOptimizer: Fix analysis invalidation after devirtualization.
Devirtualizing try_apply modified the CFG, but passes that run
devirtualization were not invalidating any CFG analyses, such as the
domtree.

This could hypothetically have caused miscompilation, but will be
caught by running with -sil-verify-all.
2020-03-18 10:21:35 -07:00
Ben Langmuir
a46b35b5ca More explicit StringRef -> std::string conversions
On the older compiler/stdlib used by our Ubuntu 16.04 bots, the
construction

        std::pair<std::string, X>(StringRef, X)

fails unless you call `.str()`. Newer compilers/stdlib treat this as an
explicit construction, which is what is now needed on master-next, so it
only fails on Ubuntu 16.04.

rdar://60514063
2020-03-18 09:50:56 -07:00
Pavel Yaskevich
d6ebb03c97 Merge pull request #30247 from owenv/combined-descriptive-diag-flags
Support the combination of -enable-educational-notes and -enable-experimental-diagnostic-formatting
2020-03-18 09:44:29 -07:00
Ashley Garland
58edd83f37 [SymbolGraph] Completely filter unavailable/obsoleted symbols
Symbol graph files are processed per platform--documentation for symbols that
are unconditionally unavailable or obsoleted on a platform shouldn't be shown
for that same platform.

Also, removes `isUnconditionallyUnavailable` from the JSON format. If it's
unconditionally unavailable, it won't show up at all.

rdar://60193675
2020-03-18 09:43:08 -07:00
Andrew Trick
75bad901a3 Merge pull request #30467 from atrick/add-inline-never
Add -sil-inline-never-functions flag.
2020-03-18 08:27:46 -07:00
Pavel Yaskevich
2df9bb509e Merge pull request #30440 from LucianoPAlmeida/SR-11540-ambiguos-closure-inference
[SR-11540] Fix ambiguos overload apply to argument for contextual closure
2020-03-18 08:26:34 -07:00
Slava Pestov
c543838854 Sema: Rewrite partial applications into closures
When a method is called with fewer than two parameter lists,
transform it into a fully-applied call by wrapping it in a
closure.

Eg,

Foo.bar => { self in { args... self.bar(args...) } }
foo.bar => { self in { args... self.bar(args...) } }(self)

super.bar => { args... in super.bar(args...) }

With this change, SILGen only ever sees fully-applied calls,
which will allow ripping out some code.

This new way of doing curry thunks fixes a long-standing bug
where unbound references to protocol methods did not work.

This is because such a reference must open the existential
*inside* the closure, after 'self' has been applied, whereas
the old SILGen implementation of curry thunks really wanted
the type of the method reference to match the opened type of
the method.

A follow-up cleanup will remove the SILGen curry thunk
implementation.

Fixes rdar://21289579 and https://bugs.swift.org/browse/SR-75.
2020-03-18 09:29:22 -04:00
Martin Boehme
490021fec6 Fix: Access NamedDecl::getName() only if the name is an identifier.
Non-identifier names aren't currently an issue, but it will become one
when we add more support for C++, e.g. for C++ constructors (which I
plan to tackle soon).
2020-03-18 09:04:36 +01:00
Andrew Trick
e8d3ee11eb Add -sil-inline-never-functions flag.
And fix a test case that assumes Array.append is never inlined.

We need to be able to prevent inlining a function and any of its
specializations. There's no way to specify multiple function names on
the command line, so we use the partial match technique.
2020-03-18 00:36:49 -07:00
Andrew Trick
80d502c8ef Move the FSO bailout to the beginning of the pass.
This way we catch the DeadFunctionArgs optimization too, which is a
separate sub-pass.
2020-03-17 23:35:02 -07:00
Alex Langford
8953af519f [Driver] Don't pass ELF shared objects to swift-autolink-extract
Prior to performing linking on ELF platforms (except the PS4) we extract
autolink information from the object files that will be used during linking.
The current implementation passes all the linker inputs that are marked as an
TY_Object to swift-autolink-extract. There are a two cases where this is
not necessary or problematic.

In the first case, we are looking at an ELF shared object. Although
harmless, this is wasted work. Specifically, the `.swift1_autolink_entries`
entry in the object files are marked as `SHF_EXCLUDE`, meaning they will not be
merged into the final product during linking.

In the second case, we are linking against a linker script that looks like an
ELF shared object (ends with `.so`). In the previous case, the autolink-extract
step will succeed even if it does unnecessary work. In this case, the
autolink-extract step will fail because it cannot recognize the linker script as
an object file. You will observe an error something like this:
```
<unknown>:0: error: error opening input file '/path/to/libLinkerScript.so'
(The file was not recognized as a valid object file
```
Although your linker will know what to do with it, autolink-extract will halt
before you get to that point.
2020-03-17 21:54:00 -07:00
swift-ci
270f734403 Merge pull request #30435 from zoecarver/fix/builtin-is-dead 2020-03-17 20:48:59 -07:00
Saleem Abdulrasool
2c1c13d911 Merge pull request #30430 from compnerd/rpath
Driver: honour `-no-toolchain-stdlib-rpath` on Unices
2020-03-17 19:14:11 -07:00
Brent Royal-Gordon
a27fdad4e5 Provide fallback SourceLoc for swiftinterface build errors
When a swiftinterface fails to build for any of various reasons, we try to diagnose the failure at the site of the `import` declaration. But if the import is implicitly added—which happens for many SDK modules, like the standard library and ClangImporter overlays—there is no source location for the import, so the error ends up being diagnosed at <unknown>:0. This causes a number of issues; most notably, Xcode doesn’t display the diagnostic as prominently as others.

This change falls back to diagnosing the error at line 1, column 1 of the swiftinterface file itself. This is perhaps not an ideal location, and it won’t help with I/O errors where we can’t open the swiftinterface file (and therefore can’t diagnose an error in it), but it should improve the way we display most module interface building errors.
2020-03-17 18:44:31 -07:00
Luciano Almeida
3b2dd8cc98 [CSSimplify] Increase the score with SK_FunctionConversion whenever we have to implode parameters to support SE-110 cases 2020-03-17 20:40:07 -03:00
Slava Pestov
4caa6d7003 IDE: Fix indexing for Sema-built curry thunks 2020-03-17 19:03:03 -04:00
Slava Pestov
b45f70d8b0 IDE: Clean up traversal logic in SourceEntityWalker
Try to make this a bit more self-documenting.
2020-03-17 19:03:03 -04:00
zoecarver
8f1594685f Polymorphic builtins should have empy attributes 2020-03-17 15:17:10 -07:00