summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-11-27 23:05:37 +0000
committerTed Kremenek <kremenek@apple.com>2012-11-27 23:05:37 +0000
commit5092c73187627acb2a5f8374afb4474af1c94609 (patch)
tree2f29e0f50b720c90f7d279e2f1e40ef57c2da46f /clang/lib
parentfbd19749a34546865cf40bd2855861e16ca1a801 (diff)
downloadbcm5719-llvm-5092c73187627acb2a5f8374afb4474af1c94609.tar.gz
bcm5719-llvm-5092c73187627acb2a5f8374afb4474af1c94609.zip
Provide stop-gap solution to crash reported in PR 14436.
This was also covered by <rdar://problem/12753384>. The static analyzer evaluates a CXXConstructExpr within an initializer expression and RegionStore doesn't know how to handle the resulting CXXTempObjectRegion that gets created. We need a better solution than just dropping the value, but we need to better understand how to implement the right semantics here. Thanks to Jordan for his help diagnosing the behavior here. llvm-svn: 168741
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Core/RegionStore.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index aed994df411..875a7ce4d4e 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1581,14 +1581,16 @@ StoreRef RegionStoreManager::BindArray(Store store, const TypedValueRegion* R,
Size = CAT->getSize().getZExtValue();
// Check if the init expr is a string literal.
- if (loc::MemRegionVal *MRV = dyn_cast<loc::MemRegionVal>(&Init)) {
- const StringRegion *S = cast<StringRegion>(MRV->getRegion());
-
- // Treat the string as a lazy compound value.
- nonloc::LazyCompoundVal LCV =
- cast<nonloc::LazyCompoundVal>(svalBuilder.
- makeLazyCompoundVal(StoreRef(store, *this), S));
- return BindAggregate(store, R, LCV);
+ if (const MemRegion *Reg = Init.getAsRegion()) {
+ if (const StringRegion *S = dyn_cast<StringRegion>(Reg)) {
+ // Treat the string as a lazy compound value.
+ NonLoc V = svalBuilder.makeLazyCompoundVal(StoreRef(store, *this), S);
+ return BindAggregate(store, R, V);
+ }
+ // FIXME: Handle CXXTempObjectRegion, which can occur in cases
+ // where a struct contains an array of structs in C++.
+ assert(isa<CXXTempObjectRegion>(Reg));
+ return BindAggregate(store, R, UnknownVal());
}
// Handle lazy compound values.
OpenPOWER on IntegriCloud