Commit Graph

2348 Commits

Author SHA1 Message Date
Steven Wu 28cfeac17b [Caching] Improve swift caching remarks
Make swift caching remarks more friendly to use by:
* Allow environmental variable `SWIFT_ENABLE_COMPILE_CACHE_REMARK` to
  control if the remarks are emitted or not. This avoids updating and
  reconfiguring build flags just to see the caching remarks.
* Add a new cache hit remark on top of the existing cache replay output
  remarks. Cache output replay remark is one per output, while cache hit
  remark is one per invocation. This allows better cache hit/miss rate
  calculation just based on the number of remarks emitted.

rdar://178563432
2026-06-02 15:49:20 -07:00
Sam Pyankov 73852c2195 Merge pull request #89190 from sepy97/ipi-clang-modules
Sema: Enforce IPI library level for Clang modules
2026-05-27 17:50:33 -07:00
Sam Pyankov e292be9a1b Sema: Enforce IPI library level for Clang modules
Add -ipi-clang-module flag to enforce IPI library level for Clang modules.
Compiler stores names of those modules and checks them during typechecking.

rdar://177196788
2026-05-27 10:04:15 -07:00
Henrik G. Olsson 8cab956b23 Merge pull request #88548 from hnrklssn/verify-child-notes
[DiagnosticVerifier] add -verify-child-notes
2026-05-21 17:10:28 -07:00
John Hui ddb983cbe6 [swift-synthesize-interface] Support feature flags
This is helpful for inspecting interfaces where the output depends on
experimental and upcoming compiler features.
2026-05-21 09:32:46 -07:00
Xi Ge 099ffee696 Merge pull request #89288 from nkcsgexi/176993716
Frontend: drop implicitly inferred blocklist
2026-05-20 14:49:12 -07:00
Xi Ge c883fdce6d Frontend: drop implicitly inferred blocklist
All blocklists are currently provided by build system as compiler flags explicitly. We shouldn't
need to infer those blocklist paths from the resource dir. Additionally, one recent change from Pavel (https://github.com/swiftlang/swift/pull/88631)
shows that the inference logics never worked in the first place. Let's take this opportunity to drop it.

rdar://176993716
2026-05-20 09:56:43 -07:00
Doug Gregor 7d48e98f5e Replace the DeferredCodeGen feature with CodeGenerationModel=<model>
The default code generation model for Embedded Swift is "inlinable".
DeferredCodeGen made the default code generation model
"implementation", and there was no spelling for "interface".

Introduce the experimental feature CodeGenerationModel=<model>, which
can be any of those three options. The default remains "inlinable", but
one can now specify "implementation" (which keeps most everything in
SIL) or "interface" (which only keeps the generic things in SIL). The
"interface" mode is more like non-embedded Swift for non-generic
declarations, emitting them into the IR (only) but not SIL. Generic
declarations would remain in SIL.

Implements rdar://172433062.
2026-05-20 08:35:13 -07:00
Michael Gottesman c36f842bed [diagnostic] Convert diagnostics-assert-on-{error,warning} and sil-region-isolation-assert-on-unknown-pattern from llvm::cl::opt globals to Swift frontend flags, and add -diagnostics-assert-on-group
llvm::cl::opt flags are compiled out in non-asserts builds, making these
debug flags unavailable in an important category of use cases — debugging
a release compiler in lldb. By promoting them to Swift frontend flags stored
in DiagnosticOptions/SILOptions, they are available in all build
configurations.

The three existing flags are migrated:
  -diagnostics-assert-on-error
  -diagnostics-assert-on-warning
  -sil-region-isolation-assert-on-unknown-pattern
    (backing field renamed to AbortOnUnknownRegionIsolationPatternError)

A new flag is added:
  -diagnostics-assert-on-group <group>
    Traps when any diagnostic belonging to the named group is emitted,
    allowing targeted breakpoints on a single diagnostic group rather than
    all errors or all warnings.

The assert-on-{error,warning,group} flags are intentionally kept separate
from the normal diagnostic suppression/escalation machinery so that they
remain useful while other diagnostics are also being emitted.

Tests are added for all four flags.
2026-05-14 17:36:08 -07:00
Artem Chikin e1b0e520b3 Merge pull request #88950 from artemcm/DefaultSourceWarningControl
[SourceWarningControl] Promote `@diagnose` attribute to a default language feature
2026-05-11 17:03:04 +01:00
Artem Chikin 740800dd21 [SourceWarningControl] Promote '@diagnose' attribute to a default language feature
No longer experimental as of approval of SE-0522.

Resolves rdar://176535491
2026-05-08 09:59:11 +01:00
Henrik G. Olsson 8e7036f78b Merge pull request #88621 from hnrklssn/swiftify-span-typedefless
[Swiftify] enable safe wrappers for std::span without typedef
2026-05-07 09:56:47 -07:00
Pavel Yaskevich 4201e579be Merge pull request #88162 from CognitiveDisson/feat/scope-based-expression-type-checking-warnings
[Sema] Add scope-based analogues of -warn-long-expression-type-checking
2026-05-04 06:35:35 -07:00
Henrik G. Olsson 3a2ec2b51b [Macros] add -eager-macro-checking frontend option
Normally macro expansions are typechecked through the normal traversal
of the AST. This does not happen with macro expansions in clang modules
however, since the clang module is not traversed by the typechecker.
This is not too problematic, since all the code in clang modules is
generated by the toolchain, so incorrect code would only occur when
there's a bug in the toolchain. Catching these bugs would be a lot
easier if we actually ran the typechecker during testing. We don't want
to do this normally, as it breaks the laziness of the typechecking, so
this adds -eager-macro-checking to specifically enable this behavior.
It's intended for testing purposes only.
2026-04-29 12:30:47 -07:00
Keith Smiley 9d484d4ca1 Early return computeCXXStdlibOptions if disabled
https://github.com/swiftlang/swift/pull/88664/changes#r3141083622
2026-04-27 12:04:04 -07:00
Pavel Yaskevich 53e4e450b0 Merge pull request #88631 from xedin/fix-blocklist-extension-checking
[Frontend] Fix matching of blocklist extensions
2026-04-24 09:24:19 -07:00
Kavon Farvardin ffedccb3f3 Merge pull request #88307 from kavon/supp-assoc-types-enable
Enable SE-503 (SuppressedAssociatedTypesWithDefaults)
2026-04-23 18:59:14 -07:00
Pavel Yaskevich a13bb50799 [Frontend] Fix matching of blocklist extensions
`llvm::sys::path::extension` produces an extension together with
the leading `.` which the original code didn't respect. We also
don't care about any other components as long as the last one is
`.yaml` or `.yml`.
2026-04-23 11:28:26 -07:00
CognitiveDisson 575e69f90e [Sema] Add scope-based analogues of -warn-long-expression-type-checking 2026-04-23 10:46:03 +01:00
Kavon Farvardin 610a9f98ed SuppAssocTypes: enable SE-503 by default 2026-04-22 22:11:41 -07:00
Steven Wu 9a5ac1748b [Option] Make -const-gather-protocols-list a frontend argument
Make `-const-gather-protocols-list` behaves just like
`-const-gather-protocols-file` as a frontend flag. This is cause
swift-driver needs to query the frontend flag to see if the compiler
supports the feature. It was a driver flag only, which causes the
swift-driver failed to prefix mapping the file, results in build
failures.

rdar://175194244
2026-04-20 14:31:32 -07:00
Henrik G. Olsson aa1f0f2bfb [DiagnosticVerifier] add -verify-child-notes
With this option enabled the DiagnosticVerifier enforces a strict child
note hierarchy: if a note has a parent diagnostic (which it should), it
can only be matched by an expected-note matcher in the {{children:}}
block of the matcher of its parent diagnostic. This makes it clear when
reviewing which note belongs to which diagnostic, and lets
update-verify-tests keep that structure (support in update-verify-tests
not yet added). If the note is far away from the parent it can be
matched with a line marker (#foo on the line of the emitted note).

Without this option enabled (default behavior) {{children:}} blocks are
an error.

Additionally, change the verification error sort order to use buffer
ID as the primary key (address within buffer as secondary), so that
error output is stable across source files in multi-file compilations.
2026-04-19 14:18:20 -07:00
Doug Gregor aad51cab01 [Embedded] Remove the ability to disable existentials in Embedded Swift
Support for existentials in Embedded Swift has been available for a
little while now and appears to be solid. Remove the ability to disable
them (via `-disable-experimental-feature EmbeddedExistentials`), both
because it simplifies the code and because it's an ABI break to
disable the feature.
2026-04-17 17:38:01 -07:00
Saleem Abdulrasool e3dd0235cd ClangImporter,Frontend: honour --sysroot for C/C++ library searches
We previously forwarded `-sysroot` as `-isysroot` which reached cc1, but
left the driver's view of sysroot empty which is used to derive the
system include paths. Thread `--sysroot=` into the clang importer,
ensuring that we do not do so with `-direct-clang-cc1-module-build` as
that directly goes to CC1 rather than the driver.
2026-04-07 15:44:43 -07:00
Max Desiatov 090a8ff936 Embedded WASI: make import _Concurrency implicit (#88297)
**Explanation**: Existing `wasip1` triples for Embedded Swift already support concurrency, so this import should be implicit and no longer require package authors to make it explicit for Embedded Swift for WASI compatibility.
**Scope**: limited to Embedded Swift for Wasm;
**Risk**: low due to limited scope;
**Testing**: added a new lit test that verifies the change.
**Issue**: rdar://174021193
2026-04-05 07:17:27 -07:00
Ben Langmuir 768fb73f8b Merge pull request #87862 from benlangmuir/casoptions-adaptation
[cas] Adapt to clang::CASOptions change to remove internal cache of instances
2026-03-19 09:42:20 -07:00
Ben Langmuir 11312f84de [cas] Introduce a frontend option to write CAS hash to an xattr
With the new option, when doing caching we write the hash that we already
computed for the main output file to an extended attribute (xattr) on the file.
This is equivalent to clang's -fwrite-output-hash-xattr option.

The format of the xattr is
name: com.apple.clang.cas_output_hash
data:
* Null-terminated hash schema name, e.g. llvm.builtin.v2[BLAKE3].
* Hash length (4 bytes, little-endian).
* Hash bytes

rdar://171185394
2026-03-16 15:06:33 -07:00
Steven Wu f620d37dda Reapply: [Caching][NFC] Using llvm::cas::CASConfiguration
This no longer causes a regression in number of CAS instances.

Prefer llvm::cas::CASConfiguration where it used to clang::CASOption.

(cherry picked from commit 4f059033bb)
2026-03-13 15:41:36 -07:00
Artem Chikin c0dee449c2 Merge pull request #87749 from artemcm/LocalDiagsForDiagGroup
[Diagnostics] Support diagnostic groups with toolchain-local-only documentation
2026-03-13 14:19:12 +00:00
Steven Wu 083029a112 [DebugInfo][Caching] Using CASID for bridging header PCH
Fix the debug info emitted for bridging header PCH when compilation
caching is used. This includes:
* Bridging header should have the correct dwo_name that uses CASID
* The search_path for PCH should be the cache key that can load the PCH
  just like other modules.
2026-03-12 17:16:16 -07:00
Artem Chikin 2a6ab76bb3 Add option to have a diagnostic group have toolchain-local-only documentation 2026-03-10 15:11:33 +00:00
Tony Allevato ea70fc2f5b Merge pull request #87729 from allevato/fuzzer-no-link
Support `-sanitize=fuzzer-no-link`.
2026-03-10 07:50:28 -04:00
Artem Chikin 1ba5ae1058 Merge pull request #87646 from artemcm/GuardSyntacticWarningsOnFeature
[Diagnostics] Guard the user-controlled behavior warning logic behind experimental feature
2026-03-10 09:32:13 +00:00
Artem Chikin 8b395b3280 [Diagnostics] Guard the user-controlled behavior warning logic behind experimental feature
`-enable-experimental-feature SourceWarningControl` guards the actual *use* of `@warn` attribute, but it did not guard this logic which queries it, which is meant to be general in the absense of the attribute as well.

We are seeing some unintended compile time performance implications from this logic, so for now guard it behind the same experimental feature flag.

Related to rdar://171506799
2026-03-09 12:17:15 +00:00
Tony Allevato ca737c9b94 Support -sanitize=fuzzer-no-link.
This mirrors Clang's `-fsanitize=fuzzer-no-link`, which applies the
appropriate instrumentations but does not attempt to link to the
runtime library. More importantly, this suppresses the check in the
driver that fails the build if the library cannot be found. Since
libfuzzer is not distributed with Xcode, this allows users to build
it themselves or take it from a swift.org toolchain and use it
without having to physically copy/link it into their toolchain's
runtime directory.
2026-03-07 09:39:53 -05:00
Adrian Prantl 8ef2d49796 Merge pull request #87296 from cachemeifyoucan/eng/PR-169110002
[Caching] Support -debug-module-path type of debug info
2026-03-06 18:05:36 -08:00
Steven Wu c496931403 [Caching] Support -debug-module-path type of debug info
Add flag `-debug-module-cache-key` and flag `-debug-module-self-key` to
support embedded swift module output in the debug info via CASID.

rdar://169110002
2026-02-27 09:42:05 -08:00
Slava Pestov 9336f9860a Merge pull request #87159 from slavapestov/exact-bindings
Sema: Exact bindings
2026-02-27 11:54:32 -05:00
Allan Shortlidge 1ca0d87e2b Frontend: Require explicit language mode when emitting swiftinterfaces.
If a .swiftinterface file does not include an explicit `-language-mode` option
(or its predecessor `-swift-version`) and needs to be built as a dependency of a
client compilation, then the invocation to build the module from interface
would end up inheriting the language mode that the client code is built with.
This can result in spurious type checking diagnostics or even mis-compilation.
To ensure that a module interface is always built using the language mode that
its source code was originally built with, require an explicit `-language-mode`
option when emitting swiftinterface files.

In #84307 this diagnostic was downgraded to a warning. The failures it caused
in PR testing should now be resolved.

This is a re-attempt of https://github.com/swiftlang/swift/pull/84327.

Resolves rdar://145168219.
2026-02-25 12:42:02 -08:00
Slava Pestov 9cf7131f23 Sema: Prefer binding sets with Exact bindings 2026-02-24 21:34:39 -05:00
finagolfin 1af61400be [Frontend][Driver] Update a last note to refer to -language-mode instead (#87394)
Also, fix a no-asserts test that was missed, this is a follow-up to
#87284.
2026-02-22 07:57:54 +05:30
Slava Pestov 76dd7106f8 Merge pull request #87387 from slavapestov/incremental-disjunctions-and-bindings
Sema: Start working on incremental binding set and disjunction selection
2026-02-21 09:14:10 -05:00
Slava Pestov f0efc2350b Sema: Add temporary flags to turn generation of transitive conformance constraints on and off 2026-02-20 21:59:24 -05:00
Ryan Mansfield f07c1a1b82 Merge pull request #87284 from rjmansfield/se-0441-alias-swap
Swap the alias relationship between -language-mode and -swift-version.
2026-02-20 18:14:44 -05:00
Becca Royal-Gordon 92d5430cb9 Merge pull request #87132 from beccadax/mod-squad-for-all
[ModuleInterface] Enable module selectors by default
2026-02-20 05:25:42 -08:00
Becca Royal-Gordon 1f008fb0d0 [ModuleInterface] Enable module selectors by default
And update tests to use them.

This commit depends on fixes in swiftlang/swift PRs #86905, #87129, and #87130.

Fixes rdar://169749886.
2026-02-20 00:35:23 -08:00
Ryan Mansfield ae78773ad8 Swap the alias relationship between -language-mode and -swift-version.
As specified in SE-0441, -language-mode should appear in help output
while -swift-version should be the hidden alias.

Related to swiftlang/swift-driver#1894
2026-02-18 16:06:08 -05:00
Steven Wu 7fdf642819 [ExplicitModule] Teach scanner emit loaded module trace
During explicit module build, teach dependency scanner to emit the
module trace file instead of each following compile job command. This
reduces the duplicated info, and allows supporting fully cached build
that only loads module from CAS thus cannot produce the path to the
original module file on disk.

rdar://170007480
2026-02-18 09:10:08 -08:00
Slava Pestov 85e0a9809c Merge pull request #87193 from slavapestov/valid-salvage
Sema: Add flag to force a crash if salvage() found a valid solution
2026-02-13 20:05:58 -05:00
Slava Pestov 272f8fefeb Sema: Add flag to force a crash if salvage() found a valid solution 2026-02-13 08:18:26 -05:00