[clang] Document the const and pure attributes (PR #205881)
Nikolas Klauser via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 05:26:37 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.
----------------
philnik777 wrote:
We can, and apparently do so even at -O0 if unused: https://godbolt.org/z/j8T5MjrWT
When used in some way it can still be removed by optimizations: https://godbolt.org/z/qGPPjfKMo
https://github.com/llvm/llvm-project/pull/205881
More information about the cfe-commits
mailing list