summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2015-12-10 09:28:06 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2015-12-10 09:28:06 +0000
commit733e71b73b35eccd467c50baf12214d85941f0b0 (patch)
treed817b5cda01584f26d1cc933c984924fb7a551fe /clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
parenta5fbebc2065d12a403f82380cbe0c3a571cfccbe (diff)
downloadbcm5719-llvm-733e71b73b35eccd467c50baf12214d85941f0b0.tar.gz
bcm5719-llvm-733e71b73b35eccd467c50baf12214d85941f0b0.zip
[analyzer] Fix symbolic element index lifetime.
SymbolReaper was destroying the symbol too early when it was referenced only from an index SVal of a live ElementRegion. In order to test certain aspects of this patch, extend the debug.ExprInspection checker to allow testing SymbolReaper in a direct manner. Differential Revision: http://reviews.llvm.org/D12726 llvm-svn: 255236
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SymbolManager.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SymbolManager.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
index df4d22ad652..99b2e147cb4 100644
--- a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -391,6 +391,18 @@ void SymbolReaper::markLive(SymbolRef sym) {
void SymbolReaper::markLive(const MemRegion *region) {
RegionRoots.insert(region);
+ markElementIndicesLive(region);
+}
+
+void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
+ for (auto SR = dyn_cast<SubRegion>(region); SR;
+ SR = dyn_cast<SubRegion>(SR->getSuperRegion())) {
+ if (auto ER = dyn_cast<ElementRegion>(SR)) {
+ SVal Idx = ER->getIndex();
+ for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI)
+ markLive(*SI);
+ }
+ }
}
void SymbolReaper::markInUse(SymbolRef sym) {
OpenPOWER on IntegriCloud