Skip to content

Commit c8a2f92

Browse files
authored
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: a0f9b46 35e8e3f
1 parent 78be636 commit c8a2f92

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

absl/base/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
// LTS releases can be obtained from
113113
// https://github.com/abseil/abseil-cpp/releases.
114114
#define ABSL_LTS_RELEASE_VERSION 20230125
115-
#define ABSL_LTS_RELEASE_PATCH_LEVEL 0
115+
#define ABSL_LTS_RELEASE_PATCH_LEVEL 1
116116

117117
// Helper macro to convert a CPP variable to a string literal.
118118
#define ABSL_INTERNAL_DO_TOKEN_STR(x) #x

absl/strings/internal/cord_internal.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -768,18 +768,22 @@ class InlineData {
768768
}
769769

770770
#ifdef ABSL_INTERNAL_CORD_HAVE_SANITIZER
771-
Rep SanitizerSafeCopy() const {
772-
Rep res;
773-
if (is_tree()) {
774-
res = *this;
771+
constexpr Rep SanitizerSafeCopy() const {
772+
if (!absl::is_constant_evaluated()) {
773+
Rep res;
774+
if (is_tree()) {
775+
res = *this;
776+
} else {
777+
res.set_tag(tag());
778+
memcpy(res.as_chars(), as_chars(), inline_size());
779+
}
780+
return res;
775781
} else {
776-
res.set_tag(tag());
777-
memcpy(res.as_chars(), as_chars(), inline_size());
782+
return *this;
778783
}
779-
return res;
780784
}
781785
#else
782-
const Rep& SanitizerSafeCopy() const { return *this; }
786+
constexpr const Rep& SanitizerSafeCopy() const { return *this; }
783787
#endif
784788

785789
// If the data has length <= kMaxInline, we store it in `data`, and

ci/linux_docker_containers.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
# Test scripts should source this file to get the identifiers.
1717

1818
readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20201026"
19-
readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220217"
20-
readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220217"
19+
readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230217"
20+
readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230217"
2121
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120"

0 commit comments

Comments
 (0)