Commit Graph

351 Commits

Author SHA1 Message Date
Pavel Yaskevich
6526dca9db [Concurrency] Add ApproachableConcurrency as a pseudo upcoming feature flag
Enables upcoming features that aim to provide a more approachable path to Swift Concurrency:
 - `DisableOutwardActorInference`
 - `GlobalActorIsolatedTypesUsability`
 - `InferIsolatedConformances`
 - `InferSendableFromCaptures`
 - `NonisolatedNonsendingByDefault`

Resolves: rdar://166244164
2025-12-11 10:36:03 -08:00
Ryan Mansfield
4cc2940619 Add frontend option -verbose-asm to emit verbose assembly.
This enables the option by default to aid readability with
-emit-assembly.
2025-10-08 16:01:13 -04:00
Henrik G. Olsson
d3214de950 Merge pull request #84685 from hnrklssn/verify-all
This adds the -verify-ignore-unrelated flag. When -verify is used without -verify-ignore-unrelated, diagnostics emitted in buffers other than the main file and those passed with -verify-additional-file (except diagnostics emitted at <unknown>:0) will now result in an error. They were previously ignored. The old behaviour is still available as opt-in using -verify-ignore-unrelated, but by being strict by default it should make it harder to accidentally miss diagnostics.

To avoid unnecessary performance overhead, -verify-additional-file is still required to parse the expected-* directives in files other than the main file.
2025-10-06 18:01:47 -07:00
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Hamish Knight
669a2ce9b0 [CS] Sink placeholder handling logic into Solution::simplifyType
Move the logic from `FailureDiagnostic::resolveType` into
`Solution::simplifyType` to allow completion to use it too. While
here, also handle cases where the placeholder is from a different
member of the equivalence class to the generic parameter.
2025-10-04 12:56:52 +01:00
Erik Eckstein
afdce751cf tests: small improvement for Misc/verify-swift-feature-testing.test-sh
The `git grep` command fails if the repository has a branch named `test`.
Inserting a `--` in the git command line makes it clear that `test` is the directory and not the branch
2025-08-29 11:03:01 +02:00
Gabor Horvath
4b64abdc45 [cxx-interop] Configure requires ObjC from frontend option
We sometimes don't have the information in the modulemaps whether a
module requires ObjC or not. This info is useful for reverse interop.
This PR introduces a frontend flag to have a comma separated list of
modules that we should import as if they had "requires ObjC" in their
modulemaps.
2025-07-17 21:29:50 +01:00
Slava Pestov
84d1d115e1 Sema: Change -solver-memory-threshold into a frontend flag for consistency with the others 2025-06-25 22:07:23 -04:00
Allan Shortlidge
897a74f495 Tests: Move some availability tests into a new test/Availability directory.
Un-reverts 9c01ee2c1b.

Also, add myself as a reviewer for more availability related files.

NFC.
2025-06-23 15:57:34 -07:00
Allan Shortlidge
de1017fef4 Revert "Move some availability tests into a new test/Availability directory"
This reverts commit 9c01ee2c1b.
2025-06-08 22:22:41 -07:00
Slava Pestov
9c01ee2c1b Move some availability tests into a new test/Availability directory 2025-06-06 17:10:42 -04:00
Max Desiatov
454e5ea98f Fix test/Misc/target-cpu.swift (#81137)
It expected `apple-a7`, while the new value is `apple-a4` for `WATCHTARGETCPU2`.

rdar://150074485
2025-04-29 14:11:18 -07:00
Saleem Abdulrasool
116444432b Merge pull request #80815 from compnerd/verify
test: tweak `verify-swift-feature-testing`
2025-04-16 13:41:08 -07:00
Saleem Abdulrasool
a17a704f82 tests: disable the entities profiling
Disable the entities profiling for the stats_dir_profiler as this shaves off ~80% of the test time.
2025-04-15 16:42:45 -07:00
Saleem Abdulrasool
7695bd722d Revert "tests: run Misc/stats_dir_profiler.swift only on macos and linux" 2025-04-15 08:53:58 -07:00
Erik Eckstein
dd4e9a10e1 tests: run Misc/stats_dir_profiler.swift only on macos and linux
It's good enough to run the test on macOS and linux.
The test takes very long on Windows because the * may expand to a path longer than 260 characters.
2025-04-15 07:52:04 +02:00
Saleem Abdulrasool
a65912f095 test: tweak verify-swift-feature-testing
Attempt to use `git grep` instead of `grep`. This might help reduce the
cost of this test. Currently, on Windows, this test takes ~350s, placing
it 2nd in the slowest tests on Windows.
2025-04-14 21:37:46 -07:00
Hamish Knight
38b143d694 [test] Avoid relying on stdlib in serialized-diagnostics-prettyprint.swift
Rather than relying on the presence of particular String initializers,
emit a module with a type with an overloaded initializer.
2025-04-12 12:19:59 +01:00
Michael Ilseman
e6e4bd6056 UTF8Span (#78531)
Add support for UTF8Span

Also, refactor validation and grapheme breaking
2025-04-11 16:11:11 -06:00
Anthony Latsis
6a8213c74b test: Speed up test/Misc/verify-swift-feature-testing.test-sh some more
Instead of first invoking `grep` to get a list of files with matches,
and then invoking it again on each file to find lines with matches,
invoke it once on the entire test suite to get a list of paths and lines
with matches, and parse that output into a dictionary that maps file
paths to lists of lines.
This further reduces run time from ~2.5s to ~1s.
2025-03-04 15:55:22 +00:00
Anthony Latsis
203a1e0a11 Merge pull request #79720 from AnthonyLatsis/haliotis-rufescens
[NFC] test: Factor out feature frontend tests into subdirectory
2025-03-04 03:33:31 +00:00
Anthony Latsis
02359f451b test: Improve error messages in Swift feature usage verification script
* Place 'error: ' after file name.
* Be more clear about what's wrong and where.
2025-03-03 22:32:43 +00:00
Anthony Latsis
64dcce31a3 test: Improve regex in Swift feature usage verification script
* Account for variable number of spaces.
* Match strings like '-enable-upcoming-feature\'. We want to complain
  about these because the script cannot get the job done when the option
  and argument are on different lines.
  The capture group will match '' in these cases.
2025-03-03 22:31:41 +00:00
Anthony Latsis
986f1d40e5 test: Speed up Swift feature usage verification script
* The set of files that enable features and the set of files that
  require features are expected to have a very small, if any,
  difference. Don't compute and check each set separately.
* Find RUN and REQUIRES lines in a file in one go.
2025-03-03 22:31:36 +00:00
Anthony Latsis
d18425e3dc [NFC] test: Factor out feature frontend tests into subdirectory 2025-03-01 03:55:09 +00:00
Becca Royal-Gordon
0466d5c0ca Handle diagnostic verifier locations concretely
This commit makes a number of adjustments to how the diagnostic verifier handles source buffers and source locations. Specifically:

• Files named by `-verify-additional-file` are read as late as possible so that if some other component of the compiler has already loaded the file, even in some exotic way (e.g. ClangImporter’s source buffer mirroring), it will use the same buffer.
• Expectation source locations now ignore virtual files and other trickery; they are based on the source buffer and physical location in the file.

Hopefully this will make `-verify-additional-file` work better on Windows. As an unintended side effect, it also changes how expectations work in tests that use `#sourceLocation()`.
2025-02-11 12:05:17 -08:00
Allan Shortlidge
24f5632ca1 Frontend: Implement optional parsing diagnostics for enabled language features.
Parsing for `-enable-upcoming-feature` and `-enable-experimental-feature` is
lenient by default because some projects need to be compatible with multiple
language versions and compiler toolchains simultaneously, and strict
diagnostics would be a nuisance. On the other hand, though, it would be useful
to get feedback from the compiler when you attempt to enable a feature that
doesn't exist. This change splits the difference by introducing new diagnostics
for potential feature enablement misconfigurations but leaves those diagnostics
ignored by default. Projects that wish to use them can specify `-Wwarning
StrictLanguageFeatures`.
2025-01-15 16:34:32 -08:00
Becca Royal-Gordon
01b8bbea89 Tie attributes to language features
The new `DECL_ATTR_FEATURE_REQUIREMENT` macro in DeclAttr.def can be used to declare that an attribute should only be available when a related language feature is enabled.

Effects:

• `#if hasAttribute(someAttr)` will return `false` unless the required feature is enabled.
• Code completion will not include the attribute unless the required feature is enabled.
• `TypeChecker::checkDeclAttributes()` diagnoses non-implicit uses of the attribute.

Add this mechanism and use it to tie @abi to the ABIAttribute feature. Also design tests for it.
2024-12-19 15:49:34 -08:00
Hamish Knight
b6f6a4f026 [test] Disable maccatalyst_load_commands.swift
rdar://136779081
2024-12-16 14:32:16 +00:00
Daniel Rodríguez Troitiño
d2d830fc0e [test] Warning about Swift features that do not exist (#77542)
Sometimes features are removed from `Features.def`, but they are not
removed from the test files. The compiler ignores every feature that
does not exist. This leads to removed features still being tested, and
with the introduction of #76740, `REQUIRED:`.

Modify the code that generates the active feature set for testing to
also generate the set of existing features, and pass this list of
existing features to the verifier script. If a feature is trying to be
activated and does not exist, the verifier will warn the user.

- `SwiftParser` feature was renamed `ParserASTGen`, but some tests were
  using both spellings. Remove the mentions of `SwiftParser` in the
  tests.
- `ImportObjcForwardDeclarations` was spelled with upper case `C` in
  a couple of tests. Fix it so the matching is easier.
- `TransferringArgsAndResults` was an experimental feature that was
  removed.
- Ignore the usage of inexisting feature in `swift-export-as.swift`
  because it seems to be what the test is actually testing.
- Ignore the test `availability_define.swift` because it tests the
  pseudo-feature `AvailabilityMacro=` which is not part of
  `Features.def`.
2024-11-12 08:58:53 -08:00
Daniel Rodríguez Troitiño
e5751afd40 [test] Verify usage of swift_feature_ markers without enabling features
When a feature is removed from `Features.def` or when a test removes all
usages of `-enable-experimental/upcoming-feature` keeping the
`REQUIRES:` lines around is probably a mistake. Warn about possibly
missing flags if a `REQUIRES:` is found referencing a feature without
the equivalent `-enable-*-feature` in a `RUN:` line.
2024-11-04 20:53:06 -08:00
Daniel Rodríguez Troitiño
fff1884d9d [test] Lint test/Misc/verify-swift-feature-testing.test-sh
It is not automatically linted because of its extension.
2024-11-04 17:32:16 -08:00
Daniel Rodríguez Troitiño
2cad3ca547 [test] Add test that verify correct usage of REQUIRES for Swift features
The test will look for other tests using `RUN:` lines that use
experimental or upcoming features and will check that the tests also are
checking with the right `REQUIRES:` lines for the used features. This
should avoid new tests being introduced without the right `REQUIRES` and
should avoid breaking the toolchain in less tested configurations.
2024-11-02 11:46:46 -07:00
Slava Pestov
9cd5b03466 Frontend: Fix crash when -stats-output-dir used with -typecheck-module-from-interface
There's no ASTContext in this case, so we just skip initializing stats if
the driver passes this flag down to us.
2024-10-25 16:25:44 -04:00
Allan Shortlidge
cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00
Doug Gregor
5df96a7a6e Turn pretty-printing of a declaration into a request
The diagnostics engine has some code to pretty-print a declaration when
there is no source location for that declaration. The declaration is
pretty-printed into a source buffer, and a source location into that
buffer is synthesizes. This applies to synthesized declarations as well
as those imported from Swift modules (without source code) or from Clang.

Reimplement this pretty-printing for declarations as a request. In
doing so, change the manner in which we do the printing: the
diagnostics engine printed the entire enclosing type into a buffer
whose name was the module + that type. This meant that the buffer was
shared by every member of that type, but also meant that we would end
up deserializing a lot of declarations just for printing and
potentially doing a lot more work for these diagnostics.
2024-10-01 15:49:15 -07:00
Slava Pestov
bfc4f956fd Merge pull request #76662 from slavapestov/fine-grained-timers-flag
Add -fine-grained-timers flag
2024-09-25 08:26:08 -04:00
Slava Pestov
0814c50e19 Pass -fine-grained-timers in a couple of tests 2024-09-24 17:23:44 -04:00
Hamish Knight
8e0407b8c1 [test] Add SWIFT_USE_OLD_DRIVER=1 to some tests
The behavior of these tests varies depending on
whether the new or old driver is being used, force
the old driver for now.
2024-09-22 23:10:40 +01:00
Allan Shortlidge
2bb8b458e1 Tests: Limit maccatalyst_load_commands.swift to x86_64. 2024-09-03 22:05:20 -07:00
Allan Shortlidge
eb16025f56 Tests: Upstream some miscellaneous macCatalyst tests. 2024-07-23 17:00:10 -07:00
Saleem Abdulrasool
e89bfcf63f ClangImporter: handle -target-cpu for x86 targets
`-mcpu` is a deprecated "alias" (unsupported) on x86 targets for
`-mtune`. Unlike `-mcpu`, `-mtune` simply tunes the code for the CPU but
does not prevent execution on other targets. In order to match the
behaviour of `-mcpu` on ARM, we must use both `-march=` and `-mtune=`.
Adjust this behaviour to allow tuning of code for non-Darwin targets.
2024-04-01 14:31:52 -07:00
Doug Gregor
e3c2162be2 Cope with change to default diagnostic style 2024-02-19 02:48:36 -10:00
Rintaro Ishizaki
024726f1f1 [swift-parse-test] Dont show throughput if it the elasped time is zero
Fix division by zero.

rdar://117750086
2023-11-03 09:47:29 -07:00
Meghana Gupta
ab3a651576 Disable Misc/parse_test.swift 2023-11-01 13:13:55 -07:00
Rintaro Ishizaki
66b8946eb4 [swift-parse-test] Add -skip-bodies option
This is no-op for SwiftParser. Also add a sanity check test file.
2023-10-30 13:18:04 -07:00
Allan Shortlidge
50fdfbf7b4 Sema: Support multiple -debug-forbid-typecheck-prefix arguments.
An existing test (Frontend/skip-function-bodies.swift) was designed under the
assumption that multiple `-debug-forbid-typecheck-prefix` arguments were
already supported, and as a result the test was not actually asserting what it
was written to assert.
2023-09-25 16:43:11 -07:00
Hamish Knight
68075696eb [CS] A couple of minor improvements to operator diagnostics
- Simplify the fix locator when looking for a
fix already present in a pattern match, this
avoids us emitting both a diagnostic for the
argument conversion, and for a conformance failure.
- Include tuples in the diagnostic logic where
we emit a generic "operator cannot be applied"
diagnostic, as a conformance diagnostic is
unlikely to be helpful in that case.
2023-05-04 14:53:57 +01:00
Alex Hoppen
cebc084367 [CS] Fix locator simplification with 'Member' path element
Previously, a `Member` path element in a `ConstraintLocator` was simplified to the base on which the member was accessed. This is incorrect.
2023-03-20 09:19:21 -07:00
Luciano Almeida
22a18de1b1 [Sema] Improving integer literal as boolean diagnostic 2023-02-21 10:30:48 -03:00