[clang] [clang] Add the candiscard attribute to suppress nodiscard (PR #154943)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 22 08:11:54 PDT 2025


================
@@ -3646,6 +3646,14 @@ def Unavailable : InheritableAttr {
   let MeaningfulToClassTemplateDefinition = 1;
 }
 
+def CanDiscard : InheritableAttr {
+  let Spellings = [CXX11<"clang", "candiscard">,
----------------
erichkeane wrote:

We should NOT be doing the `GCC` spelling, this adds a `[[gnu::...]]` spelling, which we absolutely don't want. 

We should be using the `Clang` spelling ONLY for these (so : `let Spellings = [Clang<"candiscard">];`).

This should add a `__attribute__((candiscard))`, plus the two `[[clang::candiscard]]` spellings, which are all the ones we want.

https://github.com/llvm/llvm-project/pull/154943


More information about the cfe-commits mailing list