Static diagnostics now refer to the identifier for the variable requiring
exclusive diagnostics. Additionally, when two accesses conflict we now always
emit the main diagnostic on the first modifying access and the note on either
the second modifying access or the read.
The diagnostics also now highlight the source range for the expression
beginning the access.
Change the error emitted when diagnosing an exclusivity violation to an warning.
This will make it easier to evaluate on large projects while staging. The
intent it to turn it back into an error before the diagnosis is turned on
by default.
Add a diagnostic pass that emits errors when a violation of the "Law of
Exclusivity" is detected at compile time. The Law of Exclusivity requires
that the access duration of any access to an address not overlap
with an access to the same address unless both accesses are reads.
This pass relies on 'begin_access' and 'end_access' SIL instruction
markers inserted by SILGen to determine when an access to an address begins and
ends. It models the in-progress accesses with a map from storage locations to
the counts of read and write-like accesses in progress for that location.
1. Make sure the actions taken by fixits are reflected in diagnostics messages.
2. Issue missing cases diagnostics at the start of the switch statement instead of its end.
3. Use <#code#> instead of <#Code#> in the stub.
Extend the checks in `LifetimeChecker` in
`SILOptimizer/Mandatory/DefiniteInitialization.cpp`
to catch when the memory object corresponding to a let constant is used
as an inout parameter in a protocol witness method.
Initializing a let constant separate from its declaration requires write
access. Therefore it is treated as `@lvalue TestProtocol` in the AST for
a certain scope.
Checking that the constant is not written to after being initialized is
supposed to happen in the Mandatory SILOptimizer phase instead.
On loads, the Optimizer checks, that a variable is fully initialized,
but perviously did not validate what happens to it after it is loaded.
This allowed loading the memory object through an open_existential_addr
instruction and applying the result as an Operand to a mutating witness
method.
Turn on the noreturn diagnostic for cases where a reachable unreachable
could be encountered. Previously, the diagnostic would not fire if the
function was marked noreturn and any of its reachable unreachable calls
were around. While this makes sense from a SILGen perspective (it Just
Crashes tm), it is still wrong. We need to diagnose *everything* that
has reachable unreachables.
Provide a general mechanism for bridging from a Swift value type to
its corresponding Objective-C class type through the
_bridgeToObjectiveC witness of the appropriate _ObjectiveCBridgeable
protocol conformance. Only enable this new code for bridging String ->
NSString and work through the issues that crop up.
We cannot actually *delete* the _convertStringtoNSString entrypoint
yet, because there is some code that is depending on it indirectly;
I'll address that separately as part of the continued generalization
of the _ObjectiveCBridgeable mechanism.
Certain type circularities weren't being checked until this point. Such as
```
struct X<T> { let a: X<X> }
struct Y<T> { let a: (Int, Y<Y>) }
enum Z<T> { case A(Optional<Z<Z>>) }
```
We introduce a more comprehensive approach to detect these in type checker.
After name lookup, exam each value field in declared structs and enums for
self-reference types that creates inifinite sizes.
its fields are initialized. Before:
t.swift:18:24: error: variable 'self.B' captured by a closure before being initialized
after:
t.swift:19:24: error: 'self' captured by a closure before all members were initialized
self.A.withCString { cString -> () in
^
t.swift:14:7: note: 'self.B' not initialized
var B: Int
^
This drives home the fact that 'self' is being captured here, not the individual
properties.
Diagnostic categories are entirely unused and arguably useless as
implemented, as they merely denote the sub-component of the
compiler.
As far as categorizing warnings are concerned, I'm abandoning the
effort for now, as the utility is marginal and Swift and the Swift
compiler are probalby not ready for these to be nailed down. For the
sake of cleanliness, the CATEGORY field is also stripped from
WARNINGS.
If there's a need for automatic identifying of compiler sub-components
for diagnstics in the future, there are better ways to do this.
NFC
There's no longer a direct use of the variable's address when we invoke the closure, but we have a handy mark_function_escape instruction to mark the use without requiring merging analysis of the box and its contents. This also gives us a slightly more accurate error message when a variable is prematurely captured, noting the variable was captured by a closure instead of just generically used.
Designated initializers in NSManagedObject subclasses, or other
classes with @requires_stored_property_inits cannot assign to
stored properties before doing a super.init() delegation.
Assignments after are OK.
DI did the wrong thing by creating a bitmap with only one bit,
but proceeding down the usual designated initializer path.
Now, handle [derivedselfonly] more like a convenience initializer,
with no stored property access allowed prior to delegation.
Also clean up duplicated diagnostics between designated and
convenience initializers, and make convenience initializers
diagnose method calls or property accesses on self in the same
manner as designated initializers.
Fixes <rdar://problem/22110837>.
Swift SVN r32858
The problem was an uninitialized memory access. Callers were passing
the address of a local variable to isInitializedAtUse(), but this
function only stored to the pointer conditionally. Serendipitously
(or not), in the debug build the initial value was always zero.
Swift SVN r32599
Since a delegation consumes the self value, there's no self value available
in a catch block. Previously we would crash at runtime.
The diagnostics suck right now, so this is mostly for testing and
completeness.
Fixes <rdar://problem/22946400>.
Swift SVN r32583
This removes the partially-correct ABI check in Sema and diagnoses
unsupported conversions in SILGen instead. The new check is more
accurate and correctly diagnoses conversions of DeclRef's to
ABI-incompatible @convention(c) types.
This also fixes two cases where we used to crash but could instead
emit a trivial cast:
- Conversions between ABI-compatible (but not identical)
@convention(c) types
- Conversions of a DeclRef to an ABI-compatible (but not identical)
@convention(c) type
Fixes <rdar://problem/22470105>.
Swift SVN r32163
chain to another self.init, hopefully resolving confusion about what
has to be done here.
This fixes <rdar://problem/21295093> Swift protocol cannot implement default initializer
Swift SVN r29571
explicit to nudge people in the right direction of how to use it.
Fixes <rdar://problem/21355414> Error on forgetting to return on a guard
Swift SVN r29552
We now produce:
t.swift:1:15: error: negative integer '-9223372036854775808' overflows when stored into unsigned type 'UInt'
var x: UInt = -0x8000_0000_0000_0000
^
Swift SVN r27797