[PATCH] D157572: [clang] Add `[[clang::library_extension]]` attribute

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 06:21:35 PDT 2023


aaron.ballman added a comment.

In D157572#4612141 <https://reviews.llvm.org/D157572#4612141>, @cjdb wrote:

> 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?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157572/new/

https://reviews.llvm.org/D157572



More information about the cfe-commits mailing list