Added preliminary support for CompoundLiterals in the static analyzer:
- GRExprEngine::VisitCompoundLiteral...
(1) visits the initializer list (generating ExplodedNodes)
(2) creates a CompoundMemRegion for the literal
(3) creates a new state with the bound literal values using
GRStateManager::BindCompoundLiteral
- GRStateManager::BindCompoundLiteral simply calls
StoreManager::BindCompoundLiteral to get a new store and returns a persistent
GRState with that store.
- BasicStore::BindCompoundLiteral simply returns the same store, as it
doesn't handle field sensitivity
- RegionStore::BindCompoundLiteral currently fires an assert (pending discussion
of how to best implement mappings for CompoundLiteralRegion).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58277 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp
index 828be22..03b7247 100644
--- a/lib/Analysis/GRState.cpp
+++ b/lib/Analysis/GRState.cpp
@@ -92,6 +92,26 @@
return getPersistentState(NewSt);
}
+/// BindCompoundLiteral - Return the store that has the bindings currently
+/// in 'store' plus the bindings for the CompoundLiteral. 'R' is the region
+/// for the compound literal and 'BegInit' and 'EndInit' represent an
+/// array of initializer values.
+const GRState*
+GRStateManager::BindCompoundLiteral(const GRState* state,
+ const CompoundLiteralRegion* R,
+ const SVal* BegInit, const SVal* EndInit) {
+
+ Store oldStore = state->getStore();
+ Store newStore = StoreMgr->BindCompoundLiteral(oldStore, R, BegInit, EndInit);
+
+ if (newStore == oldStore)
+ return state;
+
+ GRState newState = *state;
+ newState.St = newStore;
+ return getPersistentState(newState);
+}
+
const GRState* GRStateManager::Unbind(const GRState* St, Loc LV) {
Store OldStore = St->getStore();
Store NewStore = StoreMgr->Remove(OldStore, LV);