[compiler-rt] [NFC] turn comment into static_assert (PR #71504)
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 7 01:28:07 PST 2023
https://github.com/fmayer created https://github.com/llvm/llvm-project/pull/71504
None
>From 071fa9b57e024d913b8054a3a1f555cf2aba6149 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Tue, 7 Nov 2023 01:24:22 -0800
Subject: [PATCH] [NFC] turn comment into static_assert
---
compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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