[llvm] 7de8cd6 - [llvm][TextAPI] only compare deployment version for InterfaceFile.

Cyndy Ishida via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 1 08:39:01 PDT 2023


Author: Cyndy Ishida
Date: 2023-04-01T08:38:30-07:00
New Revision: 7de8cd617b6980e0881a84e3dbfda94c3227e98a

URL: https://github.com/llvm/llvm-project/commit/7de8cd617b6980e0881a84e3dbfda94c3227e98a
DIFF: https://github.com/llvm/llvm-project/commit/7de8cd617b6980e0881a84e3dbfda94c3227e98a.diff

LOG: [llvm][TextAPI] only compare deployment version for InterfaceFile.

Added: 
    

Modified: 
    llvm/include/llvm/TextAPI/Platform.h
    llvm/include/llvm/TextAPI/Target.h
    llvm/lib/TextAPI/InterfaceFile.cpp
    llvm/lib/TextAPI/Target.cpp
    llvm/tools/llvm-tapi-diff/DiffEngine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/TextAPI/Platform.h b/llvm/include/llvm/TextAPI/Platform.h
index 834f833306d1b..d828d9ac49f65 100644
--- a/llvm/include/llvm/TextAPI/Platform.h
+++ b/llvm/include/llvm/TextAPI/Platform.h
@@ -20,6 +20,7 @@ namespace llvm {
 namespace MachO {
 
 using PlatformSet = SmallSet<PlatformType, 3>;
+using PlatformVersionSet = SmallSet<std::pair<PlatformType, VersionTuple>, 3>;
 
 PlatformType mapToPlatformType(PlatformType Platform, bool WantSim);
 PlatformType mapToPlatformType(const Triple &Target);

diff  --git a/llvm/include/llvm/TextAPI/Target.h b/llvm/include/llvm/TextAPI/Target.h
index 87895a9e412f3..c8a1c4f269d5f 100644
--- a/llvm/include/llvm/TextAPI/Target.h
+++ b/llvm/include/llvm/TextAPI/Target.h
@@ -45,12 +45,8 @@ class Target {
 };
 
 inline bool operator==(const Target &LHS, const Target &RHS) {
-  bool CrossLinkMatch =
-      std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
-  // Ignore potential mismatches due to missing deployment versions.
-  if (LHS.MinDeployment.empty() || RHS.MinDeployment.empty())
-    return CrossLinkMatch;
-  return CrossLinkMatch && LHS.MinDeployment == RHS.MinDeployment;
+  // In most cases the deployment version is not useful to compare.
+  return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
 }
 
 inline bool operator!=(const Target &LHS, const Target &RHS) {
@@ -70,6 +66,7 @@ inline bool operator!=(const Target &LHS, const Architecture &RHS) {
   return LHS.Arch != RHS;
 }
 
+PlatformVersionSet mapToPlatformVersionSet(ArrayRef<Target> Targets);
 PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
 ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
 

diff  --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp
index 5d3cf851dadc8..8c0b65916026e 100644
--- a/llvm/lib/TextAPI/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/InterfaceFile.cpp
@@ -174,6 +174,8 @@ bool InterfaceFile::operator==(const InterfaceFile &O) const {
   if (!(isYAMLTextStub(FileKind)) && !(isYAMLTextStub(O.FileKind))) {
     if (RPaths != O.RPaths)
       return false;
+    if (mapToPlatformVersionSet(Targets) != mapToPlatformVersionSet(O.Targets))
+      return false;
   }
 
   if (!std::equal(Documents.begin(), Documents.end(), O.Documents.begin(),

diff  --git a/llvm/lib/TextAPI/Target.cpp b/llvm/lib/TextAPI/Target.cpp
index 3914d0fa7e58a..e208424983314 100644
--- a/llvm/lib/TextAPI/Target.cpp
+++ b/llvm/lib/TextAPI/Target.cpp
@@ -58,6 +58,13 @@ raw_ostream &operator<<(raw_ostream &OS, const Target &Target) {
   return OS;
 }
 
+PlatformVersionSet mapToPlatformVersionSet(ArrayRef<Target> Targets) {
+  PlatformVersionSet Result;
+  for (const auto &Target : Targets)
+    Result.insert({Target.Platform, Target.MinDeployment});
+  return Result;
+}
+
 PlatformSet mapToPlatformSet(ArrayRef<Target> Targets) {
   PlatformSet Result;
   for (const auto &Target : Targets)

diff  --git a/llvm/tools/llvm-tapi-
diff /DiffEngine.cpp b/llvm/tools/llvm-tapi-
diff /DiffEngine.cpp
index 02642f4a1972b..ab61d691b07c3 100644
--- a/llvm/tools/llvm-tapi-
diff /DiffEngine.cpp
+++ b/llvm/tools/llvm-tapi-
diff /DiffEngine.cpp
@@ -16,6 +16,7 @@
 #include "llvm/TextAPI/InterfaceFile.h"
 #include "llvm/TextAPI/Symbol.h"
 #include "llvm/TextAPI/Target.h"
+#include <iterator>
 
 using namespace llvm;
 using namespace MachO;
@@ -114,6 +115,9 @@ void SymScalar::print(raw_ostream &OS, std::string Indent, MachO::Target Targ) {
 
 bool checkSymbolEquality(llvm::MachO::InterfaceFile::const_symbol_range LHS,
                          llvm::MachO::InterfaceFile::const_symbol_range RHS) {
+  if (std::distance(LHS.begin(), LHS.end()) !=
+      std::distance(RHS.begin(), RHS.end()))
+    return false;
   return std::equal(LHS.begin(), LHS.end(), RHS.begin(),
                     [&](auto LHS, auto RHS) { return *LHS == *RHS; });
 }


        


More information about the llvm-commits mailing list