[cfe-dev] Patch for References

Bill Wendling isanbard at gmail.com
Sun Jul 15 22:33:25 PDT 2007


On Jul 15, 2007, at 10:23 PM, Chris Lattner wrote:

> This patch has some of the same problems as the previous one.  For  
> example:
>
> +
> +  const FunctionType *funcT = 0;
> +
> +  if (PT == 0) {
> +    // C++ 8.5.3p1: This is a reference to a function.
> +    const ReferenceType *RT = dyn_cast<ReferenceType>(qType);
> +
> +    if (RT) {
> +      funcT = dyn_cast<FunctionType>(RT->getReferenceeType());
> +
> +      if (funcT == 0)
> +        funcT =
>
> ...
>
> The reference should be stripped off automatically by "implicit  
> conversion handling" (See [conv], S4p3), not with explicit code in  
> the call expr handler, because the callee is an rvalue.

Okay.

> +  if (const ReferenceType *ref = dyn_cast<ReferenceType> 
> (t.getCanonicalType()))
> +    t = ref->getReferenceeType(); // C++ 5p5
>
> 5p5 talks about the pointer-to-member operator, so I'm not sure how  
> it is relevant.

Mine doesn't talk about pointer-to-member operators. It is off by  
one, but not that far off (see below). :-)

> When citing the C++ standard, please use the section name as well,  
> such as "[expr.mptr.oper]".  I assume the intent is for these names  
> to be stable as the standard moves forward.

Off by one error. It's 5p6:

If an expression initially has the type “reference toT” (8.3.2,  
8.5.3), the type is adjusted to “T” prior to any further analysis,  
the expression designates the object or function denoted by the  
reference, and the expression is an lvalue.

It only has "[expr]" as the section (chapter) name.

> -Expr::isLvalueResult Expr::isLvalue() {
> +Expr::isLvalueResult Expr::isLvalue() const {
>
> Marking this method const is fine, please commit it as a separate  
> patch.

Sure.

> +  if (isa<ReferenceType>(TR.getCanonicalType())) // C++ 5p5
> +    return LV_Valid;
>
> Likewise, this citation is non-sensical, see chapter 4 for the cite  
> you are looking for.

It's 5p6 :-)

-bw





More information about the cfe-dev mailing list