[cfe-dev] Getting the value of a IntegerLiteral

Jesper Eskilson jesper.eskilson at iar.com
Thu Sep 12 06:39:57 PDT 2013


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> 
Website: www.iar.com
<http://www.iar.com> Twitter: www.twitter.com/iarsystems 
<http://www.twitter.com/iarsystems>



More information about the cfe-dev mailing list