Skip to content

Commit 5780cef

Browse files
committed
Respond to changes in SetVector in r253439.
1 parent f340ab4 commit 5780cef

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

include/swift/AST/CaptureInfo.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
#include "llvm/ADT/PointerIntPair.h"
1919
#include <vector>
2020

21+
namespace swift {
22+
class CapturedValue;
23+
}
24+
2125
namespace llvm {
2226
class raw_ostream;
27+
template <> struct DenseMapInfo<swift::CapturedValue>;
2328
}
2429

2530
namespace swift {
@@ -30,7 +35,12 @@ class FuncDecl;
3035
/// that indicate how it is captured.
3136
class CapturedValue {
3237
llvm::PointerIntPair<ValueDecl*, 2, unsigned> Value;
38+
39+
explicit CapturedValue(llvm::PointerIntPair<ValueDecl*, 2, unsigned> V) : Value(V) {}
40+
3341
public:
42+
friend struct llvm::DenseMapInfo<CapturedValue>;
43+
3444
enum {
3545
/// IsDirect is set when a VarDecl with storage *and* accessors is captured
3646
/// by its storage address. This happens in the accessors for the VarDecl.
@@ -64,7 +74,36 @@ class CapturedValue {
6474
}
6575
};
6676

77+
} // end swift namespace
6778

79+
namespace llvm {
80+
81+
template <> struct DenseMapInfo<swift::CapturedValue> {
82+
using CapturedValue = swift::CapturedValue;
83+
84+
using PtrIntPairDenseMapInfo =
85+
DenseMapInfo<llvm::PointerIntPair<swift::ValueDecl *, 2, unsigned>>;
86+
87+
static inline swift::CapturedValue getEmptyKey() {
88+
return CapturedValue{PtrIntPairDenseMapInfo::getEmptyKey()};
89+
}
90+
91+
static inline CapturedValue getTombstoneKey() {
92+
return CapturedValue{PtrIntPairDenseMapInfo::getTombstoneKey()};
93+
}
94+
95+
static unsigned getHashValue(const CapturedValue &Val) {
96+
return PtrIntPairDenseMapInfo::getHashValue(Val.Value);
97+
}
98+
99+
static bool isEqual(const CapturedValue &LHS, const CapturedValue &RHS) {
100+
return PtrIntPairDenseMapInfo::isEqual(LHS.Value, RHS.Value);
101+
}
102+
};
103+
104+
} // end llvm namespace
105+
106+
namespace swift {
68107

69108
/// \brief Stores information about captured variables.
70109
class CaptureInfo {

include/swift/AST/ModuleLoader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ enum class KnownProtocolKind : uint8_t;
3434

3535
/// Records dependencies on files outside of the current module.
3636
class DependencyTracker {
37-
llvm::SetVector<std::string, std::vector<std::string>> paths;
37+
llvm::SetVector<std::string, std::vector<std::string>,
38+
llvm::SmallSet<std::string, 16>> paths;
3839

3940
public:
4041
/// Adds a file as a dependency.

lib/AST/LookupVisibleDecls.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ static void lookupVisibleMemberDeclsImpl(
519519
}
520520

521521
namespace {
522+
522523
struct FoundDeclTy {
523524
ValueDecl *D;
524525
DeclVisibilityKind Reason;
@@ -535,6 +536,33 @@ struct FoundDeclTy {
535536
}
536537
};
537538

539+
} // end anonymous namespace
540+
541+
namespace llvm {
542+
543+
template <> struct DenseMapInfo<FoundDeclTy> {
544+
static inline FoundDeclTy getEmptyKey() {
545+
return FoundDeclTy{nullptr, DeclVisibilityKind::LocalVariable};
546+
}
547+
548+
static inline FoundDeclTy getTombstoneKey() {
549+
return FoundDeclTy{reinterpret_cast<ValueDecl *>(0x1),
550+
DeclVisibilityKind::LocalVariable};
551+
}
552+
553+
static unsigned getHashValue(const FoundDeclTy &Val) {
554+
return llvm::hash_combine(unsigned(Val.Reason), Val.D);
555+
}
556+
557+
static bool isEqual(const FoundDeclTy &LHS, const FoundDeclTy &RHS) {
558+
return LHS == RHS;
559+
}
560+
};
561+
562+
} // end llvm namespace
563+
564+
namespace {
565+
538566
/// Similar to swift::conflicting, but lenient about protocol extensions which
539567
/// don't affect code completion's concept of overloading.
540568
static bool relaxedConflicting(const OverloadSignature &sig1,

0 commit comments

Comments
 (0)