Skip to content

Commit 0fad7d7

Browse files
[llvm] Use static_assert on getEmptyKey and getTombstoneKey (NFC) (#167167)
Note that DenseMapInfo<unsigned>::getEmptyKey() and getTombstoneKey() are constexpr. This patch removes assertion messages as they don't state any more than what's expressed in the assertion condition. Identified with misc-static-assert.
1 parent e61a51d commit 0fad7d7

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

llvm/include/llvm/Analysis/IRSimilarityIdentifier.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,10 @@ struct IRInstructionMapper {
509509
: InstDataAllocator(IDA), IDLAllocator(IDLA) {
510510
// Make sure that the implementation of DenseMapInfo<unsigned> hasn't
511511
// changed.
512-
assert(DenseMapInfo<unsigned>::getEmptyKey() == static_cast<unsigned>(-1) &&
513-
"DenseMapInfo<unsigned>'s empty key isn't -1!");
514-
assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
515-
static_cast<unsigned>(-2) &&
516-
"DenseMapInfo<unsigned>'s tombstone key isn't -2!");
512+
static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
513+
static_cast<unsigned>(-1));
514+
static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
515+
static_cast<unsigned>(-2));
517516

518517
IDL = new (IDLAllocator->Allocate())
519518
IRInstructionDataList();

llvm/include/llvm/Transforms/IPO/IROutliner.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ class IROutliner {
204204
: getTTI(GTTI), getIRSI(GIRSI), getORE(GORE) {
205205

206206
// Check that the DenseMap implementation has not changed.
207-
assert(DenseMapInfo<unsigned>::getEmptyKey() == (unsigned)-1 &&
208-
"DenseMapInfo<unsigned>'s empty key isn't -1!");
209-
assert(DenseMapInfo<unsigned>::getTombstoneKey() == (unsigned)-2 &&
210-
"DenseMapInfo<unsigned>'s tombstone key isn't -2!");
207+
static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
208+
static_cast<unsigned>(-1));
209+
static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
210+
static_cast<unsigned>(-2));
211211
}
212212
bool run(Module &M);
213213

llvm/lib/CodeGen/MachineOutliner.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,10 @@ struct InstructionMapper {
420420
InstructionMapper(const MachineModuleInfo &MMI_) : MMI(MMI_) {
421421
// Make sure that the implementation of DenseMapInfo<unsigned> hasn't
422422
// changed.
423-
assert(DenseMapInfo<unsigned>::getEmptyKey() == (unsigned)-1 &&
424-
"DenseMapInfo<unsigned>'s empty key isn't -1!");
425-
assert(DenseMapInfo<unsigned>::getTombstoneKey() == (unsigned)-2 &&
426-
"DenseMapInfo<unsigned>'s tombstone key isn't -2!");
423+
static_assert(DenseMapInfo<unsigned>::getEmptyKey() ==
424+
static_cast<unsigned>(-1));
425+
static_assert(DenseMapInfo<unsigned>::getTombstoneKey() ==
426+
static_cast<unsigned>(-2));
427427
}
428428
};
429429

0 commit comments

Comments
 (0)