<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
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"
cite="mid:1595258886371.54573@accesssoftek.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none"><!-- 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" wrap="">_______________________________________________
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>
</body>
</html>