summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-10-10 21:31:21 +0000
committerJordan Rose <jordan_rose@apple.com>2012-10-10 21:31:21 +0000
commitfb29410c85a632e328877a6310b57b33908156ac (patch)
treed203d0ec3680ae6b8d8ceb06a48acf5ea244384b /clang/lib
parentb9bc47409d8ae8f7e1b1652e95ccb1ea29497476 (diff)
downloadbcm5719-llvm-fb29410c85a632e328877a6310b57b33908156ac.tar.gz
bcm5719-llvm-fb29410c85a632e328877a6310b57b33908156ac.zip
[analyzer] Treat fields of unions as having symbolic offsets.
This allows only one field to be active at a time in RegionStore. This isn't quite the correct behavior for unions, but it at least would handle the case of "value goes in, value comes out" from the same field. RegionStore currently has a number of places where any access to a union results in UnknownVal being returned. However, it is clearly missing some cases, or the original issue wouldn't have occurred. It is probably now safe to remove those changes, but that's a potentially destabilizing change that should wait for more thorough testing. Fixes PR14054. llvm-svn: 165660
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/MemRegion.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index 7c66739558a..da34a799682 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1168,8 +1168,12 @@ RegionOffset MemRegion::getAsOffset() const {
R = FR->getSuperRegion();
const RecordDecl *RD = FR->getDecl()->getParent();
- if (!RD->isCompleteDefinition()) {
+ if (/*RD->isUnion() || */!RD->isCompleteDefinition()) {
// We cannot compute offset for incomplete type.
+ // For unions, we could treat everything as offset 0, but we'd rather
+ // treat each field as a symbolic offset so they aren't stored on top
+ // of each other, since we depend on things in typed regions actually
+ // matching their types.
SymbolicOffsetBase = R;
}
OpenPOWER on IntegriCloud