[cfe-dev] How can I get a FieldRegion in a CompoundAssignOperator in Static Analyzer?

Arthur Yoo phjy007 at gmail.com
Tue Jan 21 21:33:14 PST 2014

Hi Jordan,

When evaluating a BinaryAssignOperator(*obj.a = 1;*), if I use
C.getLocationContext())*, I will get the SVal of LHS, which actually is a
MemRegionVal. So I can get LHS's MemRegion via MemRegionVal. However, for
my test code snippet above, I've tried to use *state->getSVal(LHS,
C.getLocationContext())* to get the SVal of LHS when evaluating '*obj.a +=
sizeof(long);*' in *void checkPostStmt(const BinaryOperator *Op,
CheckerContext &C) const, *the Analyzer gave me '0 S32b'. I know that '0
S32b' does be the value for obj.a. But I want to get the FieldRegion of obj.a,
not its SVal. However, I don't know how to get its FieldRegion when
evaluating a CompoundAssignOperator.

2014/1/22 Jordan Rose <jordan_rose at apple.com>

> On Jan 21, 2014, at 5:19 , Arthur Yoo <phjy007 at gmail.com> wrote:
> Hi all,
> I want to get a FieldRegion when evaluating a CompoundAssignOperator. The
> code snippet for my test is like below:
> typedef struct {
>            int a;
>            int *p;
> } Obj;
> Obj obj;
> obj.a = 0;
> obj.a += sizeof(long);
> When evaluating the statement ‘*obj.a += sizeof(long);*’ in the method *void
> checkPostStmt(const BinaryOperator *Op, CheckerContext &C) const*, I want
> to get the FieldRegion of *obj.a*. But I don’t know how to get it. Is
> there anyone can provide me a way to get *obj.a*’s FieldRegion? Thanks a
> lot.
> Hi, Arthur. The value of the BinaryOperator's LHS should be an SVal
> representing the FieldRegion. Are you not seeing that?
> Jordan

Best regards,
Arthur Yoo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140122/6bbcb4c4/attachment.html>

More information about the cfe-dev mailing list