Commit Graph

24822 Commits

Author SHA1 Message Date
Holly Borla
66e85721cb Merge pull request #30807 from hborla/property-wrapper-refactoring
[Property Wrappers] Refactor property wrappers so the synthesized backing init is only type checked once
2020-04-14 10:48:22 -07:00
Rintaro Ishizaki
5d6298ad05 Merge pull request #30996 from rintaro/ide-completion-performcachedoperaiton
[CodeCompletion][NFC] Fix typo
2020-04-13 16:20:09 -07:00
swift-ci
9a0efcac2a Merge pull request #30548 from AnthonyLatsis/sr-7855 2020-04-13 13:20:27 -07:00
Rintaro Ishizaki
2bf9dde17b [CodeCompletion][NFC] Fix typo 2020-04-13 11:55:34 -07:00
Nathan Hawes
b3b7aa8ecf Merge pull request #30964 from nathawes/syntactic-rename-for-callAsFunction
[IDE][Refactoring] Handle 'callAsFunction' specially in syntactic rename
2020-04-13 11:36:53 -07:00
Slava Pestov
ab45d517d5 Merge pull request #29931 from theblixguy/fix/SR-12178
[Typechecker] Fix _modify for wrapped properties with observers
2020-04-12 22:11:10 -04:00
Nathan Hawes
bce68fa4e5 [IDE][Refactoring] Handle 'callAsFunction' specially in syntactic rename.
This change makes us treat it exactly as we do 'init'. We don't allow renaming the base name,
and don't fail if the basename doesn't match for calls.

Also:
  - explicit init calls/references like `MyType.init(42)` are now reported with
    'init' as a keywordBase range, rather than nothing.
  - cursor info no longer reports rename as available on init/callAsFunction
    calls without arguments, as there's nothing to rename in that case.
  - Improved detection of when a referenced function is a call (rather than
    reference) across syntactic rename, cursor-info, and indexing.

Resolves rdar://problem/60340429
2020-04-12 17:14:15 -07:00
Slava Pestov
1af01edbf0 Merge pull request #30965 from slavapestov/enable-dynamic-replacement-vs-library-evolution
Enable dynamic replacement with library evolution
2020-04-11 01:39:09 -04:00
eeckstein
628bf7beae Merge pull request #30957 from eeckstein/fix-large-string-arrays
Several compile time fixes related to large string arrays.
2020-04-11 06:55:00 +02:00
Slava Pestov
365f0c7af5 Merge pull request #30861 from slavapestov/outdated-fixme
IRGen: Type reconstruction supports opaque result types now
2020-04-10 23:32:43 -04:00
Slava Pestov
23cac673ca IRGen: Enable dynamic replacement with library evolution
It looks like the only thing that fails is the linkage computation
for the dynamic replacement key of class methods. Even though
methods have hidden linkage to prevent them from being directly
referenced from outside a resilient module, we need to ensure
the dynamic replacement key is visible.

Fixes <rdar://problem/58457716>.
2020-04-10 22:53:36 -04:00
Xi Ge
bae31467a3 Merge pull request #30962 from nkcsgexi/44777994
AST: making `export: true` in @_specialized attribute a no-operation
2020-04-10 18:39:22 -07:00
Xi Ge
435d13496e AST: making export: true in @_specialized attribute a no-operation
The client code doesn't actually call into these specialized functions even
though they have public linkage. This could lead to TBD verification failure
shown in rdar://44777994.

This patch also warns users' codebase when `export: true` is specified.
2020-04-10 16:52:22 -07:00
Artem Chikin
e3ce6f7b7e Merge pull request #30939 from artemcm/ImplOnlyPropertyWrappers
[Sema] Diagnose use of implementation-only property wrappers
2020-04-10 15:12:41 -07:00
Rintaro Ishizaki
579e662362 Merge pull request #30954 from rintaro/ide-completion-prettystacktrace
[CodeCompletion] Add pretty stacktrace for completion operation
2020-04-10 13:14:54 -07:00
Hamish Knight
a61223a255 [CS] Visit all fixed bindings for constraint re-activation (#30886)
[CS] Visit all fixed bindings for constraint re-activation
2020-04-10 12:27:47 -07:00
Dan Zheng
486e667904 [AutoDiff] Support direct init reference differentiation. (#30946)
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 12:23:19 -07:00
Slava Pestov
41ccedc999 AST: Fix opaque type mangling used by type reconstruction
Make sure we mangle opaque types using the same settings as the
debugger mangling (with OptimizeProtocolNames = false) to ensure
that we can reconstruct those names again.
2020-04-10 15:05:54 -04:00
Artem Chikin
efdfceeb9b [Sema] Diagnose use of implementation-only property wrappers
We already ban all structs from declaring storage that comes from implementation-only imports. Until now we missed property wrappers, they were just dropped in deserialization.

Resolves rdar://problem/59403617
2020-04-10 11:19:42 -07:00
Erik Eckstein
1de19a1b32 SimplifyCFG: fix a compile time problem with block merging
When merging many blocks to a single block (in the wrong order), instructions are getting moved over and over again.
This is quadratic and can result in very long compile times for large functions.
To fix this, always move the instruction to smaller block to the larger block.

rdar://problem/56268570
2020-04-10 20:10:24 +02:00
Erik Eckstein
6da902ef8b Add an option to completely disable SIL verification.
This is useful to disable SIL verification in an assert build of the compiler.
2020-04-10 20:10:24 +02:00
Erik Eckstein
d73686a5b5 SILCombine: limit the worklist size for instruction canonicalization
To be precise: don't add instruction uses to the worklist if it already has more than 10000 elements.
This avoids quadratic behavior for very large functions.

rdar://problem/56268570
2020-04-10 20:10:24 +02:00
Erik Eckstein
fd6c26e948 EscapeAnalysis: don't compute the connection graph for very large functions
For functions which results in > 10000 nodes, just bail and don't compute the connection graph.
The node merging algorithm is quadratic and can result in significant compile times for very large functions.

rdar://problem/56268570
2020-04-10 20:10:24 +02:00
Erik Eckstein
f33c2ade1d EscapeAnalysis: remove an unused parameter from canOptimizeArrayUninitializedCall
NFC
2020-04-10 20:10:24 +02:00
Hamish Knight
d69a42d656 [CS] Preserve compatibility for collection coercions
Previously we could allow some invalid coercions to
sneak past Sema. In most cases these would either
cause crashes later down the pipeline or
miscompiles. However, for coercions between
collections, we emitted somewhat reasonable code
that performed a force cast.

This commit aims to preserve compatibility with
those collection coercions that previously
compiled, and emits a warning telling the user to
use either 'as?' or 'as!' instead.
2020-04-10 10:16:07 -07:00
Rintaro Ishizaki
de6a402116 [CodeCompletion] Add pretty stacktrace for completion operation 2020-04-10 09:28:40 -07:00
Dan Zheng
b4fa7e0027 [AutoDiff] Support direct init reference differentiation.
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 01:26:34 -07:00
Owen Voorhees
cfbedd81c4 [DiagnosticVerifier] Add support for asserting presence of edu notes 2020-04-09 18:18:25 -07:00
Suyash Srijan
84f8e41dee [Typechecker] Add an hasObservers() convenience method and simplify some code 2020-04-10 00:26:52 +01:00
Holly Borla
65105f3a26 [Property Wrappers] Introduce a new Expr node for the property wrapper
wrapped value placeholder in an init(wrappedValue:) call that was previously
injected as an OpaqueValueExpr. This commit also restores the old design of
OpaqueValueExpr.
2020-04-09 16:00:57 -07:00
Robert Widmann
0f15af520b Merge pull request #30795 from davidungar/typo-fix
[NFC] Fix a typo in a comment
2020-04-09 15:31:11 -07:00
tbkka
110e5136c1 Float16 optimal formatting (#30862)
Extend SwiftDtoa to provide optimal formatting for Float16 and use that for `Float16.description` and `Float16.debugDescription`.

Notes on signaling NaNs: LLVM's Float16 support passes Float16s on x86
by legalizing to Float32.  This works well for most purposes but incidentally
loses the signaling marker from any NaN (because it's a conversion as far
as the hardware is concerned), with a side effect that the print code never
actually sees a true sNaN.  This is similar to what happens with Float and
Double on i386 backends.  The earlier code here tried to detect sNaN in a
different way, but that approach isn't guaranteed to work so we decided to
make this code use the correct detection logic -- sNaN printing will just be
broken until we can get a better argument passing convention.

Resolves rdar://61414101
2020-04-09 09:37:38 -04:00
Dan Zheng
20dedfb40f [Gardening] Remove unnecessary forward declaration. 2020-04-09 01:10:47 -07:00
Dan Zheng
3999b8b23f Merge pull request #30912 from dan-zheng/fix-synthesized-file-unit
Fix SynthesizedFileUnit serialization and TBDGen issues.
2020-04-09 00:30:26 -07:00
swift-ci
83e176bd5e Merge pull request #30913 from atrick/fix-assert-termoper 2020-04-08 23:41:42 -07:00
Andrew Trick
8636c39259 Fix assert in MemAccessUtils isLetAccess
Assertion failed:
(accessedAddress == getAccessedAddress(accessedAddress) &&
"caller must find the address root"), function isLetAddress,
file /Users/rjmccall/dev/swift/swift/lib/SIL/Utils/MemAccessUtils.cpp,
line 63.

Teach the getAccessedAddress utility to iterate through nested access
markers with projections interposed.

Fixes <rdar://problem/61464370>
Crash in SILOptimizer/access_marker_verify.swift
2020-04-08 22:04:16 -07:00
Dan Zheng
165af547f3 Fix SynthesizedFileUnit serialization and TBDGen issues.
Make `SynthesizedFileUnit` attached to a `SourceFile`. This seemed like the
least ad-hoc approach to avoid doing unnecessary work for other `FileUnit`s.

TBDGen: when visiting a `SourceFile`, also visit its `SynthesizedFileUnit` if
it exists.

Serialization: do not treat `SynthesizedFileUnit` declarations as xrefs when
serializing the companion `SourceFile`.

Resolves TF-1239: AutoDiff test failures.
2020-04-08 21:19:56 -07:00
Suyash Srijan
724f8c23db [Typechecker] Implement SE-0268 Refine didSet Semantics (#26632) 2020-04-09 01:23:15 +01:00
Nathan Lanza
ec928352eb Merge pull request #30882 from enferex/fix-include
[clangimporter] Include clang/AST/ASTContext.h to fix master-next build.
2020-04-08 14:44:38 -04:00
Brent Royal-Gordon
4de19e1c3c Merge pull request #30819 from brentdax/a-less-ambitious-crossover-event
Ignore transitive ObjC imports when cross-importing
2020-04-08 11:40:35 -07:00
Dan Zheng
2eb460de4d [AutoDiff upstream] Add forward-mode differentiation. (#30878)
JVP functions are forward-mode derivative functions. They take original
arguments and return original results and a differential function. Differential
functions take derivatives wrt arguments and return derivatives wrt results.

`JVPEmitter` is a cloner that emits JVP and differential functions at the same
time. In JVP functions, function applications are replaced with JVP function
applications. In differential functions, function applications are replaced
with differential function applications.

In JVP functions, each basic block takes a differential struct containing callee
differentials. These structs are consumed by differential functions.
2020-04-08 11:29:21 -07:00
Pavel Yaskevich
51267754fc Merge pull request #30867 from xedin/rdar-59874355
[TypeChecker] Diagnose key paths with contextual type but no leading dot
2020-04-08 10:05:35 -07:00
Matt Davis
792ee14e0c [clangimporter] Include clang/AST/ASTContext.h to fix master-next build. 2020-04-08 08:41:41 -07:00
Dan Zheng
a282ee622b [AutoDiff] NFC: silence unused variable warnings. 2020-04-08 00:10:12 -07:00
Dan Zheng
f27f1cde66 Merge pull request #30863 from dan-zheng/synthesized-file-unit
[AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.
2020-04-07 23:48:09 -07:00
Artem Chikin
0d1013245e Merge pull request #30782 from artemcm/Rcross-import
Add -Rcross-import option
2020-04-07 19:04:47 -07:00
Dan Zheng
de4deb5867 [AutoDiff] Lazily create synthesized file during differentiation.
Make `ADContext` lazily create a `SynthesizedFileUnit` instead of creating one
during `ADContext` construction. This avoids always creating a
`SynthesizedFileUnit` in every module, since differentiation is a mandatory
transform that always runs.

It was nonetheless useful to test always creating a `SynthesizedFileUnit` for
testing purposes.
2020-04-07 18:45:41 -07:00
Dan Zheng
f7a9eed4de [AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.
Add implicit declarations generated by the differentiation transform to a
`SynthesizedFileUnit` instead of an ad-hoc pre-existing `SourceFile`.

Resolves TF-1232: type reconstruction for AutoDiff-generated declarations.

Previously, type reconstruction failed because retroactively adding declarations
to a `SourceFile` did not update name lookup caches.
2020-04-07 18:29:34 -07:00
Dan Zheng
c834696bfa Add SynthesizedFileUnit.
`SynthesizedFileUnit` is a container for synthesized declarations. Currently, it
only supports module-level declarations.

It is used by the SIL differentiation transform, which generates implicit struct
and enum declarations.
2020-04-07 18:29:26 -07:00
Rintaro Ishizaki
496c303ab5 Merge pull request #30865 from rintaro/sourcekit-completion-rdar61367416
[SourceKit] Don't use diagnostics to indicate fast-completion
2020-04-07 17:58:19 -07:00