mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:47:34 +00:00
AK: Add RETURNS_NONNULL attribute and use it
This attribute tells compilers that the pointer returned by a function is never null, which lets it optimize away null checks in some places. This seems like a nice addition to `NonnullOwnPtr` and `NonnullRefPtr`. Using this attribute causes extra UBSan checks to be emitted. To offset its performance loss, some additional methods were marked ALWAYS_INLINE, which lets the compiler optimize duplicate checks
This commit is contained in:
parent
65b2d3add3
commit
23d66fe719
3 changed files with 29 additions and 15 deletions
|
@ -40,6 +40,11 @@
|
|||
#endif
|
||||
#define FLATTEN __attribute__((flatten))
|
||||
|
||||
#ifdef RETURNS_NONNULL
|
||||
# undef RETURNS_NONNULL
|
||||
#endif
|
||||
#define RETURNS_NONNULL __attribute__((returns_nonnull))
|
||||
|
||||
#ifdef NO_SANITIZE_ADDRESS
|
||||
# undef NO_SANITIZE_ADDRESS
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue