Skip to content

Commit

Permalink
CBL-6485 : Define LIFETIMEBOUND only for C++ (#244)
Browse files Browse the repository at this point in the history
* Moved the definition of LIFETIMEBOUND to be next to FLAPI.
* Aligned formatting with the other sections.
  • Loading branch information
pasin authored Nov 21, 2024
1 parent 016a37c commit ebe000e
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions API/fleece/CompilerSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,24 +269,24 @@
#endif

#ifdef __cplusplus
#define FLAPI noexcept
#else
#define FLAPI
#endif

// `LIFETIMEBOUND` helps Clang detect value lifetime errors, where one value's lifetime is tied to another and the
// dependent value is used after the value it depends on exits scope. For examples of usage, see slice.hh.
// "The `lifetimebound` attribute on a function parameter or implicit object parameter indicates that objects that are
// referred to by that parameter may also be referred to by the return value of the annotated function (or, for a
// parameter of a constructor, by the value of the constructed object)."
// -- https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
#if __has_cpp_attribute(clang::lifetimebound)
# define LIFETIMEBOUND [[clang::lifetimebound]]
# define FLAPI noexcept

// `LIFETIMEBOUND` helps Clang detect value lifetime errors, where one value's lifetime is tied to another and the
// dependent value is used after the value it depends on exits scope. For examples of usage, see slice.hh.
// "The `lifetimebound` attribute on a function parameter or implicit object parameter indicates that objects that are
// referred to by that parameter may also be referred to by the return value of the annotated function (or, for a
// parameter of a constructor, by the value of the constructed object)."
// -- https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
# if __has_cpp_attribute(clang::lifetimebound)
# define LIFETIMEBOUND [[clang::lifetimebound]]
# else
# define LIFETIMEBOUND
# endif
#else
# define FLAPI
# define LIFETIMEBOUND
#endif


// Type-checking for printf-style vararg functions:
#ifndef __printflike
# if __has_attribute(__format__)
Expand Down

0 comments on commit ebe000e

Please sign in to comment.