[cfe-dev] Patch for References
Chris Lattner
clattner at apple.com
Sun Jul 15 22:23:05 PDT 2007
On Jul 14, 2007, at 2:25 AM, Bill Wendling wrote:
> On Jul 13, 2007, at 9:39 AM, Chris Lattner wrote:
>
>> I still don't think this is right. Nothing in the subscript
>> operator should care about arrays. You should rely on the usual
>> unary conversions for decaying the array to a pointer. Perhaps
>> you need to implement usual unary conversions for references?
>
> Ah! I understand what you're saying now. Here's a new patch
> submission. I think it does the correct thing now. I even have the
> correct standard citation. :-)
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.
+ 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. 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.
-Expr::isLvalueResult Expr::isLvalue() {
+Expr::isLvalueResult Expr::isLvalue() const {
Marking this method const is fine, please commit it as a separate patch.
+ 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.
-Chris
More information about the cfe-dev
mailing list