Add modernize-use-std-numbers to .clang-tidy
Drive-by: Exclude from analysis a couple of .get() that clang-tidy is wrong about removing.
Bug: webrtc:424706384
Change-Id: I843170b04ceed70f4eb6f131cc1f0ad72394c5b7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/403540
Reviewed-by: Jeremy Leconte <jleconte@google.com>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45317}
diff --git a/.clang-tidy b/.clang-tidy
index a692886..8470f6b 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -3,8 +3,12 @@
Checks: '-*,
llvm-namespace-comment,
modernize-use-override,
+ modernize-use-std-numbers,
readability-container-size-empty,
readability-static-definition-in-anonymous-namespace,
readability-redundant-smartptr-get,
readability-redundant-declaration'
+ CheckOptions:
+ # The default threshold gives false positives in test data
+ modernize-use-std-numbers.DiffThreshold: 0.00001
...
diff --git a/common_audio/resampler/sinc_resampler.cc b/common_audio/resampler/sinc_resampler.cc
index fc64ba6..8317373 100644
--- a/common_audio/resampler/sinc_resampler.cc
+++ b/common_audio/resampler/sinc_resampler.cc
@@ -163,12 +163,17 @@
Flush();
RTC_DCHECK_GT(block_size_, kKernelSize);
+ // NOLINTBEGIN (readability-redundant-smartptr-get)
+ // clang-tidy tries to remove the .get() in calls to sizeof(). This will
+ // not compile.
+ // Bug report ID: 437035885
memset(kernel_storage_.get(), 0,
sizeof(*kernel_storage_.get()) * kKernelStorageSize);
memset(kernel_pre_sinc_storage_.get(), 0,
sizeof(*kernel_pre_sinc_storage_.get()) * kKernelStorageSize);
memset(kernel_window_storage_.get(), 0,
sizeof(*kernel_window_storage_.get()) * kKernelStorageSize);
+ // NOLINTEND
InitializeKernel();
}
@@ -319,6 +324,7 @@
// Step (3) -- Copy r3_, r4_ to r1_, r2_.
// This wraps the last input frames back to the start of the buffer.
+ // NOLINTNEXTLINE(readability-redundant-smartptr-get)
memcpy(r1_, r3_, sizeof(*input_buffer_.get()) * kKernelSize);
// Step (4) -- Reinitialize regions if necessary.
@@ -339,6 +345,7 @@
void SincResampler::Flush() {
virtual_source_idx_ = 0;
buffer_primed_ = false;
+ // NOLINTNEXTLINE(readability-redundant-smartptr-get)
memset(input_buffer_.get(), 0,
sizeof(*input_buffer_.get()) * input_buffer_size_);
UpdateRegions(false);
diff --git a/modules/audio_coding/codecs/opus/test/blocker.cc b/modules/audio_coding/codecs/opus/test/blocker.cc
index 321a3f9..fb5b65f 100644
--- a/modules/audio_coding/codecs/opus/test/blocker.cc
+++ b/modules/audio_coding/codecs/opus/test/blocker.cc
@@ -119,6 +119,7 @@
RTC_CHECK_LE(num_output_channels_, num_input_channels_);
RTC_CHECK_LE(shift_amount_, block_size_);
+ // NOLINTNEXTLINE(readability-redundant-smartptr-get)
memcpy(window_.get(), window, block_size_ * sizeof(*window_.get()));
input_buffer_.MoveReadPositionBackward(initial_delay_);
}