|
17 | 17 | #include "swift/AST/Import.h" |
18 | 18 | #include "swift/AST/SynthesizedFileUnit.h" |
19 | 19 | #include "swift/Basic/Debug.h" |
| 20 | +#include "llvm/ADT/Hashing.h" |
20 | 21 | #include "llvm/ADT/SetVector.h" |
21 | 22 | #include "llvm/ADT/SmallPtrSet.h" |
22 | 23 |
|
@@ -243,11 +244,20 @@ class SourceFile final : public FileUnit { |
243 | 244 | std::vector<ObjCUnsatisfiedOptReq> ObjCUnsatisfiedOptReqs; |
244 | 245 |
|
245 | 246 | /// A selector that is used by two different declarations in the same class. |
246 | | - /// Fields: typeDecl, selector, isInstanceMethod. |
247 | | - using ObjCMethodConflict = std::tuple<NominalTypeDecl *, ObjCSelector, bool>; |
| 247 | + struct ObjCMethodConflict { |
| 248 | + NominalTypeDecl *typeDecl; |
| 249 | + ObjCSelector selector; |
| 250 | + bool isInstanceMethod; |
| 251 | + |
| 252 | + ObjCMethodConflict(NominalTypeDecl *typeDecl, ObjCSelector selector, |
| 253 | + bool isInstanceMethod) |
| 254 | + : typeDecl(typeDecl), selector(selector), |
| 255 | + isInstanceMethod(isInstanceMethod) |
| 256 | + {} |
| 257 | + }; |
248 | 258 |
|
249 | 259 | /// List of Objective-C member conflicts we have found during type checking. |
250 | | - std::vector<ObjCMethodConflict> ObjCMethodConflicts; |
| 260 | + llvm::SetVector<ObjCMethodConflict> ObjCMethodConflicts; |
251 | 261 |
|
252 | 262 | /// List of attributes added by access notes, used to emit remarks for valid |
253 | 263 | /// ones. |
@@ -636,4 +646,30 @@ inline void simple_display(llvm::raw_ostream &out, const SourceFile *SF) { |
636 | 646 | } |
637 | 647 | } // end namespace swift |
638 | 648 |
|
| 649 | +namespace llvm { |
| 650 | + |
| 651 | +template<> |
| 652 | +struct DenseMapInfo<swift::SourceFile::ObjCMethodConflict> { |
| 653 | + using ObjCMethodConflict = swift::SourceFile::ObjCMethodConflict; |
| 654 | + |
| 655 | + static inline ObjCMethodConflict getEmptyKey() { |
| 656 | + return ObjCMethodConflict(nullptr, {}, false); |
| 657 | + } |
| 658 | + static inline ObjCMethodConflict getTombstoneKey() { |
| 659 | + return ObjCMethodConflict(nullptr, {}, true); |
| 660 | + } |
| 661 | + static inline unsigned getHashValue(ObjCMethodConflict a) { |
| 662 | + return hash_combine(hash_value(a.typeDecl), |
| 663 | + DenseMapInfo<swift::ObjCSelector>::getHashValue(a.selector), |
| 664 | + hash_value(a.isInstanceMethod)); |
| 665 | + } |
| 666 | + static bool isEqual(ObjCMethodConflict a, ObjCMethodConflict b) { |
| 667 | + return a.typeDecl == b.typeDecl && a.selector == b.selector && |
| 668 | + a.isInstanceMethod == b.isInstanceMethod; |
| 669 | + } |
| 670 | +}; |
| 671 | + |
| 672 | +} |
| 673 | + |
| 674 | + |
639 | 675 | #endif |
0 commit comments