Hamish Knight
edca7c85ad
Adopt ABORT throughout the compiler
...
Convert a bunch of places where we're dumping to stderr and calling
`abort` over to using `ABORT` such that the message gets printed to
the pretty stack trace. This ensures it gets picked up by
CrashReporter.
2025-05-19 20:55:01 +01:00
Slava Pestov
273c4b2b1a
RequirementMachine: Convert to new assertions
2024-06-22 08:53:22 -04:00
Tim Kientzle
1d961ba22d
Add #include "swift/Basic/Assertions.h" to a lot of source files
...
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Slava Pestov
5a49a337d9
RequirementMachine: Fix some comments
2022-08-11 14:10:01 -04:00
Josh Soref
81d3ad76ac
Spelling ast ( #42463 )
...
* spelling: accessor
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: accommodates
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: argument
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: associated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: availability
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: available
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: belongs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: bookkeeping
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: building
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clazz
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: clonable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: closure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: concatenated
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conformance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: context
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: conversion
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: correspondence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declarations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: declared
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: defining
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: delayed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: dependency
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: deployed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: descendants
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnose
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: diagnostic
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: equitable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: evaluation
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: exclusivity
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existence
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: existential
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: explicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: expressed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: for
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: foreign
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: function
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: identifier
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: implicit
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: indices
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: information
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: instance
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interchangeable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: interface
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: introduced
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: invalid
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: kind-in
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: least
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: library
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: location
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: namespace
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: necessary
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: nonexistent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: not
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: number
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: obtains
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: occurs
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: opaque
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: overridden
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: parameter
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: precede
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: preceding
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: property
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: protocol
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: qualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recognized
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: recursively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: references
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: relaxing
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: represented
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: request
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: requirements
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: retrieve
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: returned
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfied
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: satisfy
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: siblings
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: simplified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: something
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: source
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specializations
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: specially
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: statement
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: stripped
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: structure
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: substitution
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: the
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transform
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transformed
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transitively
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: transparent
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: typecheck
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unknown
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unlabeled
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: unqualified
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: whether
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: with
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
* spelling: scanner
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com >
Co-authored-by: Josh Soref <jsoref@users.noreply.github.com >
2022-04-21 12:57:16 -07:00
Slava Pestov
5bff2a02c5
RequirementMachine: Rename RewritePath::getRulesInEmptyContext() to findRulesAppearingOnceInEmptyContext()
2022-04-04 12:41:57 -04:00
Slava Pestov
deaeb36f57
RequirementMachine: Make RewritePath::getRulesInEmptyContext() const
2022-04-04 12:41:57 -04:00
Slava Pestov
86561b8865
RequirementMachine: Generalize RewritePath::replaceRuleWithPath() to replaceRulesWithPaths()
2022-03-15 13:35:34 -04:00
Slava Pestov
d4732f5a19
RequirementMachine: Move RewritePath and RewriteLoop methods from HomotopyReduction.cpp to RewriteLoop.cpp
2022-03-15 13:35:34 -04:00
Slava Pestov
b497c790fa
RequirementMachine: Check invariants in noassert builds
2022-03-03 14:05:02 -05:00
Slava Pestov
46d07fc739
RequirementMachine: Add new assertion to ConcreteTypeMatcher::verify()
2022-02-17 19:40:58 -05:00
Slava Pestov
991fe1dbd8
RequirementMachine: Preserve replacement paths for redundant rules
2022-02-16 16:28:08 -05:00
Slava Pestov
eab371d8c5
RequirementMachine: Simplify RewriteStep::Decompose
...
The inverted form no longer has to replace substitutions; we use
the inverted form of DecomposeConcrete for that. So just assert
that the substitutions are equal.
2022-02-15 04:02:46 -05:00
Slava Pestov
4d1a8dfe23
RequirementMachine: Don't record no-op PrefixSubstitutions rewrite steps
2022-02-09 00:26:04 -05:00
Slava Pestov
9ee702026f
RequirementMachine: Factor out TypeDifference::getOriginalSubstitution()
2022-02-07 08:20:59 -05:00
Slava Pestov
fcd467ad4c
RequirementMachine: Factor out TypeDifference::getReplacementSubstitution()
2022-02-07 08:20:59 -05:00
Slava Pestov
2c355de71b
RequirementMachine: Introduce RewriteStep::{Left,Right}ConcreteProjection
2022-02-07 08:20:59 -05:00
Slava Pestov
7e4a5876d1
RequirementMachine: Introduce RewriteStep::DecomposeConcrete
2022-02-07 08:20:58 -05:00
Slava Pestov
d8aa79c5e5
RequirementMachine: Rename RewriteStep::AdjustConcreteType to ::PrefixSubstitutions
2022-02-07 08:20:58 -05:00
Slava Pestov
a11151a7e3
RequirementMachine: Fix up some comments
2022-02-04 22:49:28 -05:00
Slava Pestov
3790bba7a0
RequirementMachine: Verify loops immediately when they're added to aid debugging
2022-02-04 22:48:35 -05:00
Slava Pestov
bdbf50e1e3
RequirementMachine: Replace RewriteStep::SameTypeWitness with a relation
2022-01-13 19:14:52 -05:00
Slava Pestov
6064671abd
RequirementMachine: Replace RewriteStep::ConcreteTypeWitness with relations
2022-01-13 18:01:15 -05:00
Slava Pestov
84e2a627ec
RequirementMachine: Replace RewriteStep::AbstractTypeWitness with relations
2022-01-13 00:02:31 -05:00
Slava Pestov
abb85fb3ca
RequirementMachine: Replace RewriteStep::{Superclass,Concrete}Conformance with relations
2022-01-13 00:02:31 -05:00
Slava Pestov
3d2492fe56
RequirementMachine: Rename RewriteStep::ApplyRewriteRule to RewriteStep::Rule
2022-01-13 00:02:31 -05:00
Slava Pestov
f06f59a18a
RequirementMachine: Generalize relations so they look more like rules
2022-01-13 00:02:31 -05:00
Slava Pestov
66cf913d68
RequirementMachine: Minimization understands 'relations' among layout requirements
...
A superclass requirement 'T : C' implies a layout requirement
'T : AnyObject' (if the class is @objc) or 'T : _NativeObject'
(if the class is not @objc).
In the latter case, there might already be a 'T : AnyObject'
requirement, in which case the type parameter 'T' is subject
to two layout requirements:
T : AnyObject
T : _NativeObject
The second requirement implies the first however. To encode this
in the world of rewrite loops, we the notion of a 'relation'
between property symbols, and a 'Relation' rewrite step.
Here, the relation is that _NativeObject < AnyObject. Once this
relation is recorded, the Relation rewrite step will transform
T.[layout: _NativeObject].[layout: AnyObject]
into
T.[layout: _NativeObject]
and vice versa.
This rewrite step allows us to construct a rewrite loop which
makes the first rewrite rule redundant via the second.
2022-01-04 22:35:58 -05:00
Slava Pestov
7148aea7ed
RequirementMachine: Rename RewriteStep::RuleID to RewriteStep::Arg
...
It's used to store more than just the rule ID. However, add a
getRuleID() method that also asserts that Kind is ApplyRewriteRule
for readability.
2022-01-04 22:35:58 -05:00
Slava Pestov
8bf1bc283c
RequirementMachine: Rename A/B stack to primary/secondary stack
2022-01-04 22:35:58 -05:00
Slava Pestov
2bca132380
RequirementMachine: Introduce RewriteStep::AbstractTypeWitness
2021-12-17 10:04:52 -05:00
Slava Pestov
4c83fe851d
RequirementMachine: Generalize ConcreteTypeWitness to TypeWitness
2021-12-17 10:04:52 -05:00
Slava Pestov
b1a3d2c6af
RequirementMachine: Preserve rewrite path for simplifying substitutions
2021-12-17 10:04:52 -05:00
Slava Pestov
7708c75184
RequirementMachine: Introduce RewriteStep::SameTypeWitness
2021-12-14 02:16:46 -05:00
Slava Pestov
654953cbac
RequirementMachine: Introduce RewriteStep::ConcreteTypeWitness
2021-12-14 02:16:46 -05:00
Slava Pestov
2f2249cef1
RequirementMachine: Fix various RewriteSteps to work when re-contextualized
...
When a rewrite rule is replaced with a path containing ::Adjust, ::Decompose,
::ConcreteConformance or ::SuperclassConformance rewrite steps, the steps
will get a non-zero EndOffset if the original rule appears in a step with a
non-zero EndOffset.
For this reason, these steps must work with a non-zero EndOffset, which
primarily means computing correct offsets into the term being manipulated.
2021-12-08 00:53:35 -05:00
Slava Pestov
26293c4695
RequirementMachine: Factor out Symbol::withConcreteSubstitutions()
2021-12-07 15:31:47 -05:00
Slava Pestov
7427b68785
RequirementMachine: Introduce RewriteStep::ConcreteConformance and ::SuperclassConformance
2021-12-06 23:04:46 -05:00
Slava Pestov
e9b94c1bf1
RequirementMachine: Move some methods from RewriteStep to RewritePathEvaluator
...
This better encapsulates the evaluator state into a single struct.
2021-12-06 23:04:46 -05:00
Slava Pestov
d19b15b66c
RequirementMachine: Introduce Symbol::Kind::ConcreteConformance
2021-12-06 23:04:46 -05:00
Slava Pestov
49aaedeedb
RequirementMachine: Fix RewriteStep::AdjustConcreteType
...
Using StartOffset to encode the prefix length is wrong, because
then we get an invalid rewrite step after replaceRuleWithPath().
Instead, encode the prefix length in the RuleID field.
2021-11-01 22:51:59 -04:00
Slava Pestov
450c7c268a
RequirementMachine: Split off RewriteLoop.cpp from HomotopyReduction.cpp
2021-10-27 01:28:24 -04:00