[cfe-dev] checkBind: distinguish between MemRegionVal/ElementRegion

Aitor San Juan aitor.sj at opendeusto.es
Mon May 5 02:09:41 PDT 2014


Hello,

In a checker, I want to distinguish between these kinds of statements:

1) p = "/tmp/file"; // p is declared as char *p;
2) *(p+3) = 'S';    // I'm aware this is undefined behavior

If I'm not wrong, I've decided that the best place to be aware of that is
in a check::Bind event:

void checkBind(SVal Loc, SVal Val, const Stmt *S, CheckerContext &C) const;

In the first case above, the location Loc is a MemRegionVal, and in the
2nd, it is an ElementRegion.

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):

if (clang::isa<loc::MemRegionVal>(Loc)) ...

2) ElementRegion doesn't belong to the SVal class hierarchy. How can I know
if Loc is an ElementRegin?

Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140505/62ab26ff/attachment.html>


More information about the cfe-dev mailing list