[cfe-dev] Lifetime attributes for parameters: preliminary review

David Krauss via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 10 09:44:23 PDT 2015


Hi all,

I’m trying to get a minimal demo prototype of P0066 (generalized lifetime extension, a.k.a. formal accessors and views). The ISO conference is next week and it would be nice to have something. This is my first serious Clang patch so I’m just getting up to speed.

The idea is to have per-parameter specifiers (“void f(export foo *)”) that apply to the function type, not the parameter type. It’s a bit tricky, but I’ve settled on a strategy like this:

1. Alias the specifier to the existing Objective-C lifetime qualifiers. Objective-C (indirect) lifetime types may have ObjC lifetime qualifiers; other types have C++ lifetime qualifiers. But, the C++ qualifiers only appear within parameters.

2. Like their Objective-C counterparts, C++ lifetime qualifiers are not part of the canonical type of a parameter variable. However, they are part of the canonical type of the function. This is accomplished by reintroducing <https://github.com/llvm-mirror/clang/compare/master...potswa:lifetime_extension#diff-e50bb45cfe9f513ac1cb6b2e03e92e3dR3044> them into the parameters when generating each new FunctionProtoType.

Any feedback would be nice. Have I committed any mortal sins? Will non-canonical type qualifiers bite me when I least expect it? Disambiguating the aliased qualifiers takes a bit of ongoing work, but it seems worthwhile, and the alternatives seem harder and/or inefficient.

View the changes here: https://github.com/llvm-mirror/clang/compare/master...potswa:lifetime_extension <https://github.com/llvm-mirror/clang/compare/master...potswa:lifetime_extension>

	- Thx,
	David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151011/8ac80883/attachment.html>


More information about the cfe-dev mailing list