Commit Graph

9699 Commits

Author SHA1 Message Date
Doug Gregor
89f3da6d28 [Sema] Start recording default associated conformances.
When forming the default witness table for a resilient protocol, look
for default associated conformances as well. These are identified by
associated conformance requirements whose root associated type has a
default type. For such requirements, we look for a conformance and
record it as a default associated conformance.

Emit a warning in cases where we don't find such a conformance,
because the associated type and conformance *may* have been added
with the intent of being resilient, and we can't know. This warning
might be a terrible idea, but it is only enabled under
-enable-resilience (which itself is hidden) and fires in one only
place in the standard library (which seems legitimate), so we'll try
it for now.
2018-09-18 15:49:43 -07:00
Jordan Rose
c78045e672 Merge pull request #19332 from jrose-apple/usability-testing
Enforce that a fixed-contents struct has usable-from-inline fields
2018-09-18 15:01:31 -07:00
Jordan Rose
41f364089b Enforce that a fixed-contents struct has usable-from-inline fields
That is, a stored instance property of a fixed-contents struct in a
resilient module must have a type that's public or @usableFromInline,
so that it can be manipulated from outside the module without having
to use the struct's value witness table.
2018-09-17 17:18:30 -07:00
Saleem Abdulrasool
d9aaaed6d2 AST: remove extra copy constructors
Visual Studio objects with the following:

```
  AST/AnyRequest.h(243): error: C2580: 'swift::AnyRequest::AnyRequest(const swift::AnyRequest &)': multiple versions of a defaulted special member functions are not allowed
  AST/AnyRequest(243): warning C4521: 'swift::AnyRequest': multiple copy constructors specified
```

Remove the non-const implementation, the default'ed definition should be
sufficient.  Additionally, remove the nonsense const move constructor.
2018-09-16 10:55:43 -07:00
Doug Gregor
2ef9363bd1 [ABI] Add default associated type witnesses to resilient protocols.
When an associated type witness has a default, record that as part of
the protocol and emit a default associated type metadata accessor into the
default witness table. This allows a defaulted associated type to be
added to a protocol resiliently.

This is another part of rdar://problem/44167982, but it’s still very
limiting because the new associated type cannot have any conformances.
2018-09-15 22:04:46 -07:00
Doug Gregor
4f544f965a [AST] Kill rarely-used DenseMap from ProtocolDecl.
Put a DenseMap onto the ASTContext’s implementation instead.
2018-09-15 22:04:46 -07:00
swift-ci
71f6e93e07 Merge pull request #19317 from compnerd/sfinae-request 2018-09-15 11:28:39 -07:00
Saleem Abdulrasool
4be44bf3ee AST: SFINAE away template'd constructor
Because we cannot explicitly control which constructor is used, and Visual
Studio also instantiates the templated constructor (even with the copy and move
constructors available, we end up with ambiguity in the constructor when trying
to instantiate a `llvm::SetVector<AnyRequest>` in the Evaluator.

```
	swift\include\swift\AST\AnyRequest.h(98): error C2027: use of undefined type 'swift::TypeID<Request>'
		with
		[
		    Request=ValueType
		]
	swift\include\swift\AST\AnyRequest.h(98): note: see declaration of 'swift::TypeID<Request>'
		with
		[
		    Request=ValueType
		]
	swift\include\swift\AST\AnyRequest.h(97): note: while compiling class template member function 'swift::AnyRequest::Holder<ValueType>::Holder(const Request &)'
		with
		[
		    Request=ValueType
		]
	swift\include\swift\AST\AnyRequest.h(167): note: see reference to function template instantiation 'swift::AnyRequest::Holder<ValueType>::Holder(const Request &)' being compiled
		with
		[
		    Request=ValueType
		]
	swift\include\swift\AST\AnyRequest.h(168): note: see reference to class template instantiation 'swift::AnyRequest::Holder<ValueType>' being compiled
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\xmemory0(917): note: see reference to function template instantiation 'swift::AnyRequest::AnyRequest<T&>(swift::AnyRequest&)' being compiled
		with
		[
		    T=swift::AnyRequest
		]
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\xmemory(120): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,T&>(_Alloc &,_Objty *const ,T &)' being compiled
		with
		[
		    _Alloc=std::allocator<swift::AnyRequest>,
		    _Ty=swift::AnyRequest,
		    T=swift::AnyRequest,
		    _Objty=swift::AnyRequest
		]
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\xmemory(120): note: see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,T&>(_Alloc &,_Objty *const ,T &)' being compiled
		with
		[
		    _Alloc=std::allocator<swift::AnyRequest>,
		    _Ty=swift::AnyRequest,
		    T=swift::AnyRequest,
		    _Objty=swift::AnyRequest
		]
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\xmemory(153): note: see reference to function template instantiation '_FwdIt std::_Uninitialized_copy_al_unchecked<_Iter,_Iter,_Alloc>(_InIt,_InIt,_FwdIt,_Alloc &,std::_General_ptr_iterator_tag,std::_Any_tag)' being compiled
		with
		[
		    _FwdIt=swift::AnyRequest *,
		    _Iter=swift::AnyRequest *,
		    _Alloc=std::allocator<swift::AnyRequest>,
		    _InIt=swift::AnyRequest *
		]
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\vector(1939): note: see reference to function template instantiation '_FwdIt *std::_Uninitialized_copy<swift::AnyRequest*,swift::AnyRequest*,std::allocator<_Ty>>(_InIt,_InIt,_FwdIt,_Alloc &)' being compiled
		with
		[
		    _FwdIt=swift::AnyRequest *,
		    _Ty=swift::AnyRequest,
		    _InIt=swift::AnyRequest *,
		    _Alloc=std::allocator<swift::AnyRequest>
		]
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\vector(1938): note: while compiling class template member function 'void std::vector<T,std::allocator<_Ty>>::_Umove_if_noexcept1(swift::AnyRequest *,swift::AnyRequest *,swift::AnyRequest *,std::false_type)'
		with
		[
		    T=swift::AnyRequest,
		    _Ty=swift::AnyRequest
		]
	C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.13.26128\include\vector(1944): note: see reference to function template instantiation 'void std::vector<T,std::allocator<_Ty>>::_Umove_if_noexcept1(swift::AnyRequest *,swift::AnyRequest *,swift::AnyRequest *,std::false_type)' being compiled
		with
		[
		    T=swift::AnyRequest,
		    _Ty=swift::AnyRequest
		]
	llvm\include\llvm\ADT\SetVector.h(49): note: see reference to class template instantiation 'std::vector<T,std::allocator<_Ty>>' being compiled
		with
		[
		    T=swift::AnyRequest,
		    _Ty=swift::AnyRequest
		]
	swift\include\swift\AST\Evaluator.h(208): note: see reference to class template instantiation 'llvm::SetVector<swift::AnyRequest,std::vector<T,std::allocator<_Ty>>,llvm::DenseSet<T,llvm::DenseMapInfo<swift::AnyRequest>>>' being compiled
		with
		[
		    T=swift::AnyRequest,
		    _Ty=swift::AnyRequest
		]
	swift\include\swift\AST\AnyRequest.h(97): error C2065: 'value': undeclared identifier
```

Hoist the type alias into the template specialization so that we can use that
in the SFINAE expression rather than duplicating it.
2018-09-14 22:01:51 -07:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
Saleem Abdulrasool
4baa775726 Merge pull request #19297 from compnerd/unreachable
litter the tree with `llvm_unreachable`
2018-09-14 09:04:56 -07:00
Graydon Hoare
4a9b676183 Merge pull request #19306 from graydon/one-determined-heart
[Stats] Add SWIFTC_MAXIMUM_DETERMINISM to inhibit parallelism everywhere.
2018-09-13 19:01:38 -07:00
John Holdsworth
e55d4254d2 [Parse] Allow multiline attribute messages (SE-200) (#19219)
Multiline string literal at attribute message position was disallowed in
59778f8ecb.

Reworked to try to at least get multiline strings working which might be
useful as messages for attributes (for example a detailed “unavailable”
annotation) minus the code which read off the start of the StringRef buffer.
2018-09-14 10:33:32 +09:00
swift-ci
9fdf976ecf Merge pull request #19262 from compnerd/ast-friends 2018-09-13 16:40:25 -07:00
Graydon Hoare
5a563f59af [Stats] Add SWIFTC_MAXIMUM_DETERMINISM to inhibit parallelism everywhere. 2018-09-13 16:15:49 -07:00
Saleem Abdulrasool
d281b98220 litter the tree with llvm_unreachable
This silences the instances of the warning from Visual Studio about not all
codepaths returning a value.  This makes the output more readable and less
likely to lose useful warnings.  NFC.
2018-09-13 15:26:14 -07:00
Joe Groff
8665342877 Merge pull request #19151 from jckarter/allocating-convenience-initializers
Dispatch initializers by their allocating entry point
2018-09-13 15:17:34 -07:00
Joe Groff
77a0923ca6 SILGen: Emit convenience initializers as allocating entry points.
And only dispatch designated inits by their allocating entry points. rdar://problem/29634243
2018-09-13 12:31:23 -07:00
Xi Ge
c94bc1d7db Merge pull request #19260 from nkcsgexi/parse-other-type
Parser: allow on-demand member decl parsing for other nominal types.
2018-09-12 22:28:18 -07:00
Xi Ge
a7a06d7ce3 FrontendTool: parse all delayed member decls when we're dumping parse tree or verifying parse diagnostics. 2018-09-12 19:40:28 -07:00
Xi Ge
033732b1e5 ASTVerifier: avoid verifying IterableDeclContext if it has unparsed members. 2018-09-12 14:11:41 -07:00
Mark Lacey
352e4a2de4 [ConstraintSystem] Infer empty closures as returning () more eagerly.
We previously allowed these closures to default to (), but be inferred
as other types as well, which means that we will find some expressions
to be ambiguous because we end up finding multiple viable solutions
where there is really only one reasonable solution.

Fixes: rdar://problem/42337247
2018-09-12 13:30:35 -07:00
Saleem Abdulrasool
05d2bb9fd2 AST: friend SimpleRequest without type specifier
When building with Visual Studio, the following error is identified:

  'SimpleRequest': non-class template has already been declared as a class template
  note: see declaration of 'SimpleRequest'

Change the friend declarations to friend the type without the `class` specifier.
2018-09-12 11:35:34 -07:00
Mark Lacey
3f74fbcd23 Merge pull request #19194 from rudkx/serialization-for-designated-protocols
Add serialization/deserialization support for designated protocols fo…
2018-09-11 17:19:19 -07:00
Jordan Rose
af39accab0 Sprinkle LLVM_READONLY/READNONE on a few DeclAttribute accessors (#19237)
No intended functionality change. Probably no performance change
either, but might as well.
2018-09-11 14:21:40 -07:00
Mark Lacey
03504e2c77 Merge pull request #19234 from mzp/warn_about_function_in_string_interpolation
[Sema] Warn for a function value in string interpolation
2018-09-10 22:18:18 -07:00
Slava Pestov
fe7ac5daca Merge pull request #19065 from slavapestov/remove-paren-preserving-hacks
Remove ParenType-preserving hacks
2018-09-10 20:56:59 -07:00
Doug Gregor
3962a82246 Merge pull request #19238 from DougGregor/break-request-cycles
Break request cycles
2018-09-10 20:47:28 -07:00
Mark Lacey
b214570e89 Merge pull request #19235 from rudkx/restore-protocol-decl
Revert "Revert "Store ProtocolDecl rather than TypeLoc for designated…
2018-09-10 18:05:43 -07:00
Doug Gregor
ac37747c78 [Type checker] Break isObjC/getObjCSelector cycle.
When we're marking a declaration as @objc and recording it in the
class and source-file lookup tables (for @objc collision detection),
don't cause a cycle by querying `getObjCSelector()`. This is somewhat
of a hack: a better long-term approach would be to move the recording
much later, and request'ify the name computation. That'll be follow-up
work.
2018-09-10 17:30:17 -07:00
Slava Pestov
f9d77069ae Sema: Move decomposeArgType() to CSDiag and simplify it
As usual, CSDiag is a graveyard for old crap because I'm expecting
it will be gutted over time.
2018-09-10 17:22:31 -07:00
mzp
f5ed8981b6 [Sema] Warn for a function value in string interpolation
Resolves https://bugs.swift.org/browse/SR-8464
2018-09-11 08:09:42 +09:00
Mark Lacey
5aca0aaa96 Add serialization/deserialization support for designated protocols for operators.
Parsing for these protocols in operator declarations is gated by
-enable-operator-designated-protocols (added in
https://github.com/apple/swift/pull/19145).
2018-09-10 15:57:20 -07:00
Mark Lacey
95ee91044b Revert "Revert "Store ProtocolDecl rather than TypeLoc for designated protocol.""
This reverts commit 14b4f37a31,
restoring 4be2dc7b3a, this time with a
fix for uninitialized data.
2018-09-10 15:54:12 -07:00
swift-ci
cc329fee03 Merge pull request #19141 from aschwaighofer/remove_constant_string_literal 2018-09-10 15:51:47 -07:00
Mark Lacey
14b4f37a31 Revert "Store ProtocolDecl rather than TypeLoc for designated protocol." 2018-09-10 13:16:15 -07:00
Xi Ge
59fc174d9c Merge pull request #19196 from nkcsgexi/is-primary-parse
Parser: calculating interface hash only for primary files.
2018-09-10 10:09:28 -07:00
Rintaro Ishizaki
66df646c67 Merge pull request #19206 from rintaro/rdar44228891
[Parse] Disable support for multiline/extended escaping string literal in attribute message
2018-09-11 02:01:32 +09:00
Mark Lacey
24b61b3bfa Merge pull request #19202 from rudkx/rework-type-checking-designated-protocol
Store ProtocolDecl rather than TypeLoc for designated protocol.
2018-09-10 09:13:29 -07:00
Rintaro Ishizaki
59778f8ecb [Parse] Disable support for multiline/extended escaping string literal
in attribute message

Strings of diagnostics message processed in EncodedDiagnosticMessage
aren't necessarily from parsed Swift source code. That means, they might
not have quotes around it. Furthermore, memory around them might not be
managed. The logic in 'Lexer::getEncodedStringSegment()' used to cause
access violation.

For now, disable multiline string literal and extended escaping in string
literal for attribute message position. Considering the message might be
from Clang, we cannot simply enable this.

rdar://problem/44228891
2018-09-08 17:32:36 +09:00
Harlan
eb75ad80dc [AST] Remove stored TypeLoc from TypedPattern (#19175)
* [AST] Remove stored TypeLoc from TypedPattern

TypedPattern was only using this TypeLoc as a means to a TypeRepr, which
caused it to store the pattern type twice (through the superclass and through
the TypeLoc itself.)

This also fixes a bug where deserializing a TypedPattern doesn't store
the type correctly and generally cleans up TypedPattern initialization.

Resolves rdar://44144435

* Address review comments
2018-09-07 21:14:04 -07:00
Mark Lacey
4be2dc7b3a Store ProtocolDecl rather than TypeLoc for designated protocol. 2018-09-07 18:20:55 -07:00
Xi Ge
fe0046ba26 Parser: calculating interface hash only for primary files. 2018-09-07 14:24:30 -07:00
Jordan Rose
b2538e9264 Merge pull request #19186 from jrose-apple/full-reverse
When sorting imports for uniquing purposes, use full module names
2018-09-07 11:12:43 -07:00
Mark Lacey
1e7dae3741 Merge pull request #19145 from rudkx/parse-designated-protocol
Add support for parsing designated protocols in operator declarations.
2018-09-06 22:01:02 -07:00
Jordan Rose
37ec248823 Add ModuleDecl::ReverseFullNameIterator
Package up the logic that generates a full Clang module name, so that
(a) we don't have to deal with clang::Module in quite as many places
in the /Swift/ compiler, and (b) we can avoid the cost of a temporary
string in a few places.

The main places where this is /not/ adopted is where we don't just
want to know the parent module name, but actually the module itself.
This is mostly indexing-related queries, which use the very similar
ModuleEntity class also defined in Module.h. I didn't quite see an
obvious way to unify these, but that might be where we want to go.

No functionality change.
2018-09-06 19:53:59 -07:00
Jordan Rose
d6133f408d Merge pull request #19176 from jrose-apple/important
[ModuleInterface] Print imports (including '@_exported')
2018-09-06 19:37:22 -07:00
Slava Pestov
8801aa67d3 Merge pull request #19133 from slavapestov/access-level-cleanup
Access level cleanup
2018-09-06 16:46:40 -07:00
Jordan Rose
f6ee9f6dc9 [ModuleInterface] Print imports (including '@_exported')
Part of preserving enough information to reconstitute a textual
interface back to a binary module.
2018-09-06 16:05:16 -07:00
Jordan Rose
737a405596 Add ModuleDecl::isOnoneSupportModule, and use it
A few places around the compiler were checking for this module by its
name. The implementation still checks by name, but at least that only
has to occur in one place.

(Unfortunately I can't eliminate the string constant altogether,
because the implicit import for SwiftOnoneSupport happens by name.)

No functionality change.
2018-09-06 16:05:16 -07:00
Xi Ge
b4356d4f93 Merge pull request #19104 from nkcsgexi/parser-laziness
Parser: lazily parse members in extension decls.
2018-09-06 15:24:17 -07:00