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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 25 06:30:15 PDT 2025


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

See: https://clang.llvm.org/doxygen/DeclBase_8cpp_source.html#l01188

IF you want to support all of those, we need to see tests for all of those.I was trying to help limit work by making this apply to functions ONLY, that way we can expand it if/when someone requests it.

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


More information about the cfe-commits mailing list