diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-06-21 13:24:24 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-06-21 13:24:24 +0000 |
commit | 5414a5c0add7a7a9343a1be0bda962ce8dc35449 (patch) | |
tree | 8a586d3b28b08563baf98f5293813d5fba4730d3 | |
parent | 3da83eb7bcfa6bd476ab804ecb6cf755b39a6f92 (diff) |
Return UnknownVal for pointer arithmetic on struct fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73851 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 7 | ||||
-rw-r--r-- | test/Analysis/fields.c | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 6f316c9c59..5f2b8f809d 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -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(); diff --git a/test/Analysis/fields.c b/test/Analysis/fields.c index c012a9da7b..900a6d6869 100644 --- a/test/Analysis/fields.c +++ b/test/Analysis/fields.c @@ -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; +} |