[cfe-dev] EvaluateAsLValue and non global storage

Enea Zaffanella zaffanella at cs.unipr.it
Sat Aug 29 08:08:45 PDT 2009


Hello.

Please find attached a patch to change method Expr::Evaluate() so that 
it can return an lvalue representation (Base, Offset) even for 
stack-based objects.

The EvalResult structure now has, beside HasSideEffects,
another Boolean value named IsStackBasedLValue, which is checked after 
the evaluation to see if the computed value is indeed foldable.

The patch is based on r80097 and passes all tests in debug mode.

Cheers,
Enea Zaffanella.


Eli Friedman wrote:
> On Wed, Aug 26, 2009 at 10:20 AM, Douglas Gregor<dgregor at apple.com> wrote:
>> On Aug 17, 2009, at 8:54 AM, Abramo Bagnara wrote:
>>> For an AST simplification application we'd need the exact same
>>> services
>>> of Expr::EvaluateAsLValue and other helper in ExprConstant.cpp but
>>> without current failure when DeclRefExpr has not global storage.
>>>
>>> There's a strong reason to abort the evaluation and to not instead
>>> return an LValue APValue with a non global storage base?
>>>
>>> This condition could be checked later from result value making the
>>> service given more general.
>>
>> I was hoping that someone more familiar with the expression evaluator
>> logic would chime in (Eli? Anders?). However, as I see it,
>> EvaluateAsLValue could produce a value in this case but still returns
>> false and sets the diagnostic to something that indicates that the
>> storage is non-global.
> 
> I'm a little skeptical of the concept... it seems more suited to the
> Analyzer.  I'm not strongly opposed, though.  It would be quite easy
> to delay the check for whether the lvalue is a valid base from the
> lvalue evaluation to the end of evaluation.
> 
> -Eli
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: StackBasedLValue.patch
Type: text/x-patch
Size: 3675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090829/27cfb767/attachment.bin>


More information about the cfe-dev mailing list