Skip to content

Commit

Permalink
Use static_assert instead of assert (NFC)
Browse files Browse the repository at this point in the history
Identified with misc-static-assert.
  • Loading branch information
kazutakahirata committed Jul 23, 2022
1 parent d23da0e commit 1cc7f5b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lld/ELF/SyntheticSections.cpp
Expand Up @@ -3856,7 +3856,8 @@ void InStruct::reset() {

constexpr char kMemtagAndroidNoteName[] = "Android";
void MemtagAndroidNote::writeTo(uint8_t *buf) {
assert(sizeof(kMemtagAndroidNoteName) == 8); // ABI check for Android 11 & 12.
static_assert(sizeof(kMemtagAndroidNoteName) == 8,
"ABI check for Android 11 & 12.");
assert((config->androidMemtagStack || config->androidMemtagHeap) &&
"Should only be synthesizing a note if heap || stack is enabled.");

Expand Down
2 changes: 1 addition & 1 deletion lld/MachO/SyntheticSections.cpp
Expand Up @@ -57,7 +57,7 @@ static void sha256(const uint8_t *data, size_t len, uint8_t *output) {
#else
ArrayRef<uint8_t> block(data, len);
std::array<uint8_t, 32> hash = SHA256::hash(block);
assert(hash.size() == CodeSignatureSection::hashSize);
static_assert(hash.size() == CodeSignatureSection::hashSize, "");
memcpy(output, hash.data(), hash.size());
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Expand Up @@ -12216,7 +12216,8 @@ bool RISCVTargetLowering::isVScaleKnownToBeAPowerOfTwo() const {
// FIXME: This doesn't work for zve32, but that's already broken
// elsewhere for the same reason.
assert(Subtarget.getRealMinVLen() >= 64 && "zve32* unsupported");
assert(RISCV::RVVBitsPerBlock == 64 && "RVVBitsPerBlock changed, audit needed");
static_assert(RISCV::RVVBitsPerBlock == 64,
"RVVBitsPerBlock changed, audit needed");
return true;
}

Expand Down

0 comments on commit 1cc7f5b

Please sign in to comment.