<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117890>117890</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Feature request: implement gcc's attribute access, and the extended version of attribute malloc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fefe17
</td>
</tr>
</table>
<pre>
It's the first attribute in their documentation:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
Here's how it works on gcc:
__attribute__ ((access (read_only, 1)))
int puts (const char*);
__attribute__ ((access (read_only, 2, 3)))
void* memcpy (void*, const void*, size_t);
This strengthens the ability of clang to give good warnings during compilation.
It would also make clang-tidy stronger.
attribute malloc has these forms on gcc:
malloc
malloc (deallocator)
malloc (deallocator, ptr-index)
clang only supports the first one apparently. This is useful for situations like opendir (free using closedir not free!)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVM2O4zYMfhr5QsSw5WTtHHzITmF0770HskTb6siiK1GZTZ--kD27M9iihwJEIpEUP_59VjHa2SP24vJVXH4rVOKFQj_hhHVbjGSe_TcWso3AC8JkQ2RQzMGOiRGsz2obwJBOK3pWbMmL5iaqLAvzFvNNDkIOs9bl7FNJYRZyIO-sR0M6HiYhhxdaV_KnIXmdw5xuP3BiufDqjpi_Y8A9n4XewDK8UXiNQB5yjB_A9_vPHO93ELITslNaY4z5ElCZO3n3FPIFaiGv71LdrGfYEu9emnxk0IsKQt6yufn6v4PL_NN8RniQNULeYMVVb8_84F2TPQ_IT4po_8Y7fwb_Y7ERIgf0My_oj7Go0TrLT6AJtFN-BiaY7QNhJjLwpoK3fo5gUrB-Bk3rZt0-qVJUt2-5h8kZUC4SrOoVjyAntuaZocjPGMoD_pCPBViVc6RhUXsiEWGisP5rHIfXz0Ou2uB-VEzhaMx_mF5g43Cy3uD3w09Ut6PG3GOIadso8OftJI-gtk0F9OyeJewdsxFSxCm5nCBEy2mvP4Kzrwi0oTc2ZPApIEKKe58cRcxqTwxZL2RelsL0jbk2V1VgX7eNbOvu2lyKpa-NvlRq6rSeunaqlf7StkZV6ssF2xpNVdheVvJc17Ktz-fucilHVEZd2q4yY9e0XSXOFa7KutK5x5p5UtgYE_Z13XbXqnBqRBd3pkrp8Q12q5AyEzf0-dFpTHMU58rZyPEjDFt22A-oOAWEgH8ljCyaG9h1c5iJu88r0-pjtsdO5xEob_YG43dGb9DAA0O05PPC_boLRQqu_4X4lpc0lppWIYec0_vfaQv0J2oWctgryV-C91IfvfwnAAD__xiOhSU">