Commit Graph

777 Commits

Author SHA1 Message Date
John McCall
892c903b1b Fix embarrassing copy/paste error and enable Dave's test. 2016-07-23 12:14:44 -07:00
John McCall
232a314a9f Teach the dynamic-cast machinery how to cast collection element types. 2016-07-23 10:30:10 -07:00
Luke Larson
74e0498015 Revert "Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs."
This reverts commit 62d1fa760c.
2016-07-19 15:18:17 -07:00
Mishal Shah
62d1fa760c Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-07-19 22:31:34 +02:00
Joe
67dccb283e [SE-0095] Code feedback changes; Any is parsed as a keyword
- Any is made into a keyword which is always resolved into a TypeExpr,
allowing the removal of the type system code to find TheAnyType before
an unconstrained lookup.
- Types called `Any` can be declared, they are looked up as any other
identifier is
- Renaming/redefining behaviour of source loc methods on
ProtocolCompositionTypeRepr. Added a createEmptyComposition static
method too.
- Code highlighting treats Any as a type
- simplifyTypeExpr also does not rely on source to get operator name.
- Any is now handled properly in canParseType() which was causing
generic param lists containing ‘Any’ to fail
- The import objc id as Any work has been relying on getting a decl for
the Any type. I fix up the clang importer to use Context.TheAnyType
(instead of getAnyDecl()->getDeclaredType()). When importing the id
typedef, we create a typealias to Any and declare it unavaliable.
2016-07-19 12:01:37 -07:00
Joe
3938d5682a [SE-0095] [Runtime], [Demangler], & AST printer updated to new composition syntax
- All parts of the compiler now use ‘P1 & P2’ syntax
- The demangler and AST printer wrap the composition in parens if it is
in a metatype lookup
- IRGen mangles compositions differently
    - “protocol<>” is now “swift.Any”
    - “protocol<_TP1P,_TP1Q>” is now “_TP1P&_TP1Q”
- Tests cases are updated and added to test the new syntax and mangling
2016-07-19 12:01:37 -07:00
Joe Groff
9cba38537e Runtime: Forward SwiftValue -description and -debugDescription to the boxed value.
Following the example of SwiftObject, use swift_getSummary to get the description string for a Swift value as the description of a boxed SwiftValue.
2016-07-18 12:21:54 -07:00
Joe Groff
e25c751693 Merge pull request #3538 from jckarter/id-as-any-swiftvalue-box
Runtime: Implement an opaque 'SwiftValue' ObjC class to hold bridged values.
2016-07-18 09:05:37 -07:00
Dmitri Gribenko
1edf5326a1 runtime: remove workaround for Clang 3.5
All supported OSes have Clang 3.6+.
2016-07-15 21:44:01 -06:00
Joe Groff
bc8433f186 Runtime: Implement an opaque 'SwiftValue' ObjC class to hold bridged values.
If there's no better mapping for a Swift value into an Objective-C object for bridging purposes, we can fall back to boxing the value in a class. This class doesn't have any public interface beyond being `NSObject`-conforming in Objective-C, but is recognized by the Swift runtime so that it can be dynamically cast back to the boxed type.
2016-07-15 15:56:25 -07:00
Robert Widmann
dc88e51321 Nuke entry-point-based process args
Provides a new fallback for Process arguments for those instances where we do
not own main (e.g. Frameworks, Objective-C owns main.m or main.c, etc.). This
includes a number of platform-specific specializations of argument grabbing
logic and a new thread-safe interface to Process.unsafeArgv.

main()  | _NSGetArgc/_NSGetArgv    | /proc/self/cmdline     | __argc/__argv
--------|--------------------------|------------------------|---------------
Scripts | OS X, iOS, tvOS, watchOS | Linux, FreeBSD, Cygwin | Windows

For interpreted Swift where we must filter out the arguments we now do so by
loading the standard library and calling into new SPI to override the arguments
that would have been grabbed by the runtime. This implementation completely
subsumes the use of the entry point  '_stdlib_didEnterMain' and it will be
removed in a future commit.
2016-07-14 01:06:19 -07:00
Joe Groff
02640fc1bc Runtime: Look through existentials when bridging to id. 2016-07-12 19:21:13 -07:00
Slava Pestov
67f7e773dd Runtime: Add preliminary _swift_bridgeUnknownToObject() entry point. 2016-07-12 13:49:39 -07: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
Doug Gregor
b0f9317765 [SE-0112] Add error protocols LocalizedError, RecoverableError, CustomNSError
An error type can conform to one or more of these new protocols to
customize its behavior and representation. From an implementation
standpoint, the protocol conformances are used to fill in the
user-info dictionary in NSError to interoperate with the Cocoa
error-handling system.

There are a few outstanding problems with this implementation,
although it is fully functional:
  * Population of the userInfo dictionary is currently eager; we
  should use user info providers on platforms where they are
  available.
  * At present, the Swift dynamic casting machinery is unable to unbox a
  _SwiftNativeNSError when trying to cast from it to (e.g.) an
  existential, which makes it impossible to retrieve the
  RecoverableError from the NSError. Instead, just capture the original
  error---hey, they're supposed to be value types anyway!---and use that
  to implement the entry points for the informal
  NSErrorRecoveryAttempting protocol.

This is part (1) of the proposal solution.
2016-07-12 10:53:52 -07:00
John McCall
8d1ea1c001 Fix foreign type metadata creation to not call the initializer
under the lock.

Unfortunately, unit-testing this is gratuitously difficult
because of C++ problems.  (Fixed in C++17, apparently.)  Will
be tested by a future patch which creates a nested foreign
type.
2016-07-08 15:21:34 -07:00
Saleem Abdulrasool
3d174c372a stdlib: be more DLL friendly on Windows
When the standard library is built dynamically on COFF targets, the public
interfaces must be decorated in order to generate a proper DLL which can be
confused by the dependent libraries.  When the exported interface is used, it
must be indirectly addressed.  This can be done manually in code or the MS
extension of `__declspec(dllimport)` may be used to indicate to the compiler
that this symbol be addressed indirectly.  This permits building more pieces of
the standard library dynamically on Windows.
2016-07-06 17:51:31 -07:00
Dmitri Gribenko
ef557a11ff runtime: rename 'getReflectableConformance()' to 'unwrapExistential()' 2016-07-05 14:13:54 -07:00
Dmitri Gribenko
a4fb03f1eb runtime: simplify getReflectableConformance() 2016-07-05 14:13:23 -07:00
Dmitri Gribenko
acac328eaa stdlib: remove _Reflectable 2016-07-05 14:13:23 -07:00
Roman Levenstein
40b8fd58fe Remove copy constructors and assignment operators from RelativeDirectPointerImpl.
There were places were RelativeDirectPointers were copied using bitwise copies, which is semantically wrong. This patch makes sure it cannot happen anymore.
2016-06-29 17:20:12 -07:00
Arnold Schwaighofer
8cae9874e3 Fix the assert 2016-06-27 15:29:32 -07:00
Arnold Schwaighofer
542a8b410a Fast-path dynamicCast from a class instance in an existential container to AnyObject
rdar://26981164
2016-06-27 13:29:09 -07:00
Saleem Abdulrasool
d9ba70a595 runtime: tweak the compilation
Always include all the sources as we cannot include object libraries to be
subsumed.  This allows us to conditionally build the swift runtime for foreign
hosts simultaneously (e.g. cross compile for Linux and Windows simultaneously).
2016-06-22 21:38:15 -07:00
Saleem Abdulrasool
d771054c7b build: use the new object format property
Simplify the ELF checks based on review comments from Dimitri Gribenko.
2016-06-22 09:37:56 -07:00
Saleem Abdulrasool
bbb82d4fe4 build: build the section_magic libraries for ELFish targets
Build the section_magic libraries for all the ELFish SDKs that have been
configured.  This allows us to build for SDKs which dont match the object format
at the same time (e.g. Linux and Windows).
2016-06-21 23:01:52 -07:00
William Dillon
244b448bcd Fixed stack execution for arm 2016-06-20 18:01:28 +00:00
Dmitri Gribenko
5dd3ce9195 Merge pull request #3020 from modocache/sr-1738-add-swift-library-shared-static-args
[SR-1738] add_swift_library takes SHARED/STATIC arg
2016-06-18 15:38:57 -07:00
Dmitri Gribenko
25e0dd3181 Merge pull request #3053 from tinysun212/pr-execstack
[stdlib] Don't make the stack executable
2016-06-18 01:26:19 -07:00
Dmitri Gribenko
4cd1222750 Merge pull request #3025 from compnerd/sched_yield
stdlib: avoid posix sched_yield in favour of C++11
2016-06-17 20:30:22 -07:00
Han Sangjin
1dfe3078f7 [stdlib] Don't make the stack executable
If some object file doesn't contain a section of the name '.note.GNU-stack',
the linker make the stack executable. We append the section to swift_begin.o
and swift_end.o because don't need executable stack.
(reference: http://en.chys.info/2010/12/note-gnu-stack/)
2016-06-18 05:17:32 +09:00
Dmitri Gribenko
2526da3455 Merge pull request #3037 from compnerd/buffer-lengths
Use `sizeof` for buffer lengths in snprintf
2016-06-17 00:23:02 -07:00
swift-ci
85d2167cc6 Merge pull request #3036 from compnerd/win32-lean-and-mean 2016-06-17 00:09:23 -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
Saleem Abdulrasool
6a91919509 runtime: add missing include
The use of `std::make_tuple` requires the declaration of the function which is
provided by the C++ standard header `tuple`.  This would get implicitly included
by one of the other C++ headers on the currently tested libraries, but does not
occur with the Microsoft C++ library.  Add the missing include.
2016-06-16 07:51:11 -07:00
Saleem Abdulrasool
e3c2c863d1 stdlib: define WIN32_LEAN_AND_MEAN and NOMINMAX
`WIN32_LEAN_AND_MEAN` prevents "rarely-used" headers from being pulled in.  This
significantly reduced preprocessor pressure, speeding up compile.  It also
reduces the amount of cruft pulled in by the Windows.h.

`NOMINMAX` ensures that the `min` and `max` macros are not defined.  These
macros collide with the use of `min` and `max` from C++ in certain cases: e.g.
`std::limits<T>`.
2016-06-16 07:34:17 -07:00
Saleem Abdulrasool
91a296fad6 stdlib: avoid posix sched_yield in favour of C++11
Use the C++11 std::this_thread::yield to abstract away platform specific
differences for yield execution time.  This makes the code more portable to
non-POSIX environments (i.e. Windows).  NFC.
2016-06-15 18:18:26 -07:00
Saleem Abdulrasool
c553628964 Use sizeof for buffer lengths in snprintf
Rather than duplicating the constant value, use the `sizeof` operator to have
the value propogate from the static buffer allocation.  Any standards conforming
implementation of `snprintf` will null-terminate the output unless the buffer is
NULL (a zero-sized buffer is passed to the call).  On Windows, where this is not
the case, the function is named `_snprintf` which ensures that we do not
accidentally end up with the incorrect behaviour.
2016-06-15 17:41:16 -07:00
practicalswift
4485f76794 [gardening] Use consistent capitalization for "Objective-C". 2016-06-14 22:24:43 +02:00
swift-ci
91ffcd79a7 Merge pull request #1918 from tinysun212/pr-stdlib-msvc-1 2016-06-11 03:55:47 -07:00
Han Sangjin
e6ecc9a3ec Modified for some reviews 2016-06-10 06:26:47 +09:00
practicalswift
1e0a4afeb0 [gardening] Don't compare with FALSE. 2016-06-04 08:41:29 +02:00
swift-ci
4956ba63e5 Merge pull request #2878 from apple/runtime-remove-unused-header 2016-06-03 17:12:23 -07:00
Dmitri Gribenko
f47b53350e Runtime: remove unused include 2016-06-03 15:54:42 -07:00
practicalswift
1fc5723206 [gardening] Fix two recently introduced headers. 2016-06-04 00:06:59 +02:00
Han Sangjin
198441bee9 stdlib/msvc: Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build.
2016-06-04 05:16:41 +09:00
Dmitri Gribenko
6a507d6311 Runtime: give each source file a unique basename
CMake Xcode generator does not seem to build libraries properly if we
have both a Foo.cpp and a Foo.mm in one library.
2016-06-02 01:13:40 -07:00
Han Sangjin
be815aabbb [stdlib/msvc] Runtime with MSVC library
This patch is for libswiftCore.lib, linking with the library set of Visual Studio 2015. Clang with the option -fms-extension is used to build this port.
This is the approved subpatch of a large patch.
2016-06-02 08:10:40 +09:00
Dmitri Gribenko
d227aeb64d CMake: use object libraries instead of repacking static archives 2016-06-01 03:06:33 -06:00
Dmitri Gribenko
8ac074687d runtime: remove unused includes 2016-05-30 19:36:26 -07:00