Commit Graph

53 Commits

Author SHA1 Message Date
Nate Chandler
091368ba21 [CoroutineAccessors] Added read.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Nate Chandler
98a2e6a7df [CoroutineAccessors] Added modify.
The name is a placeholder for the mutating single-yield coroutine
accessor.
2024-09-26 18:10:39 -07:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00
Slava Pestov
0ecc8efca5 Sema: Better debug output for associated type inference 2023-10-11 14:58:41 -04:00
Hamish Knight
7982e4bd7e [AST] Handle null in printDeclDescription
Sink down the null Decl printing into
`printDeclDescription` such that all callers
benefit from it.

This is an attempt at fixing at least the secondary
crash in rdar://113491294, it does not address the
underlying crash.
2023-08-21 15:35:16 +01:00
Holly Borla
684ef9c482 [AST] Add a new accessor kind for init accessors. 2023-06-06 18:57:31 -07:00
Rintaro Ishizaki
86d405bcd0 [Macros] Unify MacroExpansionDecl/MacroExpansionExpr expansion logic
'MacroExpansionDecl' and 'MacroExpansionExpr' have many common methods.
Introduce a common base class 'FreestandingMacroExpansion' that holds
'MacroExpansionInfo'.

Factor out common expansion logic to 'evaluateFreestandingMacro'
function that resembles 'evaluateAttachedMacro'.
2023-06-02 11:54:05 -07:00
zoecarver
13e64f3a3f [nfc][cxx-interop] Add some pretty stack traces for various things that crash a lot. 2022-03-17 16:54:54 -07:00
Slava Pestov
2a1b985f9e AST: PrettyStackTraceConformance doesn't need to take the ASTContext 2021-03-05 21:30:14 -05:00
Richard Wei
e494df2ee6 [AutoDiff] Add differentiability kind to differentiability witnesses and mangle them.
Differentiability witnesses are now keyed by the original function name, the differentiability kind, and the autodiff config.

Updated SIL syntax:
```
differentiability-kind ::= 'forward' | 'reverse' | 'normal' | 'linear'
sil-differentiability-witness ::=
    'sil_differentiability_witness'
    sil-linkage?
    '[' differentiability-kind ']'
    '[' 'parameters' sil-differentiability-witness-function-index-list ']'
    '[' 'results' sil-differentiability-witness-function-index-list ']'
    generic-parameter-clause?
    sil-function-name ':' sil-type
    sil-differentiability-witness-body?
sil-instruction ::=
    'differentiability_witness_function'
    '[' sil-differentiability-witness-function-kind ']'
    '[' differentiability-kind ']'
    '[' 'parameters' sil-differentiability-witness-function-index-list ']'
    '[' 'results' sil-differentiability-witness-function-index-list ']'
    generic-parameter-clause?
    sil-function-name ':' sil-type
```
```console
sil_differentiability_witness [reverse] [parameters 0 1] [results 0] <T where T: Differentiable> @foo : <T> $(T) -> T
differentiability_witness_function [vjp] [reverse] [parameters 0] [results 0] <T where T: Differentiable> @foo : $(T) -> T
```

New mangling:
```swift
  global ::= global generic-signature? 'WJ' DIFFERENTIABILITY-KIND INDEX-SUBSET 'p' INDEX-SUBSET 'r' // differentiability witness
```
```console
$s13test_mangling3fooyS2f_S2ftFWJrSpSr ---> reverse differentiability witness for test_mangling.foo(Swift.Float, Swift.Float, Swift.Float) -> Swift.Float with respect to parameters {0} and results {0}
```

Resolves rdar://74380324.
2021-02-17 18:27:42 -05:00
Nathan Hawes
4fd0cdc2ef Fix up calls to clang::Type::dump() now that it requires a clang::ASTContext. 2020-07-07 15:05:34 -07:00
Anthony Latsis
b68d827032 [NFC] AST: const-qualify ASTContext refs in PrettyStackTrace.h 2020-06-05 16:31:52 +03:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Rintaro Ishizaki
de6a402116 [CodeCompletion] Add pretty stacktrace for completion operation 2020-04-10 09:28:40 -07:00
Dan Zheng
a174243159 [AutoDiff upstream] Add SIL differentiability witness IRGen. (#29704)
SIL differentiability witnesses are a new top-level SIL construct mapping
an "original" SIL function and derivative configuration to derivative SIL
functions.

This patch adds `SILDifferentiabilityWitness` IRGen.

`SILDifferentiabilityWitness` has a fixed `{ i8*, i8* }` layout:
JVP and VJP derivative function pointers.

Resolves TF-1146.
2020-02-07 14:10:34 -08:00
John McCall
b3750a7c13 Add a PrettyStackTrace for working with Clang types. 2020-02-06 12:09:05 -05:00
Jordan Rose
8ff1dac381 [AST] Break some header dependencies for faster rebuilds (#27374)
DiagnosticEngine.h no longer depends on Attr.h.
Expr.h no longer depends on TypeRepr.h.

No functionality change.
2019-09-26 09:17:10 -07:00
Slava Pestov
ef1821e420 Sema: Add a pretty stack for capture computation 2019-08-07 15:45:08 -04:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
John McCall
6ffeb4d839 [NFC] Add PrettyStackTraceConformance and use it
Also allow the printFooDescription functions to suppress
the trailing newline.
2018-11-15 18:39:35 -05:00
John McCall
b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
John McCall
e97fde0a32 Merge pull request #17212 from rjmccall/generalize-accessor-kinds
Rename accessor kinds from IsGetter -> IsGet, etc.
2018-06-14 18:06:39 -04:00
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04:00
Jordan Rose
85275d278e Add some more PrettyStackTrace entries to AST (#17208)
No functionality change.
2018-06-14 13:55:52 -07:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Doug Gregor
c5fe5c47c9 [AST] Verify canonicalization of generic signatures.
When we canonicalize a generic signature, ensure that the resulting
signature has canonical requirements in the appropriate order.
More validation for generic signature canonicalization as part of the
ABI, which is tracked by SR-3733 / rdar://problem/31412994.
2017-11-06 21:22:36 -08:00
Alex Hoppen
f302afc97f Unify approach to printing declaration names (#9320)
Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:25:20 -07:00
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
1af1cbfb76 [gardening] Add a bunch of end namespace comments found by clang-tidy. 2016-12-06 19:22:52 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Jordan Rose
9dd6308cfb Improve PrettyStackTrace entries, especially around serialization. (#5079)
Two of them are user-facing, with the following sort of message:

    If you're seeing a crash here, check that your SDK and
    dependencies match the versions used to build 'SwiftLib'

Prompted by rdar://problem/28282310, which took a while to figure out.
The added test case is a simplified version of the issue. (Obviously
we'd prefer to not crash here, but that's hard---there's an inherited
conformance that's no longer valid, and there may be generic types
depending on that conformance.)
2016-10-04 16:22:58 -07:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Jordan Rose
c9d34f294b Print the storage decl associated with an accessor in a crash trace.
...instead of just "anonname=0xBADBEEF".

Swift SVN r28324
2015-05-08 21:01:44 +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
Dmitri Hrybenko
0ac3f6f299 Allow const Decls to be used with PrettyStackTraceDecl
Swift SVN r15045
2014-03-14 12:37:01 +00:00
John McCall
dc88f2ed04 The convention is for print*Description to print a newline.
Swift SVN r10391
2013-11-13 00:16:18 +00:00
John McCall
0f97e9307c Extract out a function to print a SourceLoc for pretty stack traces.
Swift SVN r10339
2013-11-11 19:52:32 +00:00
Dmitri Hrybenko
536ed954ad Remove FuncExpr. Add CaptureInfo to FuncDecl. Introduce AnyFunctionRef.
AnyFunctionRef is a universal function reference that can wrap all AST nodes
that represent functions and exposes a common interface to them.  Use it in two
places in SIL where CapturingExpr was used previously.

AnyFunctionRef allows further simplifications in other places, but these will
be done separately.


Swift SVN r8239
2013-09-14 02:15:48 +00:00
Doug Gregor
a85ef1e7c4 Introduce stack trace information for resolving type representations.
This should help give a slightly better experience for out-of-order
type checking issues until we manage to make type checking
order-independent. <rdar://problem/14702636>.


Swift SVN r7149
2013-08-12 14:59:13 +00:00
Dmitri Hrybenko
3d37954e81 Remove SourceManager::decompose() and switch its clients to normal location and
range printing


Swift SVN r7122
2013-08-10 02:19:50 +00:00
Dmitri Hrybenko
09837a1b88 Simplify the implementation of SourceManager::decompose() and its client
Swift SVN r7119
2013-08-10 01:32:42 +00:00
Dmitri Hrybenko
aacef757ed Move decompose from PrettyStackTrace.cpp to the SourceManager
It requires direct access to the SourceLoc internals and is generally useful
anyway.


Swift SVN r7111
2013-08-09 22:50:58 +00:00
John McCall
fcd998a48b PrettyStackTrace enhancements for SIL constructs.
Swift SVN r6966
2013-08-07 00:10:57 +00:00
Dmitri Hrybenko
e1c4ae3174 Wrap llvm::SourceMgr in swift::SourceManager so that we can add new members
to the source manager.


Swift SVN r6815
2013-08-01 20:39:22 +00:00
John McCall
77b62557a6 Add a pretty stack trace entry for a type (and a newline to
the generic source-location printer).

Swift SVN r4922
2013-04-26 18:48:36 +00:00
Eli Friedman
ae86d64644 Rename Decl::getLocStart() to Decl::getStartLoc(). Add Decl::getLoc(), which is essentially the location which should be used for diagnostics.
Swift SVN r2105
2012-05-31 23:56:30 +00:00
Eli Friedman
bfe3f8446d Fix PrettyStackTraceDecl so it doesn't crash for a NamedDecl without a name.
Swift SVN r1785
2012-05-09 02:09:21 +00:00
Chris Lattner
774a557e5c Merge NamedDecl into ValueDecl, rdar://11379147.
Swift SVN r1737
2012-05-04 04:50:53 +00:00