Commit Graph

15 Commits

Author SHA1 Message Date
Allan Shortlidge
470baff865 Driver: Remove swift-api-extract.
Now that API descriptions are emitted during module build jobs when
`-emit-api-descriptor-path` is specified and the build system has been updated
to pass that flag when the output is needed, the `swift-api-extract` frontend
alias is no longer used. Delete it and the tests that were specific to invoking
`swift-api-extract`.

Resolves rdar://116537394.
2024-06-27 17:05:32 -07:00
Allan Shortlidge
778532dbdf TBDGen: Don't emit pretty-printed API descriptor JSON by default.
Instead, use the `%validate-json` lit substitution to validate and format the
API descriptor file before running it through FileCheck. This allows us to
avoid needing to introduce a dedicated frontend option just to control whether
the output of -emit-api-descriptor is pretty printed.
2023-10-05 11:40:53 -07:00
Allan Shortlidge
e91580bf0e TBDGen: Teach APIGenRecorder to emit API descriptors during -emit-module.
Make the changes to APIGenRecorder that are necessary to make it capable of
emitting API descriptors during -emit-module jobs. The output in this mode
differs from the output when run on an existing module in a couple of important
ways:

- The value for the `file` key in the descriptor JSON is now the path to the
  source file that defines the declaration responsible for the symbol. In
  `swift-api-extract` mode, the value for this key is the path to the module or
  swiftinterface which is unavailable during an -emit-module job since the module
  is usually not being emitted to its final installed location.
- Some additional symbols may be included in the API descriptor JSON because
  more of the AST is available when emitting the module.

Resolves rdar://110916764
2023-10-05 11:40:53 -07:00
Allan Shortlidge
80b1f4c1c2 TBDGen: Improve correctness of API symbol visibility and availability.
By plumbing the currently visited Decl through to APIRecorder we can improve
the correctness of API symbol visibility and availability in swift-api-extract
output.
2023-10-04 22:06:34 -07:00
Allan Shortlidge
6f1f0b0e17 TBDGen: Use isSPI() wrapper more consistently.
This ensures that different kinds of declarations with the `@_spi_available`
attribute are handled consistently.
2023-10-04 21:46:23 -07:00
Allan Shortlidge
0bc3fd3635 TBDGen: Introduce SymbolSource::getDecl() and adopt it.
By adopting this new utility, swift-api-extract more reliably gets the
ValueDecl associated with a symbol and therefore reports more accurate
availability info.
2023-10-04 21:46:23 -07:00
Allan Shortlidge
0c130eed86 NFC: Add an @_spi_available method test case to APIJSON/spi.swift. 2023-10-04 21:46:23 -07:00
Allan Shortlidge
ea1ba1387d NFC: Add -parse-as-library and dedicated module caches to APIJSON tests. 2023-10-04 21:46:23 -07:00
Cyndy Ishida
98fa58408f [swift][TBDGen] Stop adding redundant ObjC Classes (#62068)
TBD files contain a section reserved for obj-c classes. Previously,
TBDGen was adding symbols with this + normal globals with objc class
prefixes. This patch removes the extra globals being added.

This also accounts for this behavior for `validate-tbd-against-ir`
checking.

Resolves: rdar://101442087
2022-11-11 20:36:31 -08:00
Xi Ge
94fead45df swift-api-extract: extract decls with @_spi_available attributes as SPI
Working similarly as SPI_AVAILABLE in Clang, Swift decls marked with @_spi_available should be considered private
2022-10-15 08:46:20 -07:00
Juergen Ributzka
a9e02e91cb [TBDGen] Add support for Objective-C Categories.
Emit Objective-C Categories for extensions that have the @objc attribute
directly (or indirectly via one of its methods, subscripts, etc) attached.

Also associate and emit all methods for that category into the API JSON file.

This fixes rdar://94734748.
2022-06-28 09:09:49 -07:00
Steven Wu
db97c0d187 [APIJSON] Impromve tests to it doesn't rely on SDK content
Remove the dependency of APIJSON tests on SDK to improve stability and
speed.

rdar://89448415
2022-03-03 13:47:11 -08:00
Steven Wu
5dae683933 [swift-api-extract] Handle @_spi interfaces with correct APIAccess
rdar://83506338
2021-09-24 12:40:52 -07:00
Alexis Laferrière
a18c2a18f9 [Test] Add -module-cache-path flag to the APIJSON tests
The APIJSON tests used the default module cache and generated different
modules under the same name. This lead some tests to load a different
module than intended. This was made more easily detectable with the lock
on the swiftmodules instead of the swiftinterfaces.
2021-03-02 12:38:15 -08:00
Steven Wu
02c41656be swift-api-extract to generate JSON API information
Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.
2021-02-15 15:04:52 -08:00