================
@@ -141,20 +143,55 @@ class DarwinSDKInfo {
llvm::DenseMap<VersionTuple, VersionTuple> Mapping;
};
+ // Special versions of hash and equal_to to map triples to system prefixes
+ // ignoring the Arch/SubArch.
+ struct TripleHash {
+ std::size_t operator()(const llvm::Triple &Val) const noexcept {
+ return hash_combine(Val.getVendor(), Val.getOS(), Val.getEnvironment(),
+ Val.getObjectFormat());
+ }
+ };
+ struct TripleEqualTo {
+ constexpr bool operator()(const llvm::Triple &LHS,
+ const llvm::Triple &RHS) const {
+ return (LHS.getVendor() == RHS.getVendor()) &&
+ (LHS.getOS() == RHS.getOS()) &&
+ (LHS.getEnvironment() == RHS.getEnvironment()) &&
+ (LHS.getObjectFormat() == RHS.getObjectFormat());
+ }
+ };
+
DarwinSDKInfo(
VersionTuple Version, VersionTuple MaximumDeploymentTarget,
- llvm::Triple::OSType OS,
+ llvm::Triple Triple,
+ std::unordered_map<llvm::Triple, std::string, TripleHash, TripleEqualTo>
----------------
cyndyishida wrote:
> Is there any advantage of map?
It's the same thing you said earlier, it's less code to achieve the same thing.
> There isn't really a logical implementation of that for triples
I suspect that's because no one has ever needed to support ordering, but the
usual way to do this is
```
bool operator <(const auto &LHS, const auto &RHS) {
return std::tie(LHS.attr1, LHS.attr2) <
std::tie(RHS.attr1, RHS.attr2);
}
```
> Maybe what would be best is a SupportedTarget struct
SGTM.
https://github.com/llvm/llvm-project/pull/171970
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits