Commit Graph

48 Commits

Author SHA1 Message Date
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
Max Moiseev
44f0cb9daf Fix the force unwrapping of a nil pointer 2017-01-11 10:22:01 -08:00
Max Moiseev
195691523f [stdlib] Eliminating some 'unsafeBitcast' related warnings 2017-01-10 12:36:22 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
JP Simard
ea5b665afa prefer '-> Void' over '-> ()'
Apple and the Swift community has settled on this style:
https://devforums.apple.com/message/1133616#1133616

> FWIW, we've recently decided to standardize on () -> Void
> (generally, () for parameters and Void for return types) across all of our
> documentation.
2016-12-31 17:55:19 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Brian Gesiak
c42d0d29b6 [stdlib] Only add Apple reflection test targets
When building on a macOS host, and when `SWIFT_INCLUDE_TESTS` is specified,
the `swiftSwiftReflectionTest` target is added to all platforms.
However, this target has a dependency upon Foundation, which is not
available on non-Apple platforms.

Use `add_swift_library`'s `TARGET_SDKS` parameter and other gating
logic to ensure the target is only added for platforms that actually
have Darwin available.
2016-10-07 15:41:31 -04:00
Dmitri Gribenko
99dffd7682 Merge pull request #3854 from rintaro/SE-0101-memorylayout
[SE-0101] Implement: Reconfiguring sizeof and related functions into a unified MemoryLayout struct - Part 1
2016-07-29 15:56:27 -07:00
Michael Ilseman
ccda8f33d1 [noescape by default] Proliferate @escaping
Adds an explicit @escaping throughout the standard library, validation
test suite, and tests. This will be necessary as soon as noescape is
the default for closure parameters.
2016-07-29 13:48:07 -07:00
Rintaro Ishizaki
091506315b [SE-0101] Implement: Reconfiguring sizeof and related functions into MemoryLayout struct
As of now:

* old APIs are just marked as `deprecated` not `unavaiable`. To make it
  easier to co-operate with other toolchain repos.
* Value variant of API is implemented as public @private
  `_ofInstance(_:)`.
2016-07-30 03:09:28 +09:00
Roman Levenstein
1358650d6b Use let instead of var to silence a compiler warning 2016-07-27 00:07:10 -07:00
Roman Levenstein
880be3be4f Remove unsafeAddress(of:)
rdar://problem/18589289
2016-07-26 19:57:26 -07:00
Andrew Trick
a18d490d6a Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3773)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 14:21:15 -07:00
Andrew Trick
0ed9ee8dee Revert "Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)"
This reverts commit ece0951924.

This results in lldb failues on linux that I can't readily debug.
Backing out until they can be resolved.
2016-07-26 02:50:57 -07:00
Andrew Trick
ece0951924 Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 02:18:21 -07:00
Michael Gottesman
bfbe8f83ff Merge pull request #3618 from gottesmm/when_not_including_tests_do_not_build_swift_reflection_test
Do not build SwiftReflectionTest when we are not including tests.
2016-07-22 17:47:49 -07:00
Chris Lattner
bc09af33f1 Merge pull request #3592 from practicalswift/trailing-semicolon
[gardening] Remove trailing semicolons.
2016-07-19 22:58:35 -07:00
Michael Gottesman
0258813113 Do not build SwiftReflectionTest when we are not including tests.
This avoids a cmake warning.
2016-07-19 13:38:36 -07:00
Andrew Trick
5a8271c621 Rename UnsafePointer allocate & deallocate. (#3608)
As proposed in SE-0107: UnsafeRawPointer:
Rename 'init(allocatingCapacity:)' to 'UnsafeMutablePointer.allocate(capacity:)'
Rename 'deallocateCapacity' to 'deallocate(capacity:)'

`allocate` should not be an initializer. It's primary function is to allocate
memory, not initialize a pointer.
2016-07-19 11:48:18 -07:00
Andrew Trick
73106dd7c3 Rename initialize(with:count:) to initialize(to:count:). (#3601)
As proposed in SE-0107: UnsafeRawPointer.

"with" is considered a vacuous preposition. "to" implies direction.
2016-07-18 23:37:45 -07:00
practicalswift
8287c5dfca [gardening] Remove trailing semicolons.
Inspiration: 425138c56e
2016-07-19 00:04:53 +02:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
David Farler
8f86719f9f Add more Remote Mirror closure tests with different arity/capture count 2016-05-23 16:34:54 -07:00
David Farler
a38a4ce596 SwiftRemoteMirror: Turn on reflection metadata by default
Flip the enable flags to disable and make these IRGen options
true by default.

rdar://problem/26206547
2016-05-21 17:40:37 -07:00
David Farler
e42fd92fbb SwiftReflectionTest: Don't exit until the parent asks for an instance
Child processes were exiting too early before the parent has a chance
to read a null pointer from the child, indicating that there are no
more instances to reflect. This wasn't a problem on OS X because the
I/O latency is so small compared to the iOS simulator, where the
problem would come up under heavy load. This makes the end-to-end
remote mirror tests deterministic again.

rdar://problem/26230879
2016-05-18 02:27:53 -07:00
David Farler
9dddc6492b SwiftRemoteMirror: Project error existentials
Error existentials have a kind of special heap layout and can also
be compatible as NSError instances, too.
2016-05-10 12:50:31 -07:00
Slava Pestov
75bd780aca Reflection: Add support for closure contexts to readMetadataFromInstance()
Also add end-to-end tests for this finally, and fix a bug in
the SwiftReflectionTest library where we would give up on an
module completely if it did not have a field metadata section.
This is of course wrong if the module defines closures but
not nominal types.
2016-05-09 13:41:56 -07:00
David Farler
87e1ab5dcf SwiftRemoteMirror: Add validation test for projecting existentials 2016-05-04 15:57:44 -07:00
David Farler
5f5ce39a1d SwiftRemoteMirror: Wire up existential projection API
Implement the ReflectionContext's implementation of:
swift_reflection_projectExistential.

First, we get the type info of the existential typeref - it should be a
record type info. If it's a class existential, it has trivial layout:
the first word is a pointer to the class instance. Otherwise, if the
value fits in the 3-word buffer of the existential container, it
trivially is also at the start of the container. Otherwise, the value is
off in a heap box somewhere, but the first word of the container is a
pointer to that box.
2016-05-03 21:04:31 -07:00
David Farler
b8cb128a17 swift-reflection-test: Make it possible to call reflect multiple times
This allows you to test multiple class instances in the same file.
2016-05-03 21:04:31 -07:00
Chris Willmore
af0c7bd620 Initial implementation of SE-0054 "Abolish IUO Type" (#2322)
This is a squash of the following commits:

* [SE-0054] Import function pointer arg, return types, typedefs as optional

IUOs are only allowed on function decl arguments and return types, so
don't import typedefs or function pointer args or return types as IUO.

* [SE-0054] Only allow IUOs in function arg and result type.

When validating a TypeRepr, raise a diagnostic if an IUO is found
anywhere other thn the top level or as a function parameter or return
tpye.

* [SE-0054] Disable inference of IUOs by default

When considering a constraint of the form '$T1 is convertible to T!',
generate potential bindings 'T' and 'T?' for $T1, but not 'T!'. This
prevents variables without explicit type information from ending up with
IUO type. It also prevents implicit instantiation of functions and types
with IUO type arguments.

* [SE-0054] Remove the -disable-infer-iuos flag.

* Add nonnull annotations to ObjectiveCTests.h in benchmark suite.
2016-05-03 14:06:19 -07:00
Slava Pestov
71d28691ef Reflection: Plumb through capture descriptor section 2016-05-02 01:16:25 -07:00
Slava Pestov
faecfda594 Reflection: Consolidate some code for passing around reflection sections
I'm about to add a new section, and I'd like to update as few
places as possible.
2016-04-30 15:12:38 -07:00
Slava Pestov
9d9c97336b Reflection: Update test for reflection info being moved from DATA to TEXT 2016-04-30 14:51:41 -07:00
Slava Pestov
95d648779b Reflection: Fix some bugs in swift-reflection-test
- Improper handling of read() returning an incomplete read
- Update SwiftReflectionTest library for new builtin types section

Only tested manually so far; automated tests coming soon.
2016-04-27 18:17:25 -07:00
David Farler
0c83fce1c6 Link swift-reflection-test* with swiftRemoteMirror
Eventually this tool will test solely with the C API, so wire up
the dependencies now. This also fixes an annoying dependency issue
when building some testing configurations.

rdar://problem/25943881
2016-04-27 14:42:41 -07:00
Slava Pestov
98abbdb332 Emit reflection metadata, but not reflection names, by default
This allows the reflection type lowering test to pass with the
default build configuration.
2016-04-21 15:15:30 -07:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
David Farler
5ea5bb06a3 Split swift-refleciton-test into host and target test targets
swift-reflection-test is now the test that forks a swift executable
and performs remote reflection, making it runnable on other targets,
such as the iOS simulator.

swift-reflection-dump is now a host-side tool that dumps the remote
reflection sections for any platform binary and will continue to
link in LLVM object file support.

This necessitates finally moving lib/Refleciton into stdlib/public,
since we're linking target-specific versions of the test tool and
we would eventually like to adopt some of this functionality in
the runtime anyway.
2016-03-28 16:34:44 -07:00
David Farler
aa310cf0a7 Rename SwiftReflectionTest Cmake target to swiftSwiftReflectionTest
It appears a little redundant but this follows the convention of the
other private stdlib library targets, where "SwiftReflectionTest" is
the module name, so it should be included in the target name.
2016-03-25 13:33:16 -07:00
Dmitri Gribenko
2a66514058 CMake: SwiftReflectionTest depends on Darwin 2016-03-25 11:38:45 -07:00
Chris Lattner
e4c7bca43a Merge pull request #1861 from practicalswift/weekly-cleanup-01
[gardening] Weekly gardening: typos, duplicate includes, header formatting, etc.
2016-03-24 22:39:36 -07:00
practicalswift
d00a5ef814 [gardening] Weekly gardening: typos, duplicate includes, header formatting, etc. 2016-03-24 22:41:10 +01:00
David Farler
790b7de5e4 Reenable building the SwiftReflectionTest library
This wasn't importing the Mach-O APIs from the right module.
2016-03-24 14:15:55 -07:00
David Farler
0f62e6691c Add SwiftReflectionTest helper library
This is a small helper library to communicate information back to
swift-reflection-test from a test swift executable. Each swift test
file under test/Reflection should link this library to get the main
test hook to send responses back to the test tool.
2016-03-24 12:05:18 -07:00