<div dir="ltr"><div><div><div><div>Hello,<br><br></div>In a checker, I want to distinguish between these kinds of statements:<br><br></div>1) <span style="font-family:courier new,monospace">p = "/tmp/file"; // p is declared as char *p;</span><br>
</div>2) <span style="font-family:courier new,monospace">*(p+3) = 'S'; // I'm aware this is undefined behavior</span><br><div><br></div><div>If I'm not wrong, I've decided that the best place to be aware of that is in a check::Bind event:<br>
<br><span style="font-family:courier new,monospace">void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const;</span><br><br>In the first case above, the location Loc is a MemRegionVal, and in the 2nd, it is an ElementRegion. <br>
<br>1) To test if Loc is a MemRegionVal I use the following, but there's something wrong I can't figure out (it doesn't compile), and I'm stuck (as far as I know, MemRegionVal is a subclass of SVal):<br>
<br><span style="font-family:courier new,monospace">if (clang::isa<loc::MemRegionVal></span><span style="font-family:courier new,monospace">(Loc)) ...<br><span style="font-family:arial,helvetica,sans-serif"></span></span><span style="font-family:arial,helvetica,sans-serif"><br>
</span><span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">2) ElementRegion doesn't belong to the SVal class hierarchy</span></span>. <span style="font-family:courier new,monospace"><span style="font-family:arial,helvetica,sans-serif">How can I know if Loc is an ElementRegin? </span></span></div>
<br></div><div>Thanks a lot.<br></div></div>