[clang] Document the const and pure attributes (PR #205881)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 26 05:16:06 PDT 2026


================
@@ -10253,3 +10253,52 @@ The attribute is also supported with blocks and in Objective-C.
   }
   }];
 }
+
+def ConstDocs :  Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``const`` attribute can be applied to the declaration of a function to signal that repeated calls to the function with the same argument values may be safe to elide because the subsequent calls will always return the same value as the initial call.
----------------
AaronBallman wrote:

I updated but not quite as strongly as saying all calls can be removed because that gets a bit complicated and doesn't seem worth explaining here (e.g., if we don't see the function body, we can't remove all calls, but if we do see the function body, maybe we can remove all calls but that depends on inlining behavior).

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


More information about the cfe-commits mailing list