Commit Graph

6725 Commits

Author SHA1 Message Date
David Zarzycki
362d801472 [AST] NFC: Tail allocate CaptureListExpr entries 2017-12-20 09:35:15 -05:00
David Zarzycki
5a4e96fcc2 [AST] NFC: Tail allocate UnresolvedSpecializeExpr TypeLocs 2017-12-20 09:35:15 -05:00
David Zarzycki
dbb421ba95 [AST] NFC: Tail allocate ErasureExpr conformances 2017-12-20 09:35:15 -05:00
David Zarzycki
3c128f3892 [AST] NFC: Minor performance tuning
1) Make AnyFunctionType::getParams() inline friendly (it compiles down
   to just a few instructions).
2) Byte align/size the embedded number of AnyFunctionType parameters.
   This was set to 10 bits back when the inline bitfields were 32 bits
   in size. Now with 64 bits to play with, we have room to spare.
2017-12-20 09:35:15 -05:00
David Zarzycki
af0ed2339b Merge pull request #13533 from davezarzycki/nfc_repack_expr_nodes
NFC: More Expr node layout optimization
2017-12-19 16:16:30 -05:00
Pavel Yaskevich
d3cd61d8eb Merge pull request #13291 from xedin/rdar-34920390
[Mangling/ABI] Mangle function names with parameter labels
2017-12-19 10:50:18 -08:00
David Zarzycki
60d2f5586e [AST] QoI: Track DictionaryExpr commas and tail allocate CollectionExpr comma locs 2017-12-19 13:33:09 -05:00
David Zarzycki
c75912215e [AST] NFC: Tail allocate CollectionExpr elements 2017-12-19 13:33:09 -05:00
David Zarzycki
00542951d2 [AST] NFC: Repack misc TupleExpr bits 2017-12-19 13:33:09 -05:00
Doug Gregor
4a7386e0bb Merge pull request #13520 from DougGregor/conformance-checking-unsatisfied-reqs
[Conformance checking] Don't suppress substitution failures during checking
2017-12-18 21:52:57 -08:00
swift-ci
0a9be5da79 Merge pull request #13507 from modocache/astdumper-overloaded-decl-ref-expr 2017-12-18 20:23:59 -08:00
Doug Gregor
d9095b1079 [Conformance checking] Don't suppress substitution failures during checking.
When checking whether a particular protocol conformance satisfies all of
the protocol's requirements, we were suppressing substitution failures.
In some cases, this would mean that we marked a conformance "invalid"
without ever emitting a diagnostic, which would lead to downstream crashes.

Instead, treat substitution failures somewhat more lazily. If we encounter
one while performing the checking, put the conformance into a "delayed" list
rather than failing immediately. Teach the top-level type checking
loop to re-check these conformances, emitting a diagnostic if they
fail the second time around.

Fixes rdar://problem/35082483 and likely other issues that slipped
through the type checker or blew up in unpredictable ways.
2017-12-18 16:43:59 -08:00
Joe Groff
ef3d616903 Merge pull request #13508 from jckarter/objc-protocol-keypath
AST: Property requirements in @objc protocols should return `true` for `requiresForeignGetterAndSetter`.
2017-12-18 16:04:20 -08:00
Pavel Yaskevich
34b83306bf [Demangler] Teach node printer to use LabelList for entities 2017-12-18 15:44:24 -08:00
Pavel Yaskevich
10c385d1b7 [Mangling/ABI] Add special LabelList to store parameter labels
Instead of mangling parameter labels as part of the function type
move them to the end of the function name instead, to match the
language semantics.
2017-12-18 15:44:24 -08:00
Jordan Rose
15f2161277 Move the fast path of TypeBase::getCanonicalType into the header (#13479)
I'm not sure how much benefit there'll be to inlining this, but a side
benefit is that crashes in optimized builds of the compiler are much
more likely to distinguish between "bug in getCanonicalType" (which
almost never happens) and "bug in the function calling
getCanonicalType".

Inspired by rdar://problem/35819975
2017-12-18 14:55:08 -08:00
Joe Groff
f7fc74332c AST: Property requirements in @objc protocols should return true for requiresForeignGetterAndSetter.
We need to use ObjC dispatch to get to the witness of an ObjC protocol requirement. The wrong answer here was causing us to do the wrong thing when producing identifiers for key paths that refer to ObjC protocol requirements.
2017-12-18 12:29:14 -08:00
Brian Gesiak
6af0001142 [AST] Improve OverloadedDeclRefExpr dump colors
Colorize the dump output for an OverloadedDeclRefExpr, and label the
value decl overloads so that it's clear that they are associated with the expr.
2017-12-18 15:22:02 -05:00
David Zarzycki
af361c041e Merge pull request #13494 from davezarzycki/nfc_sil_repack_part1
NFC: SIL repack of misc node bits (part 1)
2017-12-16 23:10:23 -05:00
John McCall
68af064752 Merge pull request #13482 from rjmccall/builtin-once-is-c
The callback to Builtin.once is a C function, not a Swift one
2017-12-16 18:01:31 -05:00
Doug Gregor
7d4956d37e [Name lookup] Remove debugging cruft 2017-12-16 14:03:28 -08:00
David Zarzycki
54ea315586 [Basic] NFC: Stop using transparent unions 2017-12-16 10:43:49 -05:00
Doug Gregor
8c05278ef3 [Clang importer] Lazily load all named members with a matching base name.
When loading the named members for a given name, we want to load all
of the members with that base name... not only the ones that match the
full name, because the lookup table is indexed by base name and
filtering too early drops candidates.

Fixes rdar://problem/36085994.
2017-12-15 23:54:36 -08:00
John McCall
59e2ab4277 The callback to Builtin.once is a C function, not a Swift one.
If we want it to be a Swift function, we'll have to thunk in the
runtime when using a system implementaton like dispatch_once_f,
since the function pointer ABIs could be different, depending on
the target.  Dealing with that, or avoiding it on a per-target basis,
is more complexiity than a micro-optimization of the slow path of
this builtin could possibly be worth.
2017-12-16 02:22:13 -05:00
David Zarzycki
5e9d73125e [AST] NFC: Repack misc CaseStmt bits 2017-12-15 16:00:38 -05:00
David Zarzycki
23ee4374ec [AST] NFC: Repack misc BraceStmt bits 2017-12-15 15:17:05 -05:00
David Zarzycki
97541e0d1e [Basic] NFC: Standardize and simplify inline bitfields
Inline bitfields are a common design pattern in LLVM and derived
projects, but the associated boilerplate can be demotivating and
brittle. This new header makes it easier to define and use inline
bitfields in Swift.

This also reorders some fields for better code generation.
2017-12-15 14:14:59 -05:00
Doug Gregor
5cdf8f44aa [NFC] Fix spacing 2017-12-13 23:16:37 -08:00
Doug Gregor
b3b86d7a25 Merge pull request #13424 from DougGregor/canonicalize-conformance-access-path
[GSB] Canonicalize conformance access paths on-the-fly.
2017-12-13 22:57:02 -08:00
Doug Gregor
e10ecbd80e [GSB] Only check protocol requirements not generated from the signature.
If we used the requirement signature to create a protocol requirement
element in a requirement source, there's no need to verify that it's
from the requirement signature (duh).
2017-12-13 20:17:18 -08:00
Doug Gregor
a77dec1714 [GSB] Canonicalize conformance access paths on-the-fly.
When forming a conformance access path, remove from consideration any
requirement sources that contain protocol requirements that aren't
found in the requirement signature. This ensure well-formedness of the
resulting conformance access path. Huge thanks to Slava for reducing
this one, and apologies to Arnold for having to track it down a second
time before I fixed it.

Fixes SR-6200 / rdar://problem/35113583.
2017-12-13 19:49:15 -08:00
swift-ci
a24121af65 Merge pull request #13417 from DougGregor/override-objc-diag 2017-12-13 16:06:23 -08:00
Ben Langmuir
68a454556f Merge pull request #13348 from benlangmuir/cc-generic-subscript
[parse] Recover better from malformed subscript decls for code-completion
2017-12-13 15:45:03 -08:00
Ben Langmuir
dc5888d887 [parse] Recover better from malformed subscript decls for code-completion
Code-completion of generic types expects to get a DeclContext for the
subscript, so make sure we recover well enough to produce a
SubscriptDecl.

rdar://35619175
2017-12-13 13:37:41 -08:00
Slava Pestov
422000a2f2 Sema: Remove isProtocolExtensionUsable()
It doesn't do anything that isExtensionApplied() doesn't do.
2017-12-12 21:12:46 -08:00
David Zarzycki
3af569cad2 [AST] NFC: Use llvm::TrailingObjects for ProtocolCompositionType member types
Also, fix a copy that should have been removed from the previous commit.
2017-12-12 16:29:30 -05:00
David Zarzycki
aa4d53e3dd [AST] NFC: Use llvm::TrailingObjects for BoundGenericType generic args 2017-12-12 15:47:07 -05:00
Doug Gregor
beed602bdc [NFC] Fix new file headers 2017-12-11 17:03:07 -08:00
Doug Gregor
82dde17ef4 [Conformance checking] More refactoring of associated type inference.
Move the rest of associated type inference into the new source file,
and split RequirementEnvironment into its own AST-level header, because it
can be re-used and has no ties to the type checker.
2017-12-11 16:34:49 -08:00
David Zarzycki
58d1a57cf3 [AST] NFC: Repack misc SILBoxType bits 2017-12-11 12:34:38 -05:00
David Zarzycki
f45b16574d [AST] NFC: Use llvm::TrailingObjects for TupleType elements 2017-12-11 10:31:16 -05:00
David Zarzycki
c3ae67521f [AST] NFC: Repack misc ParenType bits 2017-12-10 23:03:42 -05:00
David Zarzycki
7bede89a9b [AST] NFC: Repack misc IterableDeclContext bits 2017-12-10 20:38:01 -05:00
David Zarzycki
045d996127 [AST] NFC: Repack misc ClassDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
f3a8023059 [AST] NFC: Repack misc ProtocolDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
67f30ac3ea [AST] NFC: Repack misc GenericTypeParamDecl bits 2017-12-10 20:38:01 -05:00
David Zarzycki
dd617aafa5 [AST] NFC: Repack misc ImportDecl bits 2017-12-10 20:38:01 -05:00
Michael Gottesman
5d18bb86ba [sema] Add support for asserting on the first error that occurs.
This enables one to easily drop down into the debugger in such cases. This is
enabled by the option swift-diagnostics-assert-on-error and can only happen in
an asserts build.

rdar://34222540
2017-12-08 17:43:46 -08:00
Doug Gregor
879b1802f0 [GSB] Downgrade "neither type in same-type has a generic param" error to warning.
There is nothing specifically wrong with uttering a same-type
constraint in a where clause where both sides are concrete
types. Downgrade this to a warning; we'll check that the concrete
types match (of course), and such a well-formed constraint will simply
be canonicalized away.

This aids the migration of IndexDistance from an associated type to
Int.
2017-12-07 14:44:35 -08:00
Doug Gregor
5431400367 [Name lookup] Allow where clauses to find typealiases declared in a protocol.
Within the where clause of (e.g.) an extension, unqualified name lookup is
permitted to find associated types. Extend this to also include finding
typealiases declared within the protocol itself.

This is service of the IndexDistance change (SE-0191), and
fixes rdar://problem/35490504.
2017-12-07 13:46:33 -08:00