[clang] [clang] Add __builtin_start_object_lifetime builtin. (PR #82776)

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 23 14:11:07 PST 2024


https://github.com/sam-mccall commented:

Thanks for working on this! I'm far from an expert on the LLVM side so we'll need someone to weigh in.


We need to specify specify the behavior somewhere. I think we should add a description to `docs/LanguageExtensions.html`, which describes various other `__builtin_*`.

I'm not sure defining this in terms of "like start_lifetime_as but..." is ideal because:

 - implicit object creation recurses into only implicit-lifetimes subobjects, where this will recurse into everything. (Whether this is the same or different depends on your persepctive.
 - Unlike start_lifetime_as, it's clearly more useful to say "this starts an object's lifetime" than "this may start an object's lifetime as needed to avoid UB", I think this clarifies when you can/must call destructors. In this sense it's more like placement-new than start-lifetime-as.

https://github.com/llvm/llvm-project/pull/82776


More information about the cfe-commits mailing list