164 Commits

Author SHA1 Message Date
Cyndy Ishida
477a65a051
[TextAPI] Seperate out Arch name from enum label, NFCI (#152332)
The enum label e.g. `AK_arm64` is often the same as the architecture
name, but doesn't have to be. Seperate it out.
2025-08-06 10:44:00 -07:00
Lang Hames
1299bba404
[TextAPI] Fix memory leak in SymbolSet. (#150589)
The SymbolSet class bump-ptr-allocates Symbol objects, but Symbol has a
non-trivial destructor (since Symbol's Targets member is a SmallVector):
we need to explicitly destroy the Symbol objects to ensure that no
memory is leaked.

rdar://154778728
2025-07-26 09:32:10 +10:00
Cyndy Ishida
0c2560b29b
[TextAPI] print symbols in a stable order in v5 format (#148687)
resolves: rdar://151765704
2025-07-14 12:13:43 -07:00
Kazu Hirata
9bda38f8d9
[TextAPI] Use MapVector::try_emplace (NFC) (#143564)
- try_emplace(Key) is shorter than insert({Key, nullptr}).
- try_emplace performs value initialization without value parameters.
- We overwrite values on successful insertion anyway.
2025-06-10 11:36:24 -07:00
Cyndy Ishida
88f041f3e0
[clang][Darwin] Align all OS Versions for 26 (#143548)
* Translate the following versions to 26.
  * watchOS 12 -> 26
  * visionOS 3 -> 26
  * macos 16 -> 26
  * iOS 19 -> 26
  * tvOS 19 -> 26

* Emit diagnostics, but allow conversion when clients attempt to use
invalid gaps in OS versioning in availability.

* For target-triples, only allow "valid" versions for implicit
conversions.
2025-06-10 09:50:46 -07:00
Kazu Hirata
228f66807d
[llvm] Remove unused includes (NFC) (#142733)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-06-04 12:30:52 -07:00
Kazu Hirata
89308de4b0
[llvm] Value-initialize values with *Map::try_emplace (NFC) (#141522)
try_emplace value-initializes values, so we do not need to pass
nullptr to try_emplace when the value types are raw pointers or
std::unique_ptr<T>.
2025-05-26 15:13:02 -07:00
Kazu Hirata
5c60f06648
[TextAPI] Use llvm::replace (NFC) (#140201) 2025-05-16 07:31:20 -07:00
Cyndy Ishida
4e4e4a190f
[TextAPI] Track RPaths in the order its provided via command line. (#131665)
RPaths are basically search paths for how to load dependent libraries.
The order they appear is the order the linker will search, we should
preserve that order in tbd files.

* Additionally add this level of detection to llvm-readtapi.

resolves: rdar://145603347
2025-03-18 22:12:45 -07:00
Cyndy Ishida
03506bc0a9
[TextAPI] Add missing attribute to remove/merge/extract operations (#116729) 2024-11-19 08:01:05 -08:00
Cyndy Ishida
2d48489cc3
[Clang][Darwin] Introduce SubFrameworks as a SDK default location (#115048)
* Have clang always append & pass System/Library/SubFrameworks when determining default sdk search paths.
* Teach clang-installapi to traverse there for framework input.
* Teach llvm-readtapi that the library files (TBD or binary) in there should be considered private.

resolves: rdar://137457006
2024-11-15 09:27:08 -08:00
Kazu Hirata
d2f0d99194
[TextAPI] Use range-based for loops (NFC) (#103530) 2024-08-14 09:40:30 -07:00
Cyndy Ishida
1569e0edf3
[TextAPI] Add an assertion for adding duplicate libraries into a single TBD file (#101744)
This would lead to a malformed TBD file.
2024-08-05 10:06:50 -07:00
Jay Foad
d4a0154902
[llvm-project] Fix typo "seperate" (#95373) 2024-06-13 20:20:27 +01:00
Kazu Hirata
89d0937348
[llvm] Use StringRef::contains (NFC) (#92710) 2024-05-19 18:17:53 -07:00
Cyndy Ishida
062f6fe324
[InstallAPI] Support mutually exclusive parse options (#90686)
Projects like libc use mutually exclusive macros to compile files
multiple times and then merge the result into the final library. For
installapi to accept these, we'd need to parse the same declarations in
different ways. This patch adds the basic pipelining for installapi to
create the correct TBD file.

* -Xproject allows: -fmodules, -fobjc-arc, fvisibility=hidden, prefix
headers
* -Xlabel allows: -D and -U settings
* Error on 'private' and 'public' labels -X<label>
* Xplatform allows: -iframework <path> This is to support the case where
zippered frameworks want to pass in iOSSupport search path.
2024-05-10 09:35:41 -07:00
Troy Butler
e6e931960b
[LLVM][TextAPI] Refactor Redundant Condition (#86542)
Fixes #83241

---------

Signed-off-by: Troy-Butler <squintik@outlook.com>
Co-authored-by: Troy-Butler <squintik@outlook.com>
2024-04-19 09:36:08 -07:00
Cyndy Ishida
4c18681a2d
[InstallAPI] Add support for aliased exports (#88750)
Apple's ld supports alias_lists, described as
```
     -alias_list filename
             The specified filename contains a list of aliases. The symbol name and its alias are on one
             line, separated by whitespace.  Lines starting with # are ignored.
```
To handle this for installapi-produced TBD files, pass along the same
input and account for it in verification.
2024-04-18 07:39:21 -07:00
Cyndy Ishida
b8d0cba14b
[TextAPI] Apply NFC code fixups (#88639)
* Remove unnecessary cast
* Annotate `#endif`
2024-04-14 09:23:42 -07:00
Cyndy Ishida
515d3f7d62
[TextAPI] Reorder addRPath parameters (#87601)
It matches up with other _attribute_ adding member functions and helps
simplify InterfaceFile assignment for InstallAPI.
2024-04-04 10:45:55 -07:00
Cyndy Ishida
a4de589d11
[InstallAPI] Add support for parsing dSYMs (#86852)
InstallAPI does not directly look at object files in the dylib for
verification. To help diagnose violations where a declaration is
undiscovered in headers, parse the dSYM and look up the source location
for symbols. Emitting out the source location with a diagnostic is
enough for some IDE's (e.g. Xcode) to have them map back to editable
source files.
2024-03-29 08:29:22 -07:00
Cyndy Ishida
487720fc13
Reapply "[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)" (#86574) 2024-03-25 17:32:21 -04:00
Cyndy Ishida
2d7df3167b Revert "[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)"
This reverts commit b7d8c6188986f62573b9516fe27fdd0c7df1aaf9. And
This reverts commit 2d40f179124f874aca4cf1145fdbc42fb8fb17f3.

It caused a build failure i'll need to reproduce.
` error: could not convert ‘Rule’ from ‘llvm::Regex’ to ‘llvm::Expected<llvm::Regex>’`
2024-03-25 15:50:46 -04:00
Cyndy Ishida
b7d8c61889 [TextAPI] Add missing include for Expected type 2024-03-25 15:45:25 -04:00
Cyndy Ishida
2d40f17912
[InstallAPI] Add --extra* and --exclude* cli options for header input (#86522)
InstallAPI takes a json list of headers that is typically generated from
a build system like Xcode based on a project's attributes. Sometimes,
maintainers may want to alter this for tapi input. Using e.g.
`--extra-public-headers`, users can manipulate what headers will be used
for TBD file generation.
2024-03-25 15:38:27 -04:00
Cyndy Ishida
e470ca89ba
[InstallAPI] Report exports discovered in binary but not in interface (#86025)
This patch completes the classes of errors installapi can detect.
2024-03-21 15:03:34 -07:00
Cyndy Ishida
c51095f51b
[InstallAPI] Add installapi specific options & diagnostics (#85100)
* A lot of `tapi installapi` options are already shared with clang, but
not all. This patch handles installapi-specific options by filtering for
them in the initial argv input, then passing the rest to the clang
driver.
* Installapi not only generates a text file but also reports to library
developers when there are inconsistencies between an interface and its
implementation. To allow this, add support for reporting installapi
diagnostics. This will be leveraged in the verifier service.
2024-03-16 09:08:17 -07:00
Cyndy Ishida
50ae8a2a38
[InstallAPI] Collect global functions (#83952)
* Include whether functions are inlinable as they impact whether to add
them into the tbd file and for future verification.
* Fix how clang arguments got passed along, previously spacing was
passed along to CC1 causing search path inputs to look non-existent.
2024-03-07 15:32:44 -08:00
Cyndy Ishida
06fea93341 [TextAPI] add missing platforms for translating triples to tapi targets 2024-03-05 09:34:44 -08:00
Cyndy Ishida
10ccde30e7
[InstallAPI] Collect symbols from ObjC Ivars (#83632) 2024-03-04 14:50:04 -08:00
Cyndy Ishida
346766eae8
[TextAPI] Fixup symbol names of ivars from extensions (#83525) 2024-02-29 22:06:04 -08:00
Cyndy Ishida
3a080a0195
[TextAPI] Refactor BinaryAttrs to InterfaceFile assignment (#81551)
Create a helper method for this operation, so it can be reused in
multiple places.
Additonally move FileType enum into its own header to avoid include
cycles.
2024-02-12 16:15:21 -08:00
Cyndy Ishida
6eb7273b11
[readtapi] Ensure universal dylibs record the same input path location across slices (#80875)
resolves: https://github.com/llvm/llvm-project/issues/80868
2024-02-06 10:01:45 -08:00
Cyndy Ishida
7189219ec9
[readtapi] Add support for stubify-ing directories (#76885)
When given a directory input `llvm-readtapi` traverses through the
directory to find dylibs or tbd files to operate on. TBD files will be
created with the same base file name as the dylib. Symlinks should be
created if the input is one.

This also introduces options to delete input files which are defined as
library files that existed before `readtapi -stubify` was invoked. Also
the ability to delete private libraries where private libraries are in a
predefined file system locations on darwin based platforms.
2024-02-03 09:33:42 -08:00
Cyndy Ishida
4460fa8814
[TextAPI] Introduce granularity for handling ObjC Interface symbols (#79928)
ObjCInterfaceRecords roughly align to the objc-classes key in tbd-files.
They condensely represent up to 3 symbols. The problem here is that when
represented this way, we lose granularity when these symbols could have
different linkages or outright don't exist. This can happen frequently
in interoptable code generated by the swift compiler. This adds fields
and utility functions to express unique properties for these symbols. If
the record does represent the same properties across all of its symbols,
it will be treated the same in the TBD. Otherwise it will be printed in
global's section.

Reviewed seperately before by Juergen Ributzka
2024-01-29 18:36:48 -08:00
Cyndy Ishida
d9a9872ec4
[TextAPI] Rename SymbolKind to EncodeKind (#79622)
A distinction that doesn't _usually_ matter is that the
MachO::SymbolKind is really a mapping of entries in TBD files not
symbols. To better understand this, rename the enum so it represents an
encoding mapped to TBDs as opposed to symbols alone.

For example, it can be a bit confusing that "GlobalSymbol" is a enum
value when all of those values can represent a GlobalSymbol.
2024-01-26 16:12:50 -08:00
Cyndy Ishida
7d3466b5c3
[llvm] Introduce XROS platform (#77707)
Accepts but otherwise ignores visionOS/XROS target triples as Darwin
based platform.

https://developer.apple.com/documentation/visionos
2024-01-16 16:32:10 -08:00
Kazu Hirata
96f14ea618 [llvm] Use range-based for loops with llvm::drop_begin (NFC) 2024-01-13 18:18:47 -08:00
Cyndy Ishida
8ca0364d33
[TextAPI] Skip adding empty attributes (#77400)
An empty string attribute value (e.g. a parent-umbrella: "") is
equivalent to omitting it. Theres no reason to write it out.
2024-01-09 09:41:14 -08:00
Cyndy Ishida
8fa3184539
[TextAPI] Use function_ref where possible, NFCI (#76732) 2024-01-02 09:47:38 -08:00
Cyndy Ishida
c6f29dbb59
[readtapi] Setup simple stubify support (#76075)
Stubify broadly takes either tbd files or binary dylibs and turns them
into tbd files. In future patches, stubify will also allow additional
information to be embedded into the final TBD output too.

Add Util APIs to TextAPI for common operations used by readtapi for now.
2023-12-20 14:56:53 -08:00
Cyndy Ishida
5ea15fab19
[TextAPI] Add support to convert RecordSlices -> InterfaceFile (#75007)
Introduce RecordVisitor. This is used for different clients that want to
extract information out of RecordSlice types.
The first and immediate use case is for serializing symbol information
into TBD files.
2023-12-20 08:47:10 -08:00
Cyndy Ishida
e6ebe8bf81
[TextAPI] use unique sorted vector for holding target triples for (#75959)
reading dylibs

* This is a better fix than what I originally did to appease CI.
2023-12-19 14:49:57 -08:00
Cyndy Ishida
7ea7267cc5 [TextAPI] switch container for holding triples in dylib
Resolves buildbot failure reported on windows bot
2023-12-18 19:00:54 -08:00
Cyndy Ishida
e3627e2690
Reland '[TextAPI] Add DylibReader' (#75862)
> Add support for reading binary Mach-o dynamic libraries. It uses
libObject APIs for extracting information relevant to TAPI and tbd
files. This includes but is not limited to load commands encode data
like install names, current/compat versions, and symbols.

This originally broke because DylibReader uses Object and Object depends
on TextAPI. Breaking this up in a nested library prevents this cycle.
2023-12-18 16:55:30 -08:00
Cyndy Ishida
1fef0fac32 Revert "[TextAPI] Add missing link to libObject" and "[TextAPI] Add DylibReader (#75006)"
This reverts commit aa217eb04459039b5ff18b6b134020ed0248a241.
This reverts commit 634feddc84bfd402fc916d331627528c41346d8c.

This breaks buildbots by introducing cycle dependency between libObject
and TextAPI and breaks gcc compiles on buildbots.
2023-12-12 20:01:49 -08:00
Cyndy Ishida
aa217eb044 [TextAPI] Add missing link to libObject
* Reported in buildbot failures
2023-12-12 19:55:18 -08:00
Cyndy Ishida
634feddc84
[TextAPI] Add DylibReader (#75006)
Add support for reading binary Mach-o dynamic libraries. It uses
libObject APIs for extracting information relavant to TAPI and tbd
files. This includes but is not limited to load commands encode data
like install names, current/compat versions and symbols.
2023-12-12 19:50:24 -08:00
Kazu Hirata
586ecdf205
[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
2023-12-11 21:01:36 -08:00
Cyndy Ishida
b04b89753d
[TextAPI] Introduce Records & RecordSlice Types (#74115)
`Record`'s hold target triple specific information about APIs and
symbols. This holds information about the relationship between ObjC
symbols and their linkage properties. It will be used to compare and run
significant operations between the frontend representation of symbols in
AST and symbol information extracted from Mach-O binaries. This differs
from the lighter weight Symbol and SymbolSet class where they are
deduplicated across targets and only represent exported symbols, that
class is mostly used for serializing.
2023-12-02 13:19:01 -08:00