From 3a080a0195ed21b8e12f825cfa00c8fa79f851a6 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Mon, 12 Feb 2024 16:15:21 -0800 Subject: [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. --- llvm/lib/TextAPI/InterfaceFile.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'llvm/lib/TextAPI/InterfaceFile.cpp') 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 #include @@ -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); } -- cgit v1.1