Commit Graph

7628 Commits

Author SHA1 Message Date
Andrew Trick
e2760a7036 Add a return statement to Variant[Set|Dictionary]Storage.removeAtIndex.
This fast path is only taken when the code is specialized.
Fixes <rdar://problem/19331717> Optimizer breaks Set<T> and Dictionary<K, V>

Swift SVN r24479
2015-01-16 21:10:48 +00:00
Dmitri Hrybenko
2a744240fc Annotate compiler crasher tests that no longer crash when the compiler
is built without assertions

Swift SVN r24476
2015-01-16 18:01:12 +00:00
Jordan Rose
cb702a9035 [test] parse_stdlib.sil should parse the current target's standard library.
I'm not sure how this ever worked -- it was previously always parsing the
OS X standard library but with the current target's triple.

Should fix the buildbot.

Swift SVN r24472
2015-01-16 04:24:23 +00:00
Doug Gregor
fea55d98f2 Eliminate dependent types from within archetypes.
When dealing with multiple levels of generic parameters, the mapping
from potential archetypes down to actual archetypes did not have
access to the archetypes for outer generic parameters. When same-type
requirements equated a type from the inner generic parameter list with
one from the outer generic parameter list, the reference to the outer
generic parameter list's type would remain dependent. For example,
given:

  struct S<A: P> {
    init<Q: P where Q.T == A>(_ q: Q) {}
  }

we would end up with the dependent type for A (τ_0_0) in the same-type
constraint in the initializer requirement.

Now, notify the ArchetypeBuilder of outer generic signatures (and,
therefore, outer generic parameters), so that it has knowledge of the
mapping from those generic parameters to the corresponding
archetypes. Use that mapping when translating potential archetypes to
real archetypes. Additionally, when a potential archetype is mapped to
a concrete type (via a same-type constraint to a concrete type),
substitute archetypes for any dependent types within the concrete
type.

Remove a bunch of hacks in the compiler that identified dependent
types in "strange" places and tried to map them back to
archetypes. Those hacks handled some narrow cases we saw in the
standard library and some external code, but papered over the
underlying issue and left major gaps.

Sadly, introduce one hack into the type checker to help with the
matching of generic witnesses to generic requirements that follow the
pattern described above. See ConstraintSystem::SelfTypeVar; the proper
implementation for this matching involves substituting the adoptee
type in for Self within the requirement, and synthesizing new
archetypes from the result.

Fixes rdar://18435371, rdar://18803556, rdar://19082500,
rdar://19245317, rdar://19371678 and a half dozen compiler crashers
from the crash suite. There are a few other radars that I suspect this
fixes, but which require more steps to reproduce.

Swift SVN r24460
2015-01-16 00:27:18 +00:00
Dmitri Hrybenko
1679791dd2 The 0033 compiler crash test case now fails with an assertion, mark it
as such.

Swift SVN r24392
2015-01-13 06:56:03 +00:00
Dmitri Hrybenko
923c75bf42 tests: remove XFAIL, this test now fails under ASan
Swift SVN r24370
2015-01-12 17:41:10 +00:00
Dmitri Hrybenko
2000bdfb61 tests: check that terminating with exit(1) or abort() is counted as test
failure

Certain iOS simulator versions have a bug in 'simctl' that prevents it
from propagating the exit code to lit in all cases.  We are not running
these iOS versions on the buildbots yet.

rdar://19408362

Swift SVN r24369
2015-01-12 07:38:39 +00:00
Doug Gregor
16927ccb3d Revert "Move the computation of generic signatures into the archetype builder."
This reverts commit r23030.

This puts non-primary archetypes back in the all-archetypes list,
which is the deepest underlying problem behind
rdar://problem/19049566.

Conflicts:
	lib/AST/ArchetypeBuilder.cpp
	validation-test/compiler_crashers/0033-error.swift
	validation-test/compiler_crashers/035-multiple-typecheck-segfault.swift

Swift SVN r24333
2015-01-09 23:19:28 +00:00
David Farler
87c3d7421f Refine static func and var syntax
rdar://problem/17198298

- Allow 'static' in protocol property and func requirements, but not 'class'.
- Allow 'static' methods in classes - they are 'class final'.
- Only allow 'class' methods in classes (or extensions of classes)
- Remove now unneeded diagnostics related to finding 'static' in previously banned places.
- Update relevant diagnostics to make the new rules clear.

Swift SVN r24260
2015-01-08 03:03:29 +00:00
Chris Willmore
03a6190a1f <rdar://problem/19031957> Change failable casts from "as" to "as!"
Previously the "as" keyword could either represent coercion or or forced
downcasting. This change separates the two notions. "as" now only means
type conversion, while the new "as!" operator is used to perform forced
downcasting. If a program uses "as" where "as!" is called for, we emit a
diagnostic and fixit.

Internally, this change removes the UnresolvedCheckedCastExpr class, in
favor of directly instantiating CoerceExpr when parsing the "as"
operator, and ForcedCheckedCastExpr when parsing the "as!" operator.

Swift SVN r24253
2015-01-08 00:33:59 +00:00
Flash Sheridan
c5ebf4f2b5 Add tests for Float80, but only on the desktop; which is tricky, since Gyb doesn't know its destination.
Now 3835 tests.  Reviewed by Dmitri.

Swift SVN r24237
2015-01-07 04:58:25 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
Dmitri Hrybenko
d7179e3c03 Consolidate arithmetic trap tests
Reduces iOS testing time by 25 seconds (machine time, not wall clock
time).

Swift SVN r24086
2014-12-22 23:58:41 +00:00
Dmitri Hrybenko
5d41b6ac9f Validation testsuite: annotate compiler crashers for AddressSanitizer
Tests that crash the compiler are expected to fail under
AddressSanitizer.

Swift SVN r24071
2014-12-22 18:22:07 +00:00
Dmitri Hrybenko
6cad796ec8 Annotate compiler crasher tests so that the tests succeed reliably when
the compiler is built without assertions

Swift SVN r24061
2014-12-20 09:42:59 +00:00
Dmitri Hrybenko
90a8ba9de6 Tests: add a no_asserts fetaure
Swift SVN r24058
2014-12-20 09:42:52 +00:00
Flash Sheridan
c11eb40008 Iterate over more documented operators, now that the documentation has improved; now 3460 tests.
Replace hard-coded lists of real-number types, and of arithmetic and logical operators I’m testing, with lists added to SwiftIntTypes.py, which becomes a bit of a misnomer.  
Separate them into ones which only work on integer types, and those which also allow reals.
Do a double loop, over just the integers and then the reals as well.
Change the run line to allow importing StdlibUnittest with help from Dmitri, which I won't actually need until I do result type checking.

Approved by Dmitri.

Swift SVN r24029
2014-12-19 04:20:03 +00:00
Chris Willmore
b1e9e09ae7 Swift r23756 fixed crash test 2258.
<rdar://problem/19179412> compiler_crashers 1260, 2258 regress in Swift Stdlib (Release+Asserts) #1620

Swift SVN r23796
2014-12-09 00:05:59 +00:00
Joe Pamer
dc338c2a71 Update wording of some new diagnostics.
Swift SVN r23783
2014-12-08 21:56:52 +00:00
Joe Pamer
2912159776 Improve diagnostics for expression typecheck errors
These changes make the following improvements to how we generate diagnostics for expression typecheck failure:
- Customizing a diagnostic for a specific expression kind is as easy as adding a new method to the FailureDiagnosis class,
  and does not require intimate knowledge of the constraint solver’s inner workings.
    - As part of this patch, I’ve introduced specialized diagnostics for call, binop, unop, subscript, assignment and inout
      expressions, but we can go pretty far with this.
    - This also opens up the possibility to customize diagnostics not just for the expression kind, but for the specific types
      involved as well.
- For the purpose of presenting accurate type info, partially-specialized subexpressions are individually re-typechecked
  free of any contextual types. This allows us to:
    - Properly surface subexpression errors.
    - Almost completely avoid any type variables in our diagnostics. In cases where they could not be eliminated, we now
      substitute in "_".
    - More accurately indicate the sources of errors.
- We do a much better job of diagnosing disjunction failures. (So no more nonsensical ‘UInt8’ error messages.)
- We now present reasonable error messages for overload resolution failures, informing the user of partially-matching
  parameter lists when possible.

At the very least, these changes address the following bugs:

<rdar://problem/15863738> More information needed in type-checking error messages
<rdar://problem/16306600> QoI: passing a 'let' value as an inout results in an unfriendly diagnostic
<rdar://problem/16449805> Wrong error for struct-to-protocol downcast
<rdar://problem/16699932> improve type checker diagnostic when passing Double to function taking a Float
<rdar://problem/16707914> fatal error: Can't unwrap Optional.None…Optional.swift, line 75 running Master-Detail Swift app built from template
<rdar://problem/16785829> Inout parameter fixit
<rdar://problem/16900438> We shouldn't leak the internal type placeholder
<rdar://problem/16909379> confusing type check diagnostics
<rdar://problem/16951521> Extra arguments to functions result in an unhelpful error
<rdar://problem/16971025> Two Terrible Diagnostics
<rdar://problem/17007804> $T2 in compiler error string
<rdar://problem/17027483> Terrible diagnostic
<rdar://problem/17083239> Mysterious error using find() with Foundation types
<rdar://problem/17149771> Diagnostic for closure with no inferred return value leaks type variables
<rdar://problem/17212371> Swift poorly-worded error message when overload resolution fails on return type
<rdar://problem/17236976> QoI: Swift error for incorrectly typed parameter is confusing/misleading
<rdar://problem/17304200> Wrong error for non-self-conforming protocols
<rdar://problem/17321369> better error message for inout protocols
<rdar://problem/17539380> Swift error seems wrong
<rdar://problem/17559593> Bogus locationless "treating a forced downcast to 'NSData' as optional will never produce 'nil'" warning
<rdar://problem/17567973> 32-bit error message is really far from the mark: error: missing argument for parameter 'withFont' in call
<rdar://problem/17671058> Wrong error message: "Missing argument for parameter 'completion' in call"
<rdar://problem/17704609> Float is not convertible to UInt8
<rdar://problem/17705424> Poor error reporting for passing Doubles to NSColor: extra argument 'red' in call
<rdar://problem/17743603> Swift compiler gives misleading error message in "NSLayoutConstraint.constraintsWithVisualFormat("x", options: 123, metrics: nil, views: views)"
<rdar://problem/17784167> application of operator to generic type results in odd diagnostic
<rdar://problem/17801696> Awful diagnostic trying to construct an Int when .Int is around
<rdar://problem/17863882> cannot convert the expression's type '()' to type 'Seq'
<rdar://problem/17865869> "has different argument names" diagnostic when parameter defaulted-ness differs
<rdar://problem/17937593> Unclear error message for empty array literal without type context
<rdar://problem/17943023> QoI: compiler displays wrong error when a float is provided to a Int16 parameter in init method
<rdar://problem/17951148> Improve error messages for expressions inside if statements by pre-evaluating outside the 'if'
<rdar://problem/18057815> Unhelpful Swift error message
<rdar://problem/18077468> Incorrect argument label for insertSubview(...)
<rdar://problem/18079213> 'T1' is not identical to 'T2' lacks directionality
<rdar://problem/18086470> Confusing Swift error message: error: 'T' is not convertible to 'MirrorDisposition'
<rdar://problem/18098995> QoI: Unhelpful compiler error when leaving off an & on an inout parameter
<rdar://problem/18104379> Terrible error message
<rdar://problem/18121897> unexpected low-level error on assignment to immutable value through array writeback
<rdar://problem/18123596> unexpected error on self. capture inside class method
<rdar://problem/18152074> QoI: Improve diagnostic for type mismatch in dictionary subscripting
<rdar://problem/18242160> There could be a better error message when using [] instead of [:]
<rdar://problem/18242812> 6A1021a : Type variable leaked
<rdar://problem/18331819> Unclear error message when trying to set an element of an array constant (Swift)
<rdar://problem/18414834> Bad diagnostics example
<rdar://problem/18422468> Calculation of constant value yields unexplainable error
<rdar://problem/18427217> Misleading error message makes debugging difficult
<rdar://problem/18439742> Misleading error: "cannot invoke" mentions completely unrelated types as arguments
<rdar://problem/18535804> Wrong compiler error from swift compiler
<rdar://problem/18567914> Xcode 6.1. GM, Swift, assignment from Int64 to NSNumber. Warning shown as problem with UInt8
<rdar://problem/18784027> Negating Int? Yields Float
<rdar://problem/17691565> attempt to modify a 'let' variable with ++ results in typecheck error about @lvalue Float
<rdar://problem/17164001> "++" on let value could give a better error message

Swift SVN r23782
2014-12-08 21:56:47 +00:00
Dmitri Hrybenko
1eea220932 Use one module cache directory for all the lit tests to speed them up
Doing so is safe even though we have mock SDK.  The include paths for
modules with the same name in the real and mock SDKs are different, and
the module files will be distinct (because they will have a different
hash).

This reduces test runtime on OS X by 30% and brings it under a minute on
a 16-core machine.

This also uncovered some problems with some tests -- even when run for
iOS configurations, some tests would still run with macosx triple.  I
fixed the tests where I noticed this issue.

rdar://problem/19125022

Swift SVN r23683
2014-12-04 11:21:48 +00:00
Chris Willmore
007204a595 Crash tests 0730, 0911, 0916, 1660, 2027, 2203 no longer crash.
Swift SVN r23541
2014-11-21 23:27:40 +00:00
Chris Willmore
513b05c283 compiler_crashers: Use %target-swift-frontend instead of %swift -sdk %sdk
This fixes compiler_crashers tests that use the ObjC interface on
iOS hardware SDKs.

Swift SVN r23458
2014-11-20 00:32:59 +00:00
Chris Willmore
4e1fa4a63f Import the swift-compiler-crashes test suite.
Add all compiler crash tests to the validation-test/compiler_crashers
subdirectory. Add a RUN: line to each test case according to the current
behavior of the Swift compiler.

Swift SVN r23418
2014-11-19 01:27:58 +00:00
Greg Parker
69399885ce Test: Reconcile crashOutputMatches() with its own test, and test multiple uses.
Swift SVN r23157
2014-11-07 05:25:08 +00:00
Dmitri Hrybenko
4ac8e65ce3 Remove uses of MODULES_SDK in testing infrastructure
Swift SVN r23115
2014-11-05 04:31:12 +00:00
Dmitri Hrybenko
1347b446c9 Stop using the MODULES_SDK variable in -D flags for the C++ compiler
Swift SVN r23097
2014-11-04 05:44:12 +00:00
Flash Sheridan
05fd8fab81 Add tests for rejection of mixed type operations for all the types in SwiftIntTypes plus Float and Double,
for binary non-logical operators in _The Swift Programming Language_ "Basic Operators."
Until rdar://18695154 is fixed, + and - are disabled; this leaves 1440 tests.
Approved by Dmitri.


Swift SVN r23096
2014-11-04 04:45:50 +00:00
Joe Groff
6c3e43f653 Runtime: Fix race in conformsToProtocol failure case.
Another thread could pull enqueued records into the cache while we're waiting on the lock, leaving us with an empty queue but an updated cache. Recognize this by sticking a generation on the cache and retrying instead of failing if the generation increased while we waited. Fixes rdar://problem/18856858.

Swift SVN r23091
2014-11-04 01:22:33 +00:00
Andrew Trick
9b2fed0383 <rdar://problem/18856858> ArrayBridging validation test temporarily XFAILed
It's not really XFAILed because it's a crash.
Disabling tests is a dangerous game, but this should be very temporary.
A better long term fix is to allow performance tests to run even when
some validation tests fail.

Swift SVN r23088
2014-11-03 21:11:13 +00:00
Doug Gregor
72e9ca5d67 Move the computation of generic signatures into the archetype builder.
The archetype builder is responsible for figuring out what should go
into a generic signature anyway, so move the generic signature
creation there. This will also allow us to eliminate some code
duplication across Sema and AST.

Fixes compiler crasher 033.

Swift SVN r23030
2014-10-31 06:04:05 +00:00
Joe Groff
1c2ec918bd Update validation test for diagnostic drift.
Swift SVN r22946
2014-10-26 04:38:02 +00:00
Dave Abrahams
9857aaa1de [StdlibUnittest] Use _UnitTestArray now
This commit decouples StdlibUnittest from many details of
[Contiguous]Array, so tests can give useful feedback even in the
presence of a broken [Contiguous]Array implementation while we refactor.

Unfortunately, it wasn't practical to make _UnitTestArray use a
storage class other than _ContiguousArrayStorage[Base], so we still have
to watch out when making changes there.

Swift SVN r22875
2014-10-22 05:28:23 +00:00
Dave Abrahams
c799f3687c [StdlibUnittest] Try to use ContiguousArray
ContiguousArray is a simpler component, thus less prone to breakage.
Builting the unit testing framework atop broken components is a very bad
idea, so let's not.

This is a reinstatement of an earlier commit, plus changes to make the
validation tests work.

Swift SVN r22867
2014-10-21 22:17:06 +00:00
Dmitri Hrybenko
fea8a8660a Add an array bridging race test that I forgot to add and commit some
time ago

Swift SVN r22751
2014-10-15 11:00:30 +00:00
Dave Abrahams
1fa082b7f6 Fix a RUN line missed in the test/[1_]stdlib reorg
Swift SVN r22749
2014-10-15 05:14:47 +00:00
Dave Abrahams
afa1ba6f51 Drop stdlib internal access for two tests
Swift SVN r22637
2014-10-09 21:50:27 +00:00
Dave Abrahams
3f36a4d5e7 Use %target-run-stdlib-swift in more tests
Now that it disables access control, this lit definition applies to many
more tests, where we used to use %target-run-stdlib-swift before access
control came online.

Also, drop -Xfrontend -disable-access-control from a bunch of tests that
don't need it.

Swift SVN r22634
2014-10-09 20:53:07 +00:00
Dmitri Hrybenko
d410ee7598 Move FixedPointDiagnostics to the validation testsuite
It is taking too long to run, rdar://18594315

Swift SVN r22619
2014-10-09 09:07:45 +00:00
Dmitri Hrybenko
4e4ebd856b MicroStdlib test: refactor RUN lines according to Jordan's review
Swift SVN r22565
2014-10-07 09:54:59 +00:00
Dmitri Hrybenko
50b2ca7370 Add a micro-stdlib to the validation testsuite
Swift SVN r22547
2014-10-06 19:20:39 +00:00
Manman Ren
699cee5f00 [Printer] print AST types used by SILDeclRef in SIL mode.
This enables us parsing stdlib in non-optimized mode.


Swift SVN r22445
2014-10-01 22:06:41 +00:00
Manman Ren
b47f4d1c3d xfail parser test while I look at the failure on swift-stdlib-release-asserts-noopt.
Swift SVN r22431
2014-10-01 18:17:10 +00:00
Doug Gregor
e3573b2fd2 Drop expected-* annotations from test; it's too messy to -verify. NFC
Swift SVN r22411
2014-09-30 22:32:31 +00:00
Doug Gregor
073af87f3c Fail more gracefully when we're unable to map a dependent type to an archetype.
This can happen due to an error upstream, so don't assert on it. Fixes
rdar://problem/18503131, and crashers #51, #079, and #128.

Swift SVN r22409
2014-09-30 22:27:07 +00:00
Dave Abrahams
156020de19 [stdlib] Rename 'countElements' => 'count'
The name was not only long and unwieldy, but inconsistent with our
conscious decision to avoid the use of "elements" in APIs as mostly
redundant.

Swift SVN r22408
2014-09-30 22:00:26 +00:00
Manman Ren
26130d911b [SILParser] add a validation test to verify parsing of stdlib deserialized from module.
rdar://17979145


Swift SVN r22396
2014-09-30 18:30:31 +00:00
Dmitri Hrybenko
252c2ffba7 stdlib: add a regression test for assert accepting a string literal
rdar://16987306

Swift SVN r22386
2014-09-30 14:39:21 +00:00
Dmitri Hrybenko
a04ee3a463 stdlib/Unicode: allow transcode() to operate on mutable value-typed
sinks

Swift SVN r22302
2014-09-26 17:28:00 +00:00
Dmitri Hrybenko
a3724588cb Fix and expand the AtomicInt test
The previous version of this test was disallowing some thread
interleavings that I did not consider.  See comments in the test for
more details.

Swift SVN r22300
2014-09-26 10:29:56 +00:00