Skip to content

Commit b7d9cc0

Browse files
committed
make symbol live only if region is live
1 parent 8c8277f commit b7d9cc0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clang/lib/StaticAnalyzer/Core/DynamicExtent.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ ProgramStateRef setDynamicExtent(ProgramStateRef State, const MemRegion *MR,
131131
void markAllDynamicExtentLive(ProgramStateRef State, SymbolReaper &SymReaper) {
132132
for (const auto &I : State->get<DynamicExtentMap>())
133133
if (SymbolRef Sym = I.second.getAsSymbol())
134-
SymReaper.markLive(Sym);
134+
if (SymReaper.isLiveRegion(I.first))
135+
SymReaper.markLive(Sym);
135136
}
136137

137138
} // namespace ento

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,6 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out,
10641064
SymReaper.markLive(MR);
10651065
}
10661066

1067-
markAllDynamicExtentLive(CleanedState, SymReaper);
1068-
10691067
getCheckerManager().runCheckersForLiveSymbols(CleanedState, SymReaper);
10701068

10711069
// Create a state in which dead bindings are removed from the environment
@@ -1081,6 +1079,11 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out,
10811079
getCheckerManager().runCheckersForDeadSymbols(CheckedSet, Pred, SymReaper,
10821080
DiagnosticStmt, *this, K);
10831081

1082+
// Extend lifetime of symbols used for dynamic extent while the parent region
1083+
// is live. In this way size information about memory allocations is not lost
1084+
// if the region remains live.
1085+
markAllDynamicExtentLive(CleanedState, SymReaper);
1086+
10841087
// For each node in CheckedSet, generate CleanedNodes that have the
10851088
// environment, the store, and the constraints cleaned up but have the
10861089
// user-supplied states as the predecessors.

0 commit comments

Comments
 (0)