This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add `[[clang::library_extension]]` attribute
AbandonedPublic

Authored by philnik on Aug 9 2023, 8:21 PM.

Details

Summary

This allows standard libraries to mark symbols as extensions, so the compiler can generate extension warnings when they are used.

Diff Detail

Event Timeline

philnik created this revision.Aug 9 2023, 8:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 8:21 PM
Herald added a subscriber: arphaman. · View Herald Transcript
philnik requested review of this revision.Aug 9 2023, 8:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2023, 8:21 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
philnik added a subscriber: Restricted Project.Aug 9 2023, 8:26 PM
cjdb added a subscriber: cjdb.Aug 10 2023, 10:44 AM
cjdb added inline comments.
clang/include/clang/Basic/DiagnosticSemaKinds.td
5690–5691

We shouldn't need this one, since Clang (almost) doesn't distinguish between C++03 and C++11. To my knowledge, C++03 doesn't even support attributes, so this would be a moot addition.

clang/lib/Sema/SemaDeclAttr.cpp
8227–8229
clang/test/SemaCXX/attr-library-extension.cpp
9–13

I don't think we need to test for both of these: using [[clang::library_extension]] directly should suffice.

philnik added inline comments.Aug 10 2023, 10:58 AM
clang/include/clang/Basic/DiagnosticSemaKinds.td
5690–5691

It does enough to regularly cause headaches (no >>, constexpr, alignas, buggy enum class). C++03 has supported GNU attributes forever, and since LLVM 17 also supports C++11 attributes. Also note that this isn't a new warning.

clang/test/SemaCXX/attr-library-extension.cpp
9–13

I've been asked to test both before, and IMO it's a good idea, since there are attributes which only have one of the spellings.

I think I like this attribute.

However, I am concerned that this would make it seem more acceptable to add extensions to the library, when our policy has been that we don't (and for good reasons, we ran into big issues with e.g. std::string_view and we learned from those). Therefore, I would really support this (and obviously using it in libc++), but I would like us to write down (and justify) our policy about library extensions so that we can keep applying it firmly going forward. Then, I think it's a win-win situation for everyone. Users get diagnostics when they use extensions, libc++ gets a useful tool, and we don't start making bad decisions w.r.t. extensions that will bite us.

clang/include/clang/Basic/AttrDocs.td
1741

This should say clang::library_extension

1746

Perhaps the diagnostic should be std::string_view is a C++17 library extension?

1746–1747

This allows standard libraries to mark symbols as extensions, so the compiler can generate extension warnings when they are used.

Huh, so this is basically the opposite of the __extension__ macro (which is used to silence extension warnings)? I don't think we need to introduce a new attribute to do this, we already have diagnose_if. e.g., https://godbolt.org/z/a5ae4T56o would that suffice?

This allows standard libraries to mark symbols as extensions, so the compiler can generate extension warnings when they are used.

Huh, so this is basically the opposite of the __extension__ macro (which is used to silence extension warnings)?

I guess, kind-of. I never really understood the semantics of __extension__ though, so I'm not 100% certain.

I don't think we need to introduce a new attribute to do this, we already have diagnose_if. e.g., https://godbolt.org/z/a5ae4T56o would that suffice?

Part of the idea here is that the diagnostics should be part of -Wc++ab-extension. I guess we could allow warning flags instead of just "warning" and "error" in diagnose_if that specifies which warning group the diagnostic should be part of. Something like __attribute__((__diagnose_if__(__cplusplus >= 201703L, "basic_string_view is a C++17 extension", "-Wc++17-extensions"))). I'm not sure how one could implement that, but I guess there is some mechanism to translate "-Wwhatever" to a warning group, since you can push and pop warnings. That would open people up to add a diagnostic to pretty much any warning group. I don't know if that's a good idea. I don't really see a problem with that other than people writing weird code, but people do that all the time anyways. Maybe I'm missing something really problematic though.

This allows standard libraries to mark symbols as extensions, so the compiler can generate extension warnings when they are used.

Huh, so this is basically the opposite of the __extension__ macro (which is used to silence extension warnings)?

I guess, kind-of. I never really understood the semantics of __extension__ though, so I'm not 100% certain.

It's used in system headers to say "I'm using an extension here, don't warn about it in -pedantic mode".

I don't think we need to introduce a new attribute to do this, we already have diagnose_if. e.g., https://godbolt.org/z/a5ae4T56o would that suffice?

Part of the idea here is that the diagnostics should be part of -Wc++ab-extension.

Hmmm, okay. And I'm assuming -Wsystem-headers -pedantic is too chatty because it's telling the user about all use of extensions, not extensions being introduced by the library itself? (e.g., https://godbolt.org/z/Gs3YGheMM is also not what you're after)

I guess we could allow warning flags instead of just "warning" and "error" in diagnose_if that specifies which warning group the diagnostic should be part of. Something like __attribute__((__diagnose_if__(__cplusplus >= 201703L, "basic_string_view is a C++17 extension", "-Wc++17-extensions"))). I'm not sure how one could implement that, but I guess there is some mechanism to translate "-Wwhatever" to a warning group, since you can push and pop warnings. That would open people up to add a diagnostic to pretty much any warning group. I don't know if that's a good idea. I don't really see a problem with that other than people writing weird code, but people do that all the time anyways. Maybe I'm missing something really problematic though.

That's actually a pretty interesting idea; diagnose_if could be given another parameter to specify a diagnostic group to associate the diagnostic with. This would let you do some really handy things like:

void func(int i) __attribute__((diagnose_if(i < 0, "passing a negative value to 'func' is deprecated", "warning", "-Wdeprecated")));

But if we went this route, would we want to expose other diagnostic-related knobs like "show in system header" and "default to an error"? Also, the attribute currently can only be associated with a function; we can use this for classes by sticking it on a constructor but there's not much help for putting it on say a namespace or an enumeration. So we may need to extend the attribute in other ways. CC @cjdb as this seems of interest to you as well.

This allows standard libraries to mark symbols as extensions, so the compiler can generate extension warnings when they are used.

Huh, so this is basically the opposite of the __extension__ macro (which is used to silence extension warnings)?

I guess, kind-of. I never really understood the semantics of __extension__ though, so I'm not 100% certain.

It's used in system headers to say "I'm using an extension here, don't warn about it in -pedantic mode".

Hm, OK. I thought I tried to use it that way at some point and it didn't work in the way I expected.

I don't think we need to introduce a new attribute to do this, we already have diagnose_if. e.g., https://godbolt.org/z/a5ae4T56o would that suffice?

Part of the idea here is that the diagnostics should be part of -Wc++ab-extension.

Hmmm, okay. And I'm assuming -Wsystem-headers -pedantic is too chatty because it's telling the user about all use of extensions, not extensions being introduced by the library itself? (e.g., https://godbolt.org/z/Gs3YGheMM is also not what you're after)

Yeah, for libc++ we don't support -Wsystem-headers in any meaningful way and this doesn't achieve the effect I want.

I guess we could allow warning flags instead of just "warning" and "error" in diagnose_if that specifies which warning group the diagnostic should be part of. Something like __attribute__((__diagnose_if__(__cplusplus >= 201703L, "basic_string_view is a C++17 extension", "-Wc++17-extensions"))). I'm not sure how one could implement that, but I guess there is some mechanism to translate "-Wwhatever" to a warning group, since you can push and pop warnings. That would open people up to add a diagnostic to pretty much any warning group. I don't know if that's a good idea. I don't really see a problem with that other than people writing weird code, but people do that all the time anyways. Maybe I'm missing something really problematic though.

That's actually a pretty interesting idea; diagnose_if could be given another parameter to specify a diagnostic group to associate the diagnostic with. This would let you do some really handy things like:

void func(int i) __attribute__((diagnose_if(i < 0, "passing a negative value to 'func' is deprecated", "warning", "-Wdeprecated")));

But if we went this route, would we want to expose other diagnostic-related knobs like "show in system header" and "default to an error"? Also, the attribute currently can only be associated with a function; we can use this for classes by sticking it on a constructor but there's not much help for putting it on say a namespace or an enumeration. So we may need to extend the attribute in other ways. CC @cjdb as this seems of interest to you as well.

I looked a bit around the code yesterday and it looks like it should be relatively easy to implement. I think we would just have to extend CustomDiagInfo to save some more information and pass the warning group in there from the diagnose_if sema handler. There are already utilities to translate -Wwhatever into the corresponding warning group IDs, so that part is trivial. Given that, I think this sounds like a very interesting way to go. This would also allow us to move the libc++ atomic checks to -Watomic-memory-ordering and I'm sure there will be more use-cases. Regarding the knobs, I think that would be interesting for some things too. We could add optional string arguments at the end like "show_in_system_header={false,true}", "default_to_error={false,true}", "enable_by_default={false,true}", etc. If they aren't set we probably want to default to show_in_system_header=false, default_to_error=false and enable_by_default=true. Are there any other interesting knobs?

cjdb added a comment.Aug 23 2023, 5:04 PM

This allows standard libraries to mark symbols as extensions, so the compiler can generate extension warnings when they are used.

Huh, so this is basically the opposite of the __extension__ macro (which is used to silence extension warnings)?

I guess, kind-of. I never really understood the semantics of __extension__ though, so I'm not 100% certain.

It's used in system headers to say "I'm using an extension here, don't warn about it in -pedantic mode".

I don't think we need to introduce a new attribute to do this, we already have diagnose_if. e.g., https://godbolt.org/z/a5ae4T56o would that suffice?

Part of the idea here is that the diagnostics should be part of -Wc++ab-extension.

Hmmm, okay. And I'm assuming -Wsystem-headers -pedantic is too chatty because it's telling the user about all use of extensions, not extensions being introduced by the library itself? (e.g., https://godbolt.org/z/Gs3YGheMM is also not what you're after)

I guess we could allow warning flags instead of just "warning" and "error" in diagnose_if that specifies which warning group the diagnostic should be part of. Something like __attribute__((__diagnose_if__(__cplusplus >= 201703L, "basic_string_view is a C++17 extension", "-Wc++17-extensions"))). I'm not sure how one could implement that, but I guess there is some mechanism to translate "-Wwhatever" to a warning group, since you can push and pop warnings. That would open people up to add a diagnostic to pretty much any warning group. I don't know if that's a good idea. I don't really see a problem with that other than people writing weird code, but people do that all the time anyways. Maybe I'm missing something really problematic though.

That's actually a pretty interesting idea; diagnose_if could be given another parameter to specify a diagnostic group to associate the diagnostic with. This would let you do some really handy things like:

void func(int i) __attribute__((diagnose_if(i < 0, "passing a negative value to 'func' is deprecated", "warning", "-Wdeprecated")));

But if we went this route, would we want to expose other diagnostic-related knobs like "show in system header" and "default to an error"? Also, the attribute currently can only be associated with a function; we can use this for classes by sticking it on a constructor but there's not much help for putting it on say a namespace or an enumeration. So we may need to extend the attribute in other ways. CC @cjdb as this seems of interest to you as well.

I don't dislike it, but I am a bit concerned about misuse being noisy. As much as I hate suppressing diagnostics, I think there needs to be a way to suppress the diagnose_if forms of warning without suppressing something that the compiler would otherwise generate. Something like:

  • -Wno-deprecated: suppresses anything that -Wdeprecated would turn on.
  • -Wno-deprecated=diagnose_if: just the ones flagged by diagnose_if.
  • -Wno-deprecated=non-diagnose_if: complement to #2.

(and similarly for -Wno-error=.)

I'm not sure about the system header knob though: [[deprecated]] and [[nodiscard]] still show up even when the declaration is in a system header?

I don't dislike it, but I am a bit concerned about misuse being noisy.

So you're concerned that a library author uses diagnose_if to add a diagnostic to a warning group that makes the diagnostic seem too chatty, so the user disables the group and loses the compiler's diagnostics? Or are there other kinds of misuse you're worried about?

As much as I hate suppressing diagnostics, I think there needs to be a way to suppress the diagnose_if forms of warning without suppressing something that the compiler would otherwise generate. Something like:

  • -Wno-deprecated: suppresses anything that -Wdeprecated would turn on.
  • -Wno-deprecated=diagnose_if: just the ones flagged by diagnose_if.
  • -Wno-deprecated=non-diagnose_if: complement to #2.

(and similarly for -Wno-error=.)

I'm not sure about the system header knob though: [[deprecated]] and [[nodiscard]] still show up even when the declaration is in a system header?

Correct, those will still show up when the declaration is in a system header but not when the use is in a system header: https://godbolt.org/z/PjqKbGsrr

We currently have -Wuser-defined-warnings as the warning group for diagnose_if warning diagnostics, so I wonder if it would make sense to allow -Wno-deprecated suppresses anything that -Wdeprecated would turn on, while -Wdeprecated -Wno-user-defined-warnings would turn on only the compiler-generated deprecation warnings and not the diagnose_if-generated ones?

cjdb added a comment.Aug 24 2023, 10:56 AM

I don't dislike it, but I am a bit concerned about misuse being noisy.

So you're concerned that a library author uses diagnose_if to add a diagnostic to a warning group that makes the diagnostic seem too chatty, so the user disables the group and loses the compiler's diagnostics? Or are there other kinds of misuse you're worried about?

More or less the former. I don't know if it'll actually manifest in practice though, I don't see many diagnose_if diagnostics to begin with.

As much as I hate suppressing diagnostics, I think there needs to be a way to suppress the diagnose_if forms of warning without suppressing something that the compiler would otherwise generate. Something like:

  • -Wno-deprecated: suppresses anything that -Wdeprecated would turn on.
  • -Wno-deprecated=diagnose_if: just the ones flagged by diagnose_if.
  • -Wno-deprecated=non-diagnose_if: complement to #2.

(and similarly for -Wno-error=.)

I'm not sure about the system header knob though: [[deprecated]] and [[nodiscard]] still show up even when the declaration is in a system header?

Correct, those will still show up when the declaration is in a system header but not when the use is in a system header: https://godbolt.org/z/PjqKbGsrr

Right, my question was more "what is this knob doing?"

We currently have -Wuser-defined-warnings as the warning group for diagnose_if warning diagnostics, so I wonder if it would make sense to allow -Wno-deprecated suppresses anything that -Wdeprecated would turn on, while -Wdeprecated -Wno-user-defined-warnings would turn on only the compiler-generated deprecation warnings and not the diagnose_if-generated ones?

Oh neat, this simplifies things a lot!

I don't dislike it, but I am a bit concerned about misuse being noisy.

So you're concerned that a library author uses diagnose_if to add a diagnostic to a warning group that makes the diagnostic seem too chatty, so the user disables the group and loses the compiler's diagnostics? Or are there other kinds of misuse you're worried about?

More or less the former. I don't know if it'll actually manifest in practice though, I don't see many diagnose_if diagnostics to begin with.

I think the former is sort of a "doctor, doctor, it hurts" situation; the issue isn't really with diagnose_if, it's with the library author's use of it. But at the same time, I can see why it would be beneficial to be able to work around it if needed.

As much as I hate suppressing diagnostics, I think there needs to be a way to suppress the diagnose_if forms of warning without suppressing something that the compiler would otherwise generate. Something like:

  • -Wno-deprecated: suppresses anything that -Wdeprecated would turn on.
  • -Wno-deprecated=diagnose_if: just the ones flagged by diagnose_if.
  • -Wno-deprecated=non-diagnose_if: complement to #2.

(and similarly for -Wno-error=.)

I'm not sure about the system header knob though: [[deprecated]] and [[nodiscard]] still show up even when the declaration is in a system header?

Correct, those will still show up when the declaration is in a system header but not when the use is in a system header: https://godbolt.org/z/PjqKbGsrr

Right, my question was more "what is this knob doing?"

Ah! We have various knobs on our diagnostics, like:
ShowInSystemHeader -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L7818 (if used, the diagnostic will be shown in a system header)
SFINAEFailure -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L93 (if used, the diagnostic causes SFINAE to fail in a SFINAE context)
DefaultIgnore -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L141 (if used, the warning is off by default and must be explicitly enabled via its group)
DefaultError -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L262 (if used, the warning defaults to being an error but users can disable the error with -Wno)
(etc)

All of these have been of use to us as implementers, so it seems likely that these same knobs would be of use to library authors adding their own compiler diagnostics, so perhaps we should consider that as part of the design?

We currently have -Wuser-defined-warnings as the warning group for diagnose_if warning diagnostics, so I wonder if it would make sense to allow -Wno-deprecated suppresses anything that -Wdeprecated would turn on, while -Wdeprecated -Wno-user-defined-warnings would turn on only the compiler-generated deprecation warnings and not the diagnose_if-generated ones?

Oh neat, this simplifies things a lot!

I think it could make for a reasonable user experience.

I'm curious what @erichkeane thinks as attributes code owner, but personally, I like the idea of extending diagnose_if over the idea of adding clang::library_extension because it's a more general solution that I think will give more utility to our users. However, I also want to know if @philnik @Mordante @ldionne (and others) share that preference because I think they're going to be the guinea pigs^W^Wearly adopters of this functionality.

I don't dislike it, but I am a bit concerned about misuse being noisy.

So you're concerned that a library author uses diagnose_if to add a diagnostic to a warning group that makes the diagnostic seem too chatty, so the user disables the group and loses the compiler's diagnostics? Or are there other kinds of misuse you're worried about?

More or less the former. I don't know if it'll actually manifest in practice though, I don't see many diagnose_if diagnostics to begin with.

I think the former is sort of a "doctor, doctor, it hurts" situation; the issue isn't really with diagnose_if, it's with the library author's use of it. But at the same time, I can see why it would be beneficial to be able to work around it if needed.

As much as I hate suppressing diagnostics, I think there needs to be a way to suppress the diagnose_if forms of warning without suppressing something that the compiler would otherwise generate. Something like:

  • -Wno-deprecated: suppresses anything that -Wdeprecated would turn on.
  • -Wno-deprecated=diagnose_if: just the ones flagged by diagnose_if.
  • -Wno-deprecated=non-diagnose_if: complement to #2.

(and similarly for -Wno-error=.)

I'm not sure about the system header knob though: [[deprecated]] and [[nodiscard]] still show up even when the declaration is in a system header?

Correct, those will still show up when the declaration is in a system header but not when the use is in a system header: https://godbolt.org/z/PjqKbGsrr

Right, my question was more "what is this knob doing?"

Ah! We have various knobs on our diagnostics, like:
ShowInSystemHeader -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L7818 (if used, the diagnostic will be shown in a system header)
SFINAEFailure -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L93 (if used, the diagnostic causes SFINAE to fail in a SFINAE context)
DefaultIgnore -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L141 (if used, the warning is off by default and must be explicitly enabled via its group)
DefaultError -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L262 (if used, the warning defaults to being an error but users can disable the error with -Wno)
(etc)

All of these have been of use to us as implementers, so it seems likely that these same knobs would be of use to library authors adding their own compiler diagnostics, so perhaps we should consider that as part of the design?

We currently have -Wuser-defined-warnings as the warning group for diagnose_if warning diagnostics, so I wonder if it would make sense to allow -Wno-deprecated suppresses anything that -Wdeprecated would turn on, while -Wdeprecated -Wno-user-defined-warnings would turn on only the compiler-generated deprecation warnings and not the diagnose_if-generated ones?

Oh neat, this simplifies things a lot!

I think it could make for a reasonable user experience.

I'm curious what @erichkeane thinks as attributes code owner, but personally, I like the idea of extending diagnose_if over the idea of adding clang::library_extension because it's a more general solution that I think will give more utility to our users. However, I also want to know if @philnik @Mordante @ldionne (and others) share that preference because I think they're going to be the guinea pigs^W^Wearly adopters of this functionality.

I think this approach makes a lot of sense. I'm not sure all the knobs make sense to expose (e.g. SFINAEFailure could just be implemented with a normal enable_if IIUC), but at least ShowInSystemHeader and DefaultIgnore are ones where I already have use-cases in mind. As said before, we could also move our atomic ordering warnings from -Wuser-defined-warnings to -Watomic-memory-ordering, which seems like a huge usability improvement. I'm sure there will be more use-cases in the future for extending warning flags and having the ability to tune how and when warnings are emitted.

cjdb added a comment.EditedAug 28 2023, 10:11 AM

I don't dislike it, but I am a bit concerned about misuse being noisy.

So you're concerned that a library author uses diagnose_if to add a diagnostic to a warning group that makes the diagnostic seem too chatty, so the user disables the group and loses the compiler's diagnostics? Or are there other kinds of misuse you're worried about?

More or less the former. I don't know if it'll actually manifest in practice though, I don't see many diagnose_if diagnostics to begin with.

I think the former is sort of a "doctor, doctor, it hurts" situation; the issue isn't really with diagnose_if, it's with the library author's use of it. But at the same time, I can see why it would be beneficial to be able to work around it if needed.

As much as I hate suppressing diagnostics, I think there needs to be a way to suppress the diagnose_if forms of warning without suppressing something that the compiler would otherwise generate. Something like:

  • -Wno-deprecated: suppresses anything that -Wdeprecated would turn on.
  • -Wno-deprecated=diagnose_if: just the ones flagged by diagnose_if.
  • -Wno-deprecated=non-diagnose_if: complement to #2.

(and similarly for -Wno-error=.)

I'm not sure about the system header knob though: [[deprecated]] and [[nodiscard]] still show up even when the declaration is in a system header?

Correct, those will still show up when the declaration is in a system header but not when the use is in a system header: https://godbolt.org/z/PjqKbGsrr

Right, my question was more "what is this knob doing?"

Ah! We have various knobs on our diagnostics, like:
ShowInSystemHeader -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L7818 (if used, the diagnostic will be shown in a system header)
SFINAEFailure -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L93 (if used, the diagnostic causes SFINAE to fail in a SFINAE context)
DefaultIgnore -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L141 (if used, the warning is off by default and must be explicitly enabled via its group)
DefaultError -- https://github.com/llvm/llvm-project/blob/2dc6281b98d07f43a64d0ef34405d9a12d59e8b6/clang/include/clang/Basic/DiagnosticSemaKinds.td#L262 (if used, the warning defaults to being an error but users can disable the error with -Wno)
(etc)

All of these have been of use to us as implementers, so it seems likely that these same knobs would be of use to library authors adding their own compiler diagnostics, so perhaps we should consider that as part of the design?

We currently have -Wuser-defined-warnings as the warning group for diagnose_if warning diagnostics, so I wonder if it would make sense to allow -Wno-deprecated suppresses anything that -Wdeprecated would turn on, while -Wdeprecated -Wno-user-defined-warnings would turn on only the compiler-generated deprecation warnings and not the diagnose_if-generated ones?

Oh neat, this simplifies things a lot!

I think it could make for a reasonable user experience.

I'm curious what @erichkeane thinks as attributes code owner, but personally, I like the idea of extending diagnose_if over the idea of adding clang::library_extension because it's a more general solution that I think will give more utility to our users. However, I also want to know if @philnik @Mordante @ldionne (and others) share that preference because I think they're going to be the guinea pigs^W^Wearly adopters of this functionality.

I like this idea, but we need to acknowledge that it'll potentially lead to diagnostics with varying quality. This conversation may be better suited to a Discourse thread at this point: there seems to be a lot of design before we reach consensus, and a CL isn't the optimal place to do that.

philnik abandoned this revision.Sep 17 2023, 9:28 PM

Abandoning, since it seems like we want to extend diagnose_if instead.