Skip to content

Commit 9ff6c35

Browse files
committed
[DenseMap] clear: don't access TombstoneKey if is_trivially_destructible
1 parent ba45453 commit 9ff6c35

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/include/llvm/ADT/DenseMap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ class DenseMapBase : public DebugEpochBase {
118118
return;
119119
}
120120

121-
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
121+
const KeyT EmptyKey = getEmptyKey();
122122
if (std::is_trivially_destructible<ValueT>::value) {
123123
// Use a simpler loop when values don't need destruction.
124124
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P)
125125
P->getFirst() = EmptyKey;
126126
} else {
127+
const KeyT TombstoneKey = getTombstoneKey();
127128
unsigned NumEntries = getNumEntries();
128129
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P) {
129130
if (!KeyInfoT::isEqual(P->getFirst(), EmptyKey)) {

0 commit comments

Comments
 (0)