-
Notifications
You must be signed in to change notification settings - Fork 593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add [[nodiscard]] to cpp #3279
Add [[nodiscard]] to cpp #3279
Conversation
@@ -43,24 +43,24 @@ namespace IceInternal | |||
// This is called from the endpoint host resolver thread, so | |||
// it's safe if this this method blocks. | |||
// | |||
virtual NetworkProxyPtr resolveHost(ProtocolSupport) const = 0; | |||
[[nodiscard]] virtual NetworkProxyPtr resolveHost(ProtocolSupport) const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the rule for this attribute, we apply it to the initial declaration and to the overrides? It isn't enough to just apply it to the initial declaration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I find the API usage of getInfo
not great.
@@ -63,7 +63,7 @@ ConnectionManager::remove(const Ice::ConnectionPtr& connection) | |||
exception_ptr ex; | |||
try | |||
{ | |||
connection->getInfo(); | |||
[[maybe_unused]] auto _ = connection->getInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following this code. Doesn't getInfo
only throw if the connection is closed. Are we relying on this behavior to get the close exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's apparently what we do, yes. However, I am not following this code either.
This PR adds [[nodiscard]] to many C++ API. It's largely an automatic update using clang-tidy -fix.
I disabled modernize-use-nodiscard for a single API: ice_getConnection on proxy, which is often used in our tests to establish a connection without actually retrieving the connection.
The addition of nodiscard also unveiled two bugs (in an IceGrid test and in IcePy). Both fixed by this PR.