[compiler-rt] 1a4754c - [NFC] turn comment into static_assert (#71504)

via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 01:23:59 PST 2023


Author: Florian Mayer
Date: 2023-11-08T01:23:55-08:00
New Revision: 1a4754c8c8bceede7d7b9644bc34b44b027e0d23

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

LOG: [NFC] turn comment into static_assert (#71504)

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h b/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h
index f22e40cac284095..6222a958b116826 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h
@@ -47,7 +47,9 @@ class RingBuffer {
   void push(T t) {
     *next_ = t;
     next_--;
-    // The condition below works only if sizeof(T) is divisible by sizeof(T*).
+    static_assert((sizeof(T) % sizeof(T *)) == 0,
+                  "The condition below works only if sizeof(T) is divisible by "
+                  "sizeof(T*).");
     if (next_ <= reinterpret_cast<T*>(&next_))
       next_ = last_;
   }


        


More information about the llvm-commits mailing list