Commit c8a2f925 by Derek Mauro Committed by GitHub

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

Also update test Docker container so that LTS patches can be tested

This patch cherry-picks 2 commits:
a0f9b465
35e8e3f7
parent 78be6368
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
// LTS releases can be obtained from // LTS releases can be obtained from
// https://github.com/abseil/abseil-cpp/releases. // https://github.com/abseil/abseil-cpp/releases.
#define ABSL_LTS_RELEASE_VERSION 20230125 #define ABSL_LTS_RELEASE_VERSION 20230125
#define ABSL_LTS_RELEASE_PATCH_LEVEL 0 #define ABSL_LTS_RELEASE_PATCH_LEVEL 1
// Helper macro to convert a CPP variable to a string literal. // Helper macro to convert a CPP variable to a string literal.
#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x #define ABSL_INTERNAL_DO_TOKEN_STR(x) #x
......
...@@ -768,18 +768,22 @@ class InlineData { ...@@ -768,18 +768,22 @@ class InlineData {
} }
#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER #ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER
Rep SanitizerSafeCopy() const { constexpr Rep SanitizerSafeCopy() const {
Rep res; if (!absl::is_constant_evaluated()) {
if (is_tree()) { Rep res;
res = *this; if (is_tree()) {
res = *this;
} else {
res.set_tag(tag());
memcpy(res.as_chars(), as_chars(), inline_size());
}
return res;
} else { } else {
res.set_tag(tag()); return *this;
memcpy(res.as_chars(), as_chars(), inline_size());
} }
return res;
} }
#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
......
...@@ -16,6 +16,6 @@ ...@@ -16,6 +16,6 @@
# Test scripts should source this file to get the identifiers. # Test scripts should source this file to get the identifiers.
readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20201026" readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20201026"
readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220217" readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230217"
readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220217" readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230217"
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120" readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120"
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