Commit Graph

21693 Commits

Author SHA1 Message Date
Becca Royal-Gordon
73377fe6b4 [NFC-ish] Fix some crashes from early Decl::dump()
Changes dump output used in one test; otherwise NFC.
2024-12-19 15:47:07 -08:00
Becca Royal-Gordon
9b947f90d4 [NFC] Improve lookup flag printing facilities 2024-12-19 15:47:07 -08:00
Becca Royal-Gordon
9f0130b6b6 [NFC] Dump an ASTScopeImpl’s parent nodes 2024-12-19 15:47:07 -08:00
Allan Shortlidge
965ee8fc63 Merge pull request #78284 from tshortli/semantic-available-attr
AST: Introduce `SemanticAvailableAttr`
2024-12-19 13:05:01 -08:00
Slava Pestov
bb55d9c59a Sema: Remove -experimental-one-way-closure-params 2024-12-19 13:14:11 -05:00
Paul LeMarquand
ae88aaca8f Merge pull request #78280 from swiftlang/revert-77140-swift-lexical-lookup-validation
Revert "[SwiftLexicalLookup] New unqualified lookup implementation validation"
2024-12-19 12:40:31 -05:00
Andrew Trick
c347b66997 Merge pull request #78283 from atrick/remove-trivial-feature
Remove the experimental LifetimeDependenceDiagnoseTrivial feature.
2024-12-19 08:54:32 -08:00
Allan Shortlidge
111661e1d2 AST: Move several queries to SemanticAvailableAttr. 2024-12-19 08:40:01 -08:00
Allan Shortlidge
17dfbf5053 AST: Adopt SemanticAvailableAttr for SpecializeAttr. 2024-12-19 08:40:00 -08:00
Allan Shortlidge
f42ca1e758 AST: Introduce Decl::getSemanticAvailableAttr().
This convenience returns an optional `SemanticAvailableAttr` (since in the
future, lookup of the `AvailabilityDomain` can fail). It replaces
`Decl::getDomainForAvailableAttr()`, since most callers will need to form a
`SemanticAvailableAttr` with the resulting domain anyways.
2024-12-19 08:40:00 -08:00
Allan Shortlidge
6ce7e3cc8a AST: Adopt SemanticAvailableAttr in attribute printing. 2024-12-19 08:40:00 -08:00
Allan Shortlidge
88345f9eeb AST: Remove the unused SuppressNoAsyncAvailabilityAttr print option. 2024-12-19 08:40:00 -08:00
Allan Shortlidge
0288eaa3b7 AST: Introduce Decl::getSemanticAvailableAttrs().
This new attribute iterator returned from the query makes it simpler to
implement algorithms that need access to both the `AvailableAttr *` and its
corresponding `AvailabilityDomain`. This is also work towards making it
possible to return an optional `AvailabilityDomain` from
`Decl::getDomainForAvailableAttr()`.
2024-12-19 08:40:00 -08:00
Andrew Trick
5581ab876b Remove the experimental LifetimeDependenceDiagnoseTrivial feature.
This was never used to generate a .swiftinterface, so can be safely removed. It
was used to guard compiler fixes that might break older .swiftinterface
files. Now, we guard the same fixes by checking the source file type.
2024-12-18 17:11:32 -08:00
Ben Barham
e06d0b9357 Revert "[SwiftLexicalLookup] New unqualified lookup implementation validation" 2024-12-18 15:04:16 -08:00
Augusto Noronha
dccc52d07e Merge pull request #78104 from augusto2112/orig-defined-in
[DebugInfo] Fix handling of @_originallyDefinedIn types
2024-12-18 13:38:55 -08:00
Jakub Florek
5dbe202087 Merge pull request #77140 from MAJKFL/swift-lexical-lookup-validation
[SwiftLexicalLookup] New unqualified lookup implementation validation
2024-12-18 17:29:47 +01:00
Pavel Yaskevich
636525ebd9 Merge pull request #78171 from xedin/rdar-140300022
[TypeChecker/SILGen] Allow `any Sendable` to match `Any` while matching generic arguments
2024-12-17 20:24:34 -08:00
Andrew Trick
643cbd15e6 Merge pull request #78228 from atrick/lifedep-scopes-trivial
LifetimeDependence: redesign dependence scope handling
2024-12-16 22:56:22 -08:00
Doug Gregor
df3f45a113 Merge pull request #78198 from DougGregor/unsafe-fixes
Collected fixes for `@unsafe` and the Fix-Its it emits
2024-12-16 16:20:36 -08:00
Andrew Trick
c71e53d363 Add LifetimeDependenceDiagnoseTrivial feature.
A feature flag is needed so that newer compilers can build older standard
library interfaces.
2024-12-16 16:09:37 -08:00
Augusto Noronha
72b0120b43 [DebugInfo] Fix handling of @_originallyDefinedIn types
Emit an imported declaration for @_originallyDefinedIn under the
real module that these types live in.

This patch also changes the mangling for the debugger to respect
@_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn
that should be ignored was still being used when mangling.

rdar://137146961
2024-12-16 10:28:18 -08:00
Andrew Trick
1d1b260c8f Merge pull request #78199 from atrick/lifedep-cleanup
LifetimeDependence: minor diagnostic quality fixes and related utilities
2024-12-15 04:45:08 -08:00
Andrew Trick
89ea8f6efa [NFC] Fix @lifetime SIL parsing: handle AST output
Disable inference diagnostics because the AST output makes implicit initializers
explicit.

Enable parsing the @lifetime declaration syntax to handle explicit annotations
on declarations.
2024-12-14 22:46:54 -08:00
Doug Gregor
f49c594f7a Fix attribute insertion location in the presence of "static" and a modifier
We were incorrectly ignoring the "static" because it's not in the
DeclAttributes list.
2024-12-14 21:47:43 -08:00
Doug Gregor
f9b904f672 Implement printing of @safe(unchecked) attribute 2024-12-14 21:47:42 -08:00
Doug Gregor
268de018f4 When determining the start of a declaration, ignore attributes that aren't at the start
Otherwise, we get bad attribute/modifier insertion locations for 'rethrows' functions
2024-12-14 21:47:40 -08:00
Doug Gregor
b2ae07d089 Merge pull request #78177 from DougGregor/safe-unchecked-attr 2024-12-13 20:32:41 -08:00
Pavel Yaskevich
0de9e9cd1d [CSSimplify] Extend any Sendable -> Any conversion support to function argument/result positions in generic argument context 2024-12-13 17:27:06 -08:00
Doug Gregor
d169187d75 Stop rebuilding the world whenever a diagnostic changes
The inclusion of the full diagnostic list (via DiagnosticList.h) in
DiagnosticGroups.h meant that touching any diagnostic caused most of
the world to rebuild, making me sad. Use forward declarations to limit
how much needs to be rebuilt when changing diagnostics.
2024-12-13 16:08:13 -08:00
Doug Gregor
f33077a363 Ensure that @safe(unchecked) only applies to bodies (not declarations) 2024-12-13 13:31:21 -08:00
Doug Gregor
e260d65f71 Add @safe(unchecked) to allow unsafe code within a declaration.
Introduce an attribute to allow unsafe code within the annotated
declaration without presenting an unsafe interface to users. This is,
by its nature, and unsafe construct, and is used to document where
unsafe behavior is encapsulated in safe constructs.

There is an optional message that can be used as part of an audit
trail.
2024-12-13 11:36:40 -08:00
Doug Gregor
cb05f22b36 Merge pull request #78157 from DougGregor/unsafe-suppressed-unsafe-diags
Suppress strict safety diagnostics in `@unsafe` declarations
2024-12-13 03:16:30 -08:00
Doug Gregor
cf7fcf2da9 Fix test and improve dumper 2024-12-12 23:03:45 -08:00
Doug Gregor
268d5ccbde Suppress strict safety diagnostics in @unsafe declarations
When a declaration is `@unsafe`, don't emit strict safety diagnostics
for uses of unsafe entities, constructs, or types within it. This
allows one to account for all unsafe behavior in a module using strict
memory safety by marking the appropriate declarations `@unsafe`.

Enhance the strict-safety diagnostics to suggest the addition of
`@unsafe` where it is needed to suppress them, with a Fix-It. Ensure
that all such diagnostics can be suppressed via `@unsafe` so it's
possible to get to the above state.

Also includes a drive-by bug fix where we weren't diagnosing unsafe
methods overriding safe ones in some cases.

Fixes rdar://139467327.
2024-12-12 21:22:41 -08:00
Rintaro Ishizaki
da5caa5a22 Merge pull request #78127 from rintaro/astgen-interfacehash
[ASTGen] Syntax-tree based interface hash
2024-12-12 16:41:12 -08:00
Rintaro Ishizaki
71ca3e129a [ASTGen] Use syntax tree based interface hash 2024-12-12 09:51:09 -08:00
Henrik G. Olsson
ec8ea94fb9 Infer @PointerBounds macro from clang __counted_by parameters (#77387)
This results in an automatic wrapper function with safe pointer types
when the imported function has bounds attributes. This exercises similar
pathways as the recently added functionality for specifying macros from
swift_attr. The new functionality is guarded by the experimental
language feature SafeInteropWrappers.

rdar://97942270
2024-12-11 13:36:56 -08:00
Pavel Yaskevich
1a5f00b205 [AST] Add a new implicit conversion to model unsafe casts
`UnsafeCastExpr` - A special kind of conversion that performs an unsafe
bitcast from one type to the other.

Note that this is an unsafe operation and type-checker is allowed to
use this only in a limited number of cases like: `any Sendable` -> `Any`
conversions in some positions, covariant conversions of function and
function result types.
2024-12-11 11:40:28 -08:00
Slava Pestov
ed5e22ddab AST: Make -Xllvm -swift-diagnostics-assert-on-error and -Xllvm -swift-diagnostics-assert-on-warning work in noassert builds 2024-12-10 17:36:30 -05:00
Anthony Latsis
18669a0fcc Merge pull request #78044 from AnthonyLatsis/nelumbo-nucifera
ASTDumper: Do not escape Unicode chars in quoted fields
2024-12-10 19:12:47 +00:00
Saleem Abdulrasool
2e337aeca3 Merge pull request #78036 from compnerd/well-known
lib: use `CXX_MODULE_NAME` constant for module identifier (NFC)
2024-12-10 09:27:31 -08:00
Egor Zhdan
282f3b127b [cxx-interop] Support CxxStdlib overlay for libc++ on Linux
This teaches Swift to rebuild the CxxStdlib overlay module from its interface when using a C++ standard library that is not the platform default, specifically libc++ on Linux.

rdar://138838506
2024-12-10 14:19:59 +00:00
Anthony Latsis
1001c46e4c ASTDumper: Do not escape Unicode chars in quoted fields
Context: https://github.com/swiftlang/swift/pull/68438#discussion_r1449272860
2024-12-10 12:51:19 +00:00
Hamish Knight
0af151feb4 Merge pull request #78071 from hamishknight/thats-canon-now
[SourceKit] Use canonical type in `printTypeUSR`
2024-12-10 07:50:58 +00:00
Artem Chikin
f4accedf9a Merge pull request #77794 from artemcm/RefactorGlobalDependencyScanningCache
[Dependency Scanner] Refactor the global scanning service to no longer maintain scanner cache state
2024-12-09 14:50:04 -08:00
Hamish Knight
30a8f1988a [SourceKit] Use canonical type in printTypeUSR
Mangling a non-canonical type can run into
unexpected type sugar such as the newly introduced
LocatableType. USRs should be based on canonical
types anyway, so make sure we canonicalize before
mangling.

rdar://141168628
2024-12-09 22:04:10 +00:00
Alexis Laferrière
3d9dc81f5b Merge pull request #78005 from xymus/access-level-import-reexports
Sema: Prioritize @_exported imports over local non-public imports
2024-12-09 13:35:44 -08:00
Saleem Abdulrasool
8473d40f50 lib: use CXX_MODULE_NAME constant for module identifier (NFC)
Use the well known specifier for explicit references to the `Cxx` module
rather than re-spelling the name at the various sites.
2024-12-09 13:34:06 -08:00
Joe Groff
8436db3b9d Merge pull request #78021 from jckarter/addressable-params-2
Add an `@_addressableSelf` attribute to mark the self param of methods as addressable.
2024-12-09 08:42:49 -08:00