When profiling Environment, also profile with AnalysisContext*, bacause
we now may have identical states with different analysis context.

Set the right AnalysisContext in state when entering and leaving a callee.

With both of the above changes, we can pass the test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97724 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/GRCoreEngine.cpp b/lib/Checker/GRCoreEngine.cpp
index a9347d0..63ac31d 100644
--- a/lib/Checker/GRCoreEngine.cpp
+++ b/lib/Checker/GRCoreEngine.cpp
@@ -682,6 +682,7 @@
   // Get the callee's location context.
   const StackFrameContext *LocCtx 
                          = cast<StackFrameContext>(Pred->getLocationContext());
+  state = state->setAnalysisContext(LocCtx->getParent()->getAnalysisContext());
 
   PostStmt Loc(LocCtx->getCallSite(), LocCtx->getParent());
   bool isNew;
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index ad229c7..d25526e 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -1309,6 +1309,7 @@
 
   const GRState *state = B.getState();
   state = getStoreManager().EnterStackFrame(state, LocCtx);
+  state = state->setAnalysisContext(LocCtx->getAnalysisContext());
 
   B.GenerateNode(state, LocCtx);
 }
diff --git a/lib/Checker/GRState.cpp b/lib/Checker/GRState.cpp
index 592f930..ce7d6e2 100644
--- a/lib/Checker/GRState.cpp
+++ b/lib/Checker/GRState.cpp
@@ -23,6 +23,12 @@
 // FIXME: Move this elsewhere.
 ConstraintManager::~ConstraintManager() {}
 
+const GRState *GRState::setAnalysisContext(AnalysisContext *ctx) const {
+  GRState NewState = *this;
+  NewState.Env.setAnalysisContext(ctx);
+  return StateMgr->getPersistentState(NewState);
+}
+
 GRStateManager::~GRStateManager() {
   for (std::vector<GRState::Printer*>::iterator I=Printers.begin(),
         E=Printers.end(); I!=E; ++I)