Commit Graph

7436 Commits

Author SHA1 Message Date
Arnold Schwaighofer
eba12a7c3e Revert "Finish and default-enable named lazy member loading" 2017-12-01 07:25:54 -08:00
swift-ci
7e6f7e1c04 Merge pull request #12843 from graydon/force-on-named-lazy-member-loading 2017-12-01 02:32:10 -08:00
Graydon Hoare
9e1859469c [NamedLazyMemberLoading] Use per-IDC recursion-breaking flag, not sentinel.
The empty sentinel in the lookup table caused recursion-breaking to bottom
out in slightly different order than the old eager code, making certain
order-sensitive tests fail.
2017-11-30 22:18:25 -08:00
Rintaro Ishizaki
d28d4073b1 Merge pull request #13173 from rintaro/parse-specifier-typesimple
[Parse] Skip type specifiers in middle of composition types
2017-12-01 12:10:32 +09:00
Jordan Rose
8f8f00012a Merge pull request #12834 from jrose-apple/restrict-cross-module-struct-initializers-2
Implementation of SE-0189 "Restrict cross-module struct initializers to be delegating"

rdar://problem/34777878
2017-11-30 13:32:45 -08:00
Rintaro Ishizaki
e7be78b84d [Parse] Skip type specifiers in middle of composition types
Like `P & inout P2`.
Don't bother to construct wrapped TypeRepr for them.
2017-11-30 15:59:35 +09:00
Harlan Haskins
9732442628 [Syntax] Remove LegacyASTTransformer
As it is no longer ever instantiated, and since Syntax nodes are being
plumbed through the parser, the LegacyASTTransformer no longer needs to
exist.
2017-11-29 17:51:57 -05:00
Slava Pestov
1f2a49bf75 Merge pull request #13133 from slavapestov/who-cares-about-speling
Remove TypeBase::isSpelledLike()
2017-11-28 21:08:23 -08:00
swift-ci
b39c337285 Merge pull request #13129 from gottesmm/pr-a501646b040ec5fb99039cd0689b4468acdd0d23 2017-11-28 21:06:20 -08:00
Slava Pestov
a23d1fa0d7 AST: Remove TypeBase::isSpelledLike() 2017-11-28 20:25:22 -08:00
Michael Gottesman
566f3d1cae [sil] Move determining if two SILFunctionTypes are ABI compatible from the verifier onto SILFunctionType itself.
Right now if convert_function is used incorrectly by SILGen, we get an error via
the SILVerifier after we have finished building the entire function. This is a
pain in the butt to track down. Using this refactor, I am able to just assert in
the SILBuilder itself.

On another note, down the line we should just separate the dataflow checker part
of the verifier from specific SILInstruction verification. This would allow for
SILBuilder to perform the SILInstruction verification upon creation giving the
same effect. Such a change is a much larger change though and this is just a
commit chopped off a larger commit.

rdar://34222540
2017-11-28 20:10:37 -08:00
Ted Kremenek
e04c7fd00a Merge pull request #12964 from graydon/if-target-environment
#if targetEnvironment(simulator)
2017-11-28 19:39:44 -08:00
swift-ci
cdab55a202 Merge pull request #13124 from DougGregor/se-0143-experimental-flag 2017-11-28 16:59:27 -08:00
Doug Gregor
b59c30c1af [SE-0143] Put conditional conformances behind an "experimental" flag.
Conditional conformances aren't quite ready yet for Swift 4.1, so
introduce the flag `-enable-experimental-conditional-conformances` to
enable conditional conformaces, and an error when one declares a
conditional conformance without specifying the flag.

Add this flag when building the standard library (which will vend
conditional conformances) and to all of the tests that need it.

Fixes rdar://problem/35728337.
2017-11-28 16:01:51 -08:00
Graydon Hoare
94988a253e [Parse] Add suggestion to targetEnvironment diagnostic. 2017-11-28 15:55:12 -08:00
Graydon Hoare
d31bad45b8 [Parse] Add fixit for targetEnvironment(simulator) 2017-11-28 13:51:01 -08:00
swift-ci
e482bcb947 Merge pull request #13079 from davezarzycki/nfc_ExtInfo_feedback 2017-11-28 07:12:18 -08:00
David Zarzycki
5cc0d83db0 [AST] NFC: Use NumExtInfoBits instead of the magic value 2017-11-28 08:45:06 -05:00
David Ungar
83ee8cb7f0 Merge pull request #12920 from davidungar/Move-input-conversion
Move input conversion
2017-11-27 17:13:48 -08:00
Arnold Schwaighofer
3e04f21a41 SIL: Remove EnableGuaranteedClosureContext now that it is the default 2017-11-27 07:25:03 -08:00
David Zarzycki
a52b07faf8 [AST] NFC: Try to static_assert that ExtInfo and TypeBase agree 2017-11-27 07:55:58 -05:00
swift-ci
3546136621 Merge pull request #13075 from lattner/SourceLocCleanup 2017-11-26 23:04:17 -08:00
swift-ci
6285582c13 Merge pull request #13074 from gottesmm/pr-bae9d9e30d40c9211864b978ff3400b9b01034c9 2017-11-26 21:55:50 -08:00
Chris Lattner
ee3b01bf81 Clean up some SourceLocation manipulation logic, NFC. 2017-11-26 20:58:42 -08:00
Michael Gottesman
7be1815d3f [ast] Add support for dumping a decl to a file from the debugger.
This is often times useful when one has a wall of AST dump and one wants to
winnow the lines down in a text editor.
2017-11-26 20:16:27 -08:00
David Zarzycki
a8efe26184 Merge pull request #13053 from davezarzycki/nfc_fewer_reserved_TypeBase_bits
[AST] NFC: ExtInfo should reserve only needed TypeBase bits
2017-11-25 14:14:57 -05:00
David Zarzycki
0116b0f174 [AST] NFC: Make RecursiveTypeProperties have a natural size 2017-11-22 18:13:05 -05:00
David Zarzycki
f228e98208 [AST] NFC: Simplify truncation detection 2017-11-22 17:09:49 -05:00
David Zarzycki
882ae3ac65 [AST] NFC: ExtInfo should reserve only needed TypeBase bits
Both AnyFunctionType and SILFunctionType reserve 16 bits in the TypeBase
for their respective "ExtInfo" bits, but then these types use less than
half of the bits they reserve. This patch changes AnyFunctionType and
SILFunctionType to only reserve what they need and then verify at
construction time that ExtInfo bits are not being truncated.

This change is motivated by the need to have more TypeBase bits
available for other uses.

Finally, this change fixes a copy-and-paste error introduced when
AnyFunctionType and SILFunctionType stopped sharing the same ExtInfo
data structure.
2017-11-22 16:31:42 -05:00
swift-ci
2eca3aa27a Merge pull request #13045 from DougGregor/se-0143-check-all-conditional-requirements 2017-11-21 22:55:49 -08:00
Doug Gregor
e3a5318b97 [Type checker] Teach conformsToProtocol() to check conditional requirements.
conformsToProtocol() is the main way in which we check whether a given type
conforms to a given protocol. Extend it to check conditional requirements by
default, so that an unmodified caller will get the "does not conform" result
(with diagnostics when a location is present) rather than simply ignoring
the conditional requirements.

Some callers take responsibility for conditional requirements, e.g., to
push them into the constraint system. Allow those callers to opt out of
this checking, and do so wherever appropriate.

Fixes rdar://problem/35518088, where we were ignoring the conditional
requirements needed to verify that Equatable synthesis could be performed.
2017-11-21 21:02:00 -08:00
Rintaro Ishizaki
c0c04864db Merge pull request #12989 from rintaro/syntax-ctxt-progressive
[Syntax] Rewrite SyntaxParsingContext
2017-11-21 16:38:00 +09:00
swift-ci
2f48ba5587 Merge pull request #13041 from DougGregor/conformance-micro-opts 2017-11-20 22:03:50 -08:00
swift-ci
a786051b67 Merge pull request #13034 from davezarzycki/stale_declattr_70_comment 2017-11-20 17:58:26 -08:00
Doug Gregor
6dbde269b8 [AST] Collapse redundant specialized conformances.
Sometimes we end up mapping a conformance into and then out of a
particular context, which led to "stacked" specialized conformances
that were basically a no-op. Look through these to collapse them
eagerly.

Collapses 15786 conformances in the standard library.
2017-11-20 14:08:55 -08:00
John Fairhurst
87015e46d8 Print out param type attributes in more places 2017-11-20 19:36:50 +00:00
Slava Pestov
700aa71509 AST: Remove GenericEnvironment::getSubstitutionMap() 2017-11-20 12:59:03 -05:00
David Zarzycki
351189bf51 NFC: Remove stale comment about DeclAttr 70 2017-11-20 12:40:15 -05:00
Michael Gottesman
cb4e085e28 [all-+0] Add new field to SILOptions.EnableGuaranteedNormalArguments and use it to trigger +0 normal arguments.
This enables one to control via SILOptions whether or not normal arguments are
emitted as guaranteed. In a subsequent commit, I am going to add support for
triggering this via a frontend option.

I also got rid of the default Owned argument to DefaultConvention. Now
everywhere we create a DefaultConvention, we must be explicit about our normal
parameter convention.

rdar://34222540
2017-11-19 12:38:07 -08:00
ematejska
a00b0749c4 Merge pull request #12849 from rudkx/SE-0054
SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
2017-11-18 18:51:39 -08:00
Rintaro Ishizaki
0a401b381c [Syntax] Rewrite SyntaxParsingContext
Read RawSyntaxToken along with Parser::consumeToken()

* Single Lexer pass
* Backtracking support
* Split token support
2017-11-18 15:35:46 +09:00
Mark Lacey
8b55a0f61b SE-0054: Rework diagnostics for IUOs and revise Swift 3 /4 semantics.
For Swift 3 / 4:

Deprecate the spelling "ImplicitlyUnwrappedOptional", emitting a warning
and suggesting "!" in places where they are allowed according to
SE-0054.

In places where SE-0054 disallowed IUOs but we continued to accept them
in previous compilers, emit a warning suggesting "Optional" or "?"  as
an alternative depending on context and treat the IUO as an Optional,
noting this in the diagnostic.

For Swift 5:

Treat "ImplicitlyUnwrappedOptional" as an error, suggesting
"!" in places where they are allowed by SE-0054.

In places where SE-0054 disallowed IUOs, emit an error suggestion
"Optional" or "?" as an alternative depending on context.
2017-11-18 11:41:53 +09:00
Joe Groff
39dfe07354 IRGen: Treat class layout for classes from other modules a bit more opaquely.
We would miscompile in mixed-language-version projects when a Swift class was compiled for one language version, while using Objective-C-imported types that are only available to that version, and then imported into a Swift module with a different language version that wasn't able to see all of the properties because of incompatible imported types. This manifested in a number of ways:

- We assumed we could re-derive the constant field offsets of the class's ivars from the layout, which is wrong if properties are missing, causing accesses to final properties or subclass properties to go to the wrong offsets.
- We assumed we could re-derive the instance size and alignment of a class instance in total, causing code to allocate the wrong amount of memory.
- We neglected to account for the space that stored properties take up in the field offset vector of the class object, causing us to load vtable entries for following subclass methods from the wrong offsets.

Eventually, resilience should reduce our exposure to these kinds of problems. As an incremental step in the right direction, when we look at a class from another module in IRGen, treat it as always variably-sized, so we don't try to hardcode offsets, size, or alignment of its instances. When we import a class, and we're unable to import a stored property, leave behind a new kind of MissingMemberDecl that records the number of field offset vector slots it will take up, so that we lay out subclass objects and compute vtable offsets correctly. Fixes rdar://problem/35330067.

A side effect of this is that the RemoteAST library is no longer able to provide fixed field offsets for class ivars. This doesn't appear to impact the lldb test suite, and they will ultimately need to use more abstract access patterns to get ivar offsets from resilient classes (if they aren't already), so I just removed the RemoteAST test cases that tested for class field offsets for now.
2017-11-17 14:38:08 -08:00
Doug Gregor
7ec8512b11 Merge pull request #12970 from DougGregor/conformance-interface-type
[AST] Store only interface types in NormalProtocolConformances.
2017-11-17 07:52:59 -08:00
Nathan Hawes
fcc27f04ee Merge pull request #12981 from nathawes/rdar34859742-protocol-rename-failure-in-generic-requirement-of-subscript
[ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
2017-11-16 18:20:39 -08:00
Nathan Hawes
7403e779ad [ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
Also handle requirements in non-trailing where clauses (for -swift-version 3)
Resolves rdar://problem/34859742
2017-11-16 16:02:12 -08:00
Devin Coughlin
cf9a09e18d [Exclusivity] Diagnose when noescape closure is passed via reabstraction thunk
This fixes a serious false negative in static exclusivity enforcement when
a noescape closure performs an access that conflicts with an in-progress access
but is not reported because the closure is passed via a reabstraction thunk.

When diagnosing at a call site, the enforcement now looks through partial
applies that are passed as noescape arguments. If the partial apply takes
an argument that is itself a noescape partial apply, it recursively checks
the captures for that partial apply for conflicts and diagnoses if it finds one.

This means, for example, that the compiler will now diagnose when there is a
conflict involving a closure with a concrete return type that is passed to a
function that expects a closure returning a generic type. To preserve source
compatibility these diagnostics are emitted as warnings for now. The intent is
that they will be upgraded to errors in a future version of Swift.

rdar://problem/35215926, SR-6103
2017-11-16 16:01:08 -08:00
Huon Wilson
5f70f68c0d [AST] Store only interface types in NormalProtocolConformances.
Rather than storing contextual types in the type witnesses and associated
conformances of NormalProtocolConformance, store only interface types.

@huonw did most of the work here, and @DougGregor patched things up to
complete the change.
2017-11-16 11:45:18 -08:00
Arnold Schwaighofer
ce2966dd6e Merge pull request #12957 from aschwaighofer/callee_guaranteed_closures
SILGen: Remaining fixes for @callee_guaranteed closures and enable it
2017-11-16 11:12:54 -08:00
Slava Pestov
2920b4fd1c AST: Remove DeclContext::mapTypeOutOfContext() 2017-11-15 22:52:28 -08:00