Commit Graph

1743 Commits

Author SHA1 Message Date
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
Slava Pestov
120840e092 Fix formatting nits in test/Interpreter/dynamic_replacement.swift 2020-04-10 18:45:07 -04:00
Slava Pestov
dd271cd089 Add test cases for initializer replacement to test/Interpreter/dynamic_replacement.swift 2020-04-10 18:45:07 -04:00
Michael Gottesman
ac51ce3fc7 [polymorphic-builtins] Enable test during optimize builds.
The confusion here was around a test that was testing the behavior when one
/does not/ guard a polymorphic builtin with a _isConcrete. Specifically, without
_isConcrete, one gets weird behavior where in debug we crash, but in release we
may not due to further inlining/specialization. With _isConcrete, we never
crashand get the appropriate behavior.

This commit works by changing the current run of the polymorphic builtin test to
force -Onone and adds an extra -O run that way we validate both behaviors.
2020-04-09 14:44:45 -07:00
Owen Voorhees
43e2d107e1 [SE-0276] Implement multi-pattern catch clauses
Like switch cases, a catch clause may now include a comma-
separated list of patterns. The body will be executed if any
one of those patterns is matched.

This patch replaces `CatchStmt` with `CaseStmt` as the children
of `DoCatchStmt` in the AST. This necessitates a number of changes
throughout the compiler, including:
- Parser & libsyntax support for the new syntax and AST structure
- Typechecking of multi-pattern catches, including those which
  contain bindings.
- SILGen support
- Code completion updates
- Profiler updates
- Name lookup changes
2020-04-04 09:28:26 -07:00
Mishal Shah
88b093e9d7 Merge pull request #30615 from apple/post-back-master-xcode-11.4
Update master to build with Xcode 11.4
2020-03-24 17:19:37 -07:00
Saleem Abdulrasool
0d56b373be Merge pull request #30599 from 3405691582/OpenBSD_Port_Testing
[test] Setup testing for OpenBSD.
2020-03-24 15:39:49 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
3405691582
4a36a4b6c5 [test] Setup testing for OpenBSD.
This commit focuses the basics: setting up the relevant stanzas in
lit.cfg and adding platform conditionals for importing Glibc. Future
commits will deal with other portability fixes.
2020-03-23 20:47:31 -04:00
Brent Royal-Gordon
e7959a90cf Disable two failing opaque result type tests
See e.g. https://ci.swift.org/job/oss-swift_tools-RA_stdlib-DA_test-device-non_executable/29. The Interpeter test doesn’t actually crash in any Swift CI configuration, but its compilation step crashes in the same way with arm64e.
2020-03-21 23:17:36 -07:00
Kuba (Brecka) Mracek
ab6533a40f Merge branch 'master' into mracek/arm64e 2020-03-06 15:07:01 -08:00
Slava Pestov
adbf8da7c2 Merge pull request #23489 from AnthonyLatsis/where-clause-nongeneric-decl
[SE] Allow where clauses on non-generic declarations in generic contexts
2020-03-06 17:53:14 -05:00
lhames
1d5c008f97 Merge pull request #29863 from lhames/switch-imm-to-lljit
[Immediate] Switch immediate mode from MCJIT to LLJIT.
2020-03-06 09:12:27 -08:00
Karoy Lorentey
2d6f8838f8 Merge pull request #30212 from lorentey/fix-just-built-tests
[test] Make sure tests use just-built libraries if use_os_stdlib isn't set
2020-03-05 14:15:01 -08:00
Anthony Latsis
26ceb28d35 Interpreter: Test execution with contextual where clauses 2020-03-05 20:23:49 +03:00
Karoy Lorentey
55a32d508e [test] Use %target-run to run generated executable
Without %target-run, DYLD_LIBRARY_PATH won’t apply and the target will try to load OS-supplied libraries rather than the ones we just built even if use_os_stdlib isn’t enabled.
2020-03-04 19:51:35 -08:00
Mike Ash
614f4becef [Runtime] Reject suffixes on ObjC mangled class names.
The demangler tolerates arbitrary suffixes on mangled names, and parses them as a Suffix node. When looking up a class by an ObjC mangled name, we don't want such demanglings to succeed, because this will result in false positives. It's expected that NSClassFromString(someClassName + "some suffix") will fail, unless something has actually created a class with that suffix.

rdar://problem/60012296
2020-03-04 12:05:35 -05:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
Kuba Mracek
1bd425da67 [arm64e] Test changes to support arm64e 2020-02-27 16:10:48 -08:00
Daniel Duan
62e0da9913 [Property wrappers] Modernize self enclosing test (#30103)
The init parameter name changed to `wrappedValue` as of Swift 5.2.
2020-02-27 16:05:36 -08:00
Nate Chandler
4475f43ba0 [metadata prespecialization] Always on for stdlib.
Regardless of any flags, the stdlib will have its generic metadata
prespecialized.

Temporarily reintroduced the flag to enable the feature flag while
preserving the flag to disable it and changed the default back to off
for the moment.
2020-02-17 11:53:27 -08:00
Lang Hames
7a0754b127 [Immediate] Switch immediate mode from MCJIT to LLJIT.
LLJIT is a simple LLVM IR JIT. Its interface is similar to MCJIT, but its
implementation is based on LLVM's newer ORC APIs. This initial patch does not
make use of any of LLJIT/ORC's advanced features, but will provide better
diagnostics when JIT'd code fails to link. Once LLJIT has proven usable in
this basic configuration we can start experimenting with more advanced
features, including lazy compilation.
2020-02-14 17:59:23 -08:00
tbkka
74df8725ab SR-12161 Casting P.self to P.Type regressed in iOS13.4 beta (#29779)
* SR-12161 Casting P.self to P.Type regressed in iOS13.4 beta

An earlier fix for certain protocol casts inadvertently disabled
the check for a protocol being cast to its own metatype.
This rearranges the code so that identical types always succeed.
It also updates swift_dynamicCastMetatypeUnconditional to
include recent changes to swift_dynamicCastMetatype.

Note: These fixes only apply to debug/non-optimized builds.
Cast optimizations still break a lot of these cases.
2020-02-12 14:24:31 -08:00
nate-chandler
b62871047d Merge pull request #29345 from nate-chandler/generic-metadata-prespecialization-components/enums
Generic metadata prespecialization: enums
2020-02-12 13:09:59 -08:00
Nate Chandler
40e17d9c6f [metadata prespecialization] Direct refs to enums.
When a specialized usage of a generic enum occurs in the same module
where the enum was defined, directly reference the prespecialized
metadata.

rdar://problem/56994321
2020-02-12 10:08:33 -08:00
Doug Gregor
c1c7112110 Remove some unused code and fix a test 2020-02-10 22:01:37 -08:00
Kelvin
19a8759cee Merge branch 'master' into comparable-enums 2020-02-04 22:08:40 -06:00
kelvin13
206e3b1013 SInt comparable 2020-02-04 17:40:51 -06:00
Michael Gottesman
e5aaa68b52 [sil] Do not eliminate (apply (partial_apply)) if the partial_apply captures an @in parameter and handle @in_guaranteed appropriately.
Otherwise the code as written miscompiles code like:

```
@inline(never)
func consumeSelf<T>(_ t : __owned T) {
  print("Consuming self!")
  print(t)
}

class Klass {}
struct S<T> {
  let t: T? = (Klass() as! T)

  @inline(__always)
  __consuming func foo(_ t: T) {
    consumeSelf(self)
  }
}

public func test<T>(_ t: __owned T) {
  let k = S<T>()
  let f = k.foo

  for _ in 0..<1024 {
    f(t)
  }
}

test(Klass())
```

As one can tell, without annotations it is hard to create an example like the
above, but there is no reason why we couldn't emit more code like this from the
frontend.

If the parameter is guaranteed though, the current impl is fine for
@in_guaranteed since in the loop, we do not need to retain or release the
value.

rdar://58885352
2020-02-04 14:20:58 -08:00
kelvin13
178b0ff4d9 add tests 2020-02-02 14:52:47 -06:00
Pavel Yaskevich
ec3b783380 [Diagnostics] Improve diagnostic for invalid conversion to AnyObject 2020-01-29 00:37:39 -08:00
David Smith
8e09cd2119 Merge pull request #25864 from Catfish-Man/no-objc-complications-once-more-into-the-breach
Update fast dealloc to use new-style interposing and support objc weak refs
2020-01-22 17:21:34 -08:00
David Smith
f36a4db856 Update fast dealloc to use new-style interposing and support objc weak refs 2020-01-22 13:55:27 -08:00
Doug Gregor
def86ce402 Revert "[irgen] Force emission of objc class refs for non-foreign clang objc classes whose metadata we use."
This reverts commit 8247525471. While
correct, it has uncovered several issues in existing code bases that
need to be sorted out before we can land it again.
Fixes rdar://problem/57846390.
2020-01-11 21:46:42 -08:00
Mishal Shah
7e2c2452ad Disable objc_mangling.swift and SwiftObjectNSObject.swift test on tvOS 2019-12-12 08:32:16 -08:00
Pavel Yaskevich
3116d6ef8a Merge pull request #28539 from xedin/remove-constraint-handling-from-csdiag
[Diagnostics] Port diagnostics related to ambiguities and constraints
2019-12-04 12:15:26 -08:00
Robert Widmann
e28ee0cdbf Merge pull request #28546 from CodaFi/trailing-on-and-on
Fix getDirectlyInheritedNominalTypeDecls
2019-12-03 18:43:22 -08:00
Robert Widmann
b8779f7df7 Fix getDirectlyInheritedNominalTypeDecls
getDirectlyInheritedNominalTypeDecls looks for inherited protocols in two places: the actual inheritance clause of a declaration and the trailing where clause.  This works fine for normal declarations, but deserialized protocols that have Self constraints have no trailing where clause and appear to have no super-protocol bounds.  This means clients can potentially disagree about the structure of the protocol, and any symbols derived from it.

The test case demonstrates this problem directly: We build a hollowed-out SwiftUI preview provider then try to dynamically replace a requirement in a Self-constrained protocol extension.  The SwiftUI module sees the where clause, but when we go to deserialize the module in the "Preview" the protocol extension sees the wrong inheritance bounds and mis-mangles the call to Self.view(for:ofType).

The fix is to ask the requirement signature for Self requirements that would normally appear on a trailing where clause.

Resolves rdar://57150777
2019-12-03 17:01:57 -08:00
Pavel Yaskevich
ebdb5c7776 [ConstraintSystem] Improve handling of ambiguities related to fixes
Solutions passed to `diagnoseAmbiguityWithFixes` aren't filtered
so we need to remove all of the solutions with the score worse
than overall "best". Also logic has to account for some fixes being
"warnings".
2019-12-03 12:07:16 -08:00
Slava Pestov
6d5ff209d0 IRGen: Implement support for __attribute__((ns_consumed)) block parameters
Fixes <rdar://problem/48792177>.
2019-12-02 18:41:27 -05:00
Robert Widmann
f555d6e5f0 Merge pull request #16060 from paddlefish/arahn/rdar38514252-unit-test
[WIP] Testcase for rdar38514252: didSet called on read.
2019-12-02 10:26:36 -08:00
Michael Gottesman
5c726fbaeb [test] Use a relative install_name on the framework used by the autolink_classlookup_test
Otherwise, the install_name is the full path on the given machine which may not
be desireable.

rdar://57427875
2019-11-22 13:56:52 -08:00
Michael Gottesman
8247525471 [irgen] Force emission of objc class refs for non-foreign clang objc classes whose metadata we use.
Today in far more cases we are using mangled strings to look up metadata at
runtime. If we do this for an objc class but for whatever reason we do not have
any other references to the class, the static linker will fail to link in the
relevant framework. The reason why this happens is that autolinking is treated
by the static linker as a hint that a framework may be needed rather than as a
"one must link against the framework". If there aren't any undefined symbols
needed by the app from that framework, the linker just will ignore the hint. Of
course this then causes the class lookup to fail at runtime when we use our
mangled name to try to lookup the class.

I included an Interpreter test as well as IRGen tests to make sure that we do
not regress here in the future.

NOTE: The test modifications here are due to my moving the ObjCClasses framework
out of ./test/Interpreters/Inputs => test/Inputs since I am using it in the
IRGen test along side the interpreter test.

rdar://56136123
2019-11-21 16:03:54 -08:00
Arnold Schwaighofer
edd281ca48 Remove test of dynamic replacement and dlclose
dlclose is not really well supported with frameworks.
2019-11-19 09:27:15 -08:00
Arnold Schwaighofer
7acabfe1cf IRGen: We need to emit metadata for types that are emitted with shared linkage
Otherwise one TU could only require the type descriptor without metadata
and another TU could require metadata and type descriptor. Whether the
metadata access function is available would then depend on the linking
order of the two TUs.

rdar://56929811
2019-11-11 10:00:17 -08:00
Mishal Shah
c2c8cf5903 Disable objc_mangling and SwiftObjectNSObject test for watchOS (56959761) 2019-11-06 16:43:54 -08:00
Karoy Lorentey
821f581f77 [test] Interpreter/bridged_casts_folding: Don’t run during backdeployment tests 2019-11-01 10:47:12 -07:00
Pavel Yaskevich
58329e0c27 Revert "[Diagnostics][Qol] SR-11295 Emit diagnostics for same type coercion. " 2019-10-25 01:05:07 -07:00
Luciano Almeida
5d1eeacbe4 Resolving conflicts 2019-10-23 07:25:55 -03:00
Luciano Almeida
86ca3454d6 Fixing warning UnnecessaryCoercion tests 2019-10-21 23:11:21 -03:00