Commit Graph

583 Commits

Author SHA1 Message Date
swift-ci
9a0efcac2a Merge pull request #30548 from AnthonyLatsis/sr-7855 2020-04-13 13:20:27 -07:00
Robert Widmann
1f904ca86d Merge pull request #30669 from CodaFi/consteval
[NFC] A Handful of Sweeping Evaluator Cleanups
2020-03-27 09:43:28 -07:00
marcrasi
eae4c5eece [AutoDiff upstream] @differentiable function type sema (#30648)
Add type checking for `@differentiable` function types:
- Check that parameters and results conform to `Differentiable`.
- Implicitly conform parameters and results whose types are generic parameters
  to `Differentiable`.
- Upstream most of the differentiable_func_type_type_checking.swift test from
  `tensorflow` branch. A few function conversion tests have not been added
   because they depend on the `@differentiable` function conversion pipeline.

Diagnose gracefully when the `Differentiable` protocol is unavailable because
`_Differentiation` has not been imported.

Resolves TF-823 and TF-1219.
2020-03-26 23:28:02 -07:00
Robert Widmann
987cd55f50 [NFC] Drop llvm::Expected from Evaluation Points
A request is intended to be a pure function of its inputs. That function could, in theory, fail. In practice, there were basically no requests taking advantage of this ability - the few that were using it to explicitly detect cycles can just return reasonable defaults instead of forwarding the error on up the stack.

This is because cycles are checked by *the Evaluator*, and are unwound by the Evaluator.

Therefore, restore the idea that the evaluate functions are themselves pure, but keep the idea that *evaluation* of those requests may fail. This model enables the best of both worlds: we not only keep the evaluator flexible enough to handle future use cases like cancellation and diagnostic invalidation, but also request-based dependencies using the values computed at the evaluation points. These aforementioned use cases would use the llvm::Expected interface and the regular evaluation-point interface respectively.
2020-03-26 23:08:02 -07:00
Slava Pestov
53ab30044c GSB: Fix maybeResolveEquivalenceClass() with member type of concrete type
Fixes <rdar://problem/55401811>, <https://bugs.swift.org/browse/SR-11475>.
2020-03-25 16:53:57 -04:00
Anthony Latsis
a826da5979 [Sema] Fixits for assoc. type restatement hints should account for where clauses 2020-03-21 05:31:37 +03:00
swift-ci
cbcc377259 Merge pull request #30453 from gribozavr/simplify-append 2020-03-17 13:18:43 -07:00
Dmitri Gribenko
b2164f238a Simplified SmallString::append calls 2020-03-17 19:33:42 +01:00
Dmitri Gribenko
80e4a705fe Call placement new directly on the allocator
... avoiding handling a pointer to raw memory.
2020-03-17 19:24:09 +01:00
fischertony
6f08216936 Sema: Support where clauses on contextually generic decls 2020-03-05 04:37:12 +03:00
Robert Widmann
de72824b04 [Gardening] Canonicalize usages of ASTContext::Stats 2020-02-27 17:12:58 -08:00
Suyash Srijan
c435646825 [GSB] Delay mapping an invalid subject type to an error type (#29813) 2020-02-18 07:35:42 +00:00
swift-ci
dd4488eb2d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-28 13:04:30 -08:00
Robert Widmann
88d6559722 [GSB] Map invalid subject types in requirement constraints to ErrorType
Resolves SR-12072 and rdar://58941114
2020-01-28 10:15:43 -08:00
swift-ci
dcb4ee0582 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-12 12:23:31 -08:00
Dan Zheng
1486d6b346 NFC: Add GenericSignature::getCanonicalSignature. (#29105)
Motivation: `GenericSignatureImpl::getCanonicalSignature` crashes for
`GenericSignature` with underlying `nullptr`. This led to verbose workarounds
when computing `CanGenericSignature` from `GenericSignature`.

Solution: `GenericSignature::getCanonicalSignature` is a wrapper around
`GenericSignatureImpl::getCanonicalSignature` that returns the canonical
signature, or `nullptr` if the underlying pointer is `nullptr`.

Rewrite all verbose workarounds using `GenericSignature::getCanonicalSignature`.
2020-01-12 12:17:41 -08:00
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
Varun Gandhi
022314a640 Merge pull request #28643 from kitaisreal/using-located-instead-of-pair
[Compiler]: Using Located<T> instead of std::pair<SourceLoc, T>
2020-01-06 14:22:29 -08:00
swift_jenkins
81c0ed297a Merge remote-tracking branch 'origin/master' into master-next 2020-01-02 10:19:08 -08:00
Saleem Abdulrasool
e133b20718 GSB: inline some trivial methods
This inlines the comparators since GCC 7 objects to the definition
(which is probably due to scoping).  However, these methods are
templates, which must be visible to the consumers, and should therefore
be in the header.  Given the size, it seems reasonable to just inline
them.
2019-12-26 19:46:53 -08:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
c1444dea18 SR-11889: Fixed code review issues 2019-12-20 17:18:59 +03:00
swift_jenkins
6b53fd184c Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 11:00:08 -08:00
Brent Royal-Gordon
6a8598a99c [NFC] Remove DeclNameRef staging calls 2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
addbe3e5ed [NFC] Thread DeclNameRef through most of the compiler
This huge commit contains as many of the mechanical changes as possible.
2019-12-11 00:55:18 -08:00
swift_jenkins
fe004f5e70 Merge remote-tracking branch 'origin/master' into master-next 2019-11-20 20:00:17 -08:00
Robert Widmann
c83c0f4cb7 Filter out invalid nested types from typealias override checking
The lookupDirect means that we can see type declarations nested inside of a protocol. If we do not filter these invalid declarations, we will offer a bogus fixit on top of a cycle diagnostic.  Remove these types from consideration entirely so we don't crash and don't offer bogus fixits.

Resolves rdar://57003317
2019-11-20 15:17:09 -08:00
swift-ci
9f6c8cbf3a Merge remote-tracking branch 'origin/master' into master-next 2019-11-04 12:50:07 -08:00
Robert Widmann
ce4b20c90d [Gardening] Remove dead LazyResolver members 2019-11-04 11:13:14 -08:00
swift-ci
0b41d02a4d Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 20:49:50 -07:00
Brent Royal-Gordon
17169fc1fe Merge pull request #27950 from brentdax/dumpster-fire
[NFC] Standardize dump() methods in frontend
2019-10-31 20:36:26 -07:00
Brent Royal-Gordon
99faa033fc [NFC] Standardize dump() methods in frontend
By convention, most structs and classes in the Swift compiler include a `dump()` method which prints debugging information. This method is meant to be called only from the debugger, but this means they’re often unused and may be eliminated from optimized binaries. On the other hand, some parts of the compiler call `dump()` methods directly despite them being intended as a pure debugging aid. clang supports attributes which can be used to avoid these problems, but they’re used very inconsistently across the compiler.

This commit adds `SWIFT_DEBUG_DUMP` and `SWIFT_DEBUG_DUMPER(<name>(<params>))` macros to declare `dump()` methods with the appropriate set of attributes and adopts this macro throughout the frontend. It does not pervasively adopt this macro in SILGen, SILOptimizer, or IRGen; these components use `dump()` methods in a different way where they’re frequently called from debugging code. Nor does it adopt it in runtime components like swiftRuntime and swiftReflection, because I’m a bit worried about size.

Despite the large number of files and lines affected, this change is NFC.
2019-10-31 18:37:42 -07:00
swift-ci
2689ff9343 Merge remote-tracking branch 'origin/master' into master-next 2019-10-30 07:49:45 -07:00
Robert Widmann
b849e51768 Use operator bool to claw back some readability 2019-10-29 16:56:21 -07:00
Robert Widmann
3e1a61f425 [NFC] Fold The Tri-State In Optional<ProtocolConformanceRef>
ProtocolConformanceRef already has an invalid state.  Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it.  Mechanically
translate all of the callers and callsites to use this new
representation.
2019-10-29 16:55:56 -07:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Robert Widmann
86e5ed18a0 Add a bailout path to protocol requirement source formation
The GSB will try to form and note invalid constraints, but there are
a few paths that aren't prepared for error types to pop up.  Add
a defensive check to formProtocolRelativeType to make sure we don't wind
up force-casting an error type.

Fixes rdar://56116278
2019-10-25 13:08:41 -07:00
swift-ci
e4cbf824ae Merge remote-tracking branch 'origin/master' into master-next 2019-10-11 15:10:04 -07:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
swift-ci
d499a49526 Merge remote-tracking branch 'origin/master' into master-next 2019-10-08 06:29:18 -07:00
David Zarzycki
df078830e4 NFC: silence a few warnings 2019-10-04 10:48:04 +03:00
swift-ci
b30a6ae2ee Merge remote-tracking branch 'origin/master' into master-next 2019-10-03 08:29:37 -07:00
Saleem Abdulrasool
85b6a0542c AST: remove dump for GSB
This relied on UB as per [meta.rqmts]p4
(http://eel.is/c++draft/meta#rqmts-4) and has been UB since C++11
20.9.2p1 has the same restriction.

MSVC 19.24 became more stringent and silently ignores this now,
preventing the Swift build.  Require the user to explicitly pass in
`-DSWIFT_PERMIT_UNDEFINED_BEHAVIOR` to get the dump functionality.
2019-10-02 11:20:43 -07:00
swift-ci
5e50242b5e Merge remote-tracking branch 'origin/master' into master-next 2019-09-30 16:09:53 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
swift-ci
2891ea3897 Merge remote-tracking branch 'origin/master' into master-next 2019-09-25 06:50:22 -07:00
Slava Pestov
040be292e5 AST: TypeDecl::getDeclaredInterfaceType() always returns a non-empty Type
In the case of circular type aliases, this now returns ErrorType
instead of Type().
2019-09-24 22:38:59 -04:00
Slava Pestov
edd5105452 AST: Clean up usages of TypeAliasDecl::getStructuralType()
This also gets rid of a usage of TypeAliasType::get().
2019-09-24 22:38:59 -04:00
swift-ci
e0a9ae468a Merge remote-tracking branch 'origin/master' into master-next 2019-09-24 15:29:49 -07:00
Robert Widmann
574a450537 Extensions Do Not Have Parent Signatures
Remove the parent signature from consideration when computing the
generic signature for an extension.  This cuts off a series of crashers
that involved nested extensions with trailing where clauses a la

extension Foo {
  extension Foo where Self.Undefined == Bar {
  }
}

The inner (invalid) extension technically has a parent signature from
Foo itself.  Adding that signature to the GSB means when we go to
register the inner extension's generic parameters we crash.

Since extensions have to occur at the top level, just remove the parent
signature from consideration.

Fixes rdar://55502661
2019-09-24 13:13:51 -07:00