@@ -154,7 +154,7 @@ Environment::Environment(DataflowAnalysisContext &DACtx)
154
154
: DACtx(&DACtx), FlowConditionToken(&DACtx.makeFlowConditionToken()) {}
155
155
156
156
Environment::Environment (const Environment &Other)
157
- : DACtx(Other.DACtx), DeclCtx(Other.DeclCtx), ReturnLoc(Other.ReturnLoc),
157
+ : DACtx(Other.DACtx), ReturnLoc(Other.ReturnLoc),
158
158
ThisPointeeLoc (Other.ThisPointeeLoc), DeclToLoc(Other.DeclToLoc),
159
159
ExprToLoc(Other.ExprToLoc), LocToVal(Other.LocToVal),
160
160
MemberLocToStruct(Other.MemberLocToStruct),
@@ -168,11 +168,9 @@ Environment &Environment::operator=(const Environment &Other) {
168
168
}
169
169
170
170
Environment::Environment (DataflowAnalysisContext &DACtx,
171
- const DeclContext &DeclCtxArg )
171
+ const DeclContext &DeclCtx )
172
172
: Environment(DACtx) {
173
- setDeclCtx (&DeclCtxArg);
174
-
175
- if (const auto *FuncDecl = dyn_cast<FunctionDecl>(DeclCtx)) {
173
+ if (const auto *FuncDecl = dyn_cast<FunctionDecl>(&DeclCtx)) {
176
174
assert (FuncDecl->getBody () != nullptr );
177
175
initGlobalVars (*FuncDecl->getBody (), *this );
178
176
for (const auto *ParamDecl : FuncDecl->parameters ()) {
@@ -187,7 +185,7 @@ Environment::Environment(DataflowAnalysisContext &DACtx,
187
185
ReturnLoc = &createStorageLocation (ReturnType);
188
186
}
189
187
190
- if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclCtx)) {
188
+ if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(& DeclCtx)) {
191
189
auto *Parent = MethodDecl->getParent ();
192
190
assert (Parent != nullptr );
193
191
if (Parent->isLambda ())
@@ -212,9 +210,6 @@ Environment Environment::pushCall(const CallExpr *Call) const {
212
210
213
211
const auto *FuncDecl = Call->getDirectCallee ();
214
212
assert (FuncDecl != nullptr );
215
-
216
- Env.setDeclCtx (FuncDecl);
217
-
218
213
// FIXME: In order to allow the callee to reference globals, we probably need
219
214
// to call `initGlobalVars` here in some way.
220
215
@@ -257,12 +252,12 @@ Environment Environment::pushCall(const CallExpr *Call) const {
257
252
258
253
void Environment::popCall (const Environment &CalleeEnv) {
259
254
// We ignore `DACtx` because it's already the same in both. We don't want the
260
- // callee's `DeclCtx`, ` ReturnLoc` or `ThisPointeeLoc`. We don't bring back
261
- // `DeclToLoc` and `ExprToLoc` because we want to be able to later analyze the
262
- // same callee in a different context, and `setStorageLocation` requires there
263
- // to not already be a storage location assigned. Conceptually, these maps
264
- // capture information from the local scope, so when popping that scope, we do
265
- // not propagate the maps.
255
+ // callee's `ReturnLoc` or `ThisPointeeLoc`. We don't bring back `DeclToLoc`
256
+ // and `ExprToLoc` because we want to be able to later analyze the same callee
257
+ // in a different context, and `setStorageLocation` requires there to not
258
+ // already be a storage location assigned. Conceptually, these maps capture
259
+ // information from the local scope, so when popping that scope, we do not
260
+ // propagate the maps.
266
261
this ->LocToVal = std::move (CalleeEnv.LocToVal );
267
262
this ->MemberLocToStruct = std::move (CalleeEnv.MemberLocToStruct );
268
263
this ->FlowConditionToken = std::move (CalleeEnv.FlowConditionToken );
@@ -309,13 +304,11 @@ LatticeJoinEffect Environment::join(const Environment &Other,
309
304
assert (DACtx == Other.DACtx );
310
305
assert (ReturnLoc == Other.ReturnLoc );
311
306
assert (ThisPointeeLoc == Other.ThisPointeeLoc );
312
- assert (DeclCtx == Other.DeclCtx );
313
307
314
308
auto Effect = LatticeJoinEffect::Unchanged;
315
309
316
310
Environment JoinedEnv (*DACtx);
317
311
318
- JoinedEnv.setDeclCtx (DeclCtx);
319
312
JoinedEnv.ReturnLoc = ReturnLoc;
320
313
JoinedEnv.ThisPointeeLoc = ThisPointeeLoc;
321
314
0 commit comments