<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div dir="auto">The -100 is not the integer literal for 100 less than 0. It is the application of the unary operator '-' to the integer literal 100.
<div dir="auto"><br>
</div>
<div dir="auto">If you want to get the value, do the overload of isConstantExpr on Expr they takes a reference to APValue.</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Nov 2, 2019 1:16 PM, Devendran Mani via cfe-dev <cfe-dev@lists.llvm.org> wrote:<br type="attribution">
</div>
</div>
<div><br>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">Hi All,</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">I need a support to find the below *IL  null pointer return for negative</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">integer numbers.</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span> </p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
Checker code:</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">const Expr *e = vDecl->getInit();</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">auto *IL = dyn_cast<IntegerLiteral>(e);</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">if(IL !=NULL)</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">{</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">    double val = IL->getValue().signedRoundToDouble();</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">    cout << "val:" val;</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">}</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">test function:</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">main()</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">{</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">    int val = 100;  (int val = -100;)</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">    printf("%d", val);</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">}</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">if the local variable is positive ex: int var 100;  then cout prints the</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">right value "100".</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">But if the local variable is negative ex: int var -100;  then IL becomes</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">NULL and cout is not executed.</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">Please help me root cause this issue.</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">Thanks,</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<span style="font-family:".SFUIText"; font-size:16pt">Devendran.</span></p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69); min-height:19.1px">
<span style="font-family:".SFUIText"; font-size:16pt"></span><br>
</p>
<p style="margin:0px; font-size:16px; line-height:normal; font-family:".SF UI Text"; color:rgb(69,69,69)">
<br>
</p>
<br>
<a href="https://overview.mail.yahoo.com/?.src=iOS">Sent from Yahoo Mail for iPad</a><br>
</div>
</body>
</html>