[lld] 1cc7f5b - Use static_assert instead of assert (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 23 09:22:33 PDT 2022


Author: Kazu Hirata
Date: 2022-07-23T09:22:27-07:00
New Revision: 1cc7f5bedec74a4b94ba5074a78283ba4dafb2f2

URL: https://github.com/llvm/llvm-project/commit/1cc7f5bedec74a4b94ba5074a78283ba4dafb2f2
DIFF: https://github.com/llvm/llvm-project/commit/1cc7f5bedec74a4b94ba5074a78283ba4dafb2f2.diff

LOG: Use static_assert instead of assert (NFC)

Identified with misc-static-assert.

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp
    lld/MachO/SyntheticSections.cpp
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index acd1ed30076aa..a0c5e6d047484 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -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.");
 

diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 36677b58398a6..b47375106e792 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -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
 }

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 66cfbe2feda30..8c39e25ccffc5 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -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;
 }
 


        


More information about the llvm-commits mailing list