Update prebuilt Clang to r416183b from Android.

https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef

clang 12.0.5 (based on r416183b) from build 7284624.

Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.def b/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.def
index 4c695fe..2fcae3b 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.def
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.def
@@ -13,26 +13,27 @@
 ///
 /// X86 architectures sorted by cpu type and sub type id.
 ///
-ARCHINFO(i386, MachO::CPU_TYPE_I386, MachO::CPU_SUBTYPE_I386_ALL)
-ARCHINFO(x86_64, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_ALL)
-ARCHINFO(x86_64h, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_H)
+ARCHINFO(i386, MachO::CPU_TYPE_I386, MachO::CPU_SUBTYPE_I386_ALL, 32)
+ARCHINFO(x86_64, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_ALL, 64)
+ARCHINFO(x86_64h, MachO::CPU_TYPE_X86_64, MachO::CPU_SUBTYPE_X86_64_H, 64)
 
 
 ///
 /// ARM architectures sorted by cpu sub type id.
 ///
-ARCHINFO(armv4t, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V4T)
-ARCHINFO(armv6, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6)
-ARCHINFO(armv5, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V5TEJ)
-ARCHINFO(armv7, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7)
-ARCHINFO(armv7s, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7S)
-ARCHINFO(armv7k, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7K)
-ARCHINFO(armv6m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6M)
-ARCHINFO(armv7m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7M)
-ARCHINFO(armv7em, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7EM)
+ARCHINFO(armv4t, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V4T, 32)
+ARCHINFO(armv6, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6, 32)
+ARCHINFO(armv5, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V5TEJ, 32)
+ARCHINFO(armv7, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7, 32)
+ARCHINFO(armv7s, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7S, 32)
+ARCHINFO(armv7k, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7K, 32)
+ARCHINFO(armv6m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V6M, 32)
+ARCHINFO(armv7m, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7M, 32)
+ARCHINFO(armv7em, MachO::CPU_TYPE_ARM, MachO::CPU_SUBTYPE_ARM_V7EM, 32)
 
 
 ///
 /// ARM64 architectures sorted by cpu sub type id.
 ///
-ARCHINFO(arm64, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64_ALL)
+ARCHINFO(arm64, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64_ALL, 64)
+ARCHINFO(arm64e, MachO::CPU_TYPE_ARM64, MachO::CPU_SUBTYPE_ARM64E, 64)
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.h b/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.h
index 055baeb..7a9f951 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/Architecture.h
@@ -13,15 +13,19 @@
 #ifndef LLVM_TEXTAPI_MACHO_ARCHITECTURE_H
 #define LLVM_TEXTAPI_MACHO_ARCHITECTURE_H
 
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/raw_ostream.h"
+#include <cstdint>
+#include <utility>
 
 namespace llvm {
+class raw_ostream;
+class StringRef;
+class Triple;
+
 namespace MachO {
 
 /// Defines the architecture slices that are supported by Text-based Stub files.
 enum Architecture : uint8_t {
-#define ARCHINFO(Arch, Type, SubType) AK_##Arch,
+#define ARCHINFO(Arch, Type, SubType, NumBits) AK_##Arch,
 #include "llvm/TextAPI/MachO/Architecture.def"
 #undef ARCHINFO
   AK_unknown, // this has to go last.
@@ -39,6 +43,12 @@
 /// Convert an architecture slice to a CPU Type and Subtype pair.
 std::pair<uint32_t, uint32_t> getCPUTypeFromArchitecture(Architecture Arch);
 
+/// Convert a target to an architecture slice.
+Architecture mapToArchitecture(const llvm::Triple &Target);
+
+/// Check if architecture is 64 bit.
+bool is64Bit(Architecture);
+
 raw_ostream &operator<<(raw_ostream &OS, Architecture Arch);
 
 } // end namespace MachO.
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/ArchitectureSet.h b/linux-x64/clang/include/llvm/TextAPI/MachO/ArchitectureSet.h
index d8dfc7f..c48a4a7 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/ArchitectureSet.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/ArchitectureSet.h
@@ -13,14 +13,17 @@
 #ifndef LLVM_TEXTAPI_MACHO_ARCHITECTURE_SET_H
 #define LLVM_TEXTAPI_MACHO_ARCHITECTURE_SET_H
 
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/TextAPI/MachO/Architecture.h"
 #include <cstddef>
 #include <iterator>
 #include <limits>
+#include <string>
+#include <tuple>
 #include <vector>
 
 namespace llvm {
+class raw_ostream;
+
 namespace MachO {
 
 class ArchitectureSet {
@@ -59,6 +62,10 @@
 
   ArchSetType rawValue() const { return ArchSet; }
 
+  bool hasX86() const {
+    return has(AK_i386) || has(AK_x86_64) || has(AK_x86_64h);
+  }
+
   template <typename Ty>
   class arch_iterator
       : public std::iterator<std::forward_iterator_tag, Architecture, size_t> {
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/InterfaceFile.h b/linux-x64/clang/include/llvm/TextAPI/MachO/InterfaceFile.h
index e722449..09d2b8c 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/InterfaceFile.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/InterfaceFile.h
@@ -26,21 +26,13 @@
 #include "llvm/TextAPI/MachO/Architecture.h"
 #include "llvm/TextAPI/MachO/ArchitectureSet.h"
 #include "llvm/TextAPI/MachO/PackedVersion.h"
+#include "llvm/TextAPI/MachO/Platform.h"
 #include "llvm/TextAPI/MachO/Symbol.h"
+#include "llvm/TextAPI/MachO/Target.h"
 
 namespace llvm {
 namespace MachO {
 
-/// Defines the list of MachO platforms.
-enum class PlatformKind : unsigned {
-  unknown,
-  macOS = MachO::PLATFORM_MACOS,
-  iOS = MachO::PLATFORM_IOS,
-  tvOS = MachO::PLATFORM_TVOS,
-  watchOS = MachO::PLATFORM_WATCHOS,
-  bridgeOS = MachO::PLATFORM_BRIDGEOS,
-};
-
 /// Defines a list of Objective-C constraints.
 enum class ObjCConstraintType : unsigned {
   /// No constraint.
@@ -75,6 +67,9 @@
   /// Text-based stub file (.tbd) version 3.0
   TBD_V3  = 1U <<  2,
 
+  /// Text-based stub file (.tbd) version 4.0
+  TBD_V4  = 1U <<  3,
+
   All     = ~0U,
 
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/All),
@@ -89,29 +84,42 @@
 
   InterfaceFileRef(StringRef InstallName) : InstallName(InstallName) {}
 
-  InterfaceFileRef(StringRef InstallName, ArchitectureSet Archs)
-      : InstallName(InstallName), Architectures(Archs) {}
+  InterfaceFileRef(StringRef InstallName, const TargetList Targets)
+      : InstallName(InstallName), Targets(std::move(Targets)) {}
 
   StringRef getInstallName() const { return InstallName; };
-  void addArchitectures(ArchitectureSet Archs) { Architectures |= Archs; }
-  ArchitectureSet getArchitectures() const { return Architectures; }
-  bool hasArchitecture(Architecture Arch) const {
-    return Architectures.has(Arch);
+
+  void addTarget(const Target &Target);
+  template <typename RangeT> void addTargets(RangeT &&Targets) {
+    for (const auto &Target : Targets)
+      addTarget(Target(Target));
   }
 
+  using const_target_iterator = TargetList::const_iterator;
+  using const_target_range = llvm::iterator_range<const_target_iterator>;
+  const_target_range targets() const { return {Targets}; }
+
+  ArchitectureSet getArchitectures() const {
+    return mapToArchitectureSet(Targets);
+  }
+
+  PlatformSet getPlatforms() const { return mapToPlatformSet(Targets); }
+
   bool operator==(const InterfaceFileRef &O) const {
-    return std::tie(InstallName, Architectures) ==
-           std::tie(O.InstallName, O.Architectures);
+    return std::tie(InstallName, Targets) == std::tie(O.InstallName, O.Targets);
+  }
+
+  bool operator!=(const InterfaceFileRef &O) const {
+    return std::tie(InstallName, Targets) != std::tie(O.InstallName, O.Targets);
   }
 
   bool operator<(const InterfaceFileRef &O) const {
-    return std::tie(InstallName, Architectures) <
-           std::tie(O.InstallName, O.Architectures);
+    return std::tie(InstallName, Targets) < std::tie(O.InstallName, O.Targets);
   }
 
 private:
   std::string InstallName;
-  ArchitectureSet Architectures;
+  TargetList Targets;
 };
 
 } // end namespace MachO.
@@ -150,7 +158,7 @@
   /// Set the path from which this file was generated (if applicable).
   ///
   /// \param Path_ The path to the source file.
-  void setPath(StringRef Path_) { Path = Path_; }
+  void setPath(StringRef Path_) { Path = std::string(Path_); }
 
   /// Get the path from which this file was generated (if applicable).
   ///
@@ -170,30 +178,48 @@
   /// \return The file type.
   FileType getFileType() const { return FileKind; }
 
-  /// Set the platform.
-  void setPlatform(PlatformKind Platform_) { Platform = Platform_; }
-
-  /// Get the platform.
-  PlatformKind getPlatform() const { return Platform; }
-
-  /// Specify the set of supported architectures by this file.
-  void setArchitectures(ArchitectureSet Architectures_) {
-    Architectures = Architectures_;
+  /// Get the architectures.
+  ///
+  /// \return The applicable architectures.
+  ArchitectureSet getArchitectures() const {
+    return mapToArchitectureSet(Targets);
   }
 
-  /// Add the set of supported architectures by this file.
-  void addArchitectures(ArchitectureSet Architectures_) {
-    Architectures |= Architectures_;
+  /// Get the platforms.
+  ///
+  /// \return The applicable platforms.
+  PlatformSet getPlatforms() const { return mapToPlatformSet(Targets); }
+
+  /// Set and add target.
+  ///
+  /// \param Target the target to add into.
+  void addTarget(const Target &Target);
+
+  /// Set and add targets.
+  ///
+  /// Add the subset of llvm::triples that is supported by Tapi
+  ///
+  /// \param Targets the collection of targets.
+  template <typename RangeT> void addTargets(RangeT &&Targets) {
+    for (const auto &Target_ : Targets)
+      addTarget(Target(Target_));
   }
 
-  /// Add supported architecture by this file..
-  void addArch(Architecture Arch) { Architectures.set(Arch); }
+  using const_target_iterator = TargetList::const_iterator;
+  using const_target_range = llvm::iterator_range<const_target_iterator>;
+  const_target_range targets() const { return {Targets}; }
 
-  /// Get the set of supported architectures.
-  ArchitectureSet getArchitectures() const { return Architectures; }
+  using const_filtered_target_iterator =
+      llvm::filter_iterator<const_target_iterator,
+                            std::function<bool(const Target &)>>;
+  using const_filtered_target_range =
+      llvm::iterator_range<const_filtered_target_iterator>;
+  const_filtered_target_range targets(ArchitectureSet Archs) const;
 
   /// Set the install name of the library.
-  void setInstallName(StringRef InstallName_) { InstallName = InstallName_; }
+  void setInstallName(StringRef InstallName_) {
+    InstallName = std::string(InstallName_);
+  }
 
   /// Get the install name of the library.
   StringRef getInstallName() const { return InstallName; }
@@ -244,11 +270,18 @@
   /// Check if this file was generated during InstallAPI.
   bool isInstallAPI() const { return IsInstallAPI; }
 
-  /// Set the parent umbrella framework.
-  void setParentUmbrella(StringRef Parent) { ParentUmbrella = Parent; }
+  /// Set the parent umbrella frameworks.
+  /// \param Target_ The target applicable to Parent
+  /// \param Parent  The name of Parent
+  void addParentUmbrella(const Target &Target_, StringRef Parent);
 
-  /// Get the parent umbrella framework.
-  StringRef getParentUmbrella() const { return ParentUmbrella; }
+  /// Get the list of Parent Umbrella frameworks.
+  ///
+  /// \return Returns a list of target information and install name of parent
+  /// umbrellas.
+  const std::vector<std::pair<Target, std::string>> &umbrellas() const {
+    return ParentUmbrellas;
+  }
 
   /// Add an allowable client.
   ///
@@ -257,9 +290,9 @@
   /// that is being generated needs to match one of the allowable clients or the
   /// linker refuses to link this library.
   ///
-  /// \param Name The name of the client that is allowed to link this library.
-  /// \param Architectures The set of architecture for which this applies.
-  void addAllowableClient(StringRef Name, ArchitectureSet Architectures);
+  /// \param InstallName The name of the client that is allowed to link this library.
+  /// \param Target The target triple for which this applies.
+  void addAllowableClient(StringRef InstallName, const Target &Target);
 
   /// Get the list of allowable clients.
   ///
@@ -271,9 +304,8 @@
   /// Add a re-exported library.
   ///
   /// \param InstallName The name of the library to re-export.
-  /// \param Architectures The set of architecture for which this applies.
-  void addReexportedLibrary(StringRef InstallName,
-                            ArchitectureSet Architectures);
+  /// \param Target The target triple for which this applies.
+  void addReexportedLibrary(StringRef InstallName, const Target &Target);
 
   /// Get the list of re-exported libraries.
   ///
@@ -282,27 +314,41 @@
     return ReexportedLibraries;
   }
 
-  /// Add an architecture/UUID pair.
+  /// Add an Target/UUID pair.
   ///
-  /// \param Arch The architecture for which this applies.
+  /// \param Target The target triple for which this applies.
   /// \param UUID The UUID of the library for the specified architecture.
-  void addUUID(Architecture Arch, StringRef UUID);
+  void addUUID(const Target &Target, StringRef UUID);
 
-  /// Add an architecture/UUID pair.
+  /// Add an Target/UUID pair.
   ///
-  /// \param Arch The architecture for which this applies.
+  /// \param Target The target triple for which this applies.
   /// \param UUID The UUID of the library for the specified architecture.
-  void addUUID(Architecture Arch, uint8_t UUID[16]);
+  void addUUID(const Target &Target, uint8_t UUID[16]);
 
-  /// Get the list of architecture/UUID pairs.
+  /// Get the list of Target/UUID pairs.
   ///
-  /// \return Returns a list of architecture/UUID pairs.
-  const std::vector<std::pair<Architecture, std::string>> &uuids() const {
+  /// \return Returns a list of Target/UUID pairs.
+  const std::vector<std::pair<Target, std::string>> &uuids() const {
     return UUIDs;
   }
 
+  /// Add a library for inlining to top level library.
+  ///
+  ///\param Document The library to inline with top level library.
+  void addDocument(std::shared_ptr<InterfaceFile> &&Document) {
+    Documents.emplace_back(std::move(Document));
+  }
+
+  /// Get the list of inlined libraries.
+  ///
+  /// \return Returns a list of the inlined frameworks.
+  const std::vector<std::shared_ptr<InterfaceFile>> &documents() const {
+    return Documents;
+  }
+
   /// Add a symbol to the symbols list or extend an existing one.
-  void addSymbol(SymbolKind Kind, StringRef Name, ArchitectureSet Architectures,
+  void addSymbol(SymbolKind Kind, StringRef Name, const TargetList &Targets,
                  SymbolFlags Flags = SymbolFlags::None);
 
   using SymbolMapType = DenseMap<SymbolsMapKey, Symbol *>;
@@ -320,84 +366,35 @@
     reference operator*() const { return I->second; }
     pointer operator->() const { return I->second; }
   };
+
   using const_symbol_range = iterator_range<const_symbol_iterator>;
 
-  // Custom iterator to return only exported symbols.
-  struct const_export_iterator
-      : public iterator_adaptor_base<
-            const_export_iterator, const_symbol_iterator,
-            std::forward_iterator_tag, const Symbol *> {
-    const_symbol_iterator _end;
-
-    void skipToNextSymbol() {
-      while (I != _end && I->isUndefined())
-        ++I;
-    }
-
-    const_export_iterator() = default;
-    template <typename U>
-    const_export_iterator(U &&it, U &&end)
-        : iterator_adaptor_base(std::forward<U &&>(it)),
-          _end(std::forward<U &&>(end)) {
-      skipToNextSymbol();
-    }
-
-    const_export_iterator &operator++() {
-      ++I;
-      skipToNextSymbol();
-      return *this;
-    }
-
-    const_export_iterator operator++(int) {
-      const_export_iterator tmp(*this);
-      ++(*this);
-      return tmp;
-    }
-  };
-  using const_export_range = llvm::iterator_range<const_export_iterator>;
-
-  // Custom iterator to return only undefined symbols.
-  struct const_undefined_iterator
-      : public iterator_adaptor_base<
-            const_undefined_iterator, const_symbol_iterator,
-            std::forward_iterator_tag, const Symbol *> {
-    const_symbol_iterator _end;
-
-    void skipToNextSymbol() {
-      while (I != _end && !I->isUndefined())
-        ++I;
-    }
-
-    const_undefined_iterator() = default;
-    template <typename U>
-    const_undefined_iterator(U &&it, U &&end)
-        : iterator_adaptor_base(std::forward<U &&>(it)),
-          _end(std::forward<U &&>(end)) {
-      skipToNextSymbol();
-    }
-
-    const_undefined_iterator &operator++() {
-      ++I;
-      skipToNextSymbol();
-      return *this;
-    }
-
-    const_undefined_iterator operator++(int) {
-      const_undefined_iterator tmp(*this);
-      ++(*this);
-      return tmp;
-    }
-  };
-  using const_undefined_range = llvm::iterator_range<const_undefined_iterator>;
+  using const_filtered_symbol_iterator =
+      filter_iterator<const_symbol_iterator,
+                      std::function<bool(const Symbol *)>>;
+  using const_filtered_symbol_range =
+      iterator_range<const_filtered_symbol_iterator>;
 
   const_symbol_range symbols() const {
     return {Symbols.begin(), Symbols.end()};
   }
-  const_export_range exports() const {
-    return {{Symbols.begin(), Symbols.end()}, {Symbols.end(), Symbols.end()}};
+
+  const_filtered_symbol_range exports() const {
+    std::function<bool(const Symbol *)> fn = [](const Symbol *Symbol) {
+      return !Symbol->isUndefined();
+    };
+    return make_filter_range(
+        make_range<const_symbol_iterator>({Symbols.begin()}, {Symbols.end()}),
+        fn);
   }
-  const_undefined_range undefineds() const {
-    return {{Symbols.begin(), Symbols.end()}, {Symbols.end(), Symbols.end()}};
+
+  const_filtered_symbol_range undefineds() const {
+    std::function<bool(const Symbol *)> fn = [](const Symbol *Symbol) {
+      return Symbol->isUndefined();
+    };
+    return make_filter_range(
+        make_range<const_symbol_iterator>({Symbols.begin()}, {Symbols.end()}),
+        fn);
   }
 
 private:
@@ -411,10 +408,9 @@
     return StringRef(reinterpret_cast<const char *>(Ptr), String.size());
   }
 
+  TargetList Targets;
   std::string Path;
   FileType FileKind;
-  PlatformKind Platform;
-  ArchitectureSet Architectures;
   std::string InstallName;
   PackedVersion CurrentVersion;
   PackedVersion CompatibilityVersion;
@@ -423,10 +419,11 @@
   bool IsAppExtensionSafe{false};
   bool IsInstallAPI{false};
   ObjCConstraintType ObjcConstraint = ObjCConstraintType::None;
-  std::string ParentUmbrella;
+  std::vector<std::pair<Target, std::string>> ParentUmbrellas;
   std::vector<InterfaceFileRef> AllowableClients;
   std::vector<InterfaceFileRef> ReexportedLibraries;
-  std::vector<std::pair<Architecture, std::string>> UUIDs;
+  std::vector<std::shared_ptr<InterfaceFile>> Documents;
+  std::vector<std::pair<Target, std::string>> UUIDs;
   SymbolMapType Symbols;
 };
 
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/PackedVersion.h b/linux-x64/clang/include/llvm/TextAPI/MachO/PackedVersion.h
index 2d01380..0d9158a 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/PackedVersion.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/PackedVersion.h
@@ -13,10 +13,13 @@
 #ifndef LLVM_TEXTAPI_MACHO_PACKED_VERSION_H
 #define LLVM_TEXTAPI_MACHO_PACKED_VERSION_H
 
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/raw_ostream.h"
+#include <cstdint>
+#include <utility>
 
 namespace llvm {
+class raw_ostream;
+class StringRef;
+
 namespace MachO {
 
 class PackedVersion {
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/Platform.h b/linux-x64/clang/include/llvm/TextAPI/MachO/Platform.h
new file mode 100644
index 0000000..fc59b86
--- /dev/null
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/Platform.h
@@ -0,0 +1,46 @@
+//===- llvm/TextAPI/MachO/Platform.h - 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines the Platforms supported by Tapi and helpers.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TEXTAPI_MACHO_PLATFORM_H
+#define LLVM_TEXTAPI_MACHO_PLATFORM_H
+
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/BinaryFormat/MachO.h"
+
+namespace llvm {
+namespace MachO {
+
+/// Defines the list of MachO platforms.
+enum class PlatformKind : unsigned {
+  unknown,
+  macOS = MachO::PLATFORM_MACOS,
+  iOS = MachO::PLATFORM_IOS,
+  tvOS = MachO::PLATFORM_TVOS,
+  watchOS = MachO::PLATFORM_WATCHOS,
+  bridgeOS = MachO::PLATFORM_BRIDGEOS,
+  macCatalyst = MachO::PLATFORM_MACCATALYST,
+  iOSSimulator = MachO::PLATFORM_IOSSIMULATOR,
+  tvOSSimulator = MachO::PLATFORM_TVOSSIMULATOR,
+  watchOSSimulator = MachO::PLATFORM_WATCHOSSIMULATOR,
+  driverKit = MachO::PLATFORM_DRIVERKIT,
+};
+
+using PlatformSet = SmallSet<PlatformKind, 3>;
+
+PlatformKind mapToPlatformKind(PlatformKind Platform, bool WantSim);
+PlatformKind mapToPlatformKind(const Triple &Target);
+PlatformSet mapToPlatformSet(ArrayRef<Triple> Targets);
+StringRef getPlatformName(PlatformKind Platform);
+
+} // end namespace MachO.
+} // end namespace llvm.
+
+#endif // LLVM_TEXTAPI_MACHO_PLATFORM_H
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/Symbol.h b/linux-x64/clang/include/llvm/TextAPI/MachO/Symbol.h
index 3c7ff5e..1b1632c 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/Symbol.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/Symbol.h
@@ -14,6 +14,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TextAPI/MachO/ArchitectureSet.h"
+#include "llvm/TextAPI/MachO/Target.h"
 
 namespace llvm {
 namespace MachO {
@@ -37,7 +38,10 @@
   /// Undefined
   Undefined        = 1U << 3,
 
-  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Undefined),
+  /// Rexported
+  Rexported        = 1U << 4,
+
+  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Rexported),
 };
 
 // clang-format on
@@ -49,16 +53,18 @@
   ObjectiveCInstanceVariable,
 };
 
+using TargetList = SmallVector<Target, 5>;
 class Symbol {
 public:
-  constexpr Symbol(SymbolKind Kind, StringRef Name,
-                   ArchitectureSet Architectures, SymbolFlags Flags)
-      : Name(Name), Architectures(Architectures), Kind(Kind), Flags(Flags) {}
+  Symbol(SymbolKind Kind, StringRef Name, TargetList Targets, SymbolFlags Flags)
+      : Name(Name), Targets(std::move(Targets)), Kind(Kind), Flags(Flags) {}
 
+  void addTarget(Target target) { Targets.emplace_back(target); }
   SymbolKind getKind() const { return Kind; }
   StringRef getName() const { return Name; }
-  ArchitectureSet getArchitectures() const { return Architectures; }
-  void addArchitectures(ArchitectureSet Archs) { Architectures |= Archs; }
+  ArchitectureSet getArchitectures() const {
+    return mapToArchitectureSet(Targets);
+  }
   SymbolFlags getFlags() const { return Flags; }
 
   bool isWeakDefined() const {
@@ -78,6 +84,21 @@
     return (Flags & SymbolFlags::Undefined) == SymbolFlags::Undefined;
   }
 
+  bool isReexported() const {
+    return (Flags & SymbolFlags::Rexported) == SymbolFlags::Rexported;
+  }
+
+  using const_target_iterator = TargetList::const_iterator;
+  using const_target_range = llvm::iterator_range<const_target_iterator>;
+  const_target_range targets() const { return {Targets}; }
+
+  using const_filtered_target_iterator =
+      llvm::filter_iterator<const_target_iterator,
+                            std::function<bool(const Target &)>>;
+  using const_filtered_target_range =
+      llvm::iterator_range<const_filtered_target_iterator>;
+  const_filtered_target_range targets(ArchitectureSet architectures) const;
+
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   void dump(raw_ostream &OS) const;
   void dump() const { dump(llvm::errs()); }
@@ -85,7 +106,7 @@
 
 private:
   StringRef Name;
-  ArchitectureSet Architectures;
+  TargetList Targets;
   SymbolKind Kind;
   SymbolFlags Flags;
 };
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/Target.h b/linux-x64/clang/include/llvm/TextAPI/MachO/Target.h
new file mode 100644
index 0000000..5fe44cb
--- /dev/null
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/Target.h
@@ -0,0 +1,68 @@
+//===- llvm/TextAPI/Target.h - TAPI Target ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TEXTAPI_MACHO_TARGET_H
+#define LLVM_TEXTAPI_MACHO_TARGET_H
+
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Error.h"
+#include "llvm/TextAPI/MachO/Architecture.h"
+#include "llvm/TextAPI/MachO/ArchitectureSet.h"
+#include "llvm/TextAPI/MachO/Platform.h"
+
+namespace llvm {
+namespace MachO {
+
+// This is similar to a llvm Triple, but the triple doesn't have all the
+// information we need. For example there is no enum value for x86_64h. The
+// only way to get that information is to parse the triple string.
+class Target {
+public:
+  Target() = default;
+  Target(Architecture Arch, PlatformKind Platform)
+      : Arch(Arch), Platform(Platform) {}
+  explicit Target(const llvm::Triple &Triple)
+      : Arch(mapToArchitecture(Triple)), Platform(mapToPlatformKind(Triple)) {}
+
+  static llvm::Expected<Target> create(StringRef Target);
+
+  operator std::string() const;
+
+  Architecture Arch;
+  PlatformKind Platform;
+};
+
+inline bool operator==(const Target &LHS, const Target &RHS) {
+  return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
+}
+
+inline bool operator!=(const Target &LHS, const Target &RHS) {
+  return std::tie(LHS.Arch, LHS.Platform) != std::tie(RHS.Arch, RHS.Platform);
+}
+
+inline bool operator<(const Target &LHS, const Target &RHS) {
+  return std::tie(LHS.Arch, LHS.Platform) < std::tie(RHS.Arch, RHS.Platform);
+}
+
+inline bool operator==(const Target &LHS, const Architecture &RHS) {
+  return LHS.Arch == RHS;
+}
+
+inline bool operator!=(const Target &LHS, const Architecture &RHS) {
+  return LHS.Arch != RHS;
+}
+
+PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
+ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
+
+raw_ostream &operator<<(raw_ostream &OS, const Target &Target);
+
+} // namespace MachO
+} // namespace llvm
+
+#endif // LLVM_TEXTAPI_MACHO_TARGET_H
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIReader.h b/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIReader.h
index 6d9c09d..889b8aa 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIReader.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIReader.h
@@ -10,9 +10,11 @@
 #define LLVM_TEXTAPI_MACHO_READER_H
 
 #include "llvm/Support/Error.h"
-#include "llvm/Support/MemoryBuffer.h"
 
 namespace llvm {
+
+class MemoryBufferRef;
+
 namespace MachO {
 
 class InterfaceFile;
@@ -20,10 +22,7 @@
 class TextAPIReader {
 public:
   static Expected<std::unique_ptr<InterfaceFile>>
-  get(std::unique_ptr<MemoryBuffer> InputBuffer);
-
-  static Expected<std::unique_ptr<InterfaceFile>>
-  getUnmanaged(llvm::MemoryBuffer *InputBuffer);
+  get(MemoryBufferRef InputBuffer);
 
   TextAPIReader() = delete;
 };
diff --git a/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIWriter.h b/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIWriter.h
index 2a45bb8..109ac8e 100644
--- a/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIWriter.h
+++ b/linux-x64/clang/include/llvm/TextAPI/MachO/TextAPIWriter.h
@@ -9,9 +9,11 @@
 #ifndef LLVM_TEXTAPI_MACHO_WRITER_H
 #define LLVM_TEXTAPI_MACHO_WRITER_H
 
-#include "llvm/Support/MemoryBuffer.h"
-
 namespace llvm {
+
+class Error;
+class raw_ostream;
+
 namespace MachO {
 
 class InterfaceFile;