Commit Graph

236 Commits

Author SHA1 Message Date
Augusto Noronha 27ba7beb5c Merge pull request #89138 from augusto2112/fix-protocol-typealias-typeref
[RemoteInspection] Fix generic typealiases in DemanglingForTypeRef
2026-05-19 10:47:18 -07:00
Augusto Noronha 600d597f59 add test 2026-05-15 14:09:23 -07:00
Mike Ash acb09e2f87 Merge pull request #88935 from mikeash/remote-mirror-variadic-generic
[Reflection] Support parameter packs in generic substitutions.
2026-05-15 12:35:24 -04:00
Mike Ash 23fac72075 Merge pull request #88933 from mikeash/remote-mirror-inline-array
[Reflection] Support inspection of InlineArray.
2026-05-14 19:53:11 -04:00
Augusto Noronha e5873e820b [RemoteInspection] Fix handling of extensions in DemanglingForTypeRef
Typically, the first node of a nested type is the type that contains it.
For example:

```
Demangling for $s7ModBase5OuterV5InnerC
kind=Global
  kind=Class
    kind=Structure
      kind=Module, text="ModBase"
      kind=Identifier, text="Outer"
    kind=Identifier, text="Inner"
$s7ModBase5OuterV5InnerC ---> ModBase.Outer.Inner
```

However, when a type is declared inside an extension of "Outer", that
becomes part of the mangled name too. For example:

```
Demangling for $s7ModBase5OuterV6ModExtE5InnerC
kind=Global
  kind=Class
    kind=Extension
      kind=Module, text="ModExt"
      kind=Structure
        kind=Module, text="ModBase"
        kind=Identifier, text="Outer"
    kind=Identifier, text="Inner"
$s7ModBase5OuterV6ModExtE5InnerC ---> (extension in ModExt):ModBase.Outer.Inner
````

DemanglingForTypeRef did not treat the extension case correctly, and was
losing the extension information. This patch fixes it.

Assisted-by: claude

rdar://176586425
2026-05-13 11:06:13 -07:00
Mike Ash 2bcfe0b092 [Reflection] Support inspection of InlineArray.
Report the array count as NumFields, and report the same info for each child since InlineArray is homogeneous.

rdar://176382725
2026-05-07 14:39:05 -04:00
Mike Ash 01233ba7a3 [Reflection] Support parameter packs in generic substitutions.
Fill in the GenericParamKind::TypePack case in MetadataReader's getGenericSubst method.

rdar://165872192
2026-05-07 14:31:23 -04:00
Mike Ash d6fc306b16 [Reflection] Improve size computation for remote type metadata reading.
Take advantage of the ability to iterate over TrailingObjects when computing the size of certain kinds of type metadata. This avoids the occasional issue where a new trailing object is added to a type, the remote metadata reader isn't fully updated for it, and doesn't read enough data. This change fixes an issue with function type metadata where we didn't read the global actor field.

Not all type metadata is amenable to this, as some don't use TrailingObjects for their trailing data (e.g. various nominal types) and extended existentials need to dereference their Shape pointer to determine the number of TrailingObjects, which needs some additional code when done remotely. We are able to automatically calculate the sizes of Existential and Function.

rdar://162855053
2025-11-21 19:55:32 -05:00
Tim Kientzle bf624b1461 Fine-tune what environments should run this test 2025-01-30 08:57:38 -08:00
Tim Kientzle f48f772396 Test for #78981
**Without #78981**: This test triggers "Reflection section too small to contain next record"
errors, indicating that the field information is broken.

**With #78981**: This test runs to completion without triggering
the error message above.
2025-01-29 18:52:17 -08:00
Tim Kientzle 674c76274e Merge pull request #77062 from tbkka/tbkka-remotemirror-133890406
Let indirect enum cases export spare bits
2025-01-24 19:52:59 -08:00
swift-ci 1df3ffb7cb Merge remote-tracking branch 'origin/main' into rebranch 2024-10-17 09:12:58 -07:00
Tim Kientzle 3abefd1dda Accomodate x86_64 vs. arm64 differences 2024-10-17 08:51:47 -07:00
Tim Kientzle fe90ad5684 Let indirect enum cases export spare bits
To determine the correct enum layout, we first count various
categories of cases.  Before, we counted indirect generic cases as
"generic", but regular "generic" cases can't export spare bits.

Change this to count "indirect" cases as a separate category.
In particular, this ensures that fully-indirect enums use
spare bits from the pointers even when some or all of the cases
are generic.

Resolves rdar://133890406
2024-10-16 18:31:28 -07:00
Tim Kientzle 502941ca5a More arcana about MPEs carrying class existentials
The first word in a class existential is the class pointer itself.
This pointer exposes spare bits differently depending
on the platform, which becomes apparent when you try to reflect
an Optional carrying such an MPE.

Add new test cases and some logic to zero out the first
word of spare bit information only on platforms with 8-byte pointers.
2024-10-16 16:06:37 -07:00
Tim Kientzle a105cf5323 Fix multi-payload enums with Class Existential payloads on 32-bit targets
Class existentials expose spare bits from all of the pointers, not just the first one.
Due to a bad bug here, we were properly exposing spare bits from the first pointer,
but then claiming that all bits of subsequent pointers were spare.
This accidentally resulted in the correct operation on 64-bit targets
(it picked the highest-order spare bit, which happened to be spare
in both the broken mask and the correct mask).  But on 32-bit targets,
this exposed the high-order bits of pointers, which is incorrect.

Expand the test a bit while we're here as well.

Resolves rdar://132715829
2024-10-15 09:28:01 -07:00
swift-ci 24c3b5e002 Merge remote-tracking branch 'origin/main' into rebranch 2024-10-07 17:15:46 -07:00
Mike Ash ceb2853948 [Test] Temporarily disable reflect_Enum_values10 test on ARM64_32.
This test hits a bug on ARM64_32, disable it temporarily until we can fix it.
2024-10-07 16:16:07 -04:00
swift-ci 5e0b892e9e Merge remote-tracking branch 'origin/main' into rebranch 2024-09-20 13:09:36 -07:00
Tim Kientzle 025143138d Update an existing test that now works 2024-09-19 16:25:41 -07:00
Tim Kientzle e62560c9ca Limit this part to only 64-bit targets 2024-09-19 14:04:11 -07:00
Tim Kientzle da5383c4c3 Better support CoreFoundation types in RemoteMirror
This plugs a hole where we failed to recognize a CF type when it
appeared as the payload of an enum stored as a property.  Curiously,
RemoteMirror is able to reflect this when the enum appears by itself,
just not when it's stored as a property.

The simplest fix is to hook into the TypeInfo calculation which
computes a TypeInfo (basically, the tree of fields) from a TypeRef
(basically, the name of the type, including generic context).
Specifically, we sometimes end up here with a "type alias" that
none of the lookup support seems to be able to handle.  Fortunately,
these aliases demangle into a pretty predictable shape, so this
just pattern-matches the specific demangle tree shape to recognize
these as "type aliases in the `__C` module whose name starts with `CF`
and ends with `Ref`".

Resolves rdar://82465109
2024-09-19 13:50:41 -07:00
swift-ci 229f81a516 Merge remote-tracking branch 'origin/main' into rebranch 2024-08-29 14:34:05 -07:00
Ben Langmuir 7d11d43d6d [test] Add explicit targets to tests depending on the default
Add specific deployment target versions to some tests that need to test
10.x-specific behaviours and are currently depending on the default
deployment target.

Certain tests were only checking either the stable or unstable ABI
depending on the platform the test was running. In those cases I doubled
up the checks so that we would test both cases on platforms that
supported it. This might use a bit of extra time on targets that only
support the stable ABI, but it seemed worth it for the additional
coverage in CI.
2024-08-29 07:55:14 -07:00
Becca Royal-Gordon fd84e7273d Rename module.map -> module.modulemap in tests
The legacy `module.map` spelling of module map files was deprecated by llvm/llvm-project#75142 and clang expects to remove support for them in the future. Switch all tests to use the supported spelling.

Fixes rdar://128431478.
2024-08-12 17:47:26 -07:00
Ryan Mansfield 35fb08790b Use num_extra_inhabitants_64bit to fix reflect_CheckedContinuation.swift and
reflect_UnsafeContinuation.swift on non-Darwin platforms.
2024-08-06 16:05:55 -04:00
Tim Kientzle 1aae57a93f Suppress these tests under "asan", not "ASAN" 2024-08-05 14:24:23 -07:00
Tim Kientzle 661f368c6b Merge pull request #75620 from tbkka/tbkka-remotemirror-checkedcontinuation
Basic test for RemoteMirror reflecting checked continuations
2024-08-05 11:33:28 -07:00
Tim Kientzle 4e81902958 Disable these tests under ASAN 2024-08-01 16:35:58 -07:00
Tim Kientzle 9debfbc08c Merge pull request #75607 from tbkka/tbkka-remotemirror-unsafecontinuation
[RemoteMirror] Handle UnsafeContinuation
2024-08-01 13:46:09 -07:00
Tim Kientzle 76adead918 Basic test for RemoteMirror reflecting checked continuations 2024-08-01 09:15:01 -07:00
Tim Kientzle 8935510bcc Do not test with back deployment since this is a new-ish feature area 2024-08-01 07:27:11 -07:00
Tim Kientzle 71f010ead4 Merge pull request #75516 from tbkka/tbkka-new-actor-reflection-test
New reflect_Actor test
2024-07-31 21:01:29 -07:00
Tim Kientzle 9e1dcd6c9f [RemoteMirror] Handle UnsafeContinuation
UnsafeContinuations can be stored in variables or properties,
so it's important for RemoteMirror to be able to at least minimally
recognize them.

This just treats an UnsafeContinuation as a refcounted pointer.
Which might be "good enough" for now.

Working towards rdar://110351406
2024-07-31 18:15:27 -07:00
Tim Kientzle 725dc3c011 Merge pull request #75587 from tbkka/tbkka-remotemirror-generic-depth
[RemoteMirror] Fix generic depth calculation
2024-07-31 17:56:27 -07:00
Tim Kientzle 47de3339bb Only run this test on suitably new systems 2024-07-31 15:25:11 -07:00
Tim Kientzle 039e78d31a [RemoteMirror] Fix generic depth calculation
The "generic depth" is used to match up generic type variables.
For example:
```
struct Foo<T> { // `T` at generic depth 0
  struct Bar {
    struct Baz<U> { // 'U' at generic depth 1
      ...
}}}
```

Note in the above that `Bar` is not counted in the
generic depth.  The previous logic did count `Bar` in
the generic depth calculation, leading to mismatches
when trying to associate references to generic variables.

This adds a new test with cases like the above and of course
corrects the calculation.

Resolves rdar://127450037
2024-07-31 07:08:08 -07:00
LamTrinh.Dev 751a9d0127 Update reflect_multiple_types.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:12:12 +07:00
LamTrinh.Dev a5b4f69f8e Update reflect_NSString.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:10:53 +07:00
LamTrinh.Dev 0d8d6070a7 Update reflect_NSSet.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:10:32 +07:00
LamTrinh.Dev 9ac94d3ffa Update reflect_NSNumber.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:10:13 +07:00
LamTrinh.Dev ff63d2284e Update reflect_NSArray.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:09:15 +07:00
LamTrinh.Dev b2f9976dd8 Update reflect_Enum_values_resilient.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:07:03 +07:00
LamTrinh.Dev 39224a1ebb Update reflect_Enum_values9.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:06:17 +07:00
LamTrinh.Dev 7c47570c63 Update reflect_Enum_values8.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:05:58 +07:00
LamTrinh.Dev f3800be6d6 Update reflect_Enum_values7.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:05:37 +07:00
LamTrinh.Dev f35c57e82b Update reflect_Enum_values6.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:05:17 +07:00
LamTrinh.Dev baed1da4a9 Update reflect_Enum_values5.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:04:57 +07:00
LamTrinh.Dev bf2f25cfa2 Update reflect_Enum_values4.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:04:36 +07:00
LamTrinh.Dev aa0a602455 Update reflect_Enum_values3.swift
Adding comment for "// REQUIRES: reflection_test_support"
2024-07-29 23:04:15 +07:00