Commit Graph

6605 Commits

Author SHA1 Message Date
Alastair Houghton
18496c5626 [Backtracing] Remove support for implicit import of _Backtracing.
We're going to rename the module to Runtime, and it isn't going to be an
implicit import, so we don't need any of this.

rdar://124913332
2025-01-17 10:09:36 +00:00
Alex Hoppen
3e3e33fc13 [SourceKit] Explicitly specify the type of enums in CodeCompletinSwiftInterop.h
To match the definition in SourceKit-LSP, which were needed because enums default to `int32_t` on Windows.
2025-01-16 11:31:28 -08:00
Saleem Abdulrasool
5f0bd9b005 Merge pull request #78275 from andrurogerz/swift-inspect-android
[swift-inspect] implement Android support including remote heap iteration
2025-01-16 09:20:59 -08:00
Alex Hoppen
e2235e201c Merge pull request #78421 from ahoppen/add-sourcekit-plugin
[SourceKit] Add mechanism to load plugins for request handling into SourceKit
2025-01-15 12:42:10 -08:00
Andrew Rogers
f2649f20c8 PR Feedback: make PTrace.init fileprivate 2025-01-15 10:55:31 -08:00
Andrew Rogers
6381de4434 PR feedback: fix incorrect comment 2025-01-15 10:55:12 -08:00
Andrew Rogers
4a9087c950 update Android build command in README.md for newst Swift Android SDK 2025-01-14 15:45:43 -08:00
Andrew Rogers
e6dc4596d6 remove custom linker script in favor of implicit section maker symbols 2025-01-13 10:27:46 -08:00
Andrew Rogers
a4a7384de4 add CMake build support for Android 2025-01-13 08:56:01 -08:00
Andrew Rogers
b997bdbf55 Define a new text section and use a linker script to safely calculating remote callback length 2025-01-13 08:56:01 -08:00
Doug Gregor
8bb5bbedbc Implement an unsafe expression to cover uses of unsafe constructs
Introduce an `unsafe` expression akin to `try` and `await` that notes
that there are unsafe constructs in the expression to the right-hand
side. Extend the effects checker to also check for unsafety along with
throwing and async operations. This will result in diagnostics like
the following:

    10 |   func sum() -> Int {
    11 |     withUnsafeBufferPointer { buffer in
    12 |       let value = buffer[0]
       |                   |     `- note: reference to unsafe subscript 'subscript(_:)'
       |                   |- warning: expression uses unsafe constructs but is not marked with 'unsafe'
       |                   `- note: reference to parameter 'buffer' involves unsafe type 'UnsafeBufferPointer<Int>'
    13 |       tryWithP(X())
    14 |       return fastAdd(buffer.baseAddress, buffer.count)

These will come with a Fix-It that inserts `unsafe` into the proper
place. There's also a warning that appears when `unsafe` doesn't cover
any unsafe code, making it easier to clean up extraneous `unsafe`.

This approach requires that `@unsafe` be present on any declaration
that involves unsafe constructs within its signature. Outside of the
signature, the `unsafe` expression is used to identify unsafe code.
2025-01-10 10:39:14 -08:00
Alex Hoppen
c0ad0b62b6 [SourceKit] Support Windows for the SourceKit plugin 2025-01-10 19:21:20 +01:00
Andrew Rogers
5dd761a4f3 force 8-byte alignment on heap_iterate_callback_end 2025-01-08 13:36:37 -08:00
Alex Hoppen
21b729f195 Fix test failures of SourceKit plugin on Linux 2025-01-07 12:25:48 -08:00
Allan Shortlidge
77141c5bc5 SourceKit: Adopt SemanticAvailableAttr in SwiftDocSupport.cpp. 2025-01-07 07:31:29 -08:00
Andrew Rogers
21d139d24c missed a __volatile__ 2025-01-06 19:55:18 -08:00
Andrew Rogers
0ca4971113 Merge branch 'swift-inspect-android' of github.com:andrurogerz/swift into swift-inspect-android 2025-01-06 19:45:53 -08:00
Andrew Rogers
61cb0c3bcc PR Feedback 2025-01-06 19:45:36 -08:00
Andrew Rogers
5cc83ccd88 Merge branch 'main' into swift-inspect-android 2025-01-06 13:40:26 -08:00
Andrew Rogers
9604994645 PR Feedback: make PTrace a non-copyable struct 2025-01-06 13:09:41 -08:00
Andrew Rogers
5488f2fa88 PR Feedback: improve PTrace implementation 2025-01-06 12:46:39 -08:00
Andrew Rogers
48d62378d0 PR Feedback: use __builtin_debugtrap and safe function size calculation 2025-01-06 11:03:36 -08:00
Andrew Rogers
7b10cc88e4 PR feedback: README.md updates 2025-01-06 07:57:58 -08:00
Alex Hoppen
aeac681bae [SourceKit] Make the SourceKit plugin infrastructure buildable on Linux and Windows 2025-01-06 13:57:57 +01:00
Alex Hoppen
40b91aa97a Share logic to load dynamic libraries between SourceKit plugins and macro plugins 2025-01-03 16:23:16 +01:00
Alex Hoppen
6d0463ad82 [SourceKit] Apply clang-format to the SourceKit plugin sources 2025-01-03 15:24:52 +01:00
Alex Hoppen
b6c94aecc3 [SourceKit] Add mechanism to load plugins for request handling into SourceKit
This allows us to load plugins into the sourcekitd service to handle requests (currently only used for code completion). This allows us to implement parts of sourcekitd in Swift and outside of the compiler repository, making it easier to iterated on them because the compiler doesn’t need to be rebuilt.
2025-01-03 15:24:52 +01:00
Ian Anderson
cdb42c3535 [ClangImporter] clang's -iframework comes before builtin usr/local/include, but Swift's -Fsystem comes after
When Swift passes search paths to clang, it does so directly into the HeaderSearch. That means that those paths get ordered inconsistently compared to the equivalent clang flag, and causes inconsistencies when building clang modules with clang and with Swift. Instead of touching the HeaderSearch directly, pass Swift search paths as driver flags, just do them after the -Xcc ones.

Swift doesn't have a way to pass a search path to clang as -isystem, only as -I which usually isn't the right flag. Add an -Isystem Swift flag so that those paths can be passed to clang as -isystem.

rdar://93951328
2024-12-23 22:15:52 -08:00
Ben Barham
8111fe9343 Merge pull request #78262 from bnbarham/skip-non-wmo-diag
[Embedded] Do not produce `cannot_specialize_class` for live issues
2024-12-20 10:40:07 -08:00
Becca Royal-Gordon
08e2a4ddae Type check ABI decls
Sema now type-checks the alternate ABI-providing decls inside of @abi attributes.

Making this work—particularly, making redeclaration checking work—required making name lookup aware of ABI decls. Name lookup now evaluates both API-providing and ABI-providing declarations. In most cases, it will filter ABI-only decls out unless a specific flag is passed, in which case it will filter API-only decls out instead. Calls that simply retrieve a list of declarations, like `IterableDeclContext::getMembers()` and friends, typically only return API-providing decls; you have to access the ABI-providing ones through those.

As part of that work, I have also added some basic compiler interfaces for working with the API-providing and ABI-providing variants. `ABIRole` encodes whether a declaration provides only API, only ABI, or both, and `ABIRoleInfo` combines that with a pointer to the counterpart providing the other role (for a declaration that provides both, that’ll just be a pointer to `this`).

Decl checking of behavior specific to @abi will come in a future commit.

Note that this probably doesn’t properly exercise some of the new code (ASTScope::lookupEnclosingABIAttributeScope(), for instance); I expect that to happen only once we can rename types using an @abi attribute, since that will create distinguishable behavior differences when resolving TypeReprs in other @abi attributes.
2024-12-19 15:49:34 -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
Ben Barham
a2fda1d9f3 [Embedded] Do not produce cannot_specialize_class for live issues
SourceKit explicitly disables WMO, silence the diagnostic in this case
(but leave it enabled for explicit non-WMO builds otherwise).
2024-12-19 15:31:41 -08:00
Andrew Rogers
b73c54b645 PR feedback: CMakeLists.txt improvements 2024-12-18 14:07:14 -08:00
Andrew Rogers
4018056a58 [swift-inspect] update README.md for Linux CMake build 2024-12-18 13:45:42 -08:00
Andrew Rogers
5b4b86e038 [swift-inspect] support CMake build for Linux 2024-12-18 13:21:26 -08:00
Andrew Rogers
d965cc6612 [swift-inspect] add #pragma once to system header wrappers 2024-12-18 13:20:44 -08:00
Andrew Rogers
9fdd46f3fb refactor remote function calls to their own methods 2024-12-18 11:51:08 -08:00
Andrew Rogers
c0257d8f53 add missing copyright header to RegisterSet.swift 2024-12-18 11:51:08 -08:00
Andrew Rogers
03dae5d175 [swift-inspect] minor cleanup and documentation 2024-12-18 11:51:08 -08:00
Andrew Rogers
0a436ba32f [swift-inspect] minor cleanup 2024-12-18 11:51:08 -08:00
Andrew Rogers
ac3fec1abe [swift-inspect] move Android-specific memory region naming to Android
class
2024-12-18 11:51:08 -08:00
Andrew Rogers
25da1a9a18 [swift-inspect] use malloc_disable/malloc_enable when iterating the heap
on Android
2024-12-18 11:51:08 -08:00
Andrew Rogers
714ce52eeb [swift-inspect] indent RegisterSet.swift 2024-12-18 11:51:08 -08:00
Andrew Rogers
21ea119121 [swift-inspect] fix Android README.md 2024-12-18 11:51:07 -08:00
Andrew Rogers
d7e8c74616 [swift-inspect] add ptrace retries 2024-12-18 11:51:07 -08:00
Andrew Rogers
43c9623d2c [swift-inspect] misc cleanup 2024-12-18 11:51:07 -08:00
Andrew Rogers
e90f5c5d4b [swift-inspect] refactor heap iteration 2024-12-18 11:51:07 -08:00
Andrew Rogers
f981f35fb5 [swift-inspect] full Android implementation including heap iteration 2024-12-18 11:51:07 -08:00
Saleem Abdulrasool
ea000d6edf Merge pull request #77938 from andrurogerz/swift-inspect-linux
[swift-inspect] implement basic GNU/Linux support
2024-12-18 08:29:12 -08:00
Saleem Abdulrasool
53f16be795 Merge pull request #78125 from andrurogerz/swift-inspect-windows
[swift-inspect] incorrect error logged by `swift-inspect dump-arrays` on Windows
2024-12-16 14:18:39 -08:00