analyzer icon indicating copy to clipboard operation
analyzer copied to clipboard

Common attributes support

Open sim642 opened this issue 3 years ago • 0 comments

I happened upon GCC's common function attributes and noticed many that we could (and should) support. For example to allow more flexible specifications for LibraryFunctions or malloc wrappers. Clang also has corresponding documentation: https://clang.llvm.org/docs/AttributeReference.html.

It would be even more ideal if the standard library headers used these attributes and we could directly handle them without hard-coding everything into LibraryFunctions, but that doesn't seem to be the case yet for all of them. They could also be used for declaring more stubs in C itself.

Attributes

  • [ ] access for LibraryFunctions invalidation.
  • [ ] alloc_size for blob sizes from custom alloc functions.
  • [ ] malloc for custom alloc functions, but also other classes of functions with similar trackable pointers.
  • [ ] nonnull for excluding NULLs.
  • [ ] noreturn for dead code (related issue #501).
  • [ ] pure for avoiding invalidation.
  • [ ] returns_nonnull for excluding NULLs.
  • [ ] warn_unused_result and nodiscard for emitting warnings.

sim642 avatar Apr 25 '22 13:04 sim642