[clang][clang-tools-extra] Remove unused DenseMapInfo::getEmptyKey (#201987)

After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
This commit is contained in:
Fangrui Song 2026-06-06 13:38:23 -07:00 committed by GitHub
parent 02b26ec29b
commit c5c9676496
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 2 additions and 353 deletions

View file

@ -83,20 +83,12 @@ struct DenseMapInfo<
using ClassDefId =
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
static ClassDefId getEmptyKey() {
return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(), "EMPTY"};
}
static unsigned getHashValue(const ClassDefId &Val) {
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
const std::hash<ClassDefId::second_type> SecondHash;
return Val.first.getHashValue() + SecondHash(Val.second);
}
static bool isEqual(const ClassDefId &LHS, const ClassDefId &RHS) {
if (RHS == getEmptyKey())
return LHS == getEmptyKey();
return LHS == RHS;
}
};

View file

@ -30,20 +30,12 @@ template <>
struct DenseMapInfo<clang::tidy::RenamerClangTidyCheck::NamingCheckId> {
using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;
static NamingCheckId getEmptyKey() {
return {DenseMapInfo<clang::SourceLocation>::getEmptyKey(), "EMPTY"};
}
static unsigned getHashValue(NamingCheckId Val) {
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
return DenseMapInfo<clang::SourceLocation>::getHashValue(Val.first) +
DenseMapInfo<StringRef>::getHashValue(Val.second);
}
static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) {
if (RHS == getEmptyKey())
return LHS == getEmptyKey();
return LHS == RHS;
}
};

View file

@ -229,9 +229,6 @@ struct Config {
namespace llvm {
template <> struct DenseMapInfo<clang::clangd::Config::ExternalIndexSpec> {
using ExternalIndexSpec = clang::clangd::Config::ExternalIndexSpec;
static inline ExternalIndexSpec getEmptyKey() {
return {ExternalIndexSpec::File, "", ""};
}
static unsigned getHashValue(const ExternalIndexSpec &Val) {
return llvm::hash_combine(Val.Kind, Val.Location, Val.MountPoint);
}

View file

@ -273,10 +273,6 @@ namespace llvm {
// Support HeaderIDs as DenseMap keys.
template <> struct DenseMapInfo<clang::clangd::IncludeStructure::HeaderID> {
static inline clang::clangd::IncludeStructure::HeaderID getEmptyKey() {
return static_cast<clang::clangd::IncludeStructure::HeaderID>(-1);
}
static unsigned
getHashValue(const clang::clangd::IncludeStructure::HeaderID &Tag) {
return hash_value(static_cast<unsigned>(Tag));

View file

@ -2108,11 +2108,6 @@ namespace llvm {
template <> struct DenseMapInfo<clang::clangd::Range> {
using Range = clang::clangd::Range;
static inline Range getEmptyKey() {
static clang::clangd::Position Tomb{-1, -1};
static Range R{Tomb, Tomb};
return R;
}
static unsigned getHashValue(const Range &Val) {
return llvm::hash_combine(Val.start.line, Val.start.character, Val.end.line,
Val.end.character);

View file

@ -207,8 +207,6 @@ struct DriverArgs {
return Args;
}
static DriverArgs getEmpty() { return {}; }
private:
DriverArgs() = default;
};
@ -217,11 +215,6 @@ private:
namespace llvm {
using DriverArgs = clang::clangd::DriverArgs;
template <> struct DenseMapInfo<DriverArgs> {
static DriverArgs getEmptyKey() {
auto Driver = DriverArgs::getEmpty();
Driver.Driver = "EMPTY_KEY";
return Driver;
}
static unsigned getHashValue(const DriverArgs &Val) {
unsigned FixedFieldsHash = llvm::hash_value(std::tuple{
Val.Driver,

View file

@ -171,10 +171,6 @@ private:
namespace llvm {
template <> struct DenseMapInfo<clang::clangd::RefSlab::Builder::Entry> {
using Entry = clang::clangd::RefSlab::Builder::Entry;
static inline Entry getEmptyKey() {
static Entry E{clang::clangd::SymbolID(""), {}};
return E;
}
static unsigned getHashValue(const Entry &Val) {
return llvm::hash_combine(
Val.Symbol, reinterpret_cast<uintptr_t>(Val.Reference.Location.FileURI),

View file

@ -81,10 +81,6 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolID &ID);
namespace llvm {
// Support SymbolIDs as DenseMap keys.
template <> struct DenseMapInfo<clang::clangd::SymbolID> {
static inline clang::clangd::SymbolID getEmptyKey() {
static clang::clangd::SymbolID EmptyKey("EMPTYKEY");
return EmptyKey;
}
static unsigned getHashValue(const clang::clangd::SymbolID &Sym) {
return hash_value(Sym);
}

View file

@ -64,8 +64,7 @@ public:
ProximityURI,
/// Type of symbol (see `Symbol::Type`).
Type,
/// Internal Token type for invalid/special tokens, e.g. empty tokens for
/// llvm::DenseMap.
/// Internal Token type for invalid/special tokens.
Sentinel,
};
@ -115,10 +114,6 @@ namespace llvm {
// Support Tokens as DenseMap keys.
template <> struct DenseMapInfo<clang::clangd::dex::Token> {
static inline clang::clangd::dex::Token getEmptyKey() {
return {clang::clangd::dex::Token::Kind::Sentinel, "EmptyKey"};
}
static unsigned getHashValue(const clang::clangd::dex::Token &Tag) {
return hash_value(Tag);
}

View file

@ -37,9 +37,6 @@ namespace dex {
// Trigram generation is the hot path of indexing, so Token is too wasteful.
class Trigram {
std::array<char, 4> Data; // Last element is length.
// Steal an invalid bit pattern for the DenseMap sentinel.
enum class Sentinel { Empty = 4 };
Trigram(Sentinel S) : Data{0, 0, 0, static_cast<char>(S)} {}
uint32_t id() const { return llvm::bit_cast<uint32_t>(Data); }
public:
@ -90,9 +87,6 @@ std::vector<Token> generateQueryTrigrams(llvm::StringRef Query);
namespace llvm {
template <> struct DenseMapInfo<clang::clangd::dex::Trigram> {
using Trigram = clang::clangd::dex::Trigram;
static inline Trigram getEmptyKey() {
return Trigram(Trigram::Sentinel::Empty);
}
static unsigned getHashValue(Trigram V) {
// Finalize step from MurmurHash3.
uint32_t X = V.id();

View file

@ -78,11 +78,6 @@ private:
// Order must match Kind enum!
std::variant<const Decl *, struct Macro> Storage;
// Disambiguation tag to make sure we can call the right constructor from
// DenseMapInfo methods.
struct SentinelTag {};
Symbol(SentinelTag, decltype(Storage) Sentinel)
: Storage(std::move(Sentinel)) {}
friend llvm::DenseMapInfo<Symbol>;
};
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Symbol &);
@ -144,11 +139,6 @@ private:
// Order must match Kind enum!
std::variant<FileEntryRef, tooling::stdlib::Header, StringRef> Storage;
// Disambiguation tag to make sure we can call the right constructor from
// DenseMapInfo methods.
struct SentinelTag {};
Header(SentinelTag, decltype(Storage) Sentinel)
: Storage(std::move(Sentinel)) {}
friend llvm::DenseMapInfo<Header>;
};
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Header &);
@ -219,9 +209,6 @@ template <> struct DenseMapInfo<clang::include_cleaner::Symbol> {
using Outer = clang::include_cleaner::Symbol;
using Base = DenseMapInfo<decltype(Outer::Storage)>;
static Outer getEmptyKey() {
return {Outer::SentinelTag{}, Base::getEmptyKey()};
}
static unsigned getHashValue(const Outer &Val) {
return Base::getHashValue(Val.Storage);
}
@ -233,7 +220,6 @@ template <> struct DenseMapInfo<clang::include_cleaner::Macro> {
using Outer = clang::include_cleaner::Macro;
using Base = DenseMapInfo<decltype(Outer::Definition)>;
static Outer getEmptyKey() { return {nullptr, Base::getEmptyKey()}; }
static unsigned getHashValue(const Outer &Val) {
return Base::getHashValue(Val.Definition);
}
@ -245,9 +231,6 @@ template <> struct DenseMapInfo<clang::include_cleaner::Header> {
using Outer = clang::include_cleaner::Header;
using Base = DenseMapInfo<decltype(Outer::Storage)>;
static Outer getEmptyKey() {
return {Outer::SentinelTag{}, Base::getEmptyKey()};
}
static unsigned getHashValue(const Outer &Val) {
return Base::getHashValue(Val.Storage);
}

View file

@ -838,7 +838,6 @@ private:
namespace llvm {
template<> struct DenseMapInfo<clang::APValue::LValueBase> {
static clang::APValue::LValueBase getEmptyKey();
static unsigned getHashValue(const clang::APValue::LValueBase &Base);
static bool isEqual(const clang::APValue::LValueBase &LHS,
const clang::APValue::LValueBase &RHS);

View file

@ -70,9 +70,6 @@ struct ScalableVecTyKey {
// Provide a DenseMapInfo specialization so that ScalableVecTyKey can be used
// as a key in DenseMap.
template <> struct DenseMapInfo<ScalableVecTyKey> {
static inline ScalableVecTyKey getEmptyKey() {
return {DenseMapInfo<clang::QualType>::getEmptyKey(), ~0U, ~0U};
}
static unsigned getHashValue(const ScalableVecTyKey &Val) {
return hash_combine(DenseMapInfo<clang::QualType>::getHashValue(Val.EltTy),
Val.NumElts, Val.NumFields);
@ -4008,8 +4005,6 @@ typename clang::LazyGenerationalUpdatePtr<Owner, T, Update>::ValueType
return Value;
}
template <> struct llvm::DenseMapInfo<llvm::FoldingSetNodeID> {
static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; }
static unsigned getHashValue(const FoldingSetNodeID &Val) {
return Val.ComputeHash();
}

View file

@ -109,7 +109,6 @@ public:
/// Hooks for using ASTNodeKind as a key in a DenseMap.
struct DenseMapInfo {
// ASTNodeKind() is a good empty key because it is represented as a 0.
static inline ASTNodeKind getEmptyKey() { return ASTNodeKind(); }
static unsigned getHashValue(const ASTNodeKind &Val) { return Val.KindId; }
static bool isEqual(const ASTNodeKind &LHS, const ASTNodeKind &RHS) {
return LHS.KindId == RHS.KindId;
@ -369,11 +368,6 @@ public:
/// Hooks for using DynTypedNode as a key in a DenseMap.
struct DenseMapInfo {
static inline DynTypedNode getEmptyKey() {
DynTypedNode Node;
Node.NodeKind = ASTNodeKind::DenseMapInfo::getEmptyKey();
return Node;
}
static unsigned getHashValue(const DynTypedNode &Val) {
// FIXME: Add hashing support for the remaining types.
if (ASTNodeKind::getFromNodeKind<TypeLoc>().isBaseOf(Val.NodeKind)) {
@ -394,10 +388,7 @@ public:
return llvm::hash_value(Val.getMemoizationData());
}
static bool isEqual(const DynTypedNode &LHS, const DynTypedNode &RHS) {
auto Empty = ASTNodeKind::DenseMapInfo::getEmptyKey();
return (ASTNodeKind::DenseMapInfo::isEqual(LHS.NodeKind, Empty) &&
ASTNodeKind::DenseMapInfo::isEqual(RHS.NodeKind, Empty)) ||
LHS == RHS;
return LHS == RHS;
}
};

View file

@ -55,12 +55,6 @@ public:
namespace llvm {
template<> struct DenseMapInfo<clang::BaseSubobject> {
static clang::BaseSubobject getEmptyKey() {
return clang::BaseSubobject(
DenseMapInfo<const clang::CXXRecordDecl *>::getEmptyKey(),
clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getEmptyKey()));
}
static unsigned getHashValue(const clang::BaseSubobject &Base) {
using PairTy = std::pair<const clang::CXXRecordDecl *, clang::CharUnits>;

View file

@ -230,13 +230,6 @@ inline clang::CharUnits operator* (clang::CharUnits::QuantityType Scale,
namespace llvm {
template<> struct DenseMapInfo<clang::CharUnits> {
static clang::CharUnits getEmptyKey() {
clang::CharUnits::QuantityType Quantity =
DenseMapInfo<clang::CharUnits::QuantityType>::getEmptyKey();
return clang::CharUnits::fromQuantity(Quantity);
}
static unsigned getHashValue(const clang::CharUnits &CU) {
clang::CharUnits::QuantityType Quantity = CU.getQuantity();
return DenseMapInfo<clang::CharUnits::QuantityType>::getHashValue(Quantity);

View file

@ -248,10 +248,6 @@ template <> struct DenseMapInfo<clang::GlobalDeclID> {
using GlobalDeclID = clang::GlobalDeclID;
using DeclID = GlobalDeclID::DeclID;
static GlobalDeclID getEmptyKey() {
return GlobalDeclID(DenseMapInfo<DeclID>::getEmptyKey());
}
static unsigned getHashValue(const GlobalDeclID &Key) {
return DenseMapInfo<DeclID>::getHashValue(Key.getRawValue());
}
@ -265,10 +261,6 @@ template <> struct DenseMapInfo<clang::LocalDeclID> {
using LocalDeclID = clang::LocalDeclID;
using DeclID = LocalDeclID::DeclID;
static LocalDeclID getEmptyKey() {
return LocalDeclID(DenseMapInfo<DeclID>::getEmptyKey());
}
static unsigned getHashValue(const LocalDeclID &Key) {
return DenseMapInfo<DeclID>::getHashValue(Key.getRawValue());
}

View file

@ -552,12 +552,6 @@ public:
return LHS.Ptr != RHS.Ptr;
}
static DeclarationName getEmptyMarker() {
DeclarationName Name;
Name.Ptr = uintptr_t(-1);
return Name;
}
static int compare(DeclarationName LHS, DeclarationName RHS);
void print(raw_ostream &OS, const PrintingPolicy &Policy) const;
@ -924,10 +918,6 @@ namespace llvm {
/// in DenseMap and DenseSets.
template<>
struct DenseMapInfo<clang::DeclarationName> {
static inline clang::DeclarationName getEmptyKey() {
return clang::DeclarationName::getEmptyMarker();
}
static unsigned getHashValue(clang::DeclarationName Name) {
return DenseMapInfo<void*>::getHashValue(Name.getAsOpaquePtr());
}

View file

@ -215,10 +215,6 @@ public:
namespace llvm {
template<> struct DenseMapInfo<clang::GlobalDecl> {
static inline clang::GlobalDecl getEmptyKey() {
return clang::GlobalDecl();
}
static unsigned getHashValue(clang::GlobalDecl GD) {
return DenseMapInfo<void*>::getHashValue(GD.getAsOpaquePtr());
}

View file

@ -253,8 +253,6 @@ SourceRange NestedNameSpecifierLocBuilder::getSourceRange() const {
namespace llvm {
template <> struct DenseMapInfo<clang::NestedNameSpecifier> {
static clang::NestedNameSpecifier getEmptyKey() { return std::nullopt; }
static unsigned getHashValue(const clang::NestedNameSpecifier &V) {
return hash_combine(V.getAsVoidPointer());
}
@ -264,11 +262,6 @@ template <> struct DenseMapInfo<clang::NestedNameSpecifierLoc> {
using FirstInfo = DenseMapInfo<clang::NestedNameSpecifier>;
using SecondInfo = DenseMapInfo<void *>;
static clang::NestedNameSpecifierLoc getEmptyKey() {
return clang::NestedNameSpecifierLoc(FirstInfo::getEmptyKey(),
SecondInfo::getEmptyKey());
}
static unsigned getHashValue(const clang::NestedNameSpecifierLoc &PairVal) {
return hash_combine(
FirstInfo::getHashValue(PairVal.getNestedNameSpecifier()),

View file

@ -383,14 +383,6 @@ struct DenseMapInfo<clang::CanonicalDeclPtr<decl_type>> {
using CanonicalDeclPtr = clang::CanonicalDeclPtr<decl_type>;
using BaseInfo = DenseMapInfo<decl_type *>;
static CanonicalDeclPtr getEmptyKey() {
// Construct our CanonicalDeclPtr this way because the regular constructor
// would dereference P.Ptr, which is not allowed.
CanonicalDeclPtr P;
P.Ptr = BaseInfo::getEmptyKey();
return P;
}
static unsigned getHashValue(const CanonicalDeclPtr &P) {
return BaseInfo::getHashValue(P);
}

View file

@ -36,8 +36,6 @@ struct QualTypeOrdering {
namespace llvm {
template<> struct DenseMapInfo<clang::QualType> {
static inline clang::QualType getEmptyKey() { return clang::QualType(); }
static unsigned getHashValue(clang::QualType Val) {
return (unsigned)((uintptr_t)Val.getAsOpaquePtr()) ^
((unsigned)((uintptr_t)Val.getAsOpaquePtr() >> 9));
@ -49,10 +47,6 @@ namespace llvm {
};
template<> struct DenseMapInfo<clang::CanQualType> {
static inline clang::CanQualType getEmptyKey() {
return clang::CanQualType();
}
static unsigned getHashValue(clang::CanQualType Val) {
return (unsigned)((uintptr_t)Val.getAsOpaquePtr()) ^
((unsigned)((uintptr_t)Val.getAsOpaquePtr() >> 9));

View file

@ -99,10 +99,6 @@ template <typename Tag>
struct DenseMapInfo<clang::lifetimes::internal::utils::ID<Tag>> {
using ID = clang::lifetimes::internal::utils::ID<Tag>;
static inline ID getEmptyKey() {
return {DenseMapInfo<uint32_t>::getEmptyKey()};
}
static unsigned getHashValue(const ID &Val) {
return DenseMapInfo<uint32_t>::getHashValue(Val.Value);
}

View file

@ -214,12 +214,6 @@ namespace llvm {
// Specialize DenseMapInfo for clang::CallGraphNode::CallRecord.
template <> struct DenseMapInfo<clang::CallGraphNode::CallRecord> {
static inline clang::CallGraphNode::CallRecord getEmptyKey() {
return clang::CallGraphNode::CallRecord(
DenseMapInfo<clang::CallGraphNode *>::getEmptyKey(),
DenseMapInfo<clang::Expr *>::getEmptyKey());
}
static unsigned getHashValue(const clang::CallGraphNode::CallRecord &Val) {
// NOTE: we are comparing based on the callee only.
// Different call records with the same callee will compare equal!

View file

@ -242,11 +242,6 @@ private:
friend class Environment;
struct NullableQualTypeDenseMapInfo : private llvm::DenseMapInfo<QualType> {
static QualType getEmptyKey() {
// Allow a NULL `QualType` by using a different value as the empty key.
return QualType::getFromOpaquePtr(reinterpret_cast<Type *>(1));
}
using DenseMapInfo::getHashValue;
using DenseMapInfo::isEqual;
};

View file

@ -137,7 +137,6 @@ template <> struct DenseMapInfo<clang::dataflow::Atom> {
using Atom = clang::dataflow::Atom;
using Underlying = std::underlying_type_t<Atom>;
static inline Atom getEmptyKey() { return Atom(Underlying(-1)); }
static unsigned getHashValue(const Atom &Val) {
return DenseMapInfo<Underlying>::getHashValue(Underlying(Val));
}

View file

@ -751,13 +751,6 @@ namespace llvm { // Traits specialization for DenseMap
template <> struct DenseMapInfo<clang::ProgramPoint> {
static inline clang::ProgramPoint getEmptyKey() {
uintptr_t x =
reinterpret_cast<uintptr_t>(DenseMapInfo<void*>::getEmptyKey()) & ~0x7;
return clang::BlockEntrance(nullptr, reinterpret_cast<clang::CFGBlock *>(x),
nullptr);
}
static unsigned getHashValue(const clang::ProgramPoint &Loc) {
return Loc.getHashValue();
}

View file

@ -246,11 +246,6 @@ template <> struct FoldingSetTrait<RetEffect> {
};
template <> struct DenseMapInfo<ObjCSummaryKey> {
static inline ObjCSummaryKey getEmptyKey() {
return ObjCSummaryKey(DenseMapInfo<IdentifierInfo*>::getEmptyKey(),
DenseMapInfo<Selector>::getEmptyKey());
}
static unsigned getHashValue(const ObjCSummaryKey &V) {
typedef std::pair<IdentifierInfo*, Selector> PairTy;
return DenseMapInfo<PairTy>::getHashValue(PairTy(V.getIdentifier(),

View file

@ -95,14 +95,6 @@ private:
bool hasOptionalValue() const { return ME; }
friend struct llvm::DenseMapInfo<DirectoryEntryRef>;
struct dense_map_empty_tag {};
// Private constructor for use by DenseMapInfo.
DirectoryEntryRef(dense_map_empty_tag)
: ME(llvm::DenseMapInfo<const MapEntry *>::getEmptyKey()) {}
bool isSpecialDenseMapKey() const {
return isSameRef(DirectoryEntryRef(dense_map_empty_tag()));
}
const MapEntry *ME;
};
@ -199,26 +191,14 @@ template <> struct PointerLikeTypeTraits<clang::DirectoryEntryRef> {
/// Specialisation of DenseMapInfo for DirectoryEntryRef.
template <> struct DenseMapInfo<clang::DirectoryEntryRef> {
static inline clang::DirectoryEntryRef getEmptyKey() {
return clang::DirectoryEntryRef(
clang::DirectoryEntryRef::dense_map_empty_tag());
}
static unsigned getHashValue(clang::DirectoryEntryRef Val) {
return hash_value(Val);
}
static bool isEqual(clang::DirectoryEntryRef LHS,
clang::DirectoryEntryRef RHS) {
// Catch the easy cases: both empty or the same ref.
if (LHS.isSameRef(RHS))
return true;
// Confirm LHS and RHS are valid.
if (LHS.isSpecialDenseMapKey() || RHS.isSpecialDenseMapKey())
return false;
// It's safe to use operator==.
return LHS == RHS;
}
};

View file

@ -183,14 +183,6 @@ private:
bool hasOptionalValue() const { return ME; }
friend struct llvm::DenseMapInfo<FileEntryRef>;
struct dense_map_empty_tag {};
// Private constructor for use by DenseMapInfo.
FileEntryRef(dense_map_empty_tag)
: ME(llvm::DenseMapInfo<const MapEntry *>::getEmptyKey()) {}
bool isSpecialDenseMapKey() const {
return isSameRef(FileEntryRef(dense_map_empty_tag()));
}
const MapEntry *ME;
};
@ -235,24 +227,13 @@ namespace llvm {
/// Specialisation of DenseMapInfo for FileEntryRef.
template <> struct DenseMapInfo<clang::FileEntryRef> {
static inline clang::FileEntryRef getEmptyKey() {
return clang::FileEntryRef(clang::FileEntryRef::dense_map_empty_tag());
}
static unsigned getHashValue(clang::FileEntryRef Val) {
return hash_value(Val);
}
static bool isEqual(clang::FileEntryRef LHS, clang::FileEntryRef RHS) {
// Catch the easy cases: both empty or the same ref.
if (LHS.isSameRef(RHS))
return true;
// Confirm LHS and RHS are valid.
if (LHS.isSpecialDenseMapKey() || RHS.isSpecialDenseMapKey())
return false;
// It's safe to use operator==.
return LHS == RHS;
}
@ -262,8 +243,6 @@ template <> struct DenseMapInfo<clang::FileEntryRef> {
return llvm::hash_value(Val);
}
static bool isEqual(const clang::FileEntry *LHS, clang::FileEntryRef RHS) {
if (RHS.isSpecialDenseMapKey())
return false;
return LHS == RHS;
}
/// @}

View file

@ -1185,10 +1185,6 @@ public:
return getStringFormatFamilyImpl(*this);
}
static Selector getEmptyMarker() {
return Selector(uintptr_t(-1));
}
static ObjCInstanceTypeFamily getInstTypeMethodFamily(Selector sel);
};
@ -1269,10 +1265,6 @@ namespace llvm {
/// DenseSets.
template <>
struct DenseMapInfo<clang::Selector> {
static clang::Selector getEmptyKey() {
return clang::Selector::getEmptyMarker();
}
static unsigned getHashValue(clang::Selector S);
static bool isEqual(clang::Selector LHS, clang::Selector RHS) {

View file

@ -1156,10 +1156,6 @@ private:
} // namespace clang
template <> struct llvm::DenseMapInfo<clang::ModuleFileKey> {
static clang::ModuleFileKey getEmptyKey() {
return DenseMapInfo<const void *>::getEmptyKey();
}
static unsigned getHashValue(const clang::ModuleFileKey &Val) {
return hash_combine(Val.Ptr, Val.ImplicitModulePathSuffix);
}

View file

@ -494,10 +494,6 @@ namespace llvm {
/// DenseSets.
template <>
struct DenseMapInfo<clang::FileID, void> {
static clang::FileID getEmptyKey() {
return {};
}
static unsigned getHashValue(clang::FileID S) {
return S.getHashValue();
}
@ -511,11 +507,6 @@ namespace llvm {
/// DenseMap and DenseSet. This trait class is eqivalent to
/// DenseMapInfo<unsigned> which uses SourceLocation::ID is used as a key.
template <> struct DenseMapInfo<clang::SourceLocation, void> {
static clang::SourceLocation getEmptyKey() {
constexpr clang::SourceLocation::UIntTy Zero = 0;
return clang::SourceLocation::getFromRawEncoding(~Zero);
}
static unsigned getHashValue(clang::SourceLocation Loc) {
return Loc.getHashValue();
}
@ -531,10 +522,6 @@ namespace llvm {
};
template <> struct DenseMapInfo<clang::SourceRange> {
static clang::SourceRange getEmptyKey() {
return DenseMapInfo<clang::SourceLocation>::getEmptyKey();
}
static unsigned getHashValue(clang::SourceRange Range) {
return detail::combineHashValue(Range.getBegin().getHashValue(),
Range.getEnd().getHashValue());

View file

@ -133,9 +133,6 @@ inline constexpr bool isRegularKeywordAttribute(TokenKind K) {
namespace llvm {
template <> struct DenseMapInfo<clang::tok::PPKeywordKind> {
static inline clang::tok::PPKeywordKind getEmptyKey() {
return clang::tok::PPKeywordKind::pp_not_keyword;
}
static unsigned getHashValue(const clang::tok::PPKeywordKind &Val) {
return static_cast<unsigned>(Val);
}

View file

@ -206,7 +206,6 @@ inline hash_code hash_value(const clang::dependencies::ModuleID &ID) {
template <> struct DenseMapInfo<clang::dependencies::ModuleID> {
using ModuleID = clang::dependencies::ModuleID;
static inline ModuleID getEmptyKey() { return ModuleID{"", ""}; }
static unsigned getHashValue(const ModuleID &ID) { return hash_value(ID); }
static bool isEqual(const ModuleID &LHS, const ModuleID &RHS) {
return LHS == RHS;

View file

@ -328,10 +328,6 @@ public:
// instantiated.
class DenseMapInfo {
public:
static inline WeakObjectProfileTy getEmptyKey() {
return WeakObjectProfileTy();
}
static unsigned getHashValue(const WeakObjectProfileTy &Val) {
using Pair = std::pair<BaseInfoTy, const NamedDecl *>;

View file

@ -304,10 +304,6 @@ template <> struct DenseMapInfo<clang::SemaCUDA::FunctionDeclAndLoc> {
using FDBaseInfo =
DenseMapInfo<clang::CanonicalDeclPtr<const clang::FunctionDecl>>;
static FunctionDeclAndLoc getEmptyKey() {
return {FDBaseInfo::getEmptyKey(), clang::SourceLocation()};
}
static unsigned getHashValue(const FunctionDeclAndLoc &FDL) {
return hash_combine(FDBaseInfo::getHashValue(FDL.FD),
FDL.Loc.getHashValue());

View file

@ -36,9 +36,6 @@ public:
struct DenseMapInfoByAliasOnly
: private llvm::DenseMapInfo<const IdentifierInfo *> {
static inline WeakInfo getEmptyKey() {
return WeakInfo(DenseMapInfo::getEmptyKey(), SourceLocation());
}
static unsigned getHashValue(const WeakInfo &W) {
return DenseMapInfo::getHashValue(W.getAlias());
}

View file

@ -134,10 +134,6 @@ static_assert(alignof(TypeIdx) == 4);
struct UnsafeQualTypeDenseMapInfo {
static bool isEqual(QualType A, QualType B) { return A == B; }
static QualType getEmptyKey() {
return QualType::getFromOpaquePtr((void *)1);
}
static unsigned getHashValue(QualType T) {
assert(!T.getLocalFastQualifiers() &&
"hash invalid for types with fast quals");
@ -2210,10 +2206,6 @@ public:
namespace llvm {
template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> {
static clang::serialization::DeclarationNameKey getEmptyKey() {
return clang::serialization::DeclarationNameKey(-1, 1);
}
static unsigned
getHashValue(const clang::serialization::DeclarationNameKey &Key) {
return Key.getHash();

View file

@ -120,10 +120,6 @@ private:
namespace llvm {
template <> struct DenseMapInfo<clang::tooling::stdlib::Header> {
static inline clang::tooling::stdlib::Header getEmptyKey() {
return clang::tooling::stdlib::Header(-1,
clang::tooling::stdlib::Lang::CXX);
}
static unsigned getHashValue(const clang::tooling::stdlib::Header &H) {
return hash_value(H.ID);
}
@ -134,10 +130,6 @@ template <> struct DenseMapInfo<clang::tooling::stdlib::Header> {
};
template <> struct DenseMapInfo<clang::tooling::stdlib::Symbol> {
static inline clang::tooling::stdlib::Symbol getEmptyKey() {
return clang::tooling::stdlib::Symbol(-1,
clang::tooling::stdlib::Lang::CXX);
}
static unsigned getHashValue(const clang::tooling::stdlib::Symbol &S) {
return hash_value(S.ID);
}

View file

@ -361,11 +361,6 @@ namespace llvm {
template <> struct DenseMapInfo<clang::api_notes::StoredObjCSelector> {
typedef DenseMapInfo<unsigned> UnsignedInfo;
static inline clang::api_notes::StoredObjCSelector getEmptyKey() {
return clang::api_notes::StoredObjCSelector{UnsignedInfo::getEmptyKey(),
{}};
}
static unsigned
getHashValue(const clang::api_notes::StoredObjCSelector &Selector) {
auto hash = llvm::hash_value(Selector.NumArgs);
@ -384,10 +379,6 @@ template <> struct DenseMapInfo<clang::api_notes::StoredObjCSelector> {
};
template <> struct DenseMapInfo<clang::api_notes::ContextTableKey> {
static inline clang::api_notes::ContextTableKey getEmptyKey() {
return clang::api_notes::ContextTableKey();
}
static unsigned getHashValue(const clang::api_notes::ContextTableKey &value) {
return value.hashValue();
}
@ -399,10 +390,6 @@ template <> struct DenseMapInfo<clang::api_notes::ContextTableKey> {
};
template <> struct DenseMapInfo<clang::api_notes::SingleDeclTableKey> {
static inline clang::api_notes::SingleDeclTableKey getEmptyKey() {
return clang::api_notes::SingleDeclTableKey();
}
static unsigned
getHashValue(const clang::api_notes::SingleDeclTableKey &value) {
return value.hashValue();

View file

@ -184,13 +184,6 @@ APValue::LValueBase::operator bool () const {
return static_cast<bool>(Ptr);
}
clang::APValue::LValueBase
llvm::DenseMapInfo<clang::APValue::LValueBase>::getEmptyKey() {
clang::APValue::LValueBase B;
B.Ptr = DenseMapInfo<const ValueDecl*>::getEmptyKey();
return B;
}
namespace clang {
llvm::hash_code hash_value(const APValue::LValueBase &Base) {
if (Base.is<TypeInfoLValue>() || Base.is<DynamicAllocLValue>())

View file

@ -733,9 +733,6 @@ namespace {
namespace llvm {
template<> struct DenseMapInfo<ObjectUnderConstruction> {
using Base = DenseMapInfo<APValue::LValueBase>;
static ObjectUnderConstruction getEmptyKey() {
return {Base::getEmptyKey(), {}};
}
static unsigned getHashValue(const ObjectUnderConstruction &Object) {
return hash_value(Object);
}

View file

@ -74,35 +74,13 @@ struct DecompositionDeclName {
}
namespace llvm {
template <typename T> static bool isDenseMapKeyEmpty(T V) {
return llvm::DenseMapInfo<T>::isEqual(
V, llvm::DenseMapInfo<T>::getEmptyKey());
}
template <typename T>
static std::optional<bool> areDenseMapKeysEqualSpecialValues(T LHS, T RHS) {
bool LHSEmpty = isDenseMapKeyEmpty(LHS);
bool RHSEmpty = isDenseMapKeyEmpty(RHS);
if (LHSEmpty || RHSEmpty)
return LHSEmpty && RHSEmpty;
return std::nullopt;
}
template<>
struct DenseMapInfo<DecompositionDeclName> {
using ArrayInfo = llvm::DenseMapInfo<ArrayRef<const BindingDecl*>>;
static DecompositionDeclName getEmptyKey() {
return {ArrayInfo::getEmptyKey()};
}
static unsigned getHashValue(DecompositionDeclName Key) {
assert(!isEqual(Key, getEmptyKey()));
return llvm::hash_combine_range(Key);
}
static bool isEqual(DecompositionDeclName LHS, DecompositionDeclName RHS) {
if (std::optional<bool> Result =
areDenseMapKeysEqualSpecialValues(LHS.Bindings, RHS.Bindings))
return *Result;
return LHS.Bindings.size() == RHS.Bindings.size() &&
std::equal(LHS.begin(), LHS.end(), RHS.begin());
}

View file

@ -66,10 +66,6 @@ public:
(unsigned)Float.bitcastToAPInt().getZExtValue(), QTypeHash);
}
static inline NSConstantNumberMapInfo getEmptyKey() {
return NSConstantNumberMapInfo();
}
bool operator==(const NSConstantNumberMapInfo &RHS) const {
if (InfoType != RHS.InfoType || QType != RHS.QType)
return false;
@ -159,10 +155,6 @@ namespace llvm {
using namespace clang::CodeGen::CGObjCMacConstantLiteralUtil;
template <> struct DenseMapInfo<NSConstantNumberMapInfo> {
static NSConstantNumberMapInfo getEmptyKey() {
return NSConstantNumberMapInfo::getEmptyKey();
}
static unsigned getHashValue(const NSConstantNumberMapInfo &S) {
return S.getHashValue();
}

View file

@ -228,16 +228,6 @@ public:
namespace llvm {
template<> struct DenseMapInfo<clang::CodeGen::TBAAAccessInfo> {
static clang::CodeGen::TBAAAccessInfo getEmptyKey() {
unsigned UnsignedKey = DenseMapInfo<unsigned>::getEmptyKey();
return clang::CodeGen::TBAAAccessInfo(
static_cast<clang::CodeGen::TBAAAccessKind>(UnsignedKey),
DenseMapInfo<MDNode *>::getEmptyKey(),
DenseMapInfo<MDNode *>::getEmptyKey(),
DenseMapInfo<uint64_t>::getEmptyKey(),
DenseMapInfo<uint64_t>::getEmptyKey());
}
static unsigned getHashValue(const clang::CodeGen::TBAAAccessInfo &Val) {
auto KindValue = static_cast<unsigned>(Val.Kind);
return DenseMapInfo<unsigned>::getHashValue(KindValue) ^

View file

@ -4278,11 +4278,7 @@ class CatchHandlerType {
LLVM_PREFERRED_TYPE(bool)
unsigned IsPointer : 1;
// This is a special constructor to be used only with DenseMapInfo's
// getEmptyKey() function.
friend struct llvm::DenseMapInfo<CatchHandlerType>;
enum Unique { ForDenseMap };
CatchHandlerType(QualType QT, Unique) : QT(QT), IsPointer(false) {}
public:
/// Used when creating a CatchHandlerType from a handler type; will determine
@ -4319,11 +4315,6 @@ public:
namespace llvm {
template <> struct DenseMapInfo<CatchHandlerType> {
static CatchHandlerType getEmptyKey() {
return CatchHandlerType(DenseMapInfo<QualType>::getEmptyKey(),
CatchHandlerType::ForDenseMap);
}
static unsigned getHashValue(const CatchHandlerType &Base) {
return DenseMapInfo<QualType>::getHashValue(Base.underlying());
}

View file

@ -1238,10 +1238,6 @@ template <> struct DenseMapInfo<PrivateMethodKey> {
using InterfaceInfo = DenseMapInfo<const ObjCInterfaceDecl *>;
using SelectorInfo = DenseMapInfo<Selector>;
static inline PrivateMethodKey getEmptyKey() {
return {InterfaceInfo::getEmptyKey(), SelectorInfo::getEmptyKey(), false};
}
static unsigned getHashValue(const PrivateMethodKey &Key) {
return llvm::hash_combine(
llvm::hash_code(InterfaceInfo::getHashValue(Key.Interface)),

View file

@ -142,7 +142,6 @@ using OffloadingImage = OffloadBinary::OffloadingImage;
namespace llvm {
// Provide DenseMapInfo so that OffloadKind can be used in a DenseMap.
template <> struct DenseMapInfo<OffloadKind> {
static inline OffloadKind getEmptyKey() { return OFK_LAST; }
static unsigned getHashValue(const OffloadKind &Val) { return Val; }
static bool isEqual(const OffloadKind &LHS, const OffloadKind &RHS) {

View file

@ -1622,9 +1622,6 @@ static inline CXCursorSet_Impl *unpackCXCursorSet(CXCursorSet set) {
namespace llvm {
template <> struct DenseMapInfo<CXCursor> {
public:
static inline CXCursor getEmptyKey() {
return MakeCXCursorInvalid(CXCursor_InvalidFile);
}
static inline unsigned getHashValue(const CXCursor &cursor) {
return llvm::DenseMapInfo<std::pair<const void *, const void *>>::
getHashValue(std::make_pair(cursor.data[0], cursor.data[1]));

View file

@ -96,10 +96,6 @@ namespace llvm {
template <>
struct DenseMapInfo<PPRegion> {
static inline PPRegion getEmptyKey() {
return PPRegion(llvm::sys::fs::UniqueID(0, 0), unsigned(-1), 0);
}
static unsigned getHashValue(const PPRegion &S) {
llvm::FoldingSetNodeID ID;
const llvm::sys::fs::UniqueID &UniqueID = S.getUniqueID();