Enable stricter compiler warnings (-Wshadow, -Wnon-virtual-dtor, -Woverloaded-virtual)#2327
Enable stricter compiler warnings (-Wshadow, -Wnon-virtual-dtor, -Woverloaded-virtual)#2327maxwbuckley wants to merge 2 commits intorapidsai:mainfrom
Conversation
…erloaded-virtual) Add `-Wshadow`, `-Wnon-virtual-dtor`, and `-Woverloaded-virtual` to the compiler warning flags for the library, tests, and benchmarks. These are enforced as errors via the existing `-Werror`. Third-party includes (rapids_logger, spdlog) are marked as SYSTEM to suppress upstream warnings. Fix all violations: - Rename variables/parameters that shadow outer-scope names, class members, type aliases, or inherited members across headers, sources, tests, and benchmarks - Add explicit virtual destructor to owning_wrapper - Replace C-style (void)0 cast with static_cast<void>(0) - Rename GTest INSTANTIATE_TEST_SUITE_P lambda params to avoid macro-internal shadow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughCMake warning/compile flags were extended and rapids_logger/spdlog includes marked system; numerous parameter and local-variable identifier renames across src, include, benchmarks, and tests; one class destructor declaration added and a macro no-op changed to use Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~14 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment Tip You can disable the changed files summary in the walkthrough.Disable the |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
cpp/include/rmm/cuda_stream.hpp (1)
60-63:⚠️ Potential issue | 🟡 MinorUpdate Doxygen param name to match the signature.
After renaming to
stream_flags, the doc comment still uses@param flags, which makes API docs inconsistent.📝 Proposed fix
- * `@param` flags Stream creation flags. + * `@param` stream_flags Stream creation flags.As per coding guidelines, "
cpp/include/rmm/**/*.{h,hpp}: C++ public APIs must include Doxygen comments using /** ... */ format."Also applies to: 66-66
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cpp/include/rmm/cuda_stream.hpp` around lines 60 - 63, The constructor Doxygen uses an out-of-date param tag (`@param` flags); update the comment for the CUDA stream constructor to use the correct parameter name (`@param` stream_flags) to match the function signature (constructor for class cuda_stream / function name cuda_stream::cuda_stream or similar) and ensure the comment uses the required /** ... */ Doxygen style; also apply the same fix to the other occurrence mentioned (the doc at the second occurrence).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cpp/benchmarks/synchronization/synchronization.hpp`:
- Around line 69-71: Update the Doxygen `@param` for the cuda_event_timer
constructor to use the renamed parameter name "strm" instead of "stream"; locate
the declaration/definition of cuda_event_timer(benchmark::State& state, bool
flush_l2_cache, rmm::cuda_stream_view strm = rmm::cuda_stream_default) and
change the `@param` tag to `@param` strm (or rename the parameter back and make docs
consistent) so the documentation matches the actual argument name.
In `@cpp/include/rmm/exec_policy.hpp`:
- Around line 48-49: Update the Doxygen param names to match the constructor
signatures: change any "@param stream" to "@param strm" for the exec_policy
constructors (the explicit exec_policy(cuda_stream_view strm = ...,
device_async_resource_ref mr = ...) overload and the other constructor overload
referenced around the same area) so the public API docs match the actual
parameter name `strm` and avoid stale documentation.
---
Outside diff comments:
In `@cpp/include/rmm/cuda_stream.hpp`:
- Around line 60-63: The constructor Doxygen uses an out-of-date param tag
(`@param` flags); update the comment for the CUDA stream constructor to use the
correct parameter name (`@param` stream_flags) to match the function signature
(constructor for class cuda_stream / function name cuda_stream::cuda_stream or
similar) and ensure the comment uses the required /** ... */ Doxygen style; also
apply the same fix to the other occurrence mentioned (the doc at the second
occurrence).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3def1fde-be46-4e74-b628-073ded4c98c6
📒 Files selected for processing (47)
cpp/CMakeLists.txtcpp/benchmarks/CMakeLists.txtcpp/benchmarks/random_allocations/random_allocations.cppcpp/benchmarks/replay/replay.cppcpp/benchmarks/synchronization/synchronization.cppcpp/benchmarks/synchronization/synchronization.hppcpp/benchmarks/utilities/log_parser.hppcpp/include/rmm/cuda_stream.hppcpp/include/rmm/detail/logging_assert.hppcpp/include/rmm/detail/runtime_capabilities.hppcpp/include/rmm/exec_policy.hppcpp/include/rmm/mr/arena_memory_resource.hppcpp/include/rmm/mr/detail/coalescing_free_list.hppcpp/include/rmm/mr/detail/free_list.hppcpp/include/rmm/mr/owning_wrapper.hppcpp/include/rmm/mr/pinned_host_memory_resource.hppcpp/include/rmm/mr/system_memory_resource.hppcpp/src/cuda_stream.cppcpp/src/exec_policy.cppcpp/src/logger.cppcpp/tests/CMakeLists.txtcpp/tests/cuda_stream_pool_tests.cppcpp/tests/device_buffer_tests.cucpp/tests/mr/aligned_mr_tests.cppcpp/tests/mr/arena_mr_tests.cppcpp/tests/mr/callback_mr_tests.cppcpp/tests/mr/host_mr_ref_tests.cppcpp/tests/mr/hwdecompress_tests.cppcpp/tests/mr/mr_ref_arena_tests.cppcpp/tests/mr/mr_ref_binning_tests.cppcpp/tests/mr/mr_ref_cuda_async_tests.cppcpp/tests/mr/mr_ref_cuda_tests.cppcpp/tests/mr/mr_ref_fixed_size_tests.cppcpp/tests/mr/mr_ref_managed_tests.cppcpp/tests/mr/mr_ref_pinned_pool_tests.cppcpp/tests/mr/mr_ref_pinned_tests.cppcpp/tests/mr/mr_ref_pool_tests.cppcpp/tests/mr/mr_ref_system_tests.cppcpp/tests/mr/mr_ref_test.hppcpp/tests/mr/mr_ref_test_basic.hppcpp/tests/mr/pool_mr_tests.cppcpp/tests/mr/prefetch_resource_adaptor_tests.cppcpp/tests/mr/resource_ref_conversion_tests.cppcpp/tests/mr/statistics_mr_tests.cppcpp/tests/mr/thrust_allocator_tests.cucpp/tests/mr/tracking_mr_tests.cppcpp/tests/prefetch_tests.cpp
Update @param tags in exec_policy.hpp (stream → strm), cuda_stream.hpp (flags → stream_flags), synchronization.hpp (stream → strm), and replay.cpp (args → simulated_size/events) so documentation matches the actual parameter names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
All CodeRabbit review comments have been addressed in commit b9091a9:
|
| -Wall | ||
| -Werror | ||
| -Wextra | ||
| -Wshadow |
There was a problem hiding this comment.
Hi, thanks for the PR.
- Is there a specific environment where you’re observing these warnings?
- How did you select this set of warnings?
- Some seems fine to enable but I am unsure about -Wshadow. Can you justify this one in particular? We generally avoid the abbreviated names introduced here like
strmfor a stream orpfor a pointer in favor of full words.
RMM typically requires issues that motivate all pull requests so we have an archive of the library design decisions, could you file an issue containing that motivational information including what environments you observed these? I want to be sure RMM can meet requirements of the libraries depending on it, and I am not aware of any libraries requiring these flags that use RMM.
This PR has a large diff. I am currently refactoring a large part of the library and this will be hard to rebase into the staging branch. Once we settle on what changes we want to make, we can work on a PR based on the staging branch, but I may ask you to wait until some large open PRs land to avoid churn. Thanks!
There was a problem hiding this comment.
Also some companies (Google which I recently left) enforce strict compiler settings by default. So all of these issues make it harder to import RMM into third party.
There was a problem hiding this comment.
Thanks for the detailed feedback, Bradley!
Filed #2338 with the motivation. The short version: some organizations (Google, which I recently left) enforce strict compiler settings by default, so these warnings make it harder to import RMM into third-party projects using -Werror.
To answer your questions:
- I observed these warnings building with GCC 13 and Clang 18 using -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Werror.
- I selected these specific flags because they catch real bug classes (shadowing, missing virtual destructors, accidentally hidden overloads) and are commonly enforced in projects with strict warning policies.
- On -Wshadow specifically — I understand the preference for full names over abbreviations like
strm/p. Happy to rework those renames to use more descriptive alternatives that still avoid the shadowing (e.g.cuda_streaminstead ofstrm). Let me know what naming you'd prefer and I'll update.
Also happy to wait on the staging branch and rebase once your refactor lands — just let me know when it's a good time. Thanks again!
There was a problem hiding this comment.
Awesome. Yes, I think a lot of this will change on the staging branch (it's a near-total rewrite). The staging branch should stabilize in about a week or two. The last major change I need for that branch is #2325 and I'm currently working on splitting that PR up into smaller pieces and working out some design issues with CCCL upstream. I'll follow up on this thread once it's ready.
There was a problem hiding this comment.
I would expect this PR would cause some sort of breaking builds for downstream libraries. Can we switch this to draft mode, test it against downstream libraries first, apply the same set of compiler directive to them first if needed, then merge this one last?
Why
|
Summary
-Wshadow,-Wnon-virtual-dtor, and-Woverloaded-virtualto compiler warning flags for the library, tests, and benchmarks (enforced as errors via existing-Werror)owning_wrapper, C-style cast replacement, and GTest macro lambda param renamesSome company compilers enable warning as errors by default and this change makes importing and using RMM easier in those cases.
Test plan
clang-formatrun on all modified files — no style violationsctest --output-on-failure)🤖 Generated with Claude Code