[cfe-commits] [Patch review request] Binary type traits

Douglas Gregor dgregor at apple.com
Fri Oct 8 10:26:31 PDT 2010


On Oct 6, 2010, at 9:36 AM, John McCall wrote:

> 
> On Oct 6, 2010, at 7:55 AM, Douglas Gregor wrote:
> 
>> 
>> On Sep 27, 2010, at 5:56 AM, John McCall wrote:
>> 
>>> On Sep 20, 2010, at 6:30 PM, Douglas Gregor wrote:
>>>> I'd really rather not add a new expression type just for the purpose of type-checking __is_convertible_to. How about we synthesize appropriate expressions instead, e.g., a DeclRefExpr to a synthesized variable, or a CallExpr to a synthesized function with an appropriate return type?
>>> 
>>> Actually, I think there are several places in the AST where "opaque expression of fixed type and l-valueness" would be very convenient — mostly with copies, e.g. with synthesized array copies, caught-exception copies, etc.
>> 
>> Synthesized array copies always have a parameter to hang on to.
> 
> Right, but we end up synthesizing array index variables.  I'm suggesting this as a general alternative to making a reference to a synthesized variable.
> 
>> I'm on the fence. I don't like having expression nodes that don't represent ideas in the language, but there is some messiness in the expression synthesis we do in Sema.
> 
> I'm just saying that there are several places in the language where values come from no intrinsically-expressible place, and while it's obviously always possible to fake up expressions with the right properties in terms of spurious variables, I'm not sure I accept that that's somehow inherently cleaner than having a pair of expressions for "this opaque value comes from some place that the context knows about" and "the sub-expression needs these opaque values to work".  I'm basically suggesting specialized lambdas. :)  They'd definitely be constrained to a few places in the AST, though.

And.... John convinced me. We do want to add an OpaqueValueExpr (or whatever name fits) that has type + value classification information. It can be used in various places in Sema and the AST: for type checking when we need a placeholder expression, for storing placeholder arguments for block-variable copies and catch-variable copies, for the placeholder in an implicit copy-construction of an array, and for the dreaded GNU x ? : y extension.

	- Doug



More information about the cfe-commits mailing list