Skip to content

Commit e543f9d

Browse files
CEL Dev Teamcopybara-github
authored andcommitted
Suppress clang warning for direct memory write in value_variant.h.
PiperOrigin-RevId: 781114095
1 parent 2a8b2c8 commit e543f9d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

common/values/value_variant.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,14 @@ class alignas(kValueVariantAlign) CEL_COMMON_INTERNAL_VALUE_VARIANT_TRIVIAL_ABI
732732
const bool rhs_trivial =
733733
(rhs.flags_ & ValueFlags::kNonTrivial) == ValueFlags::kNone;
734734
if (lhs_trivial && rhs_trivial) {
735+
// We validated the instances can be copied byte-wise at runtime, but compilers
736+
// warn since this is not safe in the general case.
735737
#if defined(__GNUC__) && !defined(__clang__)
736-
// We validated the instances can be copied byte-wise at runtime, but GCC
737-
// warns since this is not safe in the general case.
738738
#pragma GCC diagnostic push
739739
#pragma GCC diagnostic ignored "-Wclass-memaccess"
740+
#elif defined(__clang__)
741+
#pragma clang diagnostic push
742+
#pragma clang diagnostic ignored "-Wnontrivial-memcall"
740743
#endif
741744
alignas(ValueVariant) std::byte tmp[sizeof(ValueVariant)];
742745
// NOLINTNEXTLINE(bugprone-undefined-memory-manipulation)
@@ -748,6 +751,8 @@ class alignas(kValueVariantAlign) CEL_COMMON_INTERNAL_VALUE_VARIANT_TRIVIAL_ABI
748751
std::memcpy(std::addressof(rhs), tmp, sizeof(ValueVariant));
749752
#if defined(__GNUC__) && !defined(__clang__)
750753
#pragma GCC diagnostic pop
754+
#elif defined(__clang__)
755+
#pragma clang diagnostic pop
751756
#endif
752757
} else {
753758
SlowSwap(lhs, rhs, lhs_trivial, rhs_trivial);

0 commit comments

Comments
 (0)