-
Notifications
You must be signed in to change notification settings - Fork 30k
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
src: use stricter compile-time guidance #46509
src: use stricter compile-time guidance #46509
Conversation
Review requested:
|
Why would this be necessary? This is a debugging facility that decorates the log output, it would be fine to just give up if "I don't know what it's called, so I won't attempt to tell you what the type name is, because RTTI is disallowed" (I think I relied on this when developing deserialization/serialization of new types, which was fine because it's possible to guess the name from the context anyway). |
It's certainly not necessary. I can change it to allow unknown types, but unless I'm missing something, I don't really see the point. Wouldn't it only take a one-line change to add new non-arithmetic types? |
@joyeecheung is your comment blocking? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry for missing the ping. I wouldn't say it's a hill that I'd die on but it's also weird that this restriction exists. The function is just a utility that attempts to assemble a human-readable name for a type (or it's just poor-man's RTTI). Returning an empty string for a type that we don't special case is totally acceptable. Does the static analyzer complain about it? If it does it would make more sense to do |
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v.
451850a
to
8ddfb52
Compare
@joyeecheung Sorry about the delay, I've updated the PR as requested. PTAL. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
LGTM
This comment was marked as outdated.
This comment was marked as outdated.
Landed in aa3dbe3 |
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: #46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName() appears to confuse static analysis such as Coverity. This changes the function structure to a sequence of if-else blocks and marks all branch conditions as constexpr. (Unfortunately, this results in a dangling 'else' keyword in the V macro.) As per a request in the PR discussion, this change does _not_ ensure that GetName<T>() can only be called for known types T and instead still returns an empty string in that case. Also use std::is_unsigned_v instead of !std::is_signed_v. PR-URL: nodejs#46509 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
SnapshotSerializerDeserializer::GetName()
appears to confuse static analysis such as Coverity.This changes the function structure to a sequence of
if
-else
blocks and marks all branch conditions asconstexpr
. (Unfortunately, this results in a danglingelse
keyword in theV
macro.)As a side effect, this change ensures thatAs per a request in the PR discussion, this change does not ensure thatGetName<T>()
can only be called for known types T (instead of returning an empty string).GetName<T>()
can only be called for known typesT
and instead still returns an empty string in that case.Also use
std::is_unsigned_v
instead of!std::is_signed_v
.