xref: /llvm-project/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp (revision c0725865b188f71f904ecd4dac56ef37268b30d2)
1 //===-- DataflowEnvironment.cpp ---------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //  This file defines an Environment class that is used by dataflow analyses
10 //  that run over Control-Flow Graphs (CFGs) to keep track of the state of the
11 //  program at given program points.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclCXX.h"
18 #include "clang/AST/Type.h"
19 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
20 #include "clang/Analysis/FlowSensitive/Value.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/DenseSet.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/Support/Casting.h"
25 #include "llvm/Support/ErrorHandling.h"
26 #include <cassert>
27 #include <memory>
28 #include <utility>
29 
30 namespace clang {
31 namespace dataflow {
32 
33 // FIXME: convert these to parameters of the analysis or environment. Current
34 // settings have been experimentaly validated, but only for a particular
35 // analysis.
36 static constexpr int MaxCompositeValueDepth = 3;
37 static constexpr int MaxCompositeValueSize = 1000;
38 
39 /// Returns a map consisting of key-value entries that are present in both maps.
40 template <typename K, typename V>
41 llvm::DenseMap<K, V> intersectDenseMaps(const llvm::DenseMap<K, V> &Map1,
42                                         const llvm::DenseMap<K, V> &Map2) {
43   llvm::DenseMap<K, V> Result;
44   for (auto &Entry : Map1) {
45     auto It = Map2.find(Entry.first);
46     if (It != Map2.end() && Entry.second == It->second)
47       Result.insert({Entry.first, Entry.second});
48   }
49   return Result;
50 }
51 
52 /// Attempts to merge distinct values `Val1` and `Val2` in `Env1` and `Env2`,
53 /// respectively, of the same type `Type`. Merging generally produces a single
54 /// value that (soundly) approximates the two inputs, although the actual
55 /// meaning depends on `Model`.
56 static Value *mergeDistinctValues(QualType Type, Value *Val1,
57                                   const Environment &Env1, Value *Val2,
58                                   const Environment &Env2,
59                                   Environment &MergedEnv,
60                                   Environment::ValueModel &Model) {
61   // Join distinct boolean values preserving information about the constraints
62   // in the respective path conditions.
63   if (auto *Expr1 = dyn_cast<BoolValue>(Val1)) {
64     auto *Expr2 = cast<BoolValue>(Val2);
65     auto &MergedVal = MergedEnv.makeAtomicBoolValue();
66     MergedEnv.addToFlowCondition(MergedEnv.makeOr(
67         MergedEnv.makeAnd(Env1.getFlowConditionToken(),
68                           MergedEnv.makeIff(MergedVal, *Expr1)),
69         MergedEnv.makeAnd(Env2.getFlowConditionToken(),
70                           MergedEnv.makeIff(MergedVal, *Expr2))));
71     return &MergedVal;
72   }
73 
74   // FIXME: Consider destroying `MergedValue` immediately if `ValueModel::merge`
75   // returns false to avoid storing unneeded values in `DACtx`.
76   if (Value *MergedVal = MergedEnv.createValue(Type))
77     if (Model.merge(Type, *Val1, Env1, *Val2, Env2, *MergedVal, MergedEnv))
78       return MergedVal;
79 
80   return nullptr;
81 }
82 
83 /// Initializes a global storage value.
84 static void initGlobalVar(const VarDecl &D, Environment &Env) {
85   if (!D.hasGlobalStorage() ||
86       Env.getStorageLocation(D, SkipPast::None) != nullptr)
87     return;
88 
89   auto &Loc = Env.createStorageLocation(D);
90   Env.setStorageLocation(D, Loc);
91   if (auto *Val = Env.createValue(D.getType()))
92     Env.setValue(Loc, *Val);
93 }
94 
95 /// Initializes a global storage value.
96 static void initGlobalVar(const Decl &D, Environment &Env) {
97   if (auto *V = dyn_cast<VarDecl>(&D))
98     initGlobalVar(*V, Env);
99 }
100 
101 /// Initializes global storage values that are declared or referenced from
102 /// sub-statements of `S`.
103 // FIXME: Add support for resetting globals after function calls to enable
104 // the implementation of sound analyses.
105 static void initGlobalVars(const Stmt &S, Environment &Env) {
106   for (auto *Child : S.children()) {
107     if (Child != nullptr)
108       initGlobalVars(*Child, Env);
109   }
110 
111   if (auto *DS = dyn_cast<DeclStmt>(&S)) {
112     if (DS->isSingleDecl()) {
113       initGlobalVar(*DS->getSingleDecl(), Env);
114     } else {
115       for (auto *D : DS->getDeclGroup())
116         initGlobalVar(*D, Env);
117     }
118   } else if (auto *E = dyn_cast<DeclRefExpr>(&S)) {
119     initGlobalVar(*E->getDecl(), Env);
120   } else if (auto *E = dyn_cast<MemberExpr>(&S)) {
121     initGlobalVar(*E->getMemberDecl(), Env);
122   }
123 }
124 
125 Environment::Environment(DataflowAnalysisContext &DACtx)
126     : DACtx(&DACtx), FlowConditionToken(&DACtx.makeFlowConditionToken()) {}
127 
128 Environment::Environment(const Environment &Other)
129     : DACtx(Other.DACtx), CallStack(Other.CallStack),
130       ReturnLoc(Other.ReturnLoc), ThisPointeeLoc(Other.ThisPointeeLoc),
131       DeclToLoc(Other.DeclToLoc), ExprToLoc(Other.ExprToLoc),
132       LocToVal(Other.LocToVal), MemberLocToStruct(Other.MemberLocToStruct),
133       FlowConditionToken(&DACtx->forkFlowCondition(*Other.FlowConditionToken)) {
134 }
135 
136 Environment &Environment::operator=(const Environment &Other) {
137   Environment Copy(Other);
138   *this = std::move(Copy);
139   return *this;
140 }
141 
142 Environment::Environment(DataflowAnalysisContext &DACtx,
143                          const DeclContext &DeclCtx)
144     : Environment(DACtx) {
145   CallStack.push_back(&DeclCtx);
146 
147   if (const auto *FuncDecl = dyn_cast<FunctionDecl>(&DeclCtx)) {
148     assert(FuncDecl->getBody() != nullptr);
149     initGlobalVars(*FuncDecl->getBody(), *this);
150     for (const auto *ParamDecl : FuncDecl->parameters()) {
151       assert(ParamDecl != nullptr);
152       auto &ParamLoc = createStorageLocation(*ParamDecl);
153       setStorageLocation(*ParamDecl, ParamLoc);
154       if (Value *ParamVal = createValue(ParamDecl->getType()))
155         setValue(ParamLoc, *ParamVal);
156     }
157 
158     QualType ReturnType = FuncDecl->getReturnType();
159     ReturnLoc = &createStorageLocation(ReturnType);
160   }
161 
162   if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(&DeclCtx)) {
163     auto *Parent = MethodDecl->getParent();
164     assert(Parent != nullptr);
165     if (Parent->isLambda())
166       MethodDecl = dyn_cast<CXXMethodDecl>(Parent->getDeclContext());
167 
168     if (MethodDecl && !MethodDecl->isStatic()) {
169       QualType ThisPointeeType = MethodDecl->getThisObjectType();
170       // FIXME: Add support for union types.
171       if (!ThisPointeeType->isUnionType()) {
172         ThisPointeeLoc = &createStorageLocation(ThisPointeeType);
173         if (Value *ThisPointeeVal = createValue(ThisPointeeType))
174           setValue(*ThisPointeeLoc, *ThisPointeeVal);
175       }
176     }
177   }
178 }
179 
180 bool Environment::canDescend(unsigned MaxDepth,
181                              const DeclContext *Callee) const {
182   return CallStack.size() <= MaxDepth && !llvm::is_contained(CallStack, Callee);
183 }
184 
185 Environment Environment::pushCall(const CallExpr *Call) const {
186   Environment Env(*this);
187 
188   // FIXME: Support references here.
189   Env.ReturnLoc = getStorageLocation(*Call, SkipPast::Reference);
190 
191   if (const auto *MethodCall = dyn_cast<CXXMemberCallExpr>(Call)) {
192     if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
193       if (!isa<CXXThisExpr>(Arg))
194         Env.ThisPointeeLoc = getStorageLocation(*Arg, SkipPast::Reference);
195       // Otherwise (when the argument is `this`), retain the current
196       // environment's `ThisPointeeLoc`.
197     }
198   }
199 
200   Env.pushCallInternal(Call->getDirectCallee(),
201                        llvm::makeArrayRef(Call->getArgs(), Call->getNumArgs()));
202 
203   return Env;
204 }
205 
206 Environment Environment::pushCall(const CXXConstructExpr *Call) const {
207   Environment Env(*this);
208 
209   // FIXME: Support references here.
210   Env.ReturnLoc = getStorageLocation(*Call, SkipPast::Reference);
211 
212   Env.ThisPointeeLoc = Env.ReturnLoc;
213 
214   Env.pushCallInternal(Call->getConstructor(),
215                        llvm::makeArrayRef(Call->getArgs(), Call->getNumArgs()));
216 
217   return Env;
218 }
219 
220 void Environment::pushCallInternal(const FunctionDecl *FuncDecl,
221                                    ArrayRef<const Expr *> Args) {
222   CallStack.push_back(FuncDecl);
223 
224   // FIXME: In order to allow the callee to reference globals, we probably need
225   // to call `initGlobalVars` here in some way.
226 
227   auto ParamIt = FuncDecl->param_begin();
228 
229   // FIXME: Parameters don't always map to arguments 1:1; examples include
230   // overloaded operators implemented as member functions, and parameter packs.
231   for (unsigned ArgIndex = 0; ArgIndex < Args.size(); ++ParamIt, ++ArgIndex) {
232     assert(ParamIt != FuncDecl->param_end());
233 
234     const Expr *Arg = Args[ArgIndex];
235     auto *ArgLoc = getStorageLocation(*Arg, SkipPast::Reference);
236     if (ArgLoc == nullptr)
237       continue;
238 
239     const VarDecl *Param = *ParamIt;
240     auto &Loc = createStorageLocation(*Param);
241     setStorageLocation(*Param, Loc);
242 
243     QualType ParamType = Param->getType();
244     if (ParamType->isReferenceType()) {
245       auto &Val = takeOwnership(std::make_unique<ReferenceValue>(*ArgLoc));
246       setValue(Loc, Val);
247     } else if (auto *ArgVal = getValue(*ArgLoc)) {
248       setValue(Loc, *ArgVal);
249     } else if (Value *Val = createValue(ParamType)) {
250       setValue(Loc, *Val);
251     }
252   }
253 }
254 
255 void Environment::popCall(const Environment &CalleeEnv) {
256   // We ignore `DACtx` because it's already the same in both. We don't want the
257   // callee's `DeclCtx`, `ReturnLoc` or `ThisPointeeLoc`. We don't bring back
258   // `DeclToLoc` and `ExprToLoc` because we want to be able to later analyze the
259   // same callee in a different context, and `setStorageLocation` requires there
260   // to not already be a storage location assigned. Conceptually, these maps
261   // capture information from the local scope, so when popping that scope, we do
262   // not propagate the maps.
263   this->LocToVal = std::move(CalleeEnv.LocToVal);
264   this->MemberLocToStruct = std::move(CalleeEnv.MemberLocToStruct);
265   this->FlowConditionToken = std::move(CalleeEnv.FlowConditionToken);
266 }
267 
268 bool Environment::equivalentTo(const Environment &Other,
269                                Environment::ValueModel &Model) const {
270   assert(DACtx == Other.DACtx);
271 
272   if (ReturnLoc != Other.ReturnLoc)
273     return false;
274 
275   if (ThisPointeeLoc != Other.ThisPointeeLoc)
276     return false;
277 
278   if (DeclToLoc != Other.DeclToLoc)
279     return false;
280 
281   if (ExprToLoc != Other.ExprToLoc)
282     return false;
283 
284   // Compare the contents for the intersection of their domains.
285   for (auto &Entry : LocToVal) {
286     const StorageLocation *Loc = Entry.first;
287     assert(Loc != nullptr);
288 
289     Value *Val = Entry.second;
290     assert(Val != nullptr);
291 
292     auto It = Other.LocToVal.find(Loc);
293     if (It == Other.LocToVal.end())
294       continue;
295     assert(It->second != nullptr);
296 
297     if (!areEquivalentValues(*Val, *It->second) &&
298         Model.compare(Loc->getType(), *Val, *this, *It->second, Other) !=
299             ComparisonResult::Same)
300       return false;
301   }
302 
303   return true;
304 }
305 
306 LatticeJoinEffect Environment::join(const Environment &Other,
307                                     Environment::ValueModel &Model) {
308   assert(DACtx == Other.DACtx);
309   assert(ReturnLoc == Other.ReturnLoc);
310   assert(ThisPointeeLoc == Other.ThisPointeeLoc);
311   assert(CallStack == Other.CallStack);
312 
313   auto Effect = LatticeJoinEffect::Unchanged;
314 
315   Environment JoinedEnv(*DACtx);
316 
317   JoinedEnv.CallStack = CallStack;
318   JoinedEnv.ReturnLoc = ReturnLoc;
319   JoinedEnv.ThisPointeeLoc = ThisPointeeLoc;
320 
321   JoinedEnv.DeclToLoc = intersectDenseMaps(DeclToLoc, Other.DeclToLoc);
322   if (DeclToLoc.size() != JoinedEnv.DeclToLoc.size())
323     Effect = LatticeJoinEffect::Changed;
324 
325   JoinedEnv.ExprToLoc = intersectDenseMaps(ExprToLoc, Other.ExprToLoc);
326   if (ExprToLoc.size() != JoinedEnv.ExprToLoc.size())
327     Effect = LatticeJoinEffect::Changed;
328 
329   JoinedEnv.MemberLocToStruct =
330       intersectDenseMaps(MemberLocToStruct, Other.MemberLocToStruct);
331   if (MemberLocToStruct.size() != JoinedEnv.MemberLocToStruct.size())
332     Effect = LatticeJoinEffect::Changed;
333 
334   // FIXME: set `Effect` as needed.
335   JoinedEnv.FlowConditionToken = &DACtx->joinFlowConditions(
336       *FlowConditionToken, *Other.FlowConditionToken);
337 
338   for (auto &Entry : LocToVal) {
339     const StorageLocation *Loc = Entry.first;
340     assert(Loc != nullptr);
341 
342     Value *Val = Entry.second;
343     assert(Val != nullptr);
344 
345     auto It = Other.LocToVal.find(Loc);
346     if (It == Other.LocToVal.end())
347       continue;
348     assert(It->second != nullptr);
349 
350     if (areEquivalentValues(*Val, *It->second)) {
351       JoinedEnv.LocToVal.insert({Loc, Val});
352       continue;
353     }
354 
355     if (Value *MergedVal = mergeDistinctValues(
356             Loc->getType(), Val, *this, It->second, Other, JoinedEnv, Model))
357       JoinedEnv.LocToVal.insert({Loc, MergedVal});
358   }
359   if (LocToVal.size() != JoinedEnv.LocToVal.size())
360     Effect = LatticeJoinEffect::Changed;
361 
362   *this = std::move(JoinedEnv);
363 
364   return Effect;
365 }
366 
367 StorageLocation &Environment::createStorageLocation(QualType Type) {
368   return DACtx->createStorageLocation(Type);
369 }
370 
371 StorageLocation &Environment::createStorageLocation(const VarDecl &D) {
372   // Evaluated declarations are always assigned the same storage locations to
373   // ensure that the environment stabilizes across loop iterations. Storage
374   // locations for evaluated declarations are stored in the analysis context.
375   return DACtx->getStableStorageLocation(D);
376 }
377 
378 StorageLocation &Environment::createStorageLocation(const Expr &E) {
379   // Evaluated expressions are always assigned the same storage locations to
380   // ensure that the environment stabilizes across loop iterations. Storage
381   // locations for evaluated expressions are stored in the analysis context.
382   return DACtx->getStableStorageLocation(E);
383 }
384 
385 void Environment::setStorageLocation(const ValueDecl &D, StorageLocation &Loc) {
386   assert(DeclToLoc.find(&D) == DeclToLoc.end());
387   DeclToLoc[&D] = &Loc;
388 }
389 
390 StorageLocation *Environment::getStorageLocation(const ValueDecl &D,
391                                                  SkipPast SP) const {
392   auto It = DeclToLoc.find(&D);
393   return It == DeclToLoc.end() ? nullptr : &skip(*It->second, SP);
394 }
395 
396 void Environment::setStorageLocation(const Expr &E, StorageLocation &Loc) {
397   const Expr &CanonE = ignoreCFGOmittedNodes(E);
398   assert(ExprToLoc.find(&CanonE) == ExprToLoc.end());
399   ExprToLoc[&CanonE] = &Loc;
400 }
401 
402 StorageLocation *Environment::getStorageLocation(const Expr &E,
403                                                  SkipPast SP) const {
404   // FIXME: Add a test with parens.
405   auto It = ExprToLoc.find(&ignoreCFGOmittedNodes(E));
406   return It == ExprToLoc.end() ? nullptr : &skip(*It->second, SP);
407 }
408 
409 StorageLocation *Environment::getThisPointeeStorageLocation() const {
410   return ThisPointeeLoc;
411 }
412 
413 StorageLocation *Environment::getReturnStorageLocation() const {
414   return ReturnLoc;
415 }
416 
417 PointerValue &Environment::getOrCreateNullPointerValue(QualType PointeeType) {
418   return DACtx->getOrCreateNullPointerValue(PointeeType);
419 }
420 
421 void Environment::setValue(const StorageLocation &Loc, Value &Val) {
422   LocToVal[&Loc] = &Val;
423 
424   if (auto *StructVal = dyn_cast<StructValue>(&Val)) {
425     auto &AggregateLoc = *cast<AggregateStorageLocation>(&Loc);
426 
427     const QualType Type = AggregateLoc.getType();
428     assert(Type->isStructureOrClassType());
429 
430     for (const FieldDecl *Field : getObjectFields(Type)) {
431       assert(Field != nullptr);
432       StorageLocation &FieldLoc = AggregateLoc.getChild(*Field);
433       MemberLocToStruct[&FieldLoc] = std::make_pair(StructVal, Field);
434       if (auto *FieldVal = StructVal->getChild(*Field))
435         setValue(FieldLoc, *FieldVal);
436     }
437   }
438 
439   auto It = MemberLocToStruct.find(&Loc);
440   if (It != MemberLocToStruct.end()) {
441     // `Loc` is the location of a struct member so we need to also update the
442     // value of the member in the corresponding `StructValue`.
443 
444     assert(It->second.first != nullptr);
445     StructValue &StructVal = *It->second.first;
446 
447     assert(It->second.second != nullptr);
448     const ValueDecl &Member = *It->second.second;
449 
450     StructVal.setChild(Member, Val);
451   }
452 }
453 
454 Value *Environment::getValue(const StorageLocation &Loc) const {
455   auto It = LocToVal.find(&Loc);
456   return It == LocToVal.end() ? nullptr : It->second;
457 }
458 
459 Value *Environment::getValue(const ValueDecl &D, SkipPast SP) const {
460   auto *Loc = getStorageLocation(D, SP);
461   if (Loc == nullptr)
462     return nullptr;
463   return getValue(*Loc);
464 }
465 
466 Value *Environment::getValue(const Expr &E, SkipPast SP) const {
467   auto *Loc = getStorageLocation(E, SP);
468   if (Loc == nullptr)
469     return nullptr;
470   return getValue(*Loc);
471 }
472 
473 Value *Environment::createValue(QualType Type) {
474   llvm::DenseSet<QualType> Visited;
475   int CreatedValuesCount = 0;
476   Value *Val = createValueUnlessSelfReferential(Type, Visited, /*Depth=*/0,
477                                                 CreatedValuesCount);
478   if (CreatedValuesCount > MaxCompositeValueSize) {
479     llvm::errs() << "Attempting to initialize a huge value of type: " << Type
480                  << '\n';
481   }
482   return Val;
483 }
484 
485 Value *Environment::createValueUnlessSelfReferential(
486     QualType Type, llvm::DenseSet<QualType> &Visited, int Depth,
487     int &CreatedValuesCount) {
488   assert(!Type.isNull());
489 
490   // Allow unlimited fields at depth 1; only cap at deeper nesting levels.
491   if ((Depth > 1 && CreatedValuesCount > MaxCompositeValueSize) ||
492       Depth > MaxCompositeValueDepth)
493     return nullptr;
494 
495   if (Type->isBooleanType()) {
496     CreatedValuesCount++;
497     return &makeAtomicBoolValue();
498   }
499 
500   if (Type->isIntegerType()) {
501     CreatedValuesCount++;
502     return &takeOwnership(std::make_unique<IntegerValue>());
503   }
504 
505   if (Type->isReferenceType()) {
506     CreatedValuesCount++;
507     QualType PointeeType = Type->castAs<ReferenceType>()->getPointeeType();
508     auto &PointeeLoc = createStorageLocation(PointeeType);
509 
510     if (Visited.insert(PointeeType.getCanonicalType()).second) {
511       Value *PointeeVal = createValueUnlessSelfReferential(
512           PointeeType, Visited, Depth, CreatedValuesCount);
513       Visited.erase(PointeeType.getCanonicalType());
514 
515       if (PointeeVal != nullptr)
516         setValue(PointeeLoc, *PointeeVal);
517     }
518 
519     return &takeOwnership(std::make_unique<ReferenceValue>(PointeeLoc));
520   }
521 
522   if (Type->isPointerType()) {
523     CreatedValuesCount++;
524     QualType PointeeType = Type->castAs<PointerType>()->getPointeeType();
525     auto &PointeeLoc = createStorageLocation(PointeeType);
526 
527     if (Visited.insert(PointeeType.getCanonicalType()).second) {
528       Value *PointeeVal = createValueUnlessSelfReferential(
529           PointeeType, Visited, Depth, CreatedValuesCount);
530       Visited.erase(PointeeType.getCanonicalType());
531 
532       if (PointeeVal != nullptr)
533         setValue(PointeeLoc, *PointeeVal);
534     }
535 
536     return &takeOwnership(std::make_unique<PointerValue>(PointeeLoc));
537   }
538 
539   if (Type->isStructureOrClassType()) {
540     CreatedValuesCount++;
541     // FIXME: Initialize only fields that are accessed in the context that is
542     // being analyzed.
543     llvm::DenseMap<const ValueDecl *, Value *> FieldValues;
544     for (const FieldDecl *Field : getObjectFields(Type)) {
545       assert(Field != nullptr);
546 
547       QualType FieldType = Field->getType();
548       if (Visited.contains(FieldType.getCanonicalType()))
549         continue;
550 
551       Visited.insert(FieldType.getCanonicalType());
552       if (auto *FieldValue = createValueUnlessSelfReferential(
553               FieldType, Visited, Depth + 1, CreatedValuesCount))
554         FieldValues.insert({Field, FieldValue});
555       Visited.erase(FieldType.getCanonicalType());
556     }
557 
558     return &takeOwnership(
559         std::make_unique<StructValue>(std::move(FieldValues)));
560   }
561 
562   return nullptr;
563 }
564 
565 StorageLocation &Environment::skip(StorageLocation &Loc, SkipPast SP) const {
566   switch (SP) {
567   case SkipPast::None:
568     return Loc;
569   case SkipPast::Reference:
570     // References cannot be chained so we only need to skip past one level of
571     // indirection.
572     if (auto *Val = dyn_cast_or_null<ReferenceValue>(getValue(Loc)))
573       return Val->getReferentLoc();
574     return Loc;
575   case SkipPast::ReferenceThenPointer:
576     StorageLocation &LocPastRef = skip(Loc, SkipPast::Reference);
577     if (auto *Val = dyn_cast_or_null<PointerValue>(getValue(LocPastRef)))
578       return Val->getPointeeLoc();
579     return LocPastRef;
580   }
581   llvm_unreachable("bad SkipPast kind");
582 }
583 
584 const StorageLocation &Environment::skip(const StorageLocation &Loc,
585                                          SkipPast SP) const {
586   return skip(*const_cast<StorageLocation *>(&Loc), SP);
587 }
588 
589 void Environment::addToFlowCondition(BoolValue &Val) {
590   DACtx->addFlowConditionConstraint(*FlowConditionToken, Val);
591 }
592 
593 bool Environment::flowConditionImplies(BoolValue &Val) const {
594   return DACtx->flowConditionImplies(*FlowConditionToken, Val);
595 }
596 
597 void Environment::dump() const {
598   DACtx->dumpFlowCondition(*FlowConditionToken);
599 }
600 
601 } // namespace dataflow
602 } // namespace clang
603