--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAL3rL5h_Wme%2Bx4%2B5Y7vQNr2TA854TL5JUwbe9BqMVaQxvAqX3Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAKFU2SD9MkvR4_%3DD2H1yfzWwhFaht328OKkUAUVZZUVHbdTvKQ%40mail.gmail.com.
I believe that clang CL was abandoned due to hitting too many false positives.This is probably a check that could make sense for clang-tidy rather than the clang plugin that Chrome builds with, due to the risk of false positives. I don't know if we have any pre-existing mechanism for extending clang-tidy with our own checks. +George BurgessI would strongly encourage using an enum for this. It's 100% clear, despite being a little verbose, and as a bonus, it even uses less storage (one byte for the enum vs two bytes for the optional<bool>). I suppose it's something we could consider adding to //base if it's that common.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAF3XrKryJtp9hPvjcztorruOKE-vDcKC74G4E1dkeuckf8xPrQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAHtyhaRErgOGCQKhsnxM7P6YzhvwK-O5yP9ZNnoX34XFqMoVaA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CANMaTo%3DeB29EZ9NOiqpUW%3DEeGaLZDpXeWLo_VCvS1SaOfptBWA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAGFX3sEQQ1kuTvW7j%2BF6mgq-_WnP_Ph1rYDotk%2BakUWYRcMVUQ%40mail.gmail.com.
In general I like the existence of optional<T>::operator bool but maybe we can make an exception for optional<bool> that doesn't allow it to nudge this gun away from developers' feet.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAEmk%3DMa46F7oeHBopX7PvVT0Ue3gCauiUnyH82fGNX7em4PCtA%40mail.gmail.com.
On Tue, Jun 1, 2021 at 2:25 PM Reilly Grant <rei...@chromium.org> wrote:In general I like the existence of optional<T>::operator bool but maybe we can make an exception for optional<bool> that doesn't allow it to nudge this gun away from developers' feet.Removing it just for optional<bool> will be a bit of a headache in templated code. The template works until you pass in the wrong type, now someone has to go fix the template.I'd rather we drop the operator bool from absl entirely if we want to do that, but it would preclude us from ever migrating to std::optional (if our hardening checks don't already in practice end up doing so).
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAHtyhaSiV8j_%3DQFwY6QKh_O-56wRfqV4RwhjzxeVbKorgvMw7Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGE5NG9XnKLEROK2j_dduMTfEhUXd7OpuWrd8Q-idOn5yC5KA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGE5NG9XnKLEROK2j_dduMTfEhUXd7OpuWrd8Q-idOn5yC5KA%40mail.gmail.com.
I don't think this proposed rule "pulls its weight", so to speak. I also wonder what is different about Chromium here that means we should have such a rule when the Google store guide does not
base::Value uses absl::optional<T> for the new API to get items for key/path in a dictionary (except for string where it returns a pointer to the internal stored string).This means that base::Value::FindBoolKey() returns a base::optional<bool>. For the user, this is nice, since the code to base::Value new dictionary API is the same for all types. Using an enum here would make the bool type different (also, not sure that we could use anything besides kTrue, kFalse, kUnset for base::Value since there is not enough context for the API to know what the bool mean).
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAL3rL5hSqYXqSjdr1OCS9Xm7jqqbaQ1k1j0dxhgjgMc13QCmTQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAF1j9YME3FcxNZO2U6fuBWbc-Po6NJ1Xq5eNSZQV1ijrox1NgA%40mail.gmail.com.
Alternatively one might avoid the bool in the first place with something more descriptive likeenum class Foo { kNotEnabled = 0, kEnabled };optional<Foo> is_enabled;esp. if we are passing this value as an argument somewhere, Foo::kNotEnabled avoids writing /*is_enabled=*/false, and such.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAF3XrKpZ2KCsWq0a%2BUzk5JbibvD%3DUutvPpopNP9QL5o2CCo%2BSA%40mail.gmail.com.