Commit Graph

9411 Commits

Author SHA1 Message Date
John McCall 41efb3d4d3 Only use metadata patterns for generic types; perform other
initialization in-place on demand.  Initialize parent metadata
references correctly on struct and enum metadata.

Also includes several minor improvements related to relative
pointers that I was using before deciding to simply switch the
parent reference to an absolute reference to get better access
patterns.
2016-03-23 17:04:04 -07:00
John McCall 898e0971d9 Add a convenience getNominalParent() accessor to TypeBase and CanType. 2016-03-23 17:04:04 -07:00
danra 891dea4f70 Fix comment typo (NFC) 2016-03-24 00:45:02 +02:00
Xi Ge b4d0cb4ffe ModulePrinting: Avoid printing duplicated members in synthesized extensions. 2016-03-23 15:19:16 -07:00
danra 98776388d4 Compact getCapacityInBits implementation (NFC) 2016-03-23 22:50:34 +02:00
danra dba8f98305 Add missing comment after .h file #endif 2016-03-23 10:13:28 +02:00
Chris Lattner 30ec0f4128 Fix <rdar://23036383> QoI: Invalid trailing closures in stmt-conditions produce lowsy diagnostics
It is a common problem that people use a call to a function with a
trailing closure in a if condition, foreach loop, etc.  These don't allow
trailing closures, because they are ambiguous with the brace-enclosed body
of the conditional statement.

In an effort to improve QoI on this, perform lookahead to disambiguate the most common
form of this, in a very narrow situation.  This allows us to produce a nice error
with fixit hints like:

t.swift:26:25: error: trailing closure requires parentheses for disambiguation in this context
for _ in numbers.filter {$0 > 4} {
                        ^

instead of spewing out this garbage:

t.swift:26:26: error: anonymous closure argument not contained in a closure
for _ in numbers.filter {$0 > 4} {
                         ^
t.swift:26:33: error: consecutive statements on a line must be separated by ';'
for _ in numbers.filter {$0 > 4} {
                                ^
                                ;
t.swift:26:34: error: statement cannot begin with a closure expression
for _ in numbers.filter {$0 > 4} {
                                 ^
t.swift:26:34: note: explicitly discard the result of the closure by assigning to '_'
for _ in numbers.filter {$0 > 4} {
                                 ^
                                 _ =
t.swift:26:34: error: braced block of statements is an unused closure
for _ in numbers.filter {$0 > 4} {
                                 ^
t.swift:26:18: error: type '(@noescape (Int) throws -> Bool) throws -> [Int]' does not conform to protocol 'Sequence'
for _ in numbers.filter {$0 > 4} {
                 ^
t.swift:26:34: error: expression resolves to an unused function
for _ in numbers.filter {$0 > 4} {
                                 ^
2016-03-22 22:06:06 -07:00
Doug Gregor 593932741c Remove historical flags -enable-omit-needless-words/-enable-infer-default-arguments/-enable-swift-name-lookup-tables.
NFC; all of these options are always-on now and we no longer have a
way to turn them off.
2016-03-22 17:04:19 -07:00
Xi Ge f338bdfbb7 [SourceKit] Incorporate synthesized extensions into DocInfo request. rdar://24912860
This commit reuses our code for generating synthesized extensions from module printing to enhance
documentation generation.
2016-03-22 14:49:22 -07:00
Xi Ge 33c53a12eb ASTPrinter: Pass the bracket options to pre and post printing callbacks.
Need this for rdar://24912860
2016-03-22 14:49:22 -07:00
Michael Gottesman f79a741a7d Merge pull request #1779 from danra/patch-5
Minor comment fixes
2016-03-22 14:38:13 -07:00
Chris Lattner 74c7d4164c Merge pull request #1794 from danra/patch-16
[gardening] Minor comment fix
2016-03-22 14:18:38 -07:00
Chris Lattner 09fb7226d7 Merge pull request #1793 from danra/patch-15
Add missing comment after .h file #endif
2016-03-22 14:18:10 -07:00
Chris Lattner 0ac95f1ae0 Merge pull request #1784 from danra/patch-10
Added missing 'const' to iterator comp. operators
2016-03-22 14:14:22 -07:00
danra f63f165b54 [gardening] Minor comment fix 2016-03-22 23:09:06 +02:00
Dan Raviv 24113705fe [gardening] Minor comment fixes 2016-03-22 23:06:33 +02:00
practicalswift 9f4e6372b1 Merge pull request #1791 from practicalswift/fix-recent-headers-ii
[gardening] Fix formatting of recently introduced headers.
2016-03-22 22:04:56 +01:00
danra 5eed1f748b Add missing comment after .h file #endif 2016-03-22 22:59:57 +02:00
Michael Gottesman b094e776b5 Merge pull request #1785 from danra/patch-11
[gardening] Add missing comments
2016-03-22 13:44:24 -07:00
danra 890ff9c9c8 [gardening] Fix comments style 2016-03-22 22:39:30 +02:00
danra f1e68696c9 Add missing comment after .h file #endif 2016-03-22 22:37:30 +02:00
practicalswift ac87f428ea [gardening] Fix formatting of recently introduced headers. 2016-03-22 21:36:09 +01:00
danra d6bb90253c [gardening] Add missing comments 2016-03-22 22:17:19 +02:00
danra 9b258949b3 Added missing 'const' to iterator comp. operators 2016-03-22 22:04:23 +02:00
Dmitri Gribenko 60925272b2 Merge pull request #1781 from danra/patch-7
Add missing comment after .h file #endif
2016-03-22 12:51:38 -07:00
danra 473e97504b [gardening] Add missing comments 2016-03-22 21:45:11 +02:00
danra dac7347dfa Add missing comment after .h file #endif 2016-03-22 21:41:21 +02:00
Dmitri Gribenko e039795d89 Merge pull request #1769 from danra/patch-1
Minor comments cleanup
2016-03-22 10:26:40 -07:00
Dmitri Gribenko 28b67d204e Merge pull request #1770 from danra/patch-2
Comments cleanup
2016-03-22 10:26:08 -07:00
danra c8b624a532 Add missing comment after .h file #endif 2016-03-22 19:23:00 +02:00
danra 89e10e8702 Comments cleanup
- Fix grammar in header comment.
- Remove empty comment line.
- Fix comment line longer than 80 chars.
2016-03-22 19:20:24 +02:00
danra 7d2296fe49 Minor comments cleanup
- Add missing #endif comment at end of .h file.
- Add missing period to HasIvarReleaser comment so it is consistent with the rest of the comments.
2016-03-22 19:07:33 +02:00
Chris Willmore 4cc75187c6 [Sema] Flag -disable-infer-iuos: don't infer IUO type for untyped bindings
If this option is enabled, when generating potential bindings for a type
variable, don't propagate IUO type. Instead try the optional type and
the underlying type. This way, untyped bindings will not be given IUO
type when they are initialized with exprs of IUO type.
2016-03-21 17:33:29 -07:00
Xi Ge 3dd149ab99 [SourceKit] CursorInfo: The result of cursor info for a module name starts to include group names in that module. 2016-03-21 17:20:18 -07:00
Andrew Trick acdf28f440 Merge pull request #1743 from atrick/reapply-specialize
Reapply "Merge pull request #1725 from atrick/specialize"
2016-03-21 17:19:55 -07:00
Doug Gregor 6cbffa7c2a [Sema] Make it possible to suppress warnings about Selector("foo").
When the selector named by Selector("foo") does not map to a known
Objective-C method, allow one to suppress the warning by wrapping the
string literal in an extra set of parentheses, e.g.,

  Selector(("foo"))

Suggest this via a Fix-It on a note so it's discoverable. Addresses
rdar://problem/24791200.
2016-03-21 17:02:40 -07:00
Ben Langmuir 187bc9fbb9 [CursorInfo] Annotate tuple types in fully annotated decl
We already annotate the elements, this just adds annotations around the
outer parentheses, including when the tuple is unit.

rdar://problem/25147925
2016-03-21 16:31:52 -07:00
Xi Ge 66fb8062fe ModulePrinting: For decls without doc-comment, we print the doc-comment associated with their conformances, if any.
Inspired by rdar://24409720
2016-03-21 14:35:32 -07:00
Joe Groff 5d99f7ada8 Remove dead SubstTypeVisitor. 2016-03-21 14:21:42 -07:00
Ben Langmuir 65719e8ce0 Merge pull request #1686 from regnerjr/swift-format_SR-146
[SourceKit] Move Code Formatting Logic to libIDE
2016-03-21 13:52:09 -07:00
Andrew Trick 482b264afc Reapply "Merge pull request #1725 from atrick/specialize"
This was mistakenly reverted in an attempt to fix buildbots.
Unfortunately it's now smashed into one commit.

---
Introduce @_specialize(<type list>) internal attribute.

This attribute can be attached to generic functions. The attribute's
arguments must be a list of concrete types to be substituted in the
function's generic signature. Any number of specializations may be
associated with a generic function.

This attribute provides a hint to the compiler. At -O, the compiler
will generate the specified specializations and emit calls to the
specialized code in the original generic function guarded by type
checks.

The current attribute is designed to be an internal tool for
performance experimentation. It does not affect the language or
API. This work may be extended in the future to add user-visible
attributes that do provide API guarantees and/or direct dispatch to
specialized code.

This attribute works on any generic function: a freestanding function
with generic type parameters, a nongeneric method declared in a
generic class, a generic method in a nongeneric class or a generic
method in a generic class. A function's generic signature is a
concatenation of the generic context and the function's own generic
type parameters.

e.g.

struct S<T> {
var x: T
@_specialize(Int, Float)
mutating func exchangeSecond<U>(u: U, _ t: T) -> (U, T) {
x = t
return (u, x)
}
}
// Substitutes: <T, U> with <Int, Float> producing:
// S<Int>::exchangeSecond<Float>(u: Float, t: Int) -> (Float, Int)

---
[SILOptimizer] Introduce an eager-specializer pass.

This pass finds generic functions with @_specialized attributes and
generates specialized code for the attribute's concrete types. It
inserts type checks and guarded dispatch at the beginning of the
generic function for each specialization. Since we don't currently
expose this attribute as API and don't specialize vtables and witness
tables yet, the only way to reach the specialized code is by calling
the generic function which performs the guarded dispatch.

In the future, we can build on this work in several ways:
- cross module dispatch directly to specialized code
- dynamic dispatch directly to specialized code
- automated specialization based on less specific hints
- partial specialization
- and so on...

I reorganized and refactored the optimizer's generic utilities to
support direct function specialization as opposed to apply
specialization.
2016-03-21 12:43:05 -07:00
Xin Tong 6e07c5ec60 Revert "Minor refactoring in epilogue release matcher. NFC"
This reverts commit a191ae72a7.

Broke Opt+Assert, Stdlib DebInfo+Assert.
2016-03-21 11:08:31 -07:00
Xin Tong b2b5247ba9 Merge pull request #1756 from trentxintong/FSO
Minor refactoring in epilogue release matcher
2016-03-21 07:59:46 -07:00
Xin Tong a191ae72a7 Minor refactoring in epilogue release matcher. NFC 2016-03-20 23:13:50 -07:00
Xin Tong 570c19b9c6 Merge pull request #1754 from trentxintong/FSO
Remove function signature optimization module pass.
2016-03-20 15:55:50 -07:00
Xin Tong 53888e12b5 Remove FunctionSignatureOpts.cpp.
This optimization pass has been replaced by FunctionSigatureOptCloner.cpp
and FunctionSigatureOptRewriter.cpp in cff61d7fe7
2016-03-20 15:05:02 -07:00
Xin Tong e3ec0703fd Merge pull request #1744 from trentxintong/FSO
Implement a function signature cloner and rewriter.
2016-03-20 11:44:54 -07:00
practicalswift a0d494c143 [gardening] Fix recently introduced typos: "fucntion" → "function", "functio" → "function", "mergable" → "mergeable", "mistmatched" → "mismatched" 2016-03-20 10:34:32 +01:00
Xin Tong cff61d7fe7 Implement a function signature cloner and rewriter.
This split the function signature module pass into 2 functin passes.

By doing so,  this allows us to rewrite to using the FSO-optimized
function prior to attempting inlining, but allow us to do a substantial
amount of optimization on the current function before attempting to do
FSO on that function.

And also helps us to move to a model which module pass is NOT used unless
necesary.

I do not see regression nor improvement for on the performance test suite.

functionsignopts.sil and functionsignopt_sroa.sil are modified because the
mangler now takes into account of information in the projection tree.
2016-03-19 23:57:37 -07:00
David Farler d80fe5364c Temporarily turn off reflection metadata: SR-994
This is crashing while emitting metadata for Foundation:
temporarily turning this off while I investigate locally.

https://bugs.swift.org/browse/SR-994
2016-03-19 15:31:22 -07:00