Commit Graph

47 Commits

Author SHA1 Message Date
Dmitri Gribenko
dd75aed67a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-17 14:40:05 -08:00
Jordan Rose
36a44cf308 Replace uses of llvm::Fixnum with llvm::PointerEmbeddedInt.
The two types are nearly identical, and Fixnum is only in the Swift branches of LLVM,
not in mainline LLVM.

I do want to add ++ to PointerEmbeddedInt and fix some of this ugliness, but that'll
have to go through LLVM review, so it might take a bit.
2016-02-11 09:52:07 -08:00
Max Moiseev
9a018bd77d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-20 14:38:22 -08:00
Chris Lattner
69ba5bc876 Remove shouldDiscardFailures() from ConstraintLocator,
remove shouldRecordFailures() from ConstraintSystem.  NFC.
2016-01-20 10:38:37 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
practicalswift
36d7072013 Remove immediately adjacent repeated words ("the the", "for for", "an an", etc.). 2015-12-21 22:16:04 +01:00
Doug Gregor
a97ab6dd14 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 10:15:47 -08:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Dmitri Gribenko
31598d41bf Rename GeneratorType to IteratorProtocol 2015-12-07 17:08:32 -08:00
Chris Lattner
605411ed62 remove the LvalueObjectType locator, which is never used.
Swift SVN r31621
2015-09-02 05:38:30 +00:00
Chris Lattner
16a51639ef Fix <rdar://problem/22519983> QoI: Weird error when failing to infer archetype
Introduce a new "OpenedGeneric" locator for when openGeneric opens a generic
decl into a plethora of constraints, and use this in CSDiags to distinguish 
whether a constraint refers to an Expr as a whole or an "aspect" of the constraint.

Use that information in FailureDiagnosis::diagnoseGeneralConversionFailure
to know whether (as a fallback) we can correctly re-typecheck an entire expr 
to obtain a missing type.  If we are talking about an aspect of the expr, then
this clearly won't work.

The upshot of this is that where we previously compiled the testcase in 22519983
to:

y.swift:31:9: error: type '(inout _) -> Bool' does not conform to protocol 'RawRepresentable'
let a = safeAssign
        ^

we now produce the somewhat more useful:
y.swift:31:9: error: argument for generic parameter 'T' could not be inferred
let a = safeAssign
        ^
y.swift:27:6: note: in call to function 'safeAssign'
func safeAssign<T: RawRepresentable>(inout lhs: T) -> Bool {
     ^



Swift SVN r31620
2015-09-02 05:15:22 +00:00
Chris Lattner
c9fb58c662 remove the CheckedCastOperand & AddressOf locators which are no longer needed. NFC.
Swift SVN r31617
2015-09-02 04:19:54 +00:00
Chris Lattner
c26ed58541 remove IfThen/IfElse locators which are no longer needed.
Swift SVN r31616
2015-09-02 03:44:56 +00:00
Chris Lattner
be6da087d6 remove the AssignSource and AssignDest locators, which are no longer needed.
Swift SVN r31615
2015-09-02 03:40:55 +00:00
Chris Lattner
922a7f53b3 consolidate the diagnostics produced by the "Failure" case and the expr walker in CSDiags to
get the same wording, fixing <rdar://problem/21964599> Different diagnostics for the same issue

While I'm in the area, remove some dead code.



Swift SVN r30713
2015-07-28 04:43:37 +00:00
Chris Lattner
b68379d635 add a helper "dump()" function on ConstraintLocator that takes a ConstraintSystem,
because that's what we usually have around.


Swift SVN r30630
2015-07-25 16:53:56 +00:00
Doug Gregor
e2bec4377b Don't allow existentials to be used where we need a witness table.
If we end up trying to form a substitution where the replacement type
is an existential and there is a conformance to a non-@objc protocol
(i.e., a conformance where a witness table is required), complain in
Sema rather than crashing in IRGen. Fixes rdar://problem/21087341, but
the existential/generic interaction is still quite broken.

Swift SVN r29133
2015-05-29 05:02:18 +00:00
Chris Lattner
e517ad9182 Fix unreachable code handling to properly diagnose things like:
throw x 
whatever()  

as being unreachable after the throw.



Swift SVN r28680
2015-05-17 15:13:35 +00:00
Dmitri Hrybenko
0a1f7c09df Revert "Fix unreachable code handling to properly diagnose things like:"
This reverts commit 28678.  It broke the IDE/complete_exception.swift
test.

Swift SVN r28679
2015-05-17 12:27:57 +00:00
Chris Lattner
5ead9764bd Fix unreachable code handling to properly diagnose things like:
throw x
  whatever()

as being unreachable after the throw.



Swift SVN r28678
2015-05-17 05:56:02 +00:00
John McCall
08d3460a19 Implement throw expressions. Untested.
Tests tomorrow for this and 'catch', I promise. :)

Swift SVN r26432
2015-03-23 08:10:15 +00:00
Doug Gregor
3805e18090 Explicitly track the mapping from dependent types to their opened type variables.
Previously, we were reconstructing this mapping from the "full" opened
type produced by declaration references. However, when dealing with
same-type constraints between associated types and type parameters, we
could end up with an incomplete mapping, which let archetypes slip
through. Most of the churn here is sorting out the locators we need to
use to find the opened-type information. Fixes rdar://problem/18208283
and at least 3 dupes of it that I've found so far.

Swift SVN r25375
2015-02-18 19:41:40 +00:00
Doug Gregor
476c65c180 Add a locator path element for candidate protocol witnesses. NFC
Swift SVN r25374
2015-02-18 19:41:37 +00:00
Connor Wakamo
6c11ab65ea Switch from an llvm::PointerIntPair to manually handling storage and storedKind in ConstraintLocator::PathElement.
The previous approach -- which attempted to put an llvm::Fixnum<52> into an
llvm::PointerUnion -- failed to compile for 32-bit platforms. This approach now
explicitly uses 62 bits of a uint64_t for storing either an ArchetypeType * or
an llvm::Fixnum<62>, using the remaining 2 bits to store what kind of value is
in storage.

This fixes <rdar://problem/19283881>.

Swift SVN r24084
2014-12-22 23:23:14 +00:00
Connor Wakamo
b9c3e9f55a Fixed an 80-column violation in ConstraintLocator.h.
Swift SVN r24078
2014-12-22 21:30:15 +00:00
Connor Wakamo
1fa1c01e4b Fixed a typo in the comment for ConstraintLocator::PathElement::storage.
Swift SVN r24077
2014-12-22 21:30:15 +00:00
Jordan Rose
3fcdfd40e9 Remove the "swift/Basic/Optional.h" header.
llvm::Optional lives in "llvm/ADT/Optional.h". Like Clang, we can get
Optional in the 'swift' namespace by including "swift/Basic/LLVM.h".

We're now fully switched over to llvm::Optional!

Swift SVN r22477
2014-10-02 18:51:45 +00:00
Doug Gregor
e0afb13abb Remove the APINotes library; it lives in Clang, now.
Swift SVN r22286
2014-09-25 18:48:43 +00:00
Doug Gregor
6559392293 Start re-namespacing APINotes and its dependencies.
FixNum.h and BCRecordLayout.h will move down into LLVM, APINotes
will move into Clang. Get the namespaces right before we start to move
files around.

Swift SVN r22218
2014-09-23 17:52:17 +00:00
Doug Gregor
43b6ed364a Thread constraint locators through opening of generic types.
Locators that refer to opened type parameters now carry information
about the source location where we needed to open the type, so that
(for example) we can trace an opened type parameter back to the
location it was opened. As part of this, eliminate the "rootExpr"
fallback, because we're threading constraint locators everywhere.

This is infrastructural, and should be NFC.

Swift SVN r21919
2014-09-12 20:27:19 +00:00
Doug Gregor
397f4a9888 Remove user-defined conversions from the type checker.
Nobody is using this crufty old feature now, so remove it and the
complexity that goes along with it.

Swift SVN r21379
2014-08-21 21:59:49 +00:00
Joe Groff
c56051b1b7 Remove unused constraint locators.
Swift SVN r19348
2014-06-30 18:44:05 +00:00
Doug Gregor
5a08a69ebc Remove NewArrayExpr entirely; reject "new" expressions in the parser.
Swift SVN r19293
2014-06-27 15:57:48 +00:00
Michael Gottesman
507b1587e6 Quiet unused variable warning.
Swift SVN r18734
2014-06-07 00:37:29 +00:00
John McCall
a2a4eea598 Use a unique constraint locator path for the operand of a
checked cast expression.

We don't actually *use* that path for anything right now,
because we basically re-check the cast from scratch after
constraint application.  This is nonetheless necessary to
avoid collisions with constraints which might be located
on the result, such as would arise in an initialization
context.

In particular, this patch fixes a crash arising when both
the operand and the result of a coercion require a
user-defined conversion.  Test to follow.

Swift SVN r18386
2014-05-19 04:00:45 +00:00
Nadav Rotem
72e68f7a92 Increase the number of bits in KindAndValue.
We use KindAndValue storage to encode an argument index as well as other fields. The index argument overflows with long array literals.

KindAndValue is defined like this:  typedef Fixnum<29> KindAndValueStorage;

We encode the three values in 'value' with a 16 bit offset for the first field and 8 bit offset for the second field . 29 - 16 - 8 = 5 bits. This means that we can only support 2^5 = 32 arguments.



Swift SVN r17815
2014-05-10 00:57:12 +00:00
Doug Gregor
36cbcccbe9 Generalize constraint application under -strict-keyword-arguments.
Introduce a new locator kind for argument/parameter comparisons that
tracks both the argument and the parameter, which we will eventually
use in diagnostics more regularly. For now, this helps us smooth over
scalar-to-tuple/tuple-to-tuple/tuple-to-scalar nonsense when dealing
with calls.

Fix a pile of fallout from this change.

Swift SVN r17648
2014-05-07 22:36:49 +00:00
Joe Groff
8f1c2d1e79 Sema: Implement type-checking for inout writeback conversion.
Add a third branch to the constraint system for '&x' expressions that allows conversion from an lvalue to a type via an additional writeback step:

- Add an LValueConversionExpr node that converts from @lvalue T to @lvalue U, given a pair of functions that convert T -> U and U -> T, to represent the writeback temporary.
- Allow conversion in an inout expression from @lvalue T to a type U that has the following members:

  static func __writeback_conversion(Builtin.RawPointer, T.Type) -> U
  static func __writeback_conversion_get(T) -> V
  static func __writeback_conversion_set(V) -> T

which builds a solution that produces an LValueConversion from the get/set pair before passing the pointer to the writeback temporary off to the conversion function.

Swift SVN r15764
2014-04-02 00:17:51 +00:00
Joe Groff
953c93d936 Sema: Rework inout conversion to do simple member lookup instead of using a protocol.
We'll need types to be convertible from multiple kinds of inouts, which currently can't be represented with protocol conformance since we only allow one protocol conformance per type per protocol. Instead just look for a magic "__inout_conversion" static method in the type; this is lame but easy, and inout conversions shouldn't be available outside of the stdlib anyway.

Swift SVN r15599
2014-03-29 02:50:32 +00:00
Joe Pamer
d36f33f5a0 Add option to discard constraint application failures associated with a given locator.
While diagnosing the cause of a constraint system failure, being able to ignore some failures but not others allows us to produce slightly better error messages in some cases.  This is in support of JoeG's current work.

Swift SVN r15560
2014-03-27 18:15:23 +00:00
John McCall
59ffc88fa7 When ranking constraint solutions, consider anything that causes
a function conversion to be bad.

This encourages the type-checker to place conversions within
closures rather than outside; the test case here crashed in
SIL verification because of that.  (Yes, that means that there's
an underlying problem still when the function conversion is
required; that's tracked by rdar://15875305.)  But in general,
function conversions are likely to be expensive, and it's good
to avoid them when possible.

The setup work to add SK_FunctionConversion was accidentally
committed as part of r12813.

Swift SVN r12839
2014-01-23 01:28:48 +00:00
John McCall
5c6b022cbe Track whether a constraint locator is part of a function
conversion, and use the same process to optimize isSimple()
as an afterthought.

Swift SVN r12813
2014-01-22 23:22:55 +00:00
Doug Gregor
1d12c5352c Check a complete array-new expression within a single constraint system.
Fixes <rdar://problem/15653973>.


Swift SVN r11262
2013-12-13 19:16:19 +00:00
Dmitri Hrybenko
acdd5b120a Make type checker debug output redirectable
Introduce a replaceable TypeCheckerDebugConsumer for this.


Swift SVN r9555
2013-10-21 20:26:32 +00:00
Doug Gregor
2d215d68d3 Split Constraint and ConstraintLocator into their own headers.
No functionality change.


Swift SVN r9204
2013-10-11 17:24:46 +00:00