Commit Graph

478 Commits

Author SHA1 Message Date
Hamish Knight
37ac51099d [Sema] Don't parse skipped bodies when computing discriminators
The refactoring in #68760 accidentally caused us to
start parsing skipped function bodies if they have
parameters, as the local discriminator request kicks
parsing through `getBody()`. Cherry-pick part of
47ff9568db749def08007b64a5425789cb514ac3 which was
never landed, ensuring we don't call `getBody` for
a skipped function body.

This is meant to be a minimal low-risk change that
fixes the issue in question, restoring the behavior
we had in 5.10. Fixing the parser skipping
behavior for `#sourceLocation` will be done in
a follow-up. We also ought to see if there's a
better way we can enforce that skipped function
bodies don't end up getting parsed, for now I've
added a test.

rdar://131726797
2024-07-23 21:11:25 +01:00
Hamish Knight
82cc2403d9 [ASTDumper] Respect function body skipping
Avoid parsing a body for e.g
`-experimental-skip-all-function-bodies`.
2024-06-19 15:22:20 +01:00
Artem Chikin
8a18179b29 [Parseable Output] Make Emit-Module tasks indicate their name accordingly, instead of 'compile' 2024-06-13 12:09:59 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Steven Wu
0e12f2042e [ScanDependency] Move binary module validation into scanner
Improve swift dependency scanner by validating and selecting dependency
module into scanner. This provides benefits that:
* Build system does not need to schedule interface compilation task if
  the candidate module is picked, it can just use the candidate module
  directly.
* There is no need for forwarding module in the explicit module build.
  Since the build system is coordinating the build, there is no need for
  the forwarding module in the module cache to avoid duplicated work,
* This also correctly supports all the module loading modes in the
  dependency scanner.

This is achieved by only adding validate and up-to-date binary module as
the candidate module for swift interface module dependency. This allows
caching build to construct the correct dependency in the CAS. If there
is a candidate module for the interface module, dependency scanner will
return a binary module dependency in the dependency graph.

The legacy behavior is mostly preserved with a hidden frontend flag
`-no-scanner-module-validation`, while the scanner output is mostly
interchangeable with new scanner behavior with `prefer-interface` module
loading mode except the candidate module will not be returned.

rdar://123711823
2024-04-05 07:52:14 -07:00
Alexis Laferrière
8714b6592e Tests: Use a Swift version where actors are available for skip-function-bodies 2024-04-01 15:23:33 -07:00
Alexis Laferrière
1e4b75d5b5 Parser: Don't skip nested protocols for LLDB 2024-03-29 16:36:09 -07:00
Alexis Laferrière
6e0334240c Parser: Don't skip functions with a nested typealias or actor for LLDB
The flag -experimental-skip-non-inlinable-function-bodies-without-types
is built in the emit-module-separately phase to quickly extract the API
of the target module. It is designed to not skip functions with nested
types as these are used by LLDB.

This logic relies on a simple heuristic to find nested type. Let's make
sure it detects tyealiases and actors.

rdar://120928396
2024-03-29 16:11:41 -07:00
Allan Shortlidge
12fccfc4e0 Frontend: Really allow any experimental feature when compiling a module interface.
The fix for https://github.com/apple/swift/pull/72632 was not sufficient
because when modules are built from textual interface that happens in a
sub-invocation which does not have typecheck-from-interface or
compile-from-interface requested action. Instead of checking a requested
action, set a language option to control whether non-production experimental
features are allowed.

Resolves rdar://125561443
2024-03-28 14:48:15 -07:00
Kavon Farvardin
8f97b7f1bf Test: update for NoncopyableGenerics 2024-03-14 23:10:44 -07:00
Sophia Poirier
5ce7be7e75 [Concurrency] explicit nonisolated specification for closures 2024-03-14 12:24:13 -07:00
Anthony Latsis
5b7a8b6705 [NFC] AST: Rename MemberTypeReprQualifiedIdentTypeRepr 2024-03-02 14:59:37 +03:00
Anthony Latsis
68746a0579 [NFC] AST: Rename IdentTypeReprUnqualifiedIdentTypeRepr 2024-03-02 08:28:47 +03:00
Doug Gregor
0c9c734f7e Merge pull request #71722 from DougGregor/diagnostic-style-swift-default 2024-02-24 14:42:38 -10:00
Doug Gregor
d9faff1dd6 Add comments to testcases that need spurious whitespace 2024-02-24 08:33:28 -10:00
Mishal Shah
6c306e3d43 Update the SwiftStdlib version to 6.0 and fix Frontend/crash.swift test 2024-02-21 15:20:24 -08:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Doug Gregor
8cd2f34654 Generalize tests for both diagnostic styles, or force the LLVM style
These tests are using FileCheck to check the result of diagnostic
formatting in ways that don't match the new formatter. Force the old
formatter or, where possible, generalize so that they match both
formatters.
2024-02-19 02:48:37 -10:00
Slava Pestov
1c24b880ec Merge pull request #70467 from AnthonyLatsis/recursive-member-typerepr
AST: Remodel `MemberTypeRepr` to be recursive
2024-02-16 11:36:31 -05:00
Holly Borla
f1cd9cb422 [Test] Remove REQUIRES: asserts from tests that use -swift-version 6. 2024-02-13 07:13:35 -08:00
Anthony Latsis
d9777a06b6 [NFC] AST/ASTDumper: Refactor for recursive MemberTypeRepr representation 2024-02-09 17:22:56 +03:00
Slava Pestov
23b1690f6b ASTPrinter: Refactor printing of RequirementSignatures 2024-01-31 21:55:52 -05:00
Nate Chandler
b266abe5c0 [BitwiseCopyable] Add a marker protocol.
Behind the experimental feature BitwiseCopyable.
2023-11-30 15:25:46 -08:00
Allan Shortlidge
84098f9fb1 Sema: Always mark initializers of lazy vars as subsumed.
Previously, the initializer expressions of lazy vars would only be marked as
subsumed when the getter body for the var was synthesized. This didn't work
with `-experimental-lazy-typechecking` since accessor synthesis was not
guaranteed to happen. Consequently, SILGen would emit the initializer even
though it was already subsumed and then assert/crash since the init had also
not been checked and contextualized. Now lazy var inits are marked subsumed in
the request creating storage.

Resolves rdar://118421753
2023-11-16 18:01:54 -08:00
Slava Pestov
fa3eeddf6e ASTDumper: Make the SubstitutionMap dump easier to read
Don't quote generic parameter names because then the tau gets
escaped in canonical types, and expand out the replacement
type with printRec() instead of stringifying it.
2023-11-14 15:46:58 -05:00
Ben Barham
36686d720d [Sema] Move predates concurrency remarks to warnings
Remarks are intended to be enabled via eg. `-R...`, where as
`(add|remove)_predates_concurrency_import` is a diagnostic that's always
output without any `-R` flag. Move it to a warning instead.

Resolves rdar://114207080.
2023-10-25 14:37:25 -07:00
swift-ci
b1d36b3207 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 12:54:26 -07:00
Eric Miotto
7870afb78a TDBGen: amend file type for SwiftAPIDescriptor (#69150)
This is to match the one SwiftDriver expects, so that we generate API
descriptors when they are specified in supplementary output files.

Addresses rdar://116809713
2023-10-12 12:44:06 -07:00
swift-ci
bfc9d85449 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-11 18:14:16 -07:00
Slava Pestov
c90b8e6e95 ASTDumper: Improve conformance dumping and use forEachAssociatedConformance() 2023-10-11 15:04:09 -04:00
swift-ci
4a749b3e3d Merge remote-tracking branch 'origin/main' into rebranch 2023-10-05 16:59:34 -07:00
Allan Shortlidge
e1f2e25ed5 Frontend: Introduce -emit-api-descriptor flag.
An "API descriptor" file is JSON describing the externally accessible symbols
of a module and metadata associated with those symbols like availability and
SPI status. This output was previously only generated by the
`swift-api-extract` alias of `swift-frontend`, which is desgined to take an
already built module as input. Post-processing a built module to extract this
information is inefficient because the module and the module's dependencies
need to be deserialized in order to visit the entire AST. We can generate this
output more efficiently as a supplementary output of the -emit-module job that
originally produced the module (since the AST is already available in-memory).
The -emit-api-descriptor flag can be used to request this output.

This change lays the groundwork by introducing frontend flags. Follow up
changes are needed to make API descriptor emission during -emit-module
functional.

Part of rdar://110916764.
2023-10-05 11:40:53 -07:00
swift-ci
309d089075 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-29 10:13:55 -07:00
Allan Shortlidge
1d8fc104c3 AST/SILGen: Requestify function body skipping.
Function bodies are skipped during typechecking when one of the
-experimental-skip-*-function-bodies flags is passed to the frontend. This was
implemented by setting the "body kind" of an `AbstractFunctionDecl` during decl
checking in `TypeCheckDeclPrimary`. This approach had a couple of issues:

- It is incompatible with skipping function bodies during lazy typechecking,
  since the skipping is only evaluated during a phase of eager typechecking.
- It prevents skipped function bodies from being parsed on-demand ("skipped" is
  a state that is distinct from "parsed", when they ought to be orthogonal).
  This needlessly prevented complete module interfaces from being emitted with
  -experimental-skip-all-function-bodies.

Storing the skipped status of a function separately from body kind and
requestifying the determination of whether to skip a function solves these
problems.

Resolves rdar://116020403
2023-09-28 19:18:35 -07:00
swift-ci
7fc36edb98 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-27 09:34:12 -07:00
Allan Shortlidge
62d1fe4097 Tests: Re-design skip-function-bodies.swift test.
The skip-function-bodies.swift test previously relied on `-emit-sorted-sil` to
control the order of SIL emission for matching CHECK: lines. I found that this
made the test too difficult to evolve, so I've re-written the test to instead
use SILGen's natural output order. This makes it much more straightforward to
add new test cases at the right location in the file.

There are a number of additional improvements to the test:
- SILGen without any function body skipping is now checked as a baseline to
  ensure that all the checks are in the right order. Previously, most of the
  negative CHECK lines were not properly ordered in the file, so they could have
  missed regressions.
- Every declaration in the test has a set of exhaustive CHECK lines covering
  each of the outputs explicitly. While more verbose, it should be clearer what
  is expected for every declaration.
- Module interfaces are emitted with the proper flags and are typechecked to
  verify they are valid.
- Superfluous diagnostics (e.g. unused variables) have been minimized to
  improve the experience of debugging failures.
2023-09-26 13:32:10 -07:00
Allan Shortlidge
8a88dd2362 Revert "Tests: Re-design skip-function-bodies.swift test."
This reverts commit 43e36cc184.
2023-09-26 13:20:13 -07:00
Allan Shortlidge
43e36cc184 Tests: Re-design skip-function-bodies.swift test.
The skip-function-bodies.swift test previously relied on `-emit-sorted-sil` to
control the order of SIL emission for matching CHECK: lines. I found that this
made the test too difficult to evolve, so I've re-written the test to instead
check SILGen's output by extracting just the `string_literal` lines and then
sorting them. This makes it much more straightforward to add new test cases at
the right location in the file.

There are a number of additional improvements to the test:
- SILGen without any function body skipping is now checked as a baseline to
  ensure that all the checks are in the right order. Previously, most of the
  negative CHECK lines were not properly ordered in the file, so they could have
  missed regressions.
- Every declaration in the test has a set of exhaustive CHECK lines covering
  each of the outputs explicitly. While more verbose, it should be clearer what
  is expected for every declaration.
- Module interfaces are emitted with the proper flags and are typechecked to
  verify they are valid.
- Superfluous diagnostics (e.g. unused variables) have been minimized to
  improve the experience of debugging failures.
2023-09-26 10:22:46 -07:00
swift-ci
974a96e6ee Merge remote-tracking branch 'origin/main' into rebranch 2023-09-24 17:54:55 -07:00
Allan Shortlidge
0c268e03e3 Tests: Add REQUIRES: optimized_stdlib to skip-function-bodies-Onone.swift. 2023-09-24 15:24:18 -07:00
swift-ci
494fe3d63c Merge remote-tracking branch 'origin/main' into rebranch 2023-09-24 01:33:13 -07:00
Allan Shortlidge
bb035af00e Tests: Split skip-function-bodies.swift into multiple tests.
This makes the main skip-function-bodies.swift test easier to maintain because
there are fewer `RUN:` lines to wade through in the output. The early `RUN:`
lines that redirect stderr to stdout were also making iterative debugging very
painful.
2023-09-23 23:30:44 -07:00
swift-ci
879da18ff8 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-23 08:59:33 -07:00
Allan Shortlidge
51e61aab0a Tests: Re-enable skip-function-bodies.swift.
It doesn't appear to be failing anymore.
2023-09-22 17:46:49 -07:00
swift-ci
ad2ade627b Merge remote-tracking branch 'origin/main' into rebranch 2023-09-14 16:54:08 -07:00
Kuba Mracek
b4bed4130a Add a lit test showing and documenting how to use builtins in -parse-stdlib mode 2023-09-14 10:01:46 -07:00
swift-ci
e3fd999e57 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-12 00:13:14 -07:00
Becca Royal-Gordon
8770c7f826 Rework ASTDumper (#68438)
This PR refactors the ASTDumper to make it more structured, less mistake-prone, and more amenable to future changes. For example:

```cpp
  // Before:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E) {
    printCommon(E, "unresolved_dot_expr")
      << " field '" << E->getName() << "'";
    PrintWithColorRAII(OS, ExprModifierColor)
      << " function_ref=" << getFunctionRefKindStr(E->getFunctionRefKind());
    if (E->getBase()) {
      OS << '\n';
      printRec(E->getBase());
    }
    PrintWithColorRAII(OS, ParenthesisColor) << ')';
  }

  // After:
  void visitUnresolvedDotExpr(UnresolvedDotExpr *E, StringRef label) {
    printCommon(E, "unresolved_dot_expr", label);

    printFieldQuoted(E->getName(), "field");
    printField(E->getFunctionRefKind(), "function_ref", ExprModifierColor);

    if (E->getBase()) {
      printRec(E->getBase());
    }

    printFoot();
  }
```

* Values are printed through calls to base class methods, rather than direct access to the underlying `raw_ostream`.
    * These methods tend to reduce the chances of bugs like missing/extra spaces or newlines, too much/too little indentation, etc.
    * More values are quoted, and unprintable/non-ASCII characters in quoted values are escaped before printing.
* Infrastructure to label child nodes now exists.
    * Some weird breaks from the normal "style", like `PatternBindingDecl`'s original and processed initializers, have been brought into line.
* Some types that previously used ad-hoc dumping functions, like conformances and substitution maps, are now structured similarly to the dumper classes.
* I've fixed the odd dumping bug along the way. For example, distributed actors were only marked `actor`, not `distributed actor`.

This PR doesn't change the overall style of AST dumps; they're still pseudo-S-expressions. But the logic that implements this style is now isolated into a relatively small base class, making it feasible to introduce e.g. JSON dumping in the future.
2023-09-11 23:56:38 -07:00
Evan Wilde
5a1a5f749c Disabling dependencies-fine test for rebranch
Disabling failing test:
 - Frontend/dependencies-fine.swift

Trying to get more visibility on Linux for rebranch status.
Radar to track fixing this test failure: rdar://114207865
2023-09-05 11:47:06 -07:00