[cfe-commits] [PATCH] CallExprs returning references can be lvalues

Zhongxing Xu xuzhongxing at gmail.com
Wed Jun 2 21:21:09 PDT 2010


Hi Jordy,

One small suggestion: It's easier to review if each patch only solves one
specific problem. We'd like small patches that fix one well defined and
isolated problem.

Comments below:

Index: lib/Analysis/CFG.cpp
===================================================================
--- lib/Analysis/CFG.cpp    (revision 105255)
+++ lib/Analysis/CFG.cpp    (working copy)
@@ -538,6 +538,15 @@
     addStmt(B->getRHS());
     return addStmt(B->getLHS());
   }
+  else if (B->isAssignmentOp()) {
+    if (asc.alwaysAdd()) {
+      autoCreateBlock();
+      AppendStmt(Block, B, asc);
+    }
+
+    addStmt(B->getRHS());

Is it necessary to add all RHS of assignment expr as block-level expr?

+    return addStmt(B->getLHS(), AddStmtChoice::AsLValueNotAlwaysAdd);
+  }


On Thu, Jun 3, 2010 at 6:19 AM, Jordy Rose <jediknil at belkadan.com> wrote:

> Fixes a crasher, by allowing CallExprs to be lvalues, and making sure
> assignment LHSes are treated as lvalues.
>
> char& ref();
> void t5 () {
>  ref() = 'c';
> }
>
> And an incorrect "undefined dereference" warning, by noting that assigning
> to a reference variable does not kill its value.
>
> char t1 () {
>  char& r = ref();
>  r = 'c'; // no-warning
>  if (r) return r;
>  return *(char*)0; // no-warning
> }
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100603/2835ee06/attachment.html>


More information about the cfe-commits mailing list