[CODE HEALTH] Fix clang-tidy misc-override-with-different-visibility warnings - #4215
Merged
marcalff merged 4 commits intoJul 7, 2026
Merged
Conversation
…warnings Align the visibility of virtual overrides with their base-class declaration across 13 files, resolving 31 of the 36 warnings from open-telemetry#4195. The remaining 5 (http_server.h / socket_tools.h private-inheritance cases) are deferred to a follow-up. Lower the clang-tidy warning_limit to 280 (abiv1) and 288 (abiv2) accordingly. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4215 +/- ##
=======================================
Coverage 82.83% 82.83%
=======================================
Files 415 415
Lines 17431 17431
=======================================
Hits 14437 14437
Misses 2994 2994
🚀 New features to boost your workflow:
|
marcalff
approved these changes
Jul 6, 2026
marcalff
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for the cleanup
1 task
proost
pushed a commit
to proost/opentelemetry-cpp
that referenced
this pull request
Jul 18, 2026
ayush-that
pushed a commit
to ayush-that/opentelemetry-cpp
that referenced
this pull request
Jul 21, 2026
thc1006
added a commit
to thc1006/opentelemetry-cpp
that referenced
this pull request
Jul 23, 2026
…arnings Align the visibility of the SocketCallback and Thread virtual overrides in the ext/http embedded server to match their inheritance-adjusted base visibility, resolving the 5 misc-override-with-different-visibility warnings that open-telemetry#4215 deferred: - HttpServer privately inherits SocketCallback, so its onSocketAcceptable, onSocketReadable, onSocketWritable and onSocketClosed overrides move from protected to private (the adjacent internal sendMore helper, which is not used by the FileHttpServer subclass, moves with them). - Reactor inherits Thread as protected, so its onThread override moves from public to protected. Both are invoked only through their base interfaces (via SocketCallback& and Thread::onThread virtual dispatch), so the narrower visibility is safe; a syntax-only build of the server plus the FileHttpServer subclass confirms it. Lower the clang-tidy warning_limit to 158/168 accordingly. Fixes open-telemetry#4195. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
thc1006
added a commit
to thc1006/opentelemetry-cpp
that referenced
this pull request
Jul 23, 2026
…arnings Align the visibility of the SocketCallback and Thread virtual overrides in the ext/http embedded server to match their inheritance-adjusted base visibility, resolving the 5 misc-override-with-different-visibility warnings that open-telemetry#4215 deferred: - HttpServer privately inherits SocketCallback, so its onSocketAcceptable, onSocketReadable, onSocketWritable and onSocketClosed overrides move from protected to private (the adjacent internal sendMore helper, which is not used by the FileHttpServer subclass, moves with them). - Reactor inherits Thread as protected, so its onThread override moves from public to protected. Both are invoked only through their base interfaces (via SocketCallback& and Thread::onThread virtual dispatch), so the narrower visibility is safe; a syntax-only build of the server plus the FileHttpServer subclass confirms it. Lower the clang-tidy warning_limit to 158/168 accordingly. Fixes open-telemetry#4195. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
thc1006
added a commit
to thc1006/opentelemetry-cpp
that referenced
this pull request
Jul 23, 2026
…arnings Align the visibility of the SocketCallback and Thread virtual overrides in the ext/http embedded server to match their inheritance-adjusted base visibility, resolving the 5 misc-override-with-different-visibility warnings that open-telemetry#4215 deferred: - HttpServer privately inherits SocketCallback (an implementation-detail base), so its onSocketAcceptable, onSocketReadable, onSocketWritable and onSocketClosed overrides move from protected to private. - Reactor inherits Thread as protected, so its onThread override moves from public to protected. These overrides are dispatched only through their base interfaces (SocketCallback& and Thread::onThread), so no dynamic-dispatch call path changes. The change does narrow the source-level surface a derived class could reach (for example calling the base implementation), but HttpServer is extended through its public request-handler API rather than by overriding the reactor callbacks, so this is consistent with the deliberate private inheritance. The unrelated protected sendMore() helper keeps its visibility. Lower the clang-tidy warning_limit to 158/168 accordingly. Fixes open-telemetry#4195. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes to #4195
Changes
Fixes a subset of #4195 by aligning the visibility of virtual function overrides with their base-class declaration, which is the fix the
misc-override-with-different-visibilitycheck asks for (per the check documentation).This PR resolves 31 of the 36 reported warnings across 13 files. The remaining 5 warnings (in
ext/include/opentelemetry/ext/http/server/http_server.handsocket_tools.h) arise fromprivate/protectedinheritance ofSocketTools::Reactor::SocketCallbackand need a different, more careful change; they are deferred to a follow-up PR to keep this one reviewable.Fix pattern
public-> derived override madepublic(widening; e.g. test mocks ofGetLogger/GetTracer,Predicate::Match,Fields)protected-> derived override madeprotected(e.g.sdk::logs::Logger::EnabledImplementation, gtestSetUp/TearDown)private(NVI) -> derived override madeprivate(e.g.MetricReader::OnForceFlush/OnShutDown/OnInitialized)No behavior change: only access specifiers on overrides are adjusted;
.ccdefinitions do not restate visibility.Verification
warning_limitin.github/workflows/clang-tidy.yamlis lowered accordingly (abiv1: 309 -> 280, abiv2: 319 -> 288), derived from the current CI baseline minus the 29 (abiv1) / 31 (abiv2) warnings resolved here.