Skip to content

Commit 874e2f8

Browse files
committed
[llvm][TextAPI] only compare deployment version for InterfaceFile.
(cherry picked from commit 7de8cd6)
1 parent 2ac1bd2 commit 874e2f8

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

llvm/include/llvm/TextAPI/Platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace llvm {
2020
namespace MachO {
2121

2222
using PlatformSet = SmallSet<PlatformType, 3>;
23+
using PlatformVersionSet = SmallSet<std::pair<PlatformType, VersionTuple>, 3>;
2324

2425
PlatformType mapToPlatformType(PlatformType Platform, bool WantSim);
2526
PlatformType mapToPlatformType(const Triple &Target);

llvm/include/llvm/TextAPI/Target.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ class Target {
4545
};
4646

4747
inline bool operator==(const Target &LHS, const Target &RHS) {
48-
bool CrossLinkMatch =
49-
std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
50-
// Ignore potential mismatches due to missing deployment versions.
51-
if (LHS.MinDeployment.empty() || RHS.MinDeployment.empty())
52-
return CrossLinkMatch;
53-
return CrossLinkMatch && LHS.MinDeployment == RHS.MinDeployment;
48+
// In most cases the deployment version is not useful to compare.
49+
return std::tie(LHS.Arch, LHS.Platform) == std::tie(RHS.Arch, RHS.Platform);
5450
}
5551

5652
inline bool operator!=(const Target &LHS, const Target &RHS) {
@@ -70,6 +66,7 @@ inline bool operator!=(const Target &LHS, const Architecture &RHS) {
7066
return LHS.Arch != RHS;
7167
}
7268

69+
PlatformVersionSet mapToPlatformVersionSet(ArrayRef<Target> Targets);
7370
PlatformSet mapToPlatformSet(ArrayRef<Target> Targets);
7471
ArchitectureSet mapToArchitectureSet(ArrayRef<Target> Targets);
7572

llvm/lib/TextAPI/InterfaceFile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ bool InterfaceFile::operator==(const InterfaceFile &O) const {
174174
if (!(isYAMLTextStub(FileKind)) && !(isYAMLTextStub(O.FileKind))) {
175175
if (RPaths != O.RPaths)
176176
return false;
177+
if (mapToPlatformVersionSet(Targets) != mapToPlatformVersionSet(O.Targets))
178+
return false;
177179
}
178180

179181
if (!std::equal(Documents.begin(), Documents.end(), O.Documents.begin(),

llvm/lib/TextAPI/Target.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ raw_ostream &operator<<(raw_ostream &OS, const Target &Target) {
5858
return OS;
5959
}
6060

61+
PlatformVersionSet mapToPlatformVersionSet(ArrayRef<Target> Targets) {
62+
PlatformVersionSet Result;
63+
for (const auto &Target : Targets)
64+
Result.insert({Target.Platform, Target.MinDeployment});
65+
return Result;
66+
}
67+
6168
PlatformSet mapToPlatformSet(ArrayRef<Target> Targets) {
6269
PlatformSet Result;
6370
for (const auto &Target : Targets)

llvm/tools/llvm-tapi-diff/DiffEngine.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/TextAPI/InterfaceFile.h"
1717
#include "llvm/TextAPI/Symbol.h"
1818
#include "llvm/TextAPI/Target.h"
19+
#include <iterator>
1920

2021
using namespace llvm;
2122
using namespace MachO;
@@ -114,6 +115,9 @@ void SymScalar::print(raw_ostream &OS, std::string Indent, MachO::Target Targ) {
114115

115116
bool checkSymbolEquality(llvm::MachO::InterfaceFile::const_symbol_range LHS,
116117
llvm::MachO::InterfaceFile::const_symbol_range RHS) {
118+
if (std::distance(LHS.begin(), LHS.end()) !=
119+
std::distance(RHS.begin(), RHS.end()))
120+
return false;
117121
return std::equal(LHS.begin(), LHS.end(), RHS.begin(),
118122
[&](auto LHS, auto RHS) { return *LHS == *RHS; });
119123
}

0 commit comments

Comments
 (0)