[P0936R0] add [[clang::lifetimebound]] attribute

Authored by Richard Smith <richard-llvm@metafoo.co.uk> on Jul 31 2018, 5:33 PM.


[P0936R0] add [[clang::lifetimebound]] attribute

This patch adds support for a new attribute, [[clang::lifetimebound]], that
indicates that the lifetime of a function result is related to one of the
function arguments. When walking an initializer to make sure that the lifetime
of the initial value is at least as long as the lifetime of the initialized
object, we step through parameters (including the implicit object parameter of
a non-static member function) that are marked with this attribute.

There's nowhere to write an attribute on the implicit object parameter, so in
lieu of that, it may be applied to a function type (where it appears
immediately after the cv-qualifiers and ref-qualifier, which is as close to a
declaration of the implicit object parameter as we have). I'm currently
modeling this in the AST as the attribute appertaining to the function type.

Differential Revision: https://reviews.llvm.org/D49922

llvm-svn: 338464

Event Timeline

Richard Smith <richard-llvm@metafoo.co.uk> committed rGf4e248c23e05: [P0936R0] add [[clang::lifetimebound]] attribute (authored by Richard Smith <richard-llvm@metafoo.co.uk>).Jul 31 2018, 5:33 PM