<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">></span><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Cause
 your high-level goal sounds extraordinary enough to discuss *before* discussing implementation details.</span><br>
</p>
<p><br>
</p>
<p>I'm developing this idea of a checker:<br>
</p>
<p>Consider this:<br>
</p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">std::mutex m;</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">void foo()</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">{</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">  m.lock(); // catch the context</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">  for(int i = 0; i < 99999999; ++i) //long loop</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">  {</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">    // I'm trying to detect that `m` is not used inside long/inf loop</span></div>
<div><span style="font-size: 10pt;"><span style="font-family: Consolas, monospace;">    // in other words all the rest threads may be potentially locked/idle for a long/inf time.</span></span></div>
<div><span style="font-size: 10pt;"><span style="font-family: Consolas, monospace;">    // For this I have to determine whether `m` is inside the loop body block.</span></span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">  }  </span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">  m.unlock();</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">}</span></div>
</blockquote>
<span style="font-family: Consolas, monospace; font-size: 10pt;">​</span><br>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<hr>
<div><b>Denys Petrov</b></div>
<div>Senior ó++ Developer | Kharkiv, Ukraine</div>
<div><br>
</div>
<div></div>
</div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>ïÔ:</b> Artem Dergachev <noqnoqneo@gmail.com><br>
<b>ïÔÐÒÁ×ÌÅÎÏ:</b> 20 ÉÀÌÑ 2020 Ç. 20:41<br>
<b>ëÏÍÕ:</b> Denis Petrov; cfe-dev<br>
<b>ôÅÍÁ:</b> Re: [cfe-dev] [analyzer] How to detect a block inside which SVal is used?</font>
<div> </div>
</div>
<div>
<div style="font-size:9pt; font-family:'Calibri',sans-serif">
<h3 style="background-color:#ffffff; font-size:10pt; border:1px dotted #003333; padding:.8em">
<span style="color:#ff6600">CAUTION:<strong> </strong></span>This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.  If you suspect potential phishing or spam
 email, report it to ReportSpam@accesssoftek.com</h3>
</div>
<div>There was a plan to handle this stuff with LocationContexts but it's currently stuck (<a class="moz-txt-link-freetext" href="https://reviews.llvm.org/D19979">https://reviews.llvm.org/D19979</a>). I.e., when we enter a scope, we can put another LocationContext
 on the stack that'll indicate that we're in that scope, and when we exit the scope we remove it.<br>
<br>
You can still figure this out syntactically by exploring parent statements of the current statement via ParentMap. This should work fairly well.<br>
<br>
Given that nobody needed this particular functionality so far: what are you trying to achieve? 'Cause your high-level goal sounds extraordinary enough to discuss *before* discussing implementation details.<br>
<br>
<br>
<div class="moz-cite-prefix">On 20.07.2020 08:28, Denis Petrov via cfe-dev wrote:<br>
</div>
<blockquote type="cite"><style type="text/css" style="">
<!--
p
        {margin-top:0px;
        margin-bottom:0px}
-->
</style>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"> How to detect a block inside which SVal is used</span></span><span style="font-size:16px; background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"> in
 a </span></span></span><span style="font-size:16px; background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif">path-sensitive
 way</span></span></span><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif">?</span></span></span><br style="font-family:Calibri,Arial,Helvetica,sans-serif">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif"></span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><br style="font-family:Calibri,Arial,Helvetica,sans-serif">
</span></p>
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif">E.g.</span></span></span></p>
<p><span style="font-family:"Angsana New",serif"></span></p>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt">void foo(int x) // Here `x` has a Symbolic representation (e.g. reg_$0<int x>)</span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt">{</span></div>
</div>
<div>
<div><span style="font-size:9pt"><span style="font-family:Consolas,monospace">  // block 1  </span><br style="font-family:Consolas,monospace">
</span></div>
</div>
<div>
<div><span style="font-size:9pt"><span style="font-family:Consolas,monospace">  {  </span><br style="font-family:Consolas,monospace">
</span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">    int y = x; // Here I want to know that `x`
</span></span><span style="background-color:rgb(255,255,255); font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">is used</span></span></span><span style="background-color:rgb(255,255,255); font-family:Consolas,monospace"> </span><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">inside
 a simple block</span></span></span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace">  }</span></span></div>
</div>
<div>
<div><br style="font-family:Consolas,monospace; font-size:9pt">
</div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace">  // block 2  </span></span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace">  if(){  </span></span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">    int y = x; ​ //
<span style="font-family:Consolas,monospace; font-size:12px; background-color:rgb(255,255,255)">
Here </span>I want to know that `x` </span></span><span style="background-color:rgb(255,255,255); font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">is used</span></span></span><span style="background-color:rgb(255,255,255); font-family:Consolas,monospace"> </span><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">inside
 if-true-block</span></span></span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace">  }</span></span></div>
</div>
<div>
<div><br style="font-family:Consolas,monospace; font-size:9pt">
</div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace">  // block 3  </span></span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace">  while(){  </span></span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">    int y = x; //
<span style="font-family:Consolas,monospace; font-size:12px; background-color:rgb(255,255,255)">
Here </span>​I want to know that `x` </span></span><span style="background-color:rgb(255,255,255); font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">is used</span></span></span><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace"> inside
 while-loop-body</span></span></span></div>
</div>
<div>
<div><span style="font-size:9pt"><span style="font-family:Consolas,monospace"><span style="font-family:Consolas,monospace">  }</span></span><br style="font-family:Consolas,monospace">
</span></div>
</div>
<div>
<div><span style="font-family:Consolas,monospace; font-size:9pt">}</span><br>
</div>
<div><br>
</div>
</div>
</blockquote>
<span style="font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif">​I'm fighting with this sereval days. Insensitive way (checkASTCodeBody) is
 quite poor and not the case.</span></span></span><br style="font-family:Calibri,Arial,Helvetica,sans-serif">
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<div>
<div><br style="font-family:Calibri,Arial,Helvetica,sans-serif">
</div>
</div>
</blockquote>
<span style="font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif">​</span><span style="font-size:12pt; font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif"><span style="font-family:Calibri,Arial,Helvetica,sans-serif">Thanks.</span></span></span><br>
<blockquote style="margin:0 0 0 40px; border:none; padding:0px">
<div>
<div><br>
</div>
</div>
</blockquote>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<hr>
<div><b>Denys Petrov</b></div>
<div>Senior ó++ Developer | Kharkiv, Ukraine</div>
<div><br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</body>
</html>