Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions absl/container/internal/container_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,21 @@ struct map_slot_policy {
_Pragma("GCC diagnostic pop")
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(x) \
ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(return x)
#elif defined(ABSL_HAVE_MEMORY_SANITIZER)
// Unlike GCC's -Wmaybe-uninitialized (a compile-time diagnostic),
// MemorySanitizer is a runtime tool and reports these intentional reads of
// possibly-uninitialized values (e.g. slot_array for empty tables). Mark the
// storage initialized so MSan does not flag them, preserving value/reference
// category for the various accessors. SanitizerUnpoisonMemoryRegion is a no-op
// unless a sanitizer is enabled.
template <typename T>
inline T&& SwisstableIgnoreUninitialized(T&& value) {
SanitizerUnpoisonMemoryRegion(&value, sizeof(value));
return static_cast<T&&>(value);
}
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(x) x
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(x) \
return SwisstableIgnoreUninitialized(x)
#else
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED(x) x
#define ABSL_SWISSTABLE_IGNORE_UNINITIALIZED_RETURN(x) return x
Expand Down