Importing rustc-1.56.0 Change-Id: I98941481270706fa55f8fb2cb91686ae3bd30f38
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/Architecture.cpp b/src/llvm-project/llvm/lib/TextAPI/Architecture.cpp similarity index 89% rename from src/llvm-project/llvm/lib/TextAPI/MachO/Architecture.cpp rename to src/llvm-project/llvm/lib/TextAPI/Architecture.cpp index 0c59880..e1901d5 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/Architecture.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/Architecture.cpp
@@ -10,12 +10,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TextAPI/MachO/Architecture.h" +#include "llvm/TextAPI/Architecture.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" #include "llvm/BinaryFormat/MachO.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/TextAPI/MachO/ArchitectureSet.h" +#include "llvm/TextAPI/ArchitectureSet.h" namespace llvm { namespace MachO { @@ -25,7 +25,7 @@ if (CPUType == (Type) && \ (CPUSubType & ~MachO::CPU_SUBTYPE_MASK) == (Subtype)) \ return AK_##Arch; -#include "llvm/TextAPI/MachO/Architecture.def" +#include "llvm/TextAPI/Architecture.def" #undef ARCHINFO return AK_unknown; @@ -34,7 +34,7 @@ Architecture getArchitectureFromName(StringRef Name) { return StringSwitch<Architecture>(Name) #define ARCHINFO(Arch, Type, Subtype, NumBits) .Case(#Arch, AK_##Arch) -#include "llvm/TextAPI/MachO/Architecture.def" +#include "llvm/TextAPI/Architecture.def" #undef ARCHINFO .Default(AK_unknown); } @@ -44,7 +44,7 @@ #define ARCHINFO(Arch, Type, Subtype, NumBits) \ case AK_##Arch: \ return #Arch; -#include "llvm/TextAPI/MachO/Architecture.def" +#include "llvm/TextAPI/Architecture.def" #undef ARCHINFO case AK_unknown: return "unknown"; @@ -60,7 +60,7 @@ #define ARCHINFO(Arch, Type, Subtype, NumBits) \ case AK_##Arch: \ return std::make_pair(Type, Subtype); -#include "llvm/TextAPI/MachO/Architecture.def" +#include "llvm/TextAPI/Architecture.def" #undef ARCHINFO case AK_unknown: return std::make_pair(0, 0); @@ -80,7 +80,7 @@ #define ARCHINFO(Arch, Type, Subtype, NumBits) \ case AK_##Arch: \ return NumBits == 64; -#include "llvm/TextAPI/MachO/Architecture.def" +#include "llvm/TextAPI/Architecture.def" #undef ARCHINFO case AK_unknown: return false;
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp b/src/llvm-project/llvm/lib/TextAPI/ArchitectureSet.cpp similarity index 96% rename from src/llvm-project/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp rename to src/llvm-project/llvm/lib/TextAPI/ArchitectureSet.cpp index f665706..0fc2ede 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/ArchitectureSet.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/ArchitectureSet.cpp
@@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TextAPI/MachO/ArchitectureSet.h" +#include "llvm/TextAPI/ArchitectureSet.h" #include "llvm/Support/raw_ostream.h" namespace llvm {
diff --git a/src/llvm-project/llvm/lib/TextAPI/CMakeLists.txt b/src/llvm-project/llvm/lib/TextAPI/CMakeLists.txt index e0bf842..6dc3ccc 100644 --- a/src/llvm-project/llvm/lib/TextAPI/CMakeLists.txt +++ b/src/llvm-project/llvm/lib/TextAPI/CMakeLists.txt
@@ -1,18 +1,16 @@ add_llvm_component_library(LLVMTextAPI - MachO/Architecture.cpp - MachO/ArchitectureSet.cpp - MachO/InterfaceFile.cpp - MachO/PackedVersion.cpp - MachO/Platform.cpp - MachO/Symbol.cpp - MachO/Target.cpp - MachO/TextStub.cpp - MachO/TextStubCommon.cpp + Architecture.cpp + ArchitectureSet.cpp + InterfaceFile.cpp + PackedVersion.cpp + Platform.cpp + Symbol.cpp + Target.cpp + TextStub.cpp + TextStubCommon.cpp ADDITIONAL_HEADER_DIRS "${LLVM_MAIN_INCLUDE_DIR}/llvm/TextAPI" - "${LLVM_MAIN_INCLUDE_DIR}/llvm/TextAPI/Elf" - "${LLVM_MAIN_INCLUDE_DIR}/llvm/TextAPI/MachO" LINK_COMPONENTS Support
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/InterfaceFile.cpp b/src/llvm-project/llvm/lib/TextAPI/InterfaceFile.cpp similarity index 70% rename from src/llvm-project/llvm/lib/TextAPI/MachO/InterfaceFile.cpp rename to src/llvm-project/llvm/lib/TextAPI/InterfaceFile.cpp index cfc1c58..1156a39 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/InterfaceFile.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/InterfaceFile.cpp
@@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TextAPI/MachO/InterfaceFile.h" +#include "llvm/TextAPI/InterfaceFile.h" #include <iomanip> #include <sstream> @@ -117,3 +117,47 @@ for (const auto &Target : Targets) result.first->second->addTarget(Target); } + +void InterfaceFile::addDocument(std::shared_ptr<InterfaceFile> &&Document) { + auto Pos = llvm::lower_bound(Documents, Document, + [](const std::shared_ptr<InterfaceFile> &LHS, + const std::shared_ptr<InterfaceFile> &RHS) { + return LHS->InstallName < RHS->InstallName; + }); + Document->Parent = this; + Documents.insert(Pos, Document); +} + +bool InterfaceFile::operator==(const InterfaceFile &O) const { + if (Targets != O.Targets) + return false; + if (InstallName != O.InstallName) + return false; + if ((CurrentVersion != O.CurrentVersion) || + (CompatibilityVersion != O.CompatibilityVersion)) + return false; + if (SwiftABIVersion != O.SwiftABIVersion) + return false; + if (IsTwoLevelNamespace != O.IsTwoLevelNamespace) + return false; + if (IsAppExtensionSafe != O.IsAppExtensionSafe) + return false; + if (IsInstallAPI != O.IsInstallAPI) + return false; + if (ParentUmbrellas != O.ParentUmbrellas) + return false; + if (AllowableClients != O.AllowableClients) + return false; + if (ReexportedLibraries != O.ReexportedLibraries) + return false; + if (Symbols != O.Symbols) + return false; + if (!std::equal(Documents.begin(), Documents.end(), O.Documents.begin(), + O.Documents.end(), + [](const std::shared_ptr<InterfaceFile> LHS, + const std::shared_ptr<InterfaceFile> RHS) { + return *LHS == *RHS; + })) + return false; + return true; +}
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/Platform.cpp b/src/llvm-project/llvm/lib/TextAPI/MachO/Platform.cpp deleted file mode 100644 index f454c1c..0000000 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/Platform.cpp +++ /dev/null
@@ -1,93 +0,0 @@ -//===- llvm/TextAPI/MachO/Platform.cpp - Platform ---------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Implementations of Platform Helper functions. -// -//===----------------------------------------------------------------------===// - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/Triple.h" -#include "llvm/TextAPI/MachO/Platform.h" - -namespace llvm { -namespace MachO { - -PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim) { - switch (Platform) { - default: - return Platform; - case PlatformKind::iOS: - return WantSim ? PlatformKind::iOSSimulator : PlatformKind::iOS; - case PlatformKind::tvOS: - return WantSim ? PlatformKind::tvOSSimulator : PlatformKind::tvOS; - case PlatformKind::watchOS: - return WantSim ? PlatformKind::watchOSSimulator : PlatformKind::watchOS; - } - llvm_unreachable("Unknown llvm.MachO.PlatformKind enum"); -} - -PlatformKind mapToPlatformKind(const Triple &Target) { - switch (Target.getOS()) { - default: - return PlatformKind::unknown; - case Triple::MacOSX: - return PlatformKind::macOS; - case Triple::IOS: - if (Target.isSimulatorEnvironment()) - return PlatformKind::iOSSimulator; - if (Target.getEnvironment() == Triple::MacABI) - return PlatformKind::macCatalyst; - return PlatformKind::iOS; - case Triple::TvOS: - return Target.isSimulatorEnvironment() ? PlatformKind::tvOSSimulator - : PlatformKind::tvOS; - case Triple::WatchOS: - return Target.isSimulatorEnvironment() ? PlatformKind::watchOSSimulator - : PlatformKind::watchOS; - // TODO: add bridgeOS & driverKit once in llvm::Triple - } - llvm_unreachable("Unknown Target Triple"); -} - -PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets) { - PlatformSet Result; - for (const auto &Target : Targets) - Result.insert(mapToPlatformKind(Target)); - return Result; -} - -StringRef getPlatformName(PlatformKind Platform) { - switch (Platform) { - case PlatformKind::unknown: - return "unknown"; - case PlatformKind::macOS: - return "macOS"; - case PlatformKind::iOS: - return "iOS"; - case PlatformKind::tvOS: - return "tvOS"; - case PlatformKind::watchOS: - return "watchOS"; - case PlatformKind::bridgeOS: - return "bridgeOS"; - case PlatformKind::macCatalyst: - return "macCatalyst"; - case PlatformKind::iOSSimulator: - return "iOS Simulator"; - case PlatformKind::tvOSSimulator: - return "tvOS Simulator"; - case PlatformKind::watchOSSimulator: - return "watchOS Simulator"; - case PlatformKind::driverKit: - return "DriverKit"; - } - llvm_unreachable("Unknown llvm.MachO.PlatformKind enum"); -} - -} // end namespace MachO. -} // end namespace llvm.
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/PackedVersion.cpp b/src/llvm-project/llvm/lib/TextAPI/PackedVersion.cpp similarity index 98% rename from src/llvm-project/llvm/lib/TextAPI/MachO/PackedVersion.cpp rename to src/llvm-project/llvm/lib/TextAPI/PackedVersion.cpp index 8405aba..f8171e0 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/PackedVersion.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/PackedVersion.cpp
@@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TextAPI/MachO/PackedVersion.h" +#include "llvm/TextAPI/PackedVersion.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h"
diff --git a/src/llvm-project/llvm/lib/TextAPI/Platform.cpp b/src/llvm-project/llvm/lib/TextAPI/Platform.cpp new file mode 100644 index 0000000..a2ce6d0 --- /dev/null +++ b/src/llvm-project/llvm/lib/TextAPI/Platform.cpp
@@ -0,0 +1,138 @@ +//===- llvm/TextAPI/Platform.cpp - Platform ---------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Implementations of Platform Helper functions. +// +//===----------------------------------------------------------------------===// + +#include "llvm/TextAPI/Platform.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Triple.h" + +namespace llvm { +namespace MachO { + +PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim) { + switch (Platform) { + default: + return Platform; + case PlatformKind::iOS: + return WantSim ? PlatformKind::iOSSimulator : PlatformKind::iOS; + case PlatformKind::tvOS: + return WantSim ? PlatformKind::tvOSSimulator : PlatformKind::tvOS; + case PlatformKind::watchOS: + return WantSim ? PlatformKind::watchOSSimulator : PlatformKind::watchOS; + } + llvm_unreachable("Unknown llvm::MachO::PlatformKind enum"); +} + +PlatformKind mapToPlatformKind(const Triple &Target) { + switch (Target.getOS()) { + default: + return PlatformKind::unknown; + case Triple::MacOSX: + return PlatformKind::macOS; + case Triple::IOS: + if (Target.isSimulatorEnvironment()) + return PlatformKind::iOSSimulator; + if (Target.getEnvironment() == Triple::MacABI) + return PlatformKind::macCatalyst; + return PlatformKind::iOS; + case Triple::TvOS: + return Target.isSimulatorEnvironment() ? PlatformKind::tvOSSimulator + : PlatformKind::tvOS; + case Triple::WatchOS: + return Target.isSimulatorEnvironment() ? PlatformKind::watchOSSimulator + : PlatformKind::watchOS; + // TODO: add bridgeOS & driverKit once in llvm::Triple + } + llvm_unreachable("Unknown Target Triple"); +} + +PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets) { + PlatformSet Result; + for (const auto &Target : Targets) + Result.insert(mapToPlatformKind(Target)); + return Result; +} + +StringRef getPlatformName(PlatformKind Platform) { + switch (Platform) { + case PlatformKind::unknown: + return "unknown"; + case PlatformKind::macOS: + return "macOS"; + case PlatformKind::iOS: + return "iOS"; + case PlatformKind::tvOS: + return "tvOS"; + case PlatformKind::watchOS: + return "watchOS"; + case PlatformKind::bridgeOS: + return "bridgeOS"; + case PlatformKind::macCatalyst: + return "macCatalyst"; + case PlatformKind::iOSSimulator: + return "iOS Simulator"; + case PlatformKind::tvOSSimulator: + return "tvOS Simulator"; + case PlatformKind::watchOSSimulator: + return "watchOS Simulator"; + case PlatformKind::driverKit: + return "DriverKit"; + } + llvm_unreachable("Unknown llvm::MachO::PlatformKind enum"); +} + +PlatformKind getPlatformFromName(StringRef Name) { + return StringSwitch<PlatformKind>(Name) + .Case("macos", PlatformKind::macOS) + .Case("ios", PlatformKind::iOS) + .Case("tvos", PlatformKind::tvOS) + .Case("watchos", PlatformKind::watchOS) + .Case("bridgeos", PlatformKind::macOS) + .Case("ios-macabi", PlatformKind::macCatalyst) + .Case("ios-simulator", PlatformKind::iOSSimulator) + .Case("tvos-simulator", PlatformKind::tvOSSimulator) + .Case("watchos-simulator", PlatformKind::watchOSSimulator) + .Case("driverkit", PlatformKind::driverKit) + .Default(PlatformKind::unknown); +} + +std::string getOSAndEnvironmentName(PlatformKind Platform, + std::string Version) { + switch (Platform) { + case PlatformKind::unknown: + return "darwin" + Version; + case PlatformKind::macOS: + return "macos" + Version; + case PlatformKind::iOS: + return "ios" + Version; + case PlatformKind::tvOS: + return "tvos" + Version; + case PlatformKind::watchOS: + return "watchos" + Version; + case PlatformKind::bridgeOS: + return "bridgeos" + Version; + case PlatformKind::macCatalyst: + return "ios" + Version + "-macabi"; + case PlatformKind::iOSSimulator: + return "ios" + Version + "-simulator"; + case PlatformKind::tvOSSimulator: + return "tvos" + Version + "-simulator"; + case PlatformKind::watchOSSimulator: + return "watchos" + Version + "-simulator"; + case PlatformKind::driverKit: + return "driverkit" + Version; + } + llvm_unreachable("Unknown llvm::MachO::PlatformKind enum"); +} + +} // end namespace MachO. +} // end namespace llvm.
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/Symbol.cpp b/src/llvm-project/llvm/lib/TextAPI/Symbol.cpp similarity index 97% rename from src/llvm-project/llvm/lib/TextAPI/MachO/Symbol.cpp rename to src/llvm-project/llvm/lib/TextAPI/Symbol.cpp index 9f2d817..041f553 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/Symbol.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/Symbol.cpp
@@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TextAPI/MachO/Symbol.h" +#include "llvm/TextAPI/Symbol.h" #include <string> namespace llvm {
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/Target.cpp b/src/llvm-project/llvm/lib/TextAPI/Target.cpp similarity index 90% rename from src/llvm-project/llvm/lib/TextAPI/MachO/Target.cpp rename to src/llvm-project/llvm/lib/TextAPI/Target.cpp index 6f8d9bb..35fe1bf 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/Target.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/Target.cpp
@@ -1,4 +1,4 @@ -//===- tapi/Core/Target.cpp - Target ----------------------------*- C++ -*-===// +//===- Target.cpp -----------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// +#include "llvm/TextAPI/Target.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/TextAPI/MachO/Target.h" namespace llvm { namespace MachO { @@ -72,5 +72,11 @@ return Result; } +std::string getTargetTripleName(const Target &Targ) { + return (getArchitectureName(Targ.Arch) + "-apple-" + + getOSAndEnvironmentName(Targ.Platform)) + .str(); +} + } // end namespace MachO. } // end namespace llvm.
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/TextAPIContext.h b/src/llvm-project/llvm/lib/TextAPI/TextAPIContext.h similarity index 100% rename from src/llvm-project/llvm/lib/TextAPI/MachO/TextAPIContext.h rename to src/llvm-project/llvm/lib/TextAPI/TextAPIContext.h
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/TextStub.cpp b/src/llvm-project/llvm/lib/TextAPI/TextStub.cpp similarity index 98% rename from src/llvm-project/llvm/lib/TextAPI/MachO/TextStub.cpp rename to src/llvm-project/llvm/lib/TextAPI/TextStub.cpp index 1d6352b..5d85342 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/TextStub.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/TextStub.cpp
@@ -19,12 +19,12 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/TextAPI/MachO/Architecture.h" -#include "llvm/TextAPI/MachO/ArchitectureSet.h" -#include "llvm/TextAPI/MachO/InterfaceFile.h" -#include "llvm/TextAPI/MachO/PackedVersion.h" -#include "llvm/TextAPI/MachO/TextAPIReader.h" -#include "llvm/TextAPI/MachO/TextAPIWriter.h" +#include "llvm/TextAPI/Architecture.h" +#include "llvm/TextAPI/ArchitectureSet.h" +#include "llvm/TextAPI/InterfaceFile.h" +#include "llvm/TextAPI/PackedVersion.h" +#include "llvm/TextAPI/TextAPIReader.h" +#include "llvm/TextAPI/TextAPIWriter.h" #include <algorithm> #include <set> @@ -593,7 +593,7 @@ // platforms, specifically to filter out the i386 slice from // platform macCatalyst. TargetList synthesizeTargets(ArchitectureSet Architectures, - const PlatformSet &Platforms) { + const PlatformSet &Platforms) { TargetList Targets; for (auto Platform : Platforms) {
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/TextStubCommon.cpp b/src/llvm-project/llvm/lib/TextAPI/TextStubCommon.cpp similarity index 99% rename from src/llvm-project/llvm/lib/TextAPI/MachO/TextStubCommon.cpp rename to src/llvm-project/llvm/lib/TextAPI/TextStubCommon.cpp index 0d3614b..c2713b9 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/TextStubCommon.cpp +++ b/src/llvm-project/llvm/lib/TextAPI/TextStubCommon.cpp
@@ -134,7 +134,7 @@ ArchitectureSet &Archs) { #define ARCHINFO(arch, type, subtype, numbits) \ IO.bitSetCase(Archs, #arch, 1U << static_cast<int>(AK_##arch)); -#include "llvm/TextAPI/MachO/Architecture.def" +#include "llvm/TextAPI/Architecture.def" #undef ARCHINFO }
diff --git a/src/llvm-project/llvm/lib/TextAPI/MachO/TextStubCommon.h b/src/llvm-project/llvm/lib/TextAPI/TextStubCommon.h similarity index 93% rename from src/llvm-project/llvm/lib/TextAPI/MachO/TextStubCommon.h rename to src/llvm-project/llvm/lib/TextAPI/TextStubCommon.h index f2cda50..89ae5d5 100644 --- a/src/llvm-project/llvm/lib/TextAPI/MachO/TextStubCommon.h +++ b/src/llvm-project/llvm/lib/TextAPI/TextStubCommon.h
@@ -15,10 +15,10 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/YAMLTraits.h" -#include "llvm/TextAPI/MachO/Architecture.h" -#include "llvm/TextAPI/MachO/ArchitectureSet.h" -#include "llvm/TextAPI/MachO/InterfaceFile.h" -#include "llvm/TextAPI/MachO/PackedVersion.h" +#include "llvm/TextAPI/Architecture.h" +#include "llvm/TextAPI/ArchitectureSet.h" +#include "llvm/TextAPI/InterfaceFile.h" +#include "llvm/TextAPI/PackedVersion.h" using UUID = std::pair<llvm::MachO::Target, std::string>;