diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2024-02-12 16:15:21 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-12 16:15:21 -0800 |
commit | 3a080a0195ed21b8e12f825cfa00c8fa79f851a6 (patch) | |
tree | fd9e62afbb90a83982c0e89f0887374a16012045 /llvm/lib/TextAPI/InterfaceFile.cpp | |
parent | 644ac2a018c9bf83c9ba256074e552ad7f1fe941 (diff) | |
download | llvm-3a080a0195ed21b8e12f825cfa00c8fa79f851a6.zip llvm-3a080a0195ed21b8e12f825cfa00c8fa79f851a6.tar.gz llvm-3a080a0195ed21b8e12f825cfa00c8fa79f851a6.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/TextAPI/InterfaceFile.cpp')
-rw-r--r-- | llvm/lib/TextAPI/InterfaceFile.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp index d712ed3..9979df92 100644 --- a/llvm/lib/TextAPI/InterfaceFile.cpp +++ b/llvm/lib/TextAPI/InterfaceFile.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/TextAPI/InterfaceFile.h" +#include "llvm/TextAPI/RecordsSlice.h" #include "llvm/TextAPI/TextAPIError.h" #include <iomanip> #include <sstream> @@ -351,6 +352,34 @@ InterfaceFile::extract(Architecture Arch) const { return std::move(IF); } +void InterfaceFile::setFromBinaryAttrs(const RecordsSlice::BinaryAttrs &BA, + const Target &Targ) { + if (getFileType() != BA.File) + setFileType(BA.File); + if (getInstallName().empty()) + setInstallName(BA.InstallName); + if (BA.AppExtensionSafe && !isApplicationExtensionSafe()) + setApplicationExtensionSafe(); + if (BA.TwoLevelNamespace && !isTwoLevelNamespace()) + setTwoLevelNamespace(); + if (BA.OSLibNotForSharedCache && !isOSLibNotForSharedCache()) + setOSLibNotForSharedCache(); + if (getCurrentVersion().empty()) + setCurrentVersion(BA.CurrentVersion); + if (getCompatibilityVersion().empty()) + setCompatibilityVersion(BA.CompatVersion); + if (getSwiftABIVersion() == 0) + setSwiftABIVersion(BA.SwiftABI); + if (getPath().empty()) + setPath(BA.Path); + if (!BA.ParentUmbrella.empty()) + addParentUmbrella(Targ, BA.ParentUmbrella); + for (const auto &Client : BA.AllowableClients) + addAllowableClient(Client, Targ); + for (const auto &Lib : BA.RexportedLibraries) + addReexportedLibrary(Lib, Targ); +} + static bool isYAMLTextStub(const FileType &Kind) { return (Kind >= FileType::TBD_V1) && (Kind < FileType::TBD_V5); } |