Commit Graph

11414 Commits

Author SHA1 Message Date
Max Moiseev
885b564bf5 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 17:16:37 -08:00
Xi Ge
d81edcb6b6 ModulePrinting: Properly substitute via metatype to simplify complex bound generic types appearing in synthesized extensions. rdar://25063840 2016-03-09 17:09:34 -08:00
Ben Langmuir
4a30637e08 [CodeCompletion] Don't complete unavailable methods in override
We generally don't want to override unavailable methods.  We already
filter out unavailable decls when completing values, but that's in a
separate visible decl consumer.

rdar://problem/25058233
2016-03-09 16:20:23 -08:00
Max Moiseev
02006f20bc Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-09 16:05:03 -08:00
John McCall
2840478147 When preparing necessary bindings, we sometimes decide to capture
bound generic type metadata rather than its individual components.
Don't crash when actually restoring that metadata.

Fixes SR-901.
2016-03-09 15:12:27 -08:00
Ben Langmuir
19d13c3aee Reapply "[CodeCompletion] Don't show the loop index before it is visible"
With the tests updated to account for not having the correct behaviour
for brace-stmt items from after the code-completion point.  That part
turns out to be harder to fix.

This reverts commit a5325e6281.
2016-03-09 14:02:51 -08:00
Adrian Prantl
f2596958d6 Revert "Debug Info: Retreive the layout information of exploded values from the"
This reverts commit 7e489db91b.
2016-03-09 14:01:35 -08:00
Adrian Prantl
7e489db91b Debug Info: Retreive the layout information of exploded values from the
explosion schema rather than from the debug type information and retire
a bunch of heuristics that are no longer necessary.

To enable this, this commit also includes a bugfix to debug info for
opaque data structures with the correct size and alignment information.

<rdar://problem/21470869+22707597>
2016-03-09 13:51:33 -08:00
Ben Langmuir
6581eba8e6 [CodeCompletion] Improve ordering of prefix matches vs popular names
In the experimental code-completion path.

rdar://problem/24843463
2016-03-09 11:23:06 -08:00
Joe Groff
77dd9b2992 Split exact-subclass and bindable-to-subclass queries.
In many places, we're interested in whether a type with archetypes *might be* a superclass of another type with the right bindings, particularly in the optimizer. Provide a separate Type::isBindableToSuperclassOf method that performs this check. Use it in the devirtualizer to fix rdar://problem/24993618. Using it might unblock other places where the optimizer is conservative, but we can fix those separately.
2016-03-09 11:14:45 -08:00
Chris Lattner
2aaccee71c Revert "Progress towards nested generic typealiases." apparently broke an LLDB test.
This reverts commit 2896fbb586.
2016-03-09 09:26:27 -08:00
Argyrios Kyrtzidis
c939234d1f [test] Modify the test so that it can pass on linux as well. 2016-03-08 23:59:13 -08:00
Argyrios Kyrtzidis
345d05e2e9 Introduce an internal attribute '@_show_in_interface' to be used in stdlib for underscored protocols that
should be shown in the interface.

Also switch the option and hide all underscored protocols by default, unless they are marked with the new attribute.
2016-03-08 23:30:58 -08:00
Chris Lattner
2896fbb586 Progress towards nested generic typealiases. They still don't work, but add a
(failing) testcase and progress towards supporting them.
2016-03-08 23:19:56 -08:00
Ted Kremenek
b796305846 Merge pull request #1371 from hpux735/thumb
Added thumb to supported platforms conditions
2016-03-08 22:10:13 -08:00
Chris Lattner
ae919bd447 implement mangling support for typealias archetypes, allowing them to get basic USRs. 2016-03-08 21:18:39 -08:00
Brian Gesiak
c9000af795 Merge pull request #1526 from practicalswift/fix-pep8-violations-ii
[Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
2016-03-08 23:55:46 -05:00
Ben Langmuir
a39ab90c59 [IDE] Ensure we don't miss unreconstructed types in test NFC
Just a sanity check so we don't miss something accidentally; we can
always disable this late if it becomes a burden.
2016-03-08 20:40:17 -08:00
Ben Langmuir
d59a57339e [CodeCompletion] Add some basic sanity tests for generic typealiases
Basically check that the name of the type shows up as a result, and that
we can look through to the members of the underlying type.
2016-03-08 20:13:16 -08:00
Xin Tong
8eedb43c4c Implement partially dead argument elimination.
This change includes an option on how IsLive is defined/computed. the ProjectionTree
can now choose to ignore epilogue releases and mark a node as dead if its only non-debug
user is epilogue release.

It can also mark a node as alive even its only user is epilogue release as before.

Imagine a case where one passes in an array and not access its owner
besides to release it. In such a case, we *do* want to be able to eliminate
that argument even though there is a release in the function epilogue.

This will help to get rid of the retain and release pair at the callsite. i.e.
the guaranteed paramter is elimininated.

rdar://21114206
2016-03-08 23:12:38 -05:00
Arnold Schwaighofer
3676671b7f Merge pull request #1587 from aschwaighofer/stack_promote_with_unsafe_mutable_buffer_pointer
Mark Array.withUnsafeMutableBuffer as not escaping the array storage.
2016-03-08 19:39:28 -08:00
Arnold Schwaighofer
b5f018a4b1 Mark Array.withUnsafeMutableBuffer as not escaping the array storage.
This is safe because the closure is not allowed to capture the array according
to the documentation of 'withUnsafeMutableBuffer' and the current implementation
makes sure that any such capture would observe an empty array by swapping self
with an empty array.

Users will get "almost guaranteed" stack promotion for small arrays by writing
something like:

  func testStackAllocation(p: Proto) {
    var a = [p, p, p]
    a.withUnsafeMutableBufferPointer {
      let array = $0
      work(array)
    }
  }

It is "almost guaranteed" because we need to statically be able to tell the size
required for the array (no unspecialized generics) and the total buffer size
must not exceed 1K.
2016-03-08 19:37:47 -08:00
Xi Ge
ce12c6dc95 ModulePrinting: Add an option to synthesize unconditional extensions; true by default. 2016-03-08 18:34:38 -08:00
Ben Langmuir
bac7521af7 [SourceKit] Fix crash with cursor info on generic typealias
For now, just skip mangling the name since we know the decl context will
crash the mangler.
2016-03-08 18:03:42 -08:00
Doug Gregor
3fb06d7442 [Swift runtime] Deallocation of partial class instances for Objective-C-derived classes.
Teach swift_deallocPartialClassInstance how to deal with classes that
have pure Objective-C classes in their hierarchy. In such cases, we
need to make sure a few things happen:

1) We deallocate via objc_release rather than
swift_deallocClassInstance.
2) We only attempt to find an execute ivar destroyers for
Swift-defined classes in the hierarchy
3) When we hit the most-derived pure Objective-C class, make sure that we
only execute the dealloc of that class and not any of the subclasses
(which would end up trying to destroy ivars again).

Fixes rdar://problem/25023544.
2016-03-08 16:47:57 -08:00
Arnold Schwaighofer
4319e00132 Merge pull request #1579 from aschwaighofer/escape_analysis_copy_addr
Teach escape analysis about the semantics of copy_addr instructions
2016-03-08 15:18:42 -08:00
Arnold Schwaighofer
fc96c2e53d Teach escape analysis about the semantics of copy_addr instructions
If the copy_addr cannot release the destination then it behaves just like a load
followed by a store.

This allows us to stack promote protocol typed array literals.

  protocol Proto { func at() -> Int }

  func testStackAllocation(p: Proto) {
    var a = [p, p, p]

    for e in a {
      print(e.at())
    }
  }
2016-03-08 15:07:25 -08:00
Max Moiseev
1fae0d1325 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-08 12:48:48 -08:00
Adrian Prantl
053d7cf277 Debug Info: Don't emit shadow stack copies for local variables.
The effect of this tiny change is that local variables will be described
by llvm.dbg.values, which will get lowered into an accurate location list
instead of a stack slot that is valid for the entire scope of the variable.
This means the debugger can now accurately track the liveness of variables
knowing exactly when they are initialized and when there values go away.
Function arguments are still kept in stack slots because (1) they are
already initialized at the function entry and (2) LLDB really needs self
to be available at all times for the expression evaluator.

This was made possible by recent advancements in LLVM such as the live
debug variables pass and various related bugfixes.

<rdar://problem/15746520>
2016-03-08 11:10:02 -08:00
Ben Langmuir
ce3c2de4a6 [CodeCompletion] Convert optionals when checking for literal protocol conformance
Except for nil literals, we don't want to look at the optional itself,
since the typechecker would implicitly look to the underlying type.

rdar://problem/24707210
2016-03-08 09:39:04 -08:00
Adrian Prantl
2dec70903a Fix a bug in the SIL parser's debug location handling.
Also add two SIL debug info testcases that were accidentally left
uncommitted.

SR-849
2016-03-08 09:19:51 -08:00
Ben Langmuir
c9d665ec98 [ASTPrinter] Print typealias generic parameters 2016-03-08 07:11:38 -08:00
Mark Lacey
4f2f993c68 Fix use-after-free in SimplifyCFG's block argument splitter.
We were creating new uses of an argument just prior to erasing it from
the block argument list.

We need to replace references to that value in the side structure we
generate with references to the new value that we're replacing it with.

Fixes SR-884 / rdar://problem/25008398.
2016-03-07 23:22:34 -08:00
Chris Lattner
14b5b0a73f Resolve the QoI fixme's from the generic typealiases testcase, by specifying the
correct location for generic parameters that cannot be inferred.  The cases that
I thought were incorrectly rejected on first glance were actually correct.
2016-03-07 23:04:38 -08:00
Ben Langmuir
739c409140 Revert "[CodeCompletion] Don't show variables defined after the completion loc"
This broke some tests; may need a different approach.

This reverts commit 9734bd94bb.
2016-03-07 22:29:24 -08:00
Ben Langmuir
a5325e6281 Revert "[CodeCompletion] Don't show the loop index before it is visible"
This reverts commit ce77c868d1.
2016-03-07 22:29:00 -08:00
Ben Langmuir
09754f21cd [CodeCompletion] Don't add type-relation for SequenceType protocol in loop
We don't want to prioritize the type name for protocols, since they
can't be used (generally) to construct an instance of the type. Ideally
we would prioritize types that conform to the protocol.

For rdar://problem/24873625
2016-03-07 22:22:18 -08:00
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
Ben Langmuir
ce77c868d1 [CodeCompletion] Don't show the loop index before it is visible
for i in <here>            // should *not* show 'i'
for i in ...  where <here> // should show 'i'
for i in ... { <here>      // should show 'i'

Part of rdar://problem/24873625
2016-03-07 22:04:49 -08:00
Ben Langmuir
9734bd94bb [CodeCompletion] Don't show variables defined after the completion loc
... in brace statements. Found by inspection.
2016-03-07 22:01:01 -08:00
Ben Langmuir
d12a2d7df2 [CodeCompletion] Fix completion in top-level 'is' and 'as' expressions
We forgot to return a code-completion status, so we didn't get to it in
the second phase.

"a" as <here>

rdar://problem/24376361
2016-03-07 21:16:26 -08:00
Ben Langmuir
54963be34d [CodeCompletion] Fix completion of collection type in top-level code
We forgot to return a code-completion status, so we didn't get to it in
the second phase.

let foo: [<here>]

rdar://problem/24441902
2016-03-07 21:02:25 -08:00
Xin Tong
9d118f28c0 Improve on how final release is found.
Improve when to bail while finding the final releases.

The ConsumedArgToEpilogueReleaseMatcher finds the final releases
in the following way.

1. If an instruction, which is not releaseinst nor releasevalue, that
could decrement reference count is found. bail out. This may well be the
real epilogue release.

2. If a release is found and the release that can not be mapped to any
@owned argument. bail as this release may well be the final release of
an @owned argument, but somehow rc-identity fails to prove that.

3. A release that is mapped to an argument, but we already has a release
that (partially or completely) overlaps with this release. This release
for sure is not the final release.
2016-03-07 21:26:57 -05:00
David Farler
834b03b6cd [Reflection] Substitute generics and resolve dependent members
Once an unsubstituted typeref for a field is built, we substitute
`GenericTypeParameterTypeRef`s with concrete ones built from the generic
arguments of concrete bound generic metadata.

During that process, if we run into a `DependentMemberTypeRef` (e.g.
something of type T.Index), we substitute the base (T) using the current
list of substitutions, and then resolve what `Index` is for the base
using the associated type metadata in the 'assocty' data section.
2016-03-07 17:43:13 -08:00
David Farler
4fc146a14a [GenReflection] Use declared type for associated type record keys
Similiar to the change to field reflection metadata, don't use the
interface for the key of associated type lookup, because the nominal
type descriptors don't include generics in their mangled name strings.
2016-03-07 17:43:13 -08:00
David Farler
96386b03be Don't use interface type as field descriptor key
Nominal type descriptors use declared types for their mangled names,
so we need to use them when scanning the fieldmd section for a
matching record. This is fine because the descriptor can tell us
about the type's generics. Individual field records continue to use
the interface type.
2016-03-07 17:43:12 -08:00
Slava Pestov
40bae8a6c0 SILGen: Simpler mangling for materializeForSet callback
We don't really need to mangle the AST type of the callback, besides
it doesn't have an AST type at all, because it is polymorphic.

Also, mangle the closure as if it were parented by the requirement
and not the witness, for consistency with witness thunks.

The mangling should still be unique since it includes the conformance.

NFC other than updating tests for new mangling.
2016-03-07 17:06:52 -08:00
Slava Pestov
3e7f2e195c SILGen: Refactoring MaterializeForSet to support default witness thunk emission
Previously we would emit two types of MaterializeForSet implementations
in SILGen:

- materializeForSet for a concrete storage declaration

- materializeForSet witness thunk in a conformance

This refactoring decouples the code from taking a conformance, which is
needed for two new types of materializeForSet that we need:

- materializeForSet witness thunk in a default witness table -- this is
  necessary in order to be able to resiliently add storage requirements
  with default implementations to protocols

- materializeForSet vtable thunk -- this is necessary to fix a missing
  re-abstraction case with overriding storage in a subclass

This patch brings us closer to implementing these two. For default
implementations, we still have an issue in that the materializeForSet
has a different "generic signature abstraction pattern" in concrete
and default witnesses, so default and concrete witnesses for
materializeForSet are currently ABI-incompatible because the type
metadata for the storage is passed differently to the callback.
2016-03-07 17:05:06 -08:00
Slava Pestov
924e4c4e13 SILGen: Clean up lvalue re-abstraction a bit
When we emit calls to getters and setters with emitApply(), the call
emission code ends up re-abstracting the result of a getter or the
parameter to a setter.

As a result, getOrigFormalType() was incorrect for logical path
components. This was worked around by only adding an OrigToSubst
path component to an lvalue if the last path component was physical.

This caused a problem in the following case:

1) There was an abstraction difference between the storage of the
   protocol requirement and the storage of the protocol witness

2) There was an abstraction difference between the storage of the
   protocol witness, and the fully-substituted type of the witness

An example is when the witness is in a protocol extension, and uses
'Self' or some other associated type which is concrete and loadable
in the conformance.

Fix this properly by splitting up getStorageTypeData() into two
functions, one used when adding physical path components and another
one used for logical.

As a result, we can now give the correct abstraction pattern to
logical path components.
2016-03-07 17:05:06 -08:00
practicalswift
183da818df [Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
2016-03-07 22:36:23 +01:00