Commit Graph

158 Commits

Author SHA1 Message Date
Anthony Latsis
cdae255f9f AST: Quote attributes more consistently in DiagnosticsModuleDiffer.def 2025-04-23 19:18:11 +01:00
Xi Ge
87877bd95f ABI checker: avoid diagnosing missing availability info for decls that are only explicitly available on visionOS
Resolves: rdar://145061506
2025-02-18 09:56:42 -08:00
Doug Gregor
2e9ab88c4a Genereralize standard library ABI stability test for arm64 macOS
... and now that it is fixed for the platform I'm developing odd, add the
missing entries for typed throws on withUnsafe(Mutable)BufferPointer.
2024-08-16 21:28:30 -07:00
Slava Pestov
feea84dc6c Sema: Ban uncallable protocol member operators
Member operators of concrete nominal types must declare at least
one parameter with that type, like

```
struct S {
  static func +(lhs: S, rhs: Int) -> S {}
}
```

For protocol member operators, we would look for a parameter of type
`Self`, or an existential type `any P`. While the latter was
consistent with the concrete nominal type case, it was actually
wrong because then the resulting interface type does not give the
type checker any way to bind the `Self` type parameter.

There were two existing test cases that now produce errors, which I
believe is now correct. While this is technically a source break,
because these bogus operators seemingly cannot be witnessed or called,
such a protocol probably had no conforming types.

Fixes https://github.com/apple/swift/issues/73201.
2024-04-23 15:28:16 -04:00
Kavon Farvardin
3b02f306ee APIDigester: Stringify inverses in GenericSigs
The presence of Copyable/Escapable conformances doesn't affect ABI. Only
their absence in terms of suppressed requirements like `~Copyable` need
to be output for diffing by the APIDigester.
2024-03-14 23:10:44 -07:00
Becca Royal-Gordon
46f8dfa692 Merge pull request #70106 from beccadax/a-little-too-implicit
[ClangImporter] Fix IUO ordering bug
2024-01-05 16:52:20 -08:00
Becca Royal-Gordon
b699f1c7a3 [ClangImporter] Fix IUO ordering bug
The IUO-ness of imported declarations is not actually computed by IsImplicitlyUnwrappedOptionalRequest. Instead, ClangImporter manually sets the bit to `true` after the declaration’s type is imported and expects IsImplicitlyUnwrappedOptionalRequest to always set it to `false` for all other imported declarations.

Normally, declaration types are imported greedily as soon as the declaration is created. However, a ClangImporter refactoring in apple/swift#61026 deferred the import of a VarDecl’s type, and therefore the setting of its IUO bit, until the first time InterfaceTypeRequest is evaluated.

It turns out that there is nothing to guarantee that InterfaceTypeRequest will be evaluated before IsImplicitlyUnwrappedOptionalRequest, so if isImplicitlyUnwrappedOptional() was fetched before getInterfaceType() was called, it would return an incorrect result. The only known client that accesses the information in this order is the API digester, but in theory any part of the compiler could fall into this trap.

Force the evaluation of InterfaceTypeRequest during IsImplicitlyUnwrappedOptionalRequest when necessary to compute the IUO bit for an imported VarDecl, and add a test to prove that this fixes the observed bug in the API digester.
2023-11-29 16:27:53 -08:00
Michael Spencer
b2640e15e4 [test] Rename all module.map files to module.modulemap
`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.

rdar://106123303
2023-08-21 15:58:59 -07:00
Allan Shortlidge
7dc313f1be NFC: Fix tests that mistakenly rely on unavailable stored properties.
Preparation for rdar://107449845
2023-04-04 08:52:39 -07:00
Xi Ge
0567a9b142 ABI checker: include SPI group names in ABI descriptor files 2022-06-04 21:45:14 -07:00
Xi Ge
e46b5f5966 ABIChecker: for decls with @_originallyDefinedIn, use original module names in ABI descriptors
rdar://93615410
2022-06-03 22:41:43 -07:00
Josh Soref
55d9c8353b Spelling apidigester (#42542)
* spelling: analyzer

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: considered

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: diagnostic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inherited

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interface

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: invoke

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: populating

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: referenced

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: requirement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 18:53:51 -07:00
Xi Ge
0992e97e5e ConstValues: record the values of const variable references in the side-car file 2022-02-21 19:22:25 -08:00
Doug Gregor
a5f676028b Eliminate remaining dependencies on a single underlying opaque type
The first generic parameter of an `OpaqueTypeDecl` was still being used
as the "underlying" interface type of the opaque type, which is
incorrect for both structural and named opaque result types. Eliminate
this notion, because the (declared) interface type already has the
correct structure.

Only ABI checking depended on the old "underlying" type, so rework it to
instead substitute into properly for structural opaque result types as
well.

Deserialization required a small adjustment to eliminate a cycle
because the interface type of an `OpaqueTypeDecl` involves opaque
archetype types, which reference the declaration itself... so
deserialize the interface type later, now that it's correct.
2022-01-04 11:55:42 -08:00
Artem Chikin
d2b062df49 Revert "ABI checker: use dedicated mangled name field to diagnose mangled name changes"
This reverts commit b937d0da86.
2021-10-25 11:02:21 -07:00
Xi Ge
b937d0da86 ABI checker: use dedicated mangled name field to diagnose mangled name changes 2021-10-21 10:51:19 -07:00
Xi Ge
5cf758d7ff ABI Checker: include mangled names in ABI descriptor files
Previously, we use USR as a delegate for mangled name. However, USR won't incorporate name changes made
by attributes like @_silgen_name. Instead, we should add a dedicated field for canonical mangled names.

rdar://84202064
2021-10-21 10:10:10 -07:00
Xi Ge
fee60ffd4f Revert "ABI Checker: include mangled names in ABI descriptor files"
This reverts commit a870b06055.
2021-10-21 10:09:49 -07:00
Xi Ge
a870b06055 ABI Checker: include mangled names in ABI descriptor files
Previously, we use USR as a delegate for mangled name. However, USR won't incorporate name changes made
by attributes like @_silgen_name. Instead, we should add a dedicated field for canonical mangled names.

rdar://84202064
2021-10-20 20:58:00 -07:00
Alexis Laferrière
bccea96fcc [Test] Use -parse-stdlib to avoid loading an incompatible stdlib
Tests using a mock SDK can't load the stdlib of the normal SDK (or the
just-built one) with the recent changes. Use `-parse-stdlib` in those
tests to prevent loading the stdlib implicitly.
2021-09-13 16:44:16 -07:00
Xi Ge
1a44db3dcf ABIChecker: exclude decls with the @_alwaysEmitIntoClient attribute
Removing or updating @_alwaysEmitIntoClient functions are never ABI-breaking, thus
we should exclude them from the symbol set for ABI stability checking.

rdar://67883661
2020-08-27 10:58:48 -07:00
Meghana Gupta
b34791a0a0 Update code as per Apple Style Guide
whitelist -> allowlist
blacklist -> denylist
2020-07-24 11:37:15 -07:00
Mishal Shah
02b740378f [Apple Silicon] [Test] Generalize api-digester tests for Apple Silicon macOS.
Most of this is enabled by an upstream change to generalize the tests
for the api-digester to properly handle all targets. The primary change
here is to account for the Swift-level ABI differences for the standard
library between Apple Silicon macOS and Intel macOS. Specifically, anything
related to Float80 will be removed from the standard library on Apple Silicon
macOS, so account for the differences.
2020-07-02 17:57:59 -07:00
Argyrios Kyrtzidis
f89a385756 [ClangImporter] Follow-up for #32214, fix assertion hit due to missing check 2020-06-15 18:28:26 -07:00
Argyrios Kyrtzidis
915e215a3d [ClangImporter] Make sure that inherited convenience constructors are included in members of IterableDeclContext
Previously inherited constructors would be skipped from added in member list, depending on the order of request evaluator calls.
This was a regression compared to swift 5.2
2020-06-10 13:23:12 -07:00
Xi Ge
c5730beb42 API checker: only diagnose adding enum cases to exhaustive enums
Adding new cases to a non-exhaustive enum type isn't source-breaking
since it only triggers a warning.

rdar://63464929
2020-05-23 15:56:22 -07:00
Xi Ge
9883e664b2 ABIChecker: don't diagnose missing availability attribute for decls where the attribute doesn't apply
rdar://62990671
2020-05-11 08:35:11 -07:00
Xi Ge
140a151de1 ABI-checker: diagnose missing available attributes for members of extensions instead of the extensions themselves
rdar://61644469
2020-04-11 19:00:49 -07:00
Slava Pestov
305620b354 ClangImporter: Reconcile Clang declaration hidden-ness between loadAllMembers() and lazy loading
Lazy loading checked if the ClangDecl was hidden, but loading all
members did not. Let's make loadAllMembers() behave like the lazy
path, and fix some of the mock SDKs in the test suite.
2020-01-24 17:07:08 -05:00
Harlan Haskins
4d731735d2 [api-digester] Teach the api-digester about hasMissingDesignatedInitializers
Because we won’t be serializing this attribute, add custom diagnostics for the cases where:

- We add @_hasMissingDesignatedInits to an open class, which means subclasses won’t be able to inherit its inits
- We remove @_inheritsConvenienceInitializers, which means APIs are removed
2020-01-06 10:15:07 -08:00
Xi Ge
78bb298389 ABI/API checker: diagnose adding new designated initializers to open classes
If client's subclass provides an implementation of all of its superclass designated
initializers, it automatically inherits all of the superclass convenience initializers.
This means if a new designated init is added to the base class, the inherited
convenience init may be missing and cause breakage.

SR-11454
2019-09-12 15:46:45 -07:00
Xi Ge
cc6a246deb Revert "Revert "swift-api-digester: teach the tool to find framework-specific baselines from relative path"" 2019-09-01 09:19:43 -07:00
eeckstein
63a3cee0bf Revert "swift-api-digester: teach the tool to find framework-specific baselines from relative path" 2019-09-01 09:51:06 +02:00
Xi Ge
178e5d5ecf swift-api-digester: teach the tool to find framework-specific baselines from relative path
The framework baselines are installed at 'lib/swift/FrameworkABIBaseline' and the
tool is inside 'bin'. This patch teaches the executable to locate baselines
from the relative path.

In addition, this patch moves the stdlib ABI/API baselines to the canonical
location so we don't have to check the stability of the stdlib using a
different mechanism from other Swift frameworks.
2019-08-30 23:14:03 -07:00
Xi Ge
1e173d8931 ABI/API checker: populate several lazily computed attributes to nodes
ABI/API checker should check semantic differences of two modules.
Adhering too strictly to the actual ASTs could yield false positives. This
patch populates ObjC, Dynamic and Final to the attribute list if AST
APIs say so.

rdar://50217247
2019-08-29 15:24:16 -07:00
Xi Ge
6dd41f44db ABI checker: exclude unavailable decls from ABI descriptors
Framework authors usually have different schemes for different deployment
targets. We should exclude platform-unavailable ABIs from the Json file so
developers will only be warned of the breakages that are relevant to the current
scheme.

rdar://54273296
2019-08-28 16:02:03 -07:00
Xi Ge
6374d3676a ABI/API checker: diagnose ObjC name changes as breakages
rdar://54797695
2019-08-28 11:56:03 -07:00
Xi Ge
4108beb92d ABI/API checker: always print fully qualified names for types when diagnosing module difference
This change introduces a Json format change where we always print fully
qualified type names everywhere. This is beneficial for diagnosing purposes but
may not be ideal for generating migrator scripts. To resolve this conflict, the
patch also introduces a flag -migrator to opt-out fully qualified type names.

After the format change, we need to update the ABI and API baselines for the
Swift stdlib.
2019-08-27 11:42:28 -07:00
Xi Ge
4b8abdf852 swift-api-digester: use qualified type names for generic signatures
There could be cases where several modules having types of the same name.
Using fully qualified names could help us detect changing from using
one of them to another.

The commit also updates the existing ABI/API baselines to incorporate such change.
2019-08-14 09:54:55 -07:00
Xi Ge
a79b1ff73d ABI checker: report any printed name changes for type nodes
Under ABI checking mode where we don't have sugar types, any printed name
changes of type nodes worth raising an alert.

rdar://45567621
2019-08-09 17:24:45 -07:00
Stephen Canon
ca1e808bde Replace all 9999 availability in non-stdlib tests. (#26109)
Replace all 9999 availability in non-stdlib tests with the appropriate platform availability.
2019-07-12 14:48:37 -04:00
Xi Ge
e99fac01ed ABI Checker: diagnose underlying type changes of opaque result types from inlinable decls.
Inlinable decls from swift interface files allow us to construct the underlying types
of opaque result types, whose changes can break ABI.

rdar://52273137
2019-07-01 12:06:02 -07:00
Xi Ge
abfc2bc10a test: regenerate baseline for stdlib ABI after recent format changes 2019-06-26 18:04:28 -07:00
Xi Ge
436aad3510 test: re-baseline source compatibility test after format changes 2019-06-26 18:04:28 -07:00
Xi Ge
5c22fd50e2 ABI checker: include all kinds of accessors for abstract storage decl and diagnose their missing.
Removing accessors other than getter and setter can be ABI breaking. This
patch starts to formally include all accessor decls in the tree and diagnose
their removal. This change only applies to the ABI checker since we still
exclude accessors other than getter and setter when diagnosing source
compatibility.

Including accessors formally can also allow us to check the missing
of availability attributes for newly added accessors.

rdar://52063421
2019-06-26 18:04:28 -07:00
Xi Ge
2160f65283 [SR-10972] swift-api-digester: avoid diagnosing the removal of __derived_enum_equals and __derived_struct_equals
These functions are compiler implementation details and diagnosing
them is redundant and may be confusing to framework authors.
2019-06-20 16:14:43 -07:00
Xi Ge
b10527796f test: add a mock Swift framework into the ABI checker test suite 2019-06-17 12:42:55 -07:00
Xi Ge
ec3678c486 swift-api-digester: teach the tool to compare two SDKs directly
With module stability from the compiler, we can now use an earlier version
of the SDK as the baseline and compare the new SDK with it. This patch
adds a new -bsdk flag to the tool to specify the baseline SDK path.
2019-06-16 13:00:25 -07:00
Xi Ge
d405fcd8ec swift-api-digester: teach the tool to directly compare two module interfaces
We used to use a Json format to capture the ABI/API detail of Swift modules to
walk-around module compatibility issues across different compiler versions. Since
Swift module now is in stable format, we can compare two swiftinterface files
directly without dumping the content into Json format.
2019-06-12 11:16:23 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00