[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 27 11:06:32 PDT 2018
rsmith created this revision.
rsmith added a reviewer: aaron.ballman.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.
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 a `ParmVarDecl` or to a function type, but in the latter case I'd be happy to stash it somewhere else if there is a better home for it.
Repository:
rC Clang
https://reviews.llvm.org/D49922
Files:
include/clang/AST/Type.h
include/clang/AST/TypeLoc.h
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/Type.cpp
lib/AST/TypePrinter.cpp
lib/Parse/ParseDeclCXX.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaType.cpp
utils/TableGen/ClangAttrEmitter.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49922.157711.patch
Type: text/x-patch
Size: 23437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180727/d7e58580/attachment-0001.bin>
More information about the cfe-commits
mailing list