Commit 35e8e3f7 by Martijn Vels Committed by Copybara-Service

Make `SanitizerSafeCopy()` constexpr, and check for constant evaluation

PiperOrigin-RevId: 504728034
Change-Id: Ifb338247b7484426e25a58580783a1d70d27e6fd
parent a69b0ae5
...@@ -768,7 +768,8 @@ class InlineData { ...@@ -768,7 +768,8 @@ class InlineData {
} }
#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER #ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER
Rep SanitizerSafeCopy() const { constexpr Rep SanitizerSafeCopy() const {
if (!absl::is_constant_evaluated()) {
Rep res; Rep res;
if (is_tree()) { if (is_tree()) {
res = *this; res = *this;
...@@ -777,9 +778,12 @@ class InlineData { ...@@ -777,9 +778,12 @@ class InlineData {
memcpy(res.as_chars(), as_chars(), inline_size()); memcpy(res.as_chars(), as_chars(), inline_size());
} }
return res; return res;
} else {
return *this;
}
} }
#else #else
const Rep& SanitizerSafeCopy() const { return *this; } constexpr const Rep& SanitizerSafeCopy() const { return *this; }
#endif #endif
// If the data has length <= kMaxInline, we store it in `data`, and // If the data has length <= kMaxInline, we store it in `data`, and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment