Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ABSL_ATTRIBUTE_PURE_FUNCTION and ABSL_ATTRIBUTE_CONST_FUNCTION
Pure functions have no effects except to return a value, and their return value depends only on the parameters and global variables. Functions of this kind can be subject to data flow analysis and might be eliminated. In practice, this means that repeated calls to the same function with the same arguments may be optimized away and only evaluated once. Const functions are similar to pure functions, but may not depend on global variables at all. It is an error not to use the result of a function with one of these attributes, since these functions have no other visible effects. Since some Abseil functions are tagged with these attributes, this is potentially a breaking change for code that doesn't use the result of these functions. For example, absl::Minutes() is tagged with ABSL_ATTRIBUTE_CONST_FUNCTION. If, for example, the result of absl::Minutes(n) is unused, some compilers with issue a warning or error. If this is the case, it is likely that there is a typo in the code, or the call can be removed. PiperOrigin-RevId: 560803581 Change-Id: Icd6f218be2cfb7226f8ab6b2d97cd960c0d3d72f
- Loading branch information