Commit Graph

2682 Commits

Author SHA1 Message Date
practicalswift
27eabd4fb5 Merge pull request #8498 from practicalswift/gardening-20170403
[gardening] Fix typos. Fix headers. Python cleanups.
2017-04-12 16:41:33 +02:00
practicalswift
b704f1448b [gardening] Improve header consistency 2017-04-12 15:13:11 +02:00
practicalswift
7684e73388 Merge pull request #8706 from practicalswift/excess-logic
[gardening] Remove redundant logic
2017-04-12 09:51:49 +02:00
Slava Pestov
67ec712457 SIL: Type lowering for subclass existentials 2017-04-12 00:07:30 -07:00
Michael Gottesman
159fe76f93 [gardening] Silence a warning in release builds. (#8700) 2017-04-11 21:15:10 -04:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Arnold Schwaighofer
4d60ec333b AST/SILGen support for constant string literals
rdar://30545013
2017-04-11 11:41:43 -07:00
Michael Gottesman
2e40219be7 [silgen] Convert else-if in a for-loop into a if continue. 2017-04-11 09:16:40 -07:00
Michael Gottesman
0b341359c7 [silgen] Refactor emitShuffle (~300 loc) into smaller methods (< 90 loc) on TupleShuffleArgEmitter.
This should be a pure NFC refactor. I just moved function scope state into the
helper struct and split up the already nicely scoped parts of the function into
separate methods if they were large.

In future commits, there are a bunch of improvements that can be made by
reducing indentation.
2017-04-10 20:40:27 -07:00
Michael Gottesman
7e1198420a [gardening] Fix indentation of code in anonymous namespace to match LLVM style.
This just moves the code in by 1 indentation level.
2017-04-10 16:16:17 -07:00
Joe Groff
39a0849362 SILGen: Codegen for key path applications. 2017-04-09 16:38:34 -07:00
Joe Groff
964dc0e174 Sema: (wip) Overload resolution for keypath subscripts.
TODO: Some diagnostic regressions:
test-macosx-x86_64/Compatibility/tuple_arguments.swift
test-macosx-x86_64/Constraints/diagnostics.swift
test-macosx-x86_64/Constraints/tuple_arguments.swift
test-macosx-x86_64/expr/unary/keypath/keypath.swift
test-macosx-x86_64/expr/unary/selector/selector.swift
2017-04-09 16:38:02 -07:00
Joe Groff
85ad6b355e Merge branch 'master' into keypaths 2017-04-06 18:02:07 -07:00
swift-ci
3bf1f0d5e0 Merge pull request #8591 from gottesmm/semantic_arc_opts_copy_of_copy 2017-04-06 17:48:52 -07:00
Michael Gottesman
2224584997 [semantic-arc-opts] Teach semantic arc opts how to handle (borrow (copy)) of a guaranteed argument.
rdar://29870610
2017-04-06 16:23:02 -07:00
Joe Groff
0f082dea9c Merge pull request #8589 from jckarter/magic-identifier-in-initializer
SILGen: Don't override the SourceLoc for magic identifiers in stored property initializers.
2017-04-06 13:21:45 -07:00
Joe Groff
7aa8f8cc90 SILGen: Don't override the SourceLoc for magic identifiers in stored property initializers.
Refactoring stored property initializers to reuse the codegen for default argument generators caused them to accidentally inherit this additional bit of policy we don't want. Fixes SR-4325.
2017-04-06 12:03:29 -07:00
Huon Wilson
31b92b1b46 Merge pull request #8473 from huonw/symbol-list-2
Remove dependency on IRGenModule of some linkage computations
2017-04-05 16:39:04 -07:00
Doug Gregor
5c89eb84f0 [AST] Drop substitutions from type witnesses.
Nobody is using the actual substitutions, but we sure did a lot of
work to cope with them.
2017-04-05 11:21:38 -07:00
Huon Wilson
65c6bdca90 [IRGen] Remove IGM argument, factor out conformance fragility logic. 2017-04-05 09:54:19 -07:00
John McCall
68824db585 Merge pull request #8551 from rjmccall/elementary-access-markers
Start generating elementary access markers in SILGen
2017-04-05 12:33:34 -04:00
Joe Groff
d42f2049f7 KeyPaths: Implement in-place instantiation of invariant key paths.
For key paths without generic or subscript parameterization, we can turn the compiler-generated key path pattern into a global object in-place.
2017-04-05 08:46:45 -07:00
John McCall
79cc1d53b6 Start emitting begin_access markers for local and global vars.
NFC by default.

I had a much more comprehensive version of this patch that I had to
back out in order to just get something in to unblock progress.
There's a lot of technical debt in SILGen around l-values.

Enabling this will almost certainly not get past the SIL passes.
2017-04-05 01:43:21 -04:00
John McCall
e44f37fd8d Thread an enforcement kind through a few places. NFC. 2017-04-05 01:25:35 -04:00
Doug Gregor
5e3fac1e76 Stop using ProtocolConformance::getInheritedConformances() 2017-04-04 22:03:32 -07:00
Joe Groff
f929c29bdf IRGen: Lower keypath instructions to patterns for the runtime to instantiate. 2017-04-04 11:31:15 -07:00
Joe Groff
18a6ca271a SILGen: Lower KeyPathExprs to KeyPathInsts. 2017-04-04 11:31:15 -07:00
Joe Groff
a5ca6ccd61 Restructure KeyPathExpr to allow more kinds of components.
Expand the representation in anticipation of more kinds of components. NFC intended yet.
2017-04-04 11:31:15 -07:00
Joe Groff
eb5d006e40 Rename ObjCKeyPathExpr -> KeyPathExpr.
We can use the same general shape of expression for native key paths.
2017-04-04 11:31:15 -07:00
Slava Pestov
37491e63ac AST: Refactor existential type accessors on TypeBase and CanType 2017-04-03 23:14:25 -07:00
practicalswift
288cb35b36 Merge pull request #8495 from practicalswift/gardening-20170402
[gardening] Remove unused variables and methods. Fix \t. Use isa<T>(). Typos.
2017-04-03 09:58:44 +02:00
Slava Pestov
c1c54d1462 Sema: Fix materializeForSet for members of extensions of imported classes
An assertion I added recently to check property overrides in
the ASTVerifier uncovered some bugs in this area:

- We did not synthesize a materializeForSet for properties
  defined in extensions of imported classes unless they
  witnessed a protocol requirement.

  This triggered an assertion if the property had an
  override that was checked before the protocol conformance,
  since the override's materializeForSet would not be marked
  as an override of the base materializeForSet.

- materializeForSet for properties defined in extensions would
  statically dispatch the getter and setter instead of dynamically
  dispatching. This is incorrect since we statically dispatch
  to the materializeForSet in this case, and we can in fact
  override it in a subclass.

Fixes <rdar://problem/31334272>.
2017-04-02 23:43:41 -07:00
Slava Pestov
f5b6f22ed6 Revert "[sil] Add a new API SILFunction::getTypeLowering(SILType)."
The new API is broken. Popping a generic context frees all
dependent type lowerings, so this function returns a pointer
to freed memory.

This reverts commit 24dfae0716.
2017-04-02 19:55:19 -07:00
practicalswift
00ba5dc248 [gardening] Fix typos 2017-04-02 16:23:45 +02:00
practicalswift
422bb7ff61 [gardening] Remove duplicate includes 2017-04-02 16:06:51 +02:00
Greg Titus
22fdc8977a Merge pull request #8478 from gregomni/3518
[SILGen][SR-3518] Fix crasher getting wrong phi type in shared case block
2017-04-01 12:17:14 -07:00
Greg Titus
b9ecde5fc7 If a shared case block dest got created before it's case's pattern vars were
initialized, the block arg could get created with the type from an outer scope.
2017-04-01 09:20:15 -07:00
swift-ci
3c77cb7b07 Merge pull request #8379 from DougGregor/se-0160 2017-03-31 22:31:20 -07:00
Doug Gregor
38fce28ac7 [SE-0160] Don't generate runtime warnings for deprecated @objc inference of 'dynamic'.
When a method is dynamic, we always call through the Objective-C
runtime, which leads to a huge number of false positives. Suppress the
runtime calls here.
2017-03-31 21:54:00 -07:00
Doug Gregor
5b3fe49cd0 [SE-0160] Log uses of @objc thunks emitted due to deprecated @objc inference.
Introduce a new runtime entry point,
`swift_objc_swift3ImplicitObjCEntrypoint`, which is called from any
Objective-C method that was generated due to `@objc` inference rules
that were removed by SE-0160. Aside from being a central place where
users can set a breakpoint to catch when this occurs, this operation
provides logging capabilities that can be enabled by setting the
environment variable SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT:

  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=0 (default): do not log
  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=1: log failed messages
  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=2: log failed messages with
  backtrace
  SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINT=3: log failed messages with
  backtrace and abort the process.

The log messages look something like:

    ***Swift runtime: entrypoint -[t.MyClass foo] generated by
       implicit @objc inference is deprecated and will be removed in
       Swift 4
2017-03-31 21:22:16 -07:00
John McCall
f63fece3cd Merge pull request #8471 from rjmccall/ownership-refactors
Ownership refactors
2017-03-31 22:08:35 -04:00
Vedant Kumar
d060eef398 [Coverage] Simplify a check (NFC)
When handling ternary expressions, we check that an active region exists
before attempting to access its counter. It's not necessary to check
that the parent AST node is null, and also that the region stack is
empty. The second check is stronger than the first one.
2017-03-31 17:35:09 -07:00
Vedant Kumar
7094a64f9a [Coverage] Audit uses of getCurrentCounter() (SR-4453)
We use getCurrentCounter() in one spot where there isn't guaranteed to
be an active region: the `else' part of an IfExpr in a TopLevelCodeDecl.

Fix this issue by assigning a pseudo-counter to the `else' part when the
region stack is empty. This patch also adds crash tests which cover
other code paths which rely on getCurrentCounter() when handling
TopLevelCodeDecls.

Fixes SR-4453.
2017-03-31 16:17:34 -07:00
John McCall
305c94fc5b Pare down the Initialization interface and allow implementations
to insert code before performing an in-place initialization.

Intended to be NFC, but some of the clients needed more rewriting
than others.
2017-03-31 18:55:09 -04:00
John McCall
9bd68cfdc1 Extract WritebackPseudoComponent back out as a superclass of
UnpinPseudoComponent.  NFC.

...this secondary use of LogicalLValueComponent for writebacks is
really a huge mess that I apologize for foisting on the world.
Exclusivity enforcement should eventually let us kill the awful
diagnoseWritebackConflict hack, which will make a simplification here
much easier.
2017-03-31 18:00:16 -04:00
Slava Pestov
c17d649b4b Merge pull request #8387 from slavapestov/protocol-witness-thunk-linkage
Protocol witness thunks don't need public linkage
2017-03-30 17:03:37 -07:00
Michael Gottesman
ba5be9d8e8 [silgen] Eliminate an unnecessary writeback scope.
This writeback scope's writeback is handled by the ArgumentScope for argument
emission. Since the scope will be destroyed after argument scope, we get
mismatched scope depths.

rdar://31313534
2017-03-30 14:51:53 -07:00
Michael Gottesman
08c9d4dd11 [silgen] Verify FormalEvaluationScopes in certain places in SILGenApply.
We probably could put it in more places, but this is a good first start.

rdar://31313534
2017-03-30 13:20:50 -07:00
Michael Gottesman
84f5fe6a48 [silgen] Create FormalEvaluationScope::verify().
This method verifies that all non-dead cleanup handles that a formal evaluation
scope would pop have not been popped yet.

The body of the function is if-defed out when asserts are disabled.

rdar://31313534
2017-03-30 13:20:50 -07:00
Slava Pestov
6a83e7303e SILGen: Protocol witness thunks don't need public linkage
We used to give witness thunks public linkage if the
conforming type and the protocol are public.

This is completely unnecessary. If the conformance is
fragile, the thunk should be [shared] [serialized],
allowing the thunk to be serialized into callers after
devirtualization.

Otherwise for private protocols or resilient modules,
witness thunks can just always be private.

This should reduce the size of compiled binaries.

There are two other mildly interesting consequences:

1) In the bridged cast tests, we now inline the witness
   thunks from the bridgeable conformances, which removes
   one level of indirection.

2) This uncovered a flaw in our accessibility checking
   model. Usually, we reject a witness that is less
   visible than the protocol; however, we fail to
   reject it in the case that it comes from an
   extension.

   This is because members of an extension can be
   declared 'public' even if the extended type is not
   public, and it appears that in this case the 'public'
   keyword has no effect.

   I would prefer it if a) 'public' generated a warning
   here, and b) the conformance also generated a warning.

   In Swift 4 mode, we could then make this kind of
   sillyness into an error. But for now, live with the
   broken behavior, and add a test to exercise it to ensure
   we don't crash.

   There are other places where this "allow public but
   ignore it, kinda, except respect it in some places"
   behavior causes problems. I don't know if it was intentional
   or just emergent behavior from general messiness in Sema.

3) In the TBD code, there is one less 'failure' because now
   that witness thunks are no longer public, TBDGen does not
   need to reason about them (except for the case #2 above,
   which will probably require a similar workaround in TBDGen
   as what I put into SILGen).
2017-03-30 03:52:57 -07:00