diff options
| -rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 7 | ||||
| -rw-r--r-- | clang/test/Analysis/fields.c | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 6f316c9c592..5f2b8f809de 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/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/clang/test/Analysis/fields.c b/clang/test/Analysis/fields.c index c012a9da7b8..900a6d6869a 100644 --- a/clang/test/Analysis/fields.c +++ b/clang/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; +} |

