Lifetime attributes for parameters: preliminary review

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 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:…potswa:lifetime_extension

  • Thx,