Move sanitizer.h to webrtc namespace

Bug: webrtc:42232595
Change-Id: Iaaed4fc562de7ccf29122156b4434d4c4849cbbb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/380920
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#44112}
diff --git a/api/audio_codecs/audio_decoder.cc b/api/audio_codecs/audio_decoder.cc
index aa91ac8..12ce997 100644
--- a/api/audio_codecs/audio_decoder.cc
+++ b/api/audio_codecs/audio_decoder.cc
@@ -90,7 +90,7 @@
                          int16_t* decoded,
                          SpeechType* speech_type) {
   TRACE_EVENT0("webrtc", "AudioDecoder::Decode");
-  rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
+  MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
   int duration = PacketDuration(encoded, encoded_len);
   if (duration >= 0 &&
       duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
@@ -107,7 +107,7 @@
                                   int16_t* decoded,
                                   SpeechType* speech_type) {
   TRACE_EVENT0("webrtc", "AudioDecoder::DecodeRedundant");
-  rtc::MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
+  MsanCheckInitialized(rtc::MakeArrayView(encoded, encoded_len));
   int duration = PacketDurationRedundant(encoded, encoded_len);
   if (duration >= 0 &&
       duration * Channels() * sizeof(int16_t) > max_decoded_bytes) {
diff --git a/common_audio/wav_header.cc b/common_audio/wav_header.cc
index bca209a..467dcc7 100644
--- a/common_audio/wav_header.cc
+++ b/common_audio/wav_header.cc
@@ -205,7 +205,7 @@
   RTC_CHECK(buf);
   RTC_CHECK(header_size);
   *header_size = kPcmWavHeaderSize;
-  auto header = rtc::MsanUninitialized<WavHeaderPcm>({});
+  auto header = MsanUninitialized<WavHeaderPcm>({});
   const size_t bytes_in_payload = bytes_per_sample * num_samples;
 
   header.riff.header.ID = PackFourCC('R', 'I', 'F', 'F');
@@ -236,7 +236,7 @@
   RTC_CHECK(buf);
   RTC_CHECK(header_size);
   *header_size = kIeeeFloatWavHeaderSize;
-  auto header = rtc::MsanUninitialized<WavHeaderIeeeFloat>({});
+  auto header = MsanUninitialized<WavHeaderIeeeFloat>({});
   const size_t bytes_in_payload = bytes_per_sample * num_samples;
 
   header.riff.header.ID = PackFourCC('R', 'I', 'F', 'F');
@@ -374,7 +374,7 @@
                    size_t* num_samples,
                    int64_t* data_start_pos) {
   // Read using the PCM header, even though it might be float Wav file
-  auto header = rtc::MsanUninitialized<WavHeaderPcm>({});
+  auto header = MsanUninitialized<WavHeaderPcm>({});
 
   // Read RIFF chunk.
   if (readable->Read(&header.riff, sizeof(header.riff)) != sizeof(header.riff))
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index b327c9b..feea38b 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -185,7 +185,7 @@
 int NetEqImpl::InsertPacket(const RTPHeader& rtp_header,
                             rtc::ArrayView<const uint8_t> payload,
                             const RtpPacketInfo& packet_info) {
-  rtc::MsanCheckInitialized(payload);
+  MsanCheckInitialized(payload);
   TRACE_EVENT0("webrtc", "NetEqImpl::InsertPacket");
   MutexLock lock(&mutex_);
   if (InsertPacketInternal(rtp_header, payload, packet_info) != 0) {
diff --git a/rtc_base/sanitizer.h b/rtc_base/sanitizer.h
index 7b8a6fc..1bfb8d4 100644
--- a/rtc_base/sanitizer.h
+++ b/rtc_base/sanitizer.h
@@ -113,7 +113,7 @@
 
 #ifdef __cplusplus
 
-namespace rtc {
+namespace webrtc {
 namespace sanitizer_impl {
 
 template <typename T>
@@ -157,6 +157,16 @@
   rtc_MsanCheckInitialized(mem.data(), sizeof(mem.data()[0]), mem.size());
 }
 
+}  //  namespace webrtc
+
+// Re-export symbols from the webrtc namespace for backwards compatibility.
+// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
+namespace rtc {
+using ::webrtc::AsanPoison;
+using ::webrtc::AsanUnpoison;
+using ::webrtc::MsanCheckInitialized;
+using ::webrtc::MsanMarkUninitialized;
+using ::webrtc::MsanUninitialized;
 }  // namespace rtc
 
 #endif  // __cplusplus
diff --git a/rtc_base/sanitizer_unittest.cc b/rtc_base/sanitizer_unittest.cc
index ffbfed7..e293a43 100644
--- a/rtc_base/sanitizer_unittest.cc
+++ b/rtc_base/sanitizer_unittest.cc
@@ -19,7 +19,7 @@
 #include <sanitizer/msan_interface.h>
 #endif
 
-namespace rtc {
+namespace webrtc {
 namespace {
 
 // Test sanitizer_impl::IsTriviallyCopyable (at compile time).
@@ -149,4 +149,4 @@
   RTC_LOG(LS_INFO) << "read with no init passed";
 }
 
-}  // namespace rtc
+}  // namespace webrtc