Return UnknownVal for pointer arithmetic on struct fields.

llvm-svn: 73851
This commit is contained in:
Zhongxing Xu 2009-06-21 13:24:24 +00:00
parent 6ead59f8ed
commit 540c009fbe
2 changed files with 15 additions and 1 deletions

View File

@ -773,8 +773,13 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR, getContext());
}
else
else if (isa<FieldRegion>(MR)) {
// Not track pointer arithmetic on struct fields.
return UnknownVal();
}
else {
ER = cast<ElementRegion>(MR);
}
SVal Idx = ER->getIndex();

View File

@ -8,3 +8,12 @@ void bar() {
*(unsigned*)&y = foo();
y.x = 1;
}
struct s {
int n;
};
void f() {
struct s a;
int *p = &(a.n) + 1;
}