[cfe-dev] Getting the value of a IntegerLiteral

David Blaikie dblaikie at gmail.com
Thu Sep 12 07:51:55 PDT 2013


Are you using a +asserts build? What kind of crash are you observing?
On Sep 12, 2013 6:42 AM, "Jesper Eskilson" <jesper.eskilson at iar.com> wrote:

>
> Hi,
>
> I'm trying to figure out how I can obtain the value of an IntegerLiteral.
> I tried the following:
>
> const IntegerLiteral *lit = ...;
> if (lit != 0)
> {
>     int64_t n = lit->getValue().getSExtValue()**;
>     // do something with n
> }
>
> This seems to work sometimes, but frequently crashes. I've tried to figure
> out how to use the Evaluate*-functions in the Expr class, but I cannot
> figure out how they should be called.
>
> It's ok if obtaining the value sometimes fails, but it would be nice if it
> didn't crash. :)
>
> --
> *Jesper Eskilson* /Development Engineer/
> IAR Systems AB
> Box 23051, Strandbodgatan 1
> SE-750 23 Uppsala, SWEDEN
> E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.**com<jesper.eskilson at iar.com>>
> Website: www.iar.com
> <http://www.iar.com> Twitter: www.twitter.com/iarsystems <
> http://www.twitter.com/**iarsystems <http://www.twitter.com/iarsystems>>
> ______________________________**_________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/**mailman/listinfo/cfe-dev<http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130912/d3617971/attachment.html>


More information about the cfe-dev mailing list