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

Ted Kremenek kremenek at apple.com
Wed Jun 2 22:16:00 PDT 2010


On Jun 2, 2010, at 10:12 PM, Zhongxing Xu wrote:

> 
> 
> On Thu, Jun 3, 2010 at 1:11 PM, Zhongxing Xu <xuzhongxing at gmail.com> wrote:
> 
> 
> On Thu, Jun 3, 2010 at 1:08 PM, Ted Kremenek <kremenek at apple.com> wrote:
> 
> On Jun 2, 2010, at 10:04 PM, Zhongxing Xu wrote:
> 
>> 
>> 
>> On Thu, Jun 3, 2010 at 1:02 PM, Ted Kremenek <kremenek at apple.com> wrote:
>> 
>> On Jun 2, 2010, at 9:48 PM, Zhongxing Xu wrote:
>> 
>>> Is it necessary to add all RHS of assignment expr as block-level expr?
>>> 
>>> +    return addStmt(B->getLHS(), AddStmtChoice::AsLValueNotAlwaysAdd);
>>> +  }
>>> 
>>> Here better to use visitStmt, because addStmt() means we want to 'add' the statement. Maybe we should modify some of the existing code to emphasize this.
>>>  
>>>  
>> 
>> 
>> That's right.  The rest of the cases in that method use addStmt() because they introduce real control-flow dependencies.  For the assignment operator this isn't need.
>> 
>> Zhongxing: I don't think any of the existing cases in that method need to be modified to use VisitStmt() instead of addStmt(), or do you see something?
>> 
>> I suggest the following implementation of addStmt.
>> 
>> CFGBlock *addStmt(Stmt *S) {
>>     return Visit(S, AddStmtChoice::AlwaysAdd);
>> }
> 
> That would break a fair number of the existing callers, as some use the second argument to indicate that the expression should be treated as an lvalue.
> 
> 
> Maybe those could use VisitStmt directly?
> 
> correction: use Visit()

Right.

addStmt() made sense as a convenience method when we only had two choices: add or not add the statement to the CFGBlock.  Now we have four choices, and we call addStmt() with the second argument many times.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100602/f23db1a4/attachment.html>


More information about the cfe-commits mailing list