[clang] [clang][Sema] Deprecate `global`/`unknown` in `lifetime_capture_by` (PR #196635)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 10 03:50:45 PDT 2026
AaronBallman wrote:
> I don't think there's an easy migration path for this, the only thing I can come up with is adding a new macro specifically for global/this/unknown (though maybe there's some C macro magic that I am not aware about). E.g. a separate macro for the `this` case that prefers the new spelling:
>
> ```c++
> #if ABSL_HAVE_CPP_ATTRIBUTE(clang::lifetime_capture_by_this)
> #define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS \
> [[clang::lifetime_capture_by_this]]
> #elif ABSL_HAVE_CPP_ATTRIBUTE(clang::lifetime_capture_by)
> #define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS \
> ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY(this)
> #else
> #define ABSL_INTERNAL_ATTRIBUTE_CAPTURED_BY_THIS
> #endif
> ```
FWIW, that is the migration path I was expecting folks to take (you check for the newer form and prefer it, otherwise you fall back on the older form); that's pretty idiomatic for deprecated or modified attributes.
https://github.com/llvm/llvm-project/pull/196635
More information about the cfe-commits
mailing list