Commit Graph

1745 Commits

Author SHA1 Message Date
swift-ci
f0e69349aa Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 18:13:50 -07:00
Konrad `ktoso` Malawski
54229549b3 [Distributed] Offer fixit for import Distributed when it is required (#72948) 2024-04-12 18:05:32 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Ben Barham
2fc51affb2 [Basic] Handle added/removed triples
Ananas/CloudABI/Contiki/Minix have all been removed from LLVM (in
various commits).

Also adds minimal (ie. necessary for compiling) support for the new
triples.
2024-04-08 08:58:58 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Yuta Saito
7441e039d0 wasm: Add "_multithreaded" as valid _runtime argument
This patch adds "_multithreaded" as a valid `_runtime` argument and
sets it when the target is `wasm32-unknown-wasi-threads` or other
non-none OS targets.
2024-03-29 06:30:18 +00:00
Doug Gregor
922e3daaea Remove build infrastructure for globally enabling noncopyable types
Now that the compilation model of noncopyable types is enabled everywhere,
and one can enable the feature for specific modules, we no longer need a
separate build-script/CMake option to enable it globally. Remove it all.
2024-03-19 13:35:31 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Max Desiatov
321cc8387a Embedded: enable *-unknown-windows-coff tripels in Platform.cpp (#72217)
This allows the frontend to proceed when building with `-target i686-unknown-windows-coff -enable-experimental-feature Embedded` arguments.
2024-03-11 09:26:39 -07:00
Slava Pestov
af8c8f1671 Sema: Remove non-experimental associated type inference 2024-03-07 17:30:17 -05:00
John McCall
1437acdf22 Implement conditional feature suppression.
Our standard conception of suppressible features assumes we should
always suppress the feature if the compiler doesn't support it.
This presumes that there's no harm in suppressing the feature, and
that's a fine assumption for features that are just adding information
or suppressing new diagnostics.  Features that are semantically
relevant, maybe even ABI-breaking, are not a good fit for this,
and so instead of reprinting the decl with the feature suppressed,
we just have to hide the decl entirely.  The missing middle here
is that it's sometimes useful to be able to adopt a type change
to an existing declaration, and we'd like older compilers to be
able to use the older version of the declaration.  Making a type
change this way is, of course, only really acceptable for
@_alwaysEmitIntoClient declarations; but those represent quite a
few declarations that we'd like to be able to refine the types of.

Rather than trying to come up with heuristics based on
@_alwaysEmitIntoClient or other sources of information, this design
just requires the declaration to opt in with a new attribute,
@_allowFeatureSuppress.  When a declaration opts in to suppression
for a conditionally-suppressible feature, the printer uses the
suppression serially-print-with-downgraded-options approach;
otherwise it uses the print-only-if-feature-is-available approach.
2024-03-01 22:10:14 -05:00
Alexis Laferrière
1e4fe67f40 Serialization: restrict swiftmodules to distribution channels
There are scenarios where different compilers are distributed with
compatible serialization format versions and the same tag. Distinguish
swiftmodules in such a case by assigning them to different distribution
channels. A compiler expecting a specific channel will only read
swiftmodules from the same channel. The channels should be defined by
downstream code as it is by definition vendor specific.

For development, a no-channel compiler loads or defining the env var
SWIFT_IGNORE_SWIFTMODULE_REVISION skips this new check.

rdar://123731777
2024-03-01 10:52:44 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Mishal Shah
cb96ec2893 Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-22 09:44:44 -08:00
Ben Barham
5637284e48 Merge pull request #71368 from bnbarham/std-optional-all-the-things
Migrate llvm::Optional to std::optional
2024-02-21 16:54:00 -08:00
nate-chandler
b719a6aac1 Merge pull request #71783 from nate-chandler/nfc/20240221/1
[NFC] Removed non-verifier uses of MemoryLocations.
2024-02-21 12:44:10 -08:00
Mishal Shah
b8cd763b21 Merge branch 'main' into bump-swift-version-to-6 2024-02-21 12:40:54 -08:00
Mishal Shah
9a1d86c5bb Set the minor version to 10 (5.10) for language version 2024-02-21 12:37:23 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Alex Hoppen
a49994d72f [Driver] Don’t crash if the output file map is incomplete
When using VS Code, it semi-frequently happens that sourcekitd is reading the output file map and the memory buffer containing the memory buffer containing the output file map is not complete and terminates at distinct powers of 2. I managed to attach a debugger once and the memory buffer containing the output file had size 0x3000 = 12288 while the actual output file map is 20319 bytes large. One hypothesis for this is that the read of output file map is racing with a write from a SwiftPM build but I haven’t been able to confirm it.

In either case, the result is that the output file map buffer ends with an unterminated string literal, which causes `getKey()` or `getValue()` in the JSON parser to return `nullptr` and then consequently hits an assertion failure in `dyn_cast`. Add a check for nullptr before invoking `dyn_cast` just like we do it in the outer `for` loop.

rdar://122364031
2024-02-21 07:09:23 -08:00
Mishal Shah
96d61d3c5c Merge remote-tracking branch 'origin/main' into bump-swift-version-to-6 2024-02-20 14:31:55 -08:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Nate Chandler
600164257a [NFC] Moved SmallBitVector dumping to Basic.
Moved out of MemoryLocations.h and merged the implementations of <<,
keeping the version from MemoryLocations with its brackets and commas
available via a flag but defaulting the implementation previously in the
header.
2024-02-19 11:41:38 -08:00
Artem Chikin
3c8073e093 Merge pull request #71691 from artemcm/DepScanSmartVFSOpt
[Dependency Scanning] Only omit Clang VFS overlays from Swift dependencies if unused by their Clang dependencies
2024-02-16 18:27:32 -08:00
Artem Chikin
500d2e5840 [Dependency Scanning] Only omit Clang VFS overlays from Swift dependencies if unused by Clang dependencies
We previously blanket omitted `-Xcc -vfsoverlay` flags from Swift module dependencies' command-line recipes. This is incorrect as the Swift module must have an exact matching VFS overlay that its Clang dependencies use, in order to load said Clang dependnecies successfully and resolve their headers as expected and as was done during the scan.

Resolves rdar://122667530
2024-02-16 15:36:46 -08:00
Doug Gregor
81ffafdc6a Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument
[Macros] Expression macro as caller-side default argument
2024-02-14 16:10:11 -08:00
Holly Borla
bf8f9acfbb Merge pull request #71581 from hborla/swift-6-noasserts 2024-02-13 15:13:26 -08:00
Steven Wu
9607e9dec1 Merge pull request #71497 from cachemeifyoucan/eng/PR-122423965
[Caching] Use subInvocation to verify interface
2024-02-13 09:18:40 -08:00
Holly Borla
ad63302e41 [Concurrency] Make Swift 6 available in noasserts compilers. 2024-02-13 07:05:36 -08:00
Steven Wu
3986937e03 [Caching][NFC] Restructure CASOption in swift. NFC
Clean up how CASOptions are kept and passed inside swift to make the
code more readable. Also avoid a copy of CAS configuration in
ClangImporter.
2024-02-11 14:08:09 -08:00
Kavon Farvardin
6ca57e332c Merge pull request #71488 from kavon/ncgenerics-test-fixes-kavon-v5
Ncgenerics test fixes kavon v5
2024-02-08 22:32:54 -08:00
Cyndy Ishida
9e2b97c0fd Add xrOS to silence -Wswitch violations (#71432)
To commit the necessary llvm-project changes to land xrOS support,  xrOS as a triple must be understood to swift. Add minimal support such that CI passes.
2024-02-07 21:19:40 -08:00
Kavon Farvardin
a396fcc43a LangOptions: tie NoncopyableGenerics to build
There were a handful of different places trying to enable the
feature-flag when the stdlib has been built with the feature enabled.
This change cleans that up and unifies it in one spot for all sub-tools
like sil-opt and sil-func-extractor to pick-up.
2024-02-07 15:48:31 -08:00
Apollo Zhu
b09a22a9a0 Somewhat working
Test shadowed variable of same type

Fully type check caller side macro expansion

Skip macro default arg caller side expr at decl primary

Test macro expand more complex expressions

Set synthesized expression as implicit

Add test case for with argument, not compiling currently

Test with swiftinterface

Always use the string representation of the default argument

Now works across module boundary

Check works for multiple files

Make default argument expression work in single file

Use expected-error

Disallow expression macro as default argument

Using as a sub expression in default argument still allowed as expression macros behave the same as built-in magic literals
2024-02-06 15:02:11 -08:00
Alastair Houghton
4c7822cdac Merge pull request #71213 from al45tair/eng/PR-121522431
[Frontend][AST][IRGen] Improve availability support.
2024-02-02 22:30:19 +00:00
Alastair Houghton
c226bf3c3c [AST][IRGen] Add -min-runtime-version option and IRGen support code.
Add a `-min-runtime-version` option that can be used to avoid problems
when building on Linux and Windows where because the runtime isn't
part of the OS, availability doesn't solve the problem of trying to
build the compiler against an older runtime.

Also add functions to IRGen to make it easy to test feature
availability using both the runtime version and the existing Darwin
availability support.

rdar://121522431
2024-02-02 16:17:08 +00:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Hamish Knight
246f09a1e1 [AST] Improve FailStmt source location computation
Avoid forming invalid source ranges when
`ReturnLoc` is invalid. Also introduce a utility
to make this kind of range computation easier,
and use it in a couple of other cases.
2024-01-23 19:30:32 +00:00
Steven Wu
5c8e340755 Merge pull request #70739 from cachemeifyoucan/eng/PR-120552768
Fix build failure for verify module interface during cache build
2024-01-18 14:20:03 -08:00
Steven Wu
7150e54003 [Caching] Identify input type from filename correctly
When loading input from CAS, `swift-frontend` relies on the input file
name to determine the type to look from CAS entry. In the case where
file extension is `.private.swiftinterface`, swift mis-identify that as
`.swiftinterface` file and look up the wrong input file. Add a new
file type lookup function that can figure out the type from the full
filename.

Also add few diagnostics during the CAS lookup for the input file to
error out immediately, rather than rely on the lookup failure later.
2024-01-05 13:48:32 -08:00
Ben Barham
d51c58a6f9 [Basic] hasFeature should succeed for promoted language features
Merge `$<Feature>` and `hasFeature` implementations.
  - `$<Feature>` did not support upcoming language features.
  - `hasFeature` did not support promoted language features and also
    didn't take into account `Options` in `Features.def`.

Remove `Options` entirely, it was always one of three cases:
  - `true`
  - `langOpts.hasFeature`
  - `hasSwiftSwiftParser`

Since `LangOptions::hasFeature` should always be used anyway, it's no
longer necessary. `hasSwiftSwiftParser` can be special cased when adding
the default promoted language features (by removing those features).

Resolves rdar://117917456.
2024-01-05 10:26:13 -08:00
Holly Borla
8c9eeb2edd [ASTScope] In the isBeforeInSource predicate, use the end location of the
original source location of a macro expansion when walking up the ancestor
list.

The original source range of a macro expansion buffer contains the entire
range of the code that is replaced by the expansion. In some cases, the
original code is type checked, so ASTScope needs to represent both the
original code and the macro-expanded code in the scope tree.

For accessor macros, the original code -- the initializer expression of
the property -- is type checked, but not before macro expansion, so
unqualified lookup must deal with the scope tree for the initializer and
the expanded accessors. The accessors are inserted in the tree after the
initializer scope, but the `isBeforeInSource` was using the start location
of the original source range for macro expansions, so the accessor scopes
were incorrectly considered to be ordered before a source location in the
initializer expression, which caused unqualified lookup of local variables
within the initializer to fail.
2023-12-20 15:53:02 -08:00
Artem Chikin
f5e2b24912 [Dependency Scanning] Filter out '-Xcc' search paths from Swift module compilation commands
These search paths will not get used during Swift module compilation and can only hinder module sharing among different targets.

Resolves rdar://119217774
2023-12-08 10:38:44 -08:00
Meghana Gupta
f6afc00541 Add a new flag to disable round trip through the new Swift parser 2023-12-06 16:38:40 -08:00
Doug Gregor
2bb035e1d3 Merge pull request #70126 from DougGregor/source-loc-ordering-with-macros
Implement ordering of source locations that accounts for macro expansion
2023-11-30 18:39:18 -08:00
Doug Gregor
79e31a87b3 Re-implement ASTScope's child-insertion assertions
ASTScope assertions that a new child node inserted into its parent list
is after all other child nodes in the source, which included some bespoke
code for dealing with macro expansions. Replace this bespoke code with
uses of the newer SourceManager operations that check ordering of
source locations in a manner that respects macro expansions.
2023-11-30 10:54:42 -08:00
Doug Gregor
37ed49e0bd Implement ordering of source locations that accounts for macro expansion
SourceManager's `isBeforeInBuffer` in buffer takes two source locations
that are assumed to be within the same source buffer and determines
whether the first precedes the second. However, due to macro
expansion, there can be source locations in different source buffers
that are nonetheless conceptually part of the same source file. For
such cases, `isBeforeInBuffer` will silently produce wrong results.

Extend `SourceManager` with a new `isBefore` operation that determines
whether one source location precedes another in the same conceptual
source file, even if they are in different source buffers that (e.g.)
represent macro expansions within that source file. Also introduce
`isAtOrBefore` to cover the case where the source locations might be
equivalent, which was previously handled via a separate equality check
on the source locations that won't work with macro expansions.

Add caching for the list of accessors of a buffer, so we aren't doing
a full walk up the source-buffer chain ever time we do a comparison of
source locations. LCA is still linear-time, but this eliminates
extraneous hash table lookups along the way.

Over time, we should both move more clients over to these new variants
and introduce more assertions into the old (in-buffer) versions to
catch improper uses of them.
2023-11-30 09:55:56 -08:00
Alex Hoppen
14bc8148fe Don’t include vector in `BasicBridging.h 2023-11-28 14:03:31 -08:00
Alex Hoppen
b31398215d Don’t include SourceLoc.h when USED_IN_CPP_SOURCE is not set 2023-11-27 19:34:27 -08:00
Alex Hoppen
8fd025625b [SourceKit] Use NameMatcher that is rewritten in Swift for syntactic rename 2023-11-17 09:30:04 -08:00