Commit Graph

90 Commits

Author SHA1 Message Date
Steven Wu ce64a73316 Merge pull request #87098 from cachemeifyoucan/eng/PR-169886913
[SDKInfo] Fix SDKInfo loading to use correct VFS
2026-02-11 09:58:40 -08:00
Steven Wu 17d969924c [SDKInfo] Fix SDKInfo loading to use correct VFS
Partially revert https://github.com/swiftlang/swift/pull/86309. Keep the
SDKInfo parsing in the ASTContext separately from the search path
configuration. This allows the availablity checking to load SDKSettings
from the correct VFS.

rdar://169886913
2026-02-09 15:03:53 -08:00
Hamish Knight eb45f2396d Replace vfs::getRealFileSystem -> vfs::createPhysicalFileSystem
Calling `setCurrentWorkingDirectory` on `getRealFileSystem` sets the
working directory for the process itself. This is unsafe for clients
such as SourceKit which can process multiple concurrent requests,
and may be used as an in-process library in e.g sourcekit-lsp. Switch
to `createPhysicalFileSystem` instead, where setting the working
directory is done locally on the FileSystem itself.
2026-02-09 09:46:34 +00:00
Hamish Knight 9997b1a4e7 [IDE] Avoid getting realpath for empty primary
Otherwise a physical FileSystem would return the current working
directory.
2026-02-09 09:46:34 +00:00
Hamish Knight bb9b5bf8c9 [IDE] Remove some redundant checks
`getRealFileSystem` returns a new FileSystem object each time so this
check is effectively `if (true)`.
2026-02-09 09:46:34 +00:00
Ian Anderson 48ab4b0595 [Frontend][Darwin] Use the system prefix from SDK when constructing the default search paths
Some Darwin platforms like DriverKit use a system prefix on all of their search paths. Even though DriverKit isn't supported, add support to get the system prefix from SDKSettings when constructing the default search paths.

This requires the DarwinSDKInfo to be gotten earlier in CompilerInvocation, pass that down to ASTContext through CompilerInstance.

-platform-availability-inheritance-map-path is no longer needed to support visionOS in tests, remove that and its supporting code that gets an alternative DarwinSDKInfo.

rdar://166277280
2026-01-09 12:41:32 -08:00
Hamish Knight 73710e3eef [AST] Introduce Decl::addAttribute
Introduce a convenience entrypoint that also calls `attachToDecl` on
the attribute, and migrate all existing uses of `getAttrs().add` onto
it.
2025-10-16 11:21:54 +01:00
Ryan Mansfield ba0ce8aea6 Add frontend options to write SIL and LLVM IR as additional compilation output.
This commit adds -sil-output-path and -ir-output-path frontend options that
allow generating SIL and LLVM IR files as supplementary outputs during normal
compilation.

These options can be useful for debugging and analysis tools
workflows that need access to intermediate compilation artifacts
without requiring separate compiler invocations.

Expected behaviour:

Primary File mode:
 - SIL: Generates one .sil file per source file
 - IR: Generates one .ll file per source file

Single-threaded WMO mode:
 - SIL: Generates one .sil file for the entire module
 - IR: Generates one .ll file for the entire module

Multi-threaded WMO mode:
 - SIL: Generates one .sil file for the entire module
 - IR: Generates separate .ll files per source file

File Maps with WMO:
 - Both SIL and IR outputs using first entry's naming, which is
   consistent with the behaviour of other supplementary outputs.

rdar://160297898
2025-10-06 15:45:49 -04:00
swift-ci bf9d79f5c1 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-13 06:17:00 -07:00
Hamish Knight 5c334c5f21 Requestify the loading of access notes
Replace `loadAccessNotesIfNeeded` with a request that loads the access
notes on-demand.
2025-09-11 16:54:08 +01:00
Anthony Latsis e1450e011e Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
*	utils/build_swift/build_swift/defaults.py
2025-09-04 14:07:50 +01:00
Ahmed Elrefaey 9d1436c1c8 [IDE] [Signature Help] Add basic signature help request to SourceKit (#83378) 2025-09-04 10:09:02 +01:00
swift-ci 02ce1af46b Merge remote-tracking branch 'origin/main' into rebranch 2025-08-13 15:58:04 -07:00
Hamish Knight acf6375d46 Introduce BindExtensionsForIDEInspectionRequest
This allows us to lazily bind extensions after mutating the AST,
ensuring we don't prematurely kick the building of lookup tables.
2025-08-10 23:49:03 +01:00
swift-ci 3998a187f9 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-30 09:36:41 -07:00
Anthony Latsis fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
swift-ci d61be51796 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-07 22:17:28 -07:00
Hamish Knight 2b1c82f498 [IDE] Make sure to clear cached CI when CachedCIShouldBeInvalidated
`performNewOperation` may not set a new compiler instance if e.g it
ends up being cancelled, so we need to make sure we reset the cached
compiler instance to ensure future requests don't attempt to re-use
it. Noticed by inspection.
2025-07-07 12:08:42 +01:00
swift-ci b5b2de478c Merge remote-tracking branch 'origin/main' into rebranch 2025-06-28 01:34:34 -07:00
Hamish Knight d6f8d8c9da [IDE] Avoid macro expansions in getEquivalentDeclContextFromSourceFile
Unfortunately haven't been able to come up with a test case for this,
but there seem to be cases where we're incorrectly picking up
a macro-expanded accessor from the cached AST when searching for the
original decl. Make sure we only consider decls that have been
written by the user.

rdar://151926231
2025-06-27 18:30:06 +01:00
Hamish Knight 4ae4d77d4b [IDE] NFC: Use optional instead of ~0U 2025-06-27 18:30:06 +01:00
Anthony Latsis 0981b71090 Adjust calls to clang::DiagnosticsEngine ctor (now takes ref vs. ptr)
See https://github.com/llvm/llvm-project/pull/139584
2025-06-13 21:57:36 +01:00
swift-ci a1a25f83a4 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-20 11:39:00 -07:00
Ben Barham 381684a389 [SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.

Resolves rdar://151500502.
2025-05-16 17:58:16 -07:00
Anthony Latsis c8ea55c100 ClangImporter, IDETool: Conservatively adjust uses of clang::CompilerInstance::createDiagnostics (parameter added)
Per df9a14d7bbf1180e4f1474254c9d7ed6bcb4ce55 (llvm-project).
2025-04-24 01:52:47 +01:00
Ben Langmuir e6de6d56c1 Update for change to clang's ObjectFilePCHContainerReader/Writer 2025-03-03 08:12:32 -08:00
Hamish Knight 4946c799af [AST] Remove ModuleDecl::addFile
Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
2024-11-17 14:17:20 +00:00
Hamish Knight 309c02410b [IDE] Avoid relying on after-the-fact use of addFile
We shouldn't be attempting to append SourceFiles
to the module after-the-fact for syntactic macro
expansion, refactor things such that the SourceFile
is created alongside the ModuleDecl.
2024-11-17 14:17:20 +00:00
Jan Svoboda 89048bab2f Drop -index-header-map, adopt new Module::Headers API (#77376) 2024-11-06 14:20:01 -08:00
Meghana Gupta 1985b6cceb [NFC] Add SerializationOptions to ASTContext 2024-10-31 13:40:56 -07:00
Allan Shortlidge af84818e5c IDETool: Register SourceFile for replaced function body.
This prevents a nullptr dereference in `ASTScope::unqualifiedLookup()` after
querying for the `SourceFile` containing a give source location.

Fixes rdar://137652856 and https://github.com/swiftlang/swift/issues/76944.
2024-10-10 17:24:17 -07:00
Doug Gregor 8febd3fb32 Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
ModuleDecl kept track of all of the source files in the module so that it
could find the source file containing a given location, which relied on
a sorted array all of these source files. SourceManager has its own
similar data structure for a similar query mapping the locations to
buffer IDs.

Replace ModuleDecl's dats structure with a use of the SourceManager's version
with the mapping from buffer IDs to source files.
2024-09-18 07:45:50 -07:00
Doug Gregor 49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
Alex Hoppen 577727ad55 Remove DiagnosticsEditorMode
Migrate the last diagnostic to be independent of `DiagnosticEditorMode` and remove that option.

rdar://133111163
2024-08-14 11:24:31 -07:00
Jeremy Day 221c7039bd Add explicit OpenSourcesAsVolatile option 2024-07-26 17:02:04 -07:00
Tim Kientzle 1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Alex Hoppen ccdd62038a [SourceKit] Don’t set DisableModulesValidateSystemDependencies to true
It appears that https://github.com/apple/llvm-project/commit/a6ebd3083dbf8aadae58f6f2a2f1071976649d56 changed the behavior of `-fno-modules-validate-system-headers` (aka. `DisableModulesValidateSystemDependencies`) in conjunction with `-fmodules-validate-once-per-build-session`: Before that change, `-fno-modules-validate-system-headers` needed to be passed for `-fmodules-validate-once-per-build-session` to have any effect (we were always validating system dependencies if `-fno-modules-validate-once-per-build-session` was not set). After the change, `-fno-modules-validate-once-per-build-session` causes system dependencies to never be validated, independent of the build session timestamp.

This change should have no effect on Xcode because it adds `-fmodules-validate-system-headers` to the compiler arguments for Swift files, which overrides `SearchPathOpts.DisableModulesValidateSystemDependencies = true;`
2024-05-31 16:00:26 -07:00
Harlan Haskins 1b36983b8b Add armv4t for GBA programming (#73005) 2024-04-13 18:11:16 -06:00
Victor Toni 710b1a6f98 Fix typos 2024-04-10 23:50:36 +02: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
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
Hamish Knight 16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Rintaro Ishizaki a61ed80813 [Macros] Track macro dependency separately in module trace
Macro plugins are not normal Swift modules, track them differently.
Add "swiftmacros" field to the JSON file.

rdar://118013482
2024-01-19 12:56:02 -08:00
Doug Gregor 36a2dcd927 Implement function body macros
Function body macros allow one to introduce a function body for a
particular function, either providing a body for a function that
doesn't have one, or wholesale replacing the body of a function that
was written with a new one.
2023-11-27 17:04:55 -08:00
Jan Svoboda 8b6e58ac15 [scanner] Adopt new Clang API for build arguments (#68503) 2023-10-06 11:31:05 -07:00
swift-ci 76f9337f89 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 13:13:44 -07:00
Alex Hoppen 72cadecf21 [CodeCompletion] Split result delivery into a result colleciton and consumer phase
This will allow us to run two different completion kinds and deliver results from both of them.

Also: Compute a unified type context for global lookup. Previously, we always used the expected type context of the last lookup. But really, we should be considering all possible types from all constraint system solutions when computing code completion results from the cache.
2023-08-24 15:41:36 -07:00
Ben Barham 5d9ce6fcb2 [SourceKit] Compilation fixes for SourceKit on rebranch 2023-07-28 09:03:28 -07:00
Holly Borla c867c7c917 [Macros] Allow extension macros to specify conformances in the attached
attribute.
2023-06-28 00:42:23 -07:00
Holly Borla 725374e0d8 [Macros] Implement attached extension macros. 2023-06-27 21:22:12 -07:00