Prepare to rename RTC_NOTREACHED to RTC_DCHECK_NOTREACHED

Add implementation of RTC_DCHECK_NOTREACHED equal to the RTC_NOTREACHED.
The new macros will replace the old one when old one's usage will be
removed. The idea of the renaming to provide a clear signal that this
is debug build only macros and will be stripped in the production build.

Bug: webrtc:9065
Change-Id: I4c35d8b03e74a4b3fd1ae75dba2f9c05643101db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237802
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35348}
diff --git a/modules/audio_coding/acm2/acm_receiver_unittest.cc b/modules/audio_coding/acm2/acm_receiver_unittest.cc
index 2338a53..e73acc2 100644
--- a/modules/audio_coding/acm2/acm_receiver_unittest.cc
+++ b/modules/audio_coding/acm2/acm_receiver_unittest.cc
@@ -119,7 +119,7 @@
         rtp_header_,
         rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes));
     if (ret_val < 0) {
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
       return -1;
     }
     rtp_header_.sequenceNumber++;
diff --git a/modules/audio_coding/acm2/acm_resampler.cc b/modules/audio_coding/acm2/acm_resampler.cc
index 7c7393d..e307c6c 100644
--- a/modules/audio_coding/acm2/acm_resampler.cc
+++ b/modules/audio_coding/acm2/acm_resampler.cc
@@ -30,7 +30,7 @@
   size_t in_length = in_freq_hz * num_audio_channels / 100;
   if (in_freq_hz == out_freq_hz) {
     if (out_capacity_samples < in_length) {
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
       return -1;
     }
     memcpy(out_audio, in_audio, in_length * sizeof(int16_t));
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index b742a82..e2081e2 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -344,13 +344,13 @@
 int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
                                                InputData* input_data) {
   if (audio_frame.samples_per_channel_ == 0) {
-    RTC_NOTREACHED();
+    RTC_DCHECK_NOTREACHED();
     RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, payload length is zero";
     return -1;
   }
 
   if (audio_frame.sample_rate_hz_ > kMaxInputSampleRateHz) {
-    RTC_NOTREACHED();
+    RTC_DCHECK_NOTREACHED();
     RTC_LOG(LS_ERROR) << "Cannot Add 10 ms audio, input frequency not valid";
     return -1;
   }
diff --git a/modules/audio_coding/acm2/call_statistics.cc b/modules/audio_coding/acm2/call_statistics.cc
index 0aad594..9f3bdad 100644
--- a/modules/audio_coding/acm2/call_statistics.cc
+++ b/modules/audio_coding/acm2/call_statistics.cc
@@ -45,7 +45,7 @@
     }
     case AudioFrame::kUndefined: {
       // If the audio is decoded by NetEq, `kUndefined` is not an option.
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
     }
   }
 }
diff --git a/modules/audio_coding/audio_network_adaptor/controller_manager.cc b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
index 6708bc0..87759c3 100644
--- a/modules/audio_coding/audio_network_adaptor/controller_manager.cc
+++ b/modules/audio_coding/audio_network_adaptor/controller_manager.cc
@@ -265,7 +265,7 @@
         break;
       case audio_network_adaptor::config::Controller::kFecControllerRplrBased:
         // FecControllerRplrBased has been removed and can't be used anymore.
-        RTC_NOTREACHED();
+        RTC_DCHECK_NOTREACHED();
         continue;
       case audio_network_adaptor::config::Controller::kFrameLengthController:
         controller = CreateFrameLengthController(
@@ -293,7 +293,7 @@
             encoder_frame_lengths_ms);
         break;
       default:
-        RTC_NOTREACHED();
+        RTC_DCHECK_NOTREACHED();
     }
     if (controller_config.has_scoring_point()) {
       auto& scoring_point = controller_config.scoring_point();
@@ -321,7 +321,7 @@
   }
 
 #else
-  RTC_NOTREACHED();
+  RTC_DCHECK_NOTREACHED();
   return nullptr;
 #endif  // WEBRTC_ENABLE_PROTOBUF
 }
diff --git a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
index 669cf5e..2616706 100644
--- a/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
+++ b/modules/audio_coding/audio_network_adaptor/debug_dump_writer.cc
@@ -76,7 +76,7 @@
   dump_file_ = FileWrapper(file_handle);
   RTC_CHECK(dump_file_.is_open());
 #else
-  RTC_NOTREACHED();
+  RTC_DCHECK_NOTREACHED();
 #endif
 }
 
diff --git a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
index 936e224..c5e5fa7 100644
--- a/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
+++ b/modules/audio_coding/audio_network_adaptor/fec_controller_plr_based.cc
@@ -26,7 +26,7 @@
   absl::optional<float> GetAverage() override { return last_sample_; }
 
   bool SetTimeConstantMs(int time_constant_ms) override {
-    RTC_NOTREACHED();
+    RTC_DCHECK_NOTREACHED();
     return false;
   }
 
diff --git a/modules/audio_coding/codecs/isac/isac_webrtc_api_test.cc b/modules/audio_coding/codecs/isac/isac_webrtc_api_test.cc
index be8d0c6..cafca75 100644
--- a/modules/audio_coding/codecs/isac/isac_webrtc_api_test.cc
+++ b/modules/audio_coding/codecs/isac/isac_webrtc_api_test.cc
@@ -51,8 +51,8 @@
       filename = test::ResourcePath("audio_coding/testfile32kHz", "pcm");
       break;
     default:
-      RTC_NOTREACHED() << "No test file available for " << sample_rate_hz
-                       << " Hz.";
+      RTC_DCHECK_NOTREACHED()
+          << "No test file available for " << sample_rate_hz << " Hz.";
   }
   auto pcm_file = std::make_unique<PCMFile>();
   pcm_file->ReadStereo(false);
diff --git a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
index 1d0c7fe..f81aeee 100644
--- a/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
+++ b/modules/audio_coding/codecs/legacy_encoded_audio_frame_unittest.cc
@@ -88,7 +88,7 @@
         samples_per_ms_ = 8;
         break;
       default:
-        RTC_NOTREACHED();
+        RTC_DCHECK_NOTREACHED();
         break;
     }
   }
diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h
index 9b1dce8..003d966 100644
--- a/modules/audio_coding/include/audio_coding_module.h
+++ b/modules/audio_coding/include/audio_coding_module.h
@@ -54,7 +54,7 @@
                            uint32_t timestamp,
                            const uint8_t* payload_data,
                            size_t payload_len_bytes) {
-    RTC_NOTREACHED() << "This method must be overridden, or not used.";
+    RTC_DCHECK_NOTREACHED() << "This method must be overridden, or not used.";
     return -1;
   }
 };
diff --git a/modules/audio_coding/neteq/dsp_helper.cc b/modules/audio_coding/neteq/dsp_helper.cc
index 54ec556..a979f94 100644
--- a/modules/audio_coding/neteq/dsp_helper.cc
+++ b/modules/audio_coding/neteq/dsp_helper.cc
@@ -354,7 +354,7 @@
       break;
     }
     default: {
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
       return -1;
     }
   }
diff --git a/modules/audio_coding/neteq/dtmf_tone_generator.cc b/modules/audio_coding/neteq/dtmf_tone_generator.cc
index 49cbf8f..9061e27 100644
--- a/modules/audio_coding/neteq/dtmf_tone_generator.cc
+++ b/modules/audio_coding/neteq/dtmf_tone_generator.cc
@@ -119,7 +119,7 @@
   } else if (fs == 48000) {
     fs_index = 3;
   } else {
-    RTC_NOTREACHED();
+    RTC_DCHECK_NOTREACHED();
     fs_index = 1;  // Default to 8000 Hz.
   }
 
diff --git a/modules/audio_coding/neteq/merge.cc b/modules/audio_coding/neteq/merge.cc
index ca5ec22..22cf6a7 100644
--- a/modules/audio_coding/neteq/merge.cc
+++ b/modules/audio_coding/neteq/merge.cc
@@ -372,7 +372,7 @@
   while (((best_correlation_index + input_length) <
           (timestamps_per_call_ + expand_->overlap_length())) ||
          ((best_correlation_index + input_length) < start_position)) {
-    RTC_NOTREACHED();                         // Should never happen.
+    RTC_DCHECK_NOTREACHED();                  // Should never happen.
     best_correlation_index += expand_period;  // Jump one lag ahead.
   }
   return best_correlation_index;
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 6107b17..7e3c4ef 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -221,7 +221,7 @@
       break;
     }
     default:
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
   }
   if (!vad_enabled) {
     // Always set kVadUnknown when receive VAD is inactive.
@@ -894,7 +894,7 @@
     }
     case Operation::kUndefined: {
       RTC_LOG(LS_ERROR) << "Invalid operation kUndefined.";
-      RTC_NOTREACHED();  // This should not happen.
+      RTC_DCHECK_NOTREACHED();  // This should not happen.
       last_mode_ = Mode::kError;
       return kInvalidOperation;
     }
@@ -1057,7 +1057,7 @@
       // Don't use this packet, discard it.
       if (packet_buffer_->DiscardNextPacket(stats_.get()) !=
           PacketBuffer::kOK) {
-        RTC_NOTREACHED();  // Must be ok by design.
+        RTC_DCHECK_NOTREACHED();  // Must be ok by design.
       }
       // Check buffer again.
       if (!new_codec_) {
@@ -1877,7 +1877,7 @@
   //    // it must be copied to the speech buffer.
   //    // TODO(hlundin): This code seems incorrect. (Legacy.) Write test and
   //    // verify correct operation.
-  //    RTC_NOTREACHED();
+  //    RTC_DCHECK_NOTREACHED();
   //    // Must generate enough data to replace all of the `sync_buffer_`
   //    // "future".
   //    int required_length = sync_buffer_->FutureLength();
@@ -1967,7 +1967,8 @@
     next_packet = nullptr;
     if (!packet) {
       RTC_LOG(LS_ERROR) << "Should always be able to extract a packet here";
-      RTC_NOTREACHED();  // Should always be able to extract a packet here.
+      RTC_DCHECK_NOTREACHED();  // Should always be able to extract a packet
+                                // here.
       return -1;
     }
     const uint64_t waiting_time_ms = packet->waiting_time->ElapsedMs();
@@ -2001,7 +2002,7 @@
     } else if (!has_cng_packet) {
       RTC_LOG(LS_WARNING) << "Unknown payload type "
                           << static_cast<int>(packet->payload_type);
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
     }
 
     if (packet_duration == 0) {
diff --git a/modules/audio_coding/neteq/sync_buffer.cc b/modules/audio_coding/neteq/sync_buffer.cc
index 80e1691..7d7cac7 100644
--- a/modules/audio_coding/neteq/sync_buffer.cc
+++ b/modules/audio_coding/neteq/sync_buffer.cc
@@ -28,7 +28,7 @@
     next_index_ -= samples_added;
   } else {
     // This means that we are pushing out future data that was never used.
-    //    RTC_NOTREACHED();
+    //    RTC_DCHECK_NOTREACHED();
     // TODO(hlundin): This assert must be disabled to support 60 ms frames.
     // This should not happen even for 60 ms frames, but it does. Investigate
     // why.
diff --git a/modules/audio_coding/neteq/tools/rtp_encode.cc b/modules/audio_coding/neteq/tools/rtp_encode.cc
index 204f169..ee392f2 100644
--- a/modules/audio_coding/neteq/tools/rtp_encode.cc
+++ b/modules/audio_coding/neteq/tools/rtp_encode.cc
@@ -191,7 +191,7 @@
       config.sample_rate_hz = 48000;
       return config;
     default:
-      RTC_NOTREACHED();
+      RTC_DCHECK_NOTREACHED();
       return config;
   }
 }
@@ -242,7 +242,7 @@
           GetCodecConfig<AudioEncoderIsac>(), payload_type);
     }
   }
-  RTC_NOTREACHED();
+  RTC_DCHECK_NOTREACHED();
   return nullptr;
 }
 
@@ -259,7 +259,7 @@
       case 48000:
         return 100;
       default:
-        RTC_NOTREACHED();
+        RTC_DCHECK_NOTREACHED();
     }
     return 0;
   };