--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAHtyhaQr7h_p%3DhLTiebCQC0CADwF4YzQAEyafXB2JW6KNk6qng%40mail.gmail.com.
Most of the macros have a fairly clear 1:1 correspondence with clang attributes, like ABSL_ATTRIBUTE_LIFETIME_BOUND is [[clang::lifetimebound]]. Since the correspondence is relatively obvious (and if it's not, we could rename the macro to make it so), is this a large benefit?
It also deals with the case of clang version skew, though we're usually not so aggressive about adopting attributes that that is an issue.
I have only suggested this for [[clang::attributes]] not for other __attribute__((gnu attributes)) at this time, to limit the scope.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAHtyhaRumSSrodRonfAL%2Bco2RM772XpQ2hatiqw2eW36p4-aeQ%40mail.gmail.com.
--
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAGFX3sGdUnRKQkQKgdSuMazScn-OmqkcAi1bz9jo3RfDOT0DAg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAF8qwaBaTsbtx6nho-PwxLV_k9sy%2BDasVHfpuscqrJ_FOFOZQw%40mail.gmail.com.
I'm not a big fan of this proposal.For some attributes, we discover later that there's a reason to use a different spelling. [[no_unique_address]] was a case of this. I realize that is not a clang:: attribute (though there was discussion of what a clang:: version might do in clang-cl!), but I don't think that subtle distinction moots the underlying point I'm getting at, which is that having an abstraction over the spelling is often useful.
I also think we should _require_ clang only when its reasonably difficult to do otherwise. I have within the past year attempted to locally build with msvc, and will likely do so again. I'm not asking us to bend over backwards to support every compiler, but I think we should avoid gratuitous dependencies when doing so is reasonably trivial.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAHtyhaTruV_LWR9p7E--jw1stBtGhMQi2_2jugdV_qu%3D_Wrpxw%40mail.gmail.com.
On Thu, Feb 15, 2024 at 6:50 PM Peter Kasting <pkas...@google.com> wrote:For some attributes, we discover later that there's a reason to use a different spelling. [[no_unique_address]] was a case of this. I realize that is not a clang:: attribute (though there was discussion of what a clang:: version might do in clang-cl!), but I don't think that subtle distinction moots the underlying point I'm getting at, which is that having an abstraction over the spelling is often useful.[[no_unique_address]] vs [[msvc::no_unique_address]] is an exception here that requires a macro because there is more than one way to spell it, and they mean different things. This is not representative of attributes in general, nor of [[clang::attributes]] at all. That one attribute (which is not part of this proposal) requires a macro does not imply we need to use macros for every attribute.
I also think we should _require_ clang only when its reasonably difficult to do otherwise. I have within the past year attempted to locally build with msvc, and will likely do so again. I'm not asking us to bend over backwards to support every compiler, but I think we should avoid gratuitous dependencies when doing so is reasonably trivial.If we want to support MSVC that should be a separate discussion. Current policy is that we don't. The proposal here doesn't make things worse anyway, [[clang::attributes]] would disappear on MSVC just as on GCC.
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/bd2f42c0-2fc7-4bc8-8c9a-ce47e42bc5adn%40chromium.org.
I think it'd be fine to have a shorter way to refer to these attributes (whether that's BASE_LIFETIME_BOUND or ABSL_LIFETIME_BOUND, or something else altogether).
I do think we should avoid writing these out literally: in spirit, I think it violates the "Nonstandard extensions to C++ may not be used unless otherwise specified." part of the C++ style guide.
Previous internal style discussion: http://shortn/_pPRrLvIBLY
On Tue, Feb 20, 2024 at 12:24 PM Daniel Cheng <dch...@chromium.org> wrote:I think it'd be fine to have a shorter way to refer to these attributes (whether that's BASE_LIFETIME_BOUND or ABSL_LIFETIME_BOUND, or something else altogether).
I do think we should avoid writing these out literally: in spirit, I think it violates the "Nonstandard extensions to C++ may not be used unless otherwise specified." part of the C++ style guide.
Previous internal style discussion: http://shortn/_pPRrLvIBLYAh, that's an interesting discussion.Based on this thread, my proposal for attributes is that anything we care about should have a non-prefixed version (e.g. LIFETIME_BOUND) in base/compiler_specific.h, and we ban the Abseil versions where they overlap. I don't care whether our implementation of that version delegates to Abseil or is bespoke.Dana, would that be sufficient for you? Are there other attributes you're interested in beyond [[clang::lifetimebound]]?
On Wed, Feb 21, 2024 at 2:12 PM Peter Kasting <pkas...@chromium.org> wrote:
Based on this thread, my proposal for attributes is that anything we care about should have a non-prefixed version (e.g. LIFETIME_BOUND) in base/compiler_specific.h, and we ban the Abseil versions where they overlap. I don't care whether our implementation of that version delegates to Abseil or is bespoke.
This would be a huge improvement, yes. Lifetimebound is what is top of mind, along with ABSL_ATTRIBUTE_PURE_FUNCTION and ABSL_ATTRIBUTE_CONST_FUNCTION.