@@ -54,7 +54,10 @@ class SourceFile final : public FileUnit {
54
54
// / elsewhere.
55
55
// /
56
56
// / Mutually exclusive with Exported.
57
- ImplementationOnly = 0x8
57
+ ImplementationOnly = 0x8 ,
58
+
59
+ // / Used for DenseMap.
60
+ Reserved = 0x80
58
61
};
59
62
60
63
// / \see ImportFlags
@@ -69,7 +72,8 @@ class SourceFile final : public FileUnit {
69
72
StringRef filename = {})
70
73
: module (module ), importOptions(options), filename(filename) {
71
74
assert (!(importOptions.contains (ImportFlags::Exported) &&
72
- importOptions.contains (ImportFlags::ImplementationOnly)));
75
+ importOptions.contains (ImportFlags::ImplementationOnly)) ||
76
+ importOptions.contains (ImportFlags::Reserved));
73
77
}
74
78
};
75
79
@@ -542,4 +546,58 @@ inline void simple_display(llvm::raw_ostream &out, const SourceFile *SF) {
542
546
}
543
547
} // end namespace swift
544
548
549
+ namespace llvm {
550
+
551
+ template <>
552
+ struct DenseMapInfo <swift::SourceFile::ImportOptions> {
553
+ using ImportOptions = swift::SourceFile::ImportOptions;
554
+
555
+ using UnsignedDMI = DenseMapInfo<uint8_t >;
556
+
557
+ static inline ImportOptions getEmptyKey () {
558
+ return ImportOptions (UnsignedDMI::getEmptyKey ());
559
+ }
560
+ static inline ImportOptions getTombstoneKey () {
561
+ return ImportOptions (UnsignedDMI::getTombstoneKey ());
562
+ }
563
+ static inline unsigned getHashValue (ImportOptions options) {
564
+ return UnsignedDMI::getHashValue (options.toRaw ());
565
+ }
566
+ static bool isEqual (ImportOptions a, ImportOptions b) {
567
+ return UnsignedDMI::isEqual (a.toRaw (), b.toRaw ());
568
+ }
569
+ };
570
+
571
+ template <>
572
+ struct DenseMapInfo <swift::SourceFile::ImportedModuleDesc> {
573
+ using ImportedModuleDesc = swift::SourceFile::ImportedModuleDesc;
574
+
575
+ using ImportedModuleDMI = DenseMapInfo<swift::ModuleDecl::ImportedModule>;
576
+ using ImportOptionsDMI = DenseMapInfo<swift::SourceFile::ImportOptions>;
577
+ using StringRefDMI = DenseMapInfo<StringRef>;
578
+
579
+ static inline ImportedModuleDesc getEmptyKey () {
580
+ return ImportedModuleDesc (ImportedModuleDMI::getEmptyKey (),
581
+ ImportOptionsDMI::getEmptyKey (),
582
+ StringRefDMI::getEmptyKey ());
583
+ }
584
+ static inline ImportedModuleDesc getTombstoneKey () {
585
+ return ImportedModuleDesc (ImportedModuleDMI::getTombstoneKey (),
586
+ ImportOptionsDMI::getTombstoneKey (),
587
+ StringRefDMI::getTombstoneKey ());
588
+ }
589
+ static inline unsigned getHashValue (const ImportedModuleDesc &import ) {
590
+ return combineHashValue (ImportedModuleDMI::getHashValue (import .module ),
591
+ combineHashValue (ImportOptionsDMI::getHashValue (import .importOptions ),
592
+ StringRefDMI::getHashValue (import .filename )));
593
+ }
594
+ static bool isEqual (const ImportedModuleDesc &a,
595
+ const ImportedModuleDesc &b) {
596
+ return ImportedModuleDMI::isEqual (a.module , b.module ) &&
597
+ ImportOptionsDMI::isEqual (a.importOptions , b.importOptions ) &&
598
+ StringRefDMI::isEqual (a.filename , b.filename );
599
+ }
600
+ };
601
+ }
602
+
545
603
#endif
0 commit comments