clang 17.0.0git
DataflowEnvironment.h
Go to the documentation of this file.
1//===-- DataflowEnvironment.h -----------------------------------*- 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#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H
16#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H
17
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclBase.h"
20#include "clang/AST/Expr.h"
21#include "clang/AST/Type.h"
28#include "llvm/ADT/DenseMap.h"
29#include "llvm/ADT/DenseSet.h"
30#include "llvm/Support/ErrorHandling.h"
31#include <memory>
32#include <type_traits>
33#include <utility>
34
35namespace clang {
36namespace dataflow {
37
38/// Indicates what kind of indirections should be skipped past when retrieving
39/// storage locations or values.
40///
41/// FIXME: Consider renaming this or replacing it with a more appropriate model.
42/// See the discussion in https://reviews.llvm.org/D116596 for context.
43enum class SkipPast {
44 /// No indirections should be skipped past.
45 None,
46 /// An optional reference should be skipped past.
48 /// An optional reference should be skipped past, then an optional pointer
49 /// should be skipped past.
51};
52
53/// Indicates the result of a tentative comparison.
54enum class ComparisonResult {
55 Same,
57 Unknown,
58};
59
60/// Holds the state of the program (store and heap) at a given program point.
61///
62/// WARNING: Symbolic values that are created by the environment for static
63/// local and global variables are not currently invalidated on function calls.
64/// This is unsound and should be taken into account when designing dataflow
65/// analyses.
67public:
68 /// Supplements `Environment` with non-standard comparison and join
69 /// operations.
70 class ValueModel {
71 public:
72 virtual ~ValueModel() = default;
73
74 /// Returns:
75 /// `Same`: `Val1` is equivalent to `Val2`, according to the model.
76 /// `Different`: `Val1` is distinct from `Val2`, according to the model.
77 /// `Unknown`: The model can't determine a relationship between `Val1` and
78 /// `Val2`.
79 ///
80 /// Requirements:
81 ///
82 /// `Val1` and `Val2` must be distinct.
83 ///
84 /// `Val1` and `Val2` must model values of type `Type`.
85 ///
86 /// `Val1` and `Val2` must be assigned to the same storage location in
87 /// `Env1` and `Env2` respectively.
89 const Environment &Env1, const Value &Val2,
90 const Environment &Env2) {
91 // FIXME: Consider adding QualType to StructValue and removing the Type
92 // argument here.
94 }
95
96 /// Modifies `MergedVal` to approximate both `Val1` and `Val2`. This could
97 /// be a strict lattice join or a more general widening operation.
98 ///
99 /// If this function returns true, `MergedVal` will be assigned to a storage
100 /// location of type `Type` in `MergedEnv`.
101 ///
102 /// `Env1` and `Env2` can be used to query child values and path condition
103 /// implications of `Val1` and `Val2` respectively.
104 ///
105 /// Requirements:
106 ///
107 /// `Val1` and `Val2` must be distinct.
108 ///
109 /// `Val1`, `Val2`, and `MergedVal` must model values of type `Type`.
110 ///
111 /// `Val1` and `Val2` must be assigned to the same storage location in
112 /// `Env1` and `Env2` respectively.
113 virtual bool merge(QualType Type, const Value &Val1,
114 const Environment &Env1, const Value &Val2,
115 const Environment &Env2, Value &MergedVal,
116 Environment &MergedEnv) {
117 return true;
118 }
119
120 /// This function may widen the current value -- replace it with an
121 /// approximation that can reach a fixed point more quickly than iterated
122 /// application of the transfer function alone. The previous value is
123 /// provided to inform the choice of widened value. The function must also
124 /// serve as a comparison operation, by indicating whether the widened value
125 /// is equivalent to the previous value.
126 ///
127 /// Returns either:
128 ///
129 /// `nullptr`, if this value is not of interest to the model, or
130 ///
131 /// `&Prev`, if the widened value is equivalent to `Prev`, or
132 ///
133 /// A non-null value that approximates `Current`. `Prev` is available to
134 /// inform the chosen approximation.
135 ///
136 /// `PrevEnv` and `CurrentEnv` can be used to query child values and path
137 /// condition implications of `Prev` and `Current`, respectively.
138 ///
139 /// Requirements:
140 ///
141 /// `Prev` and `Current` must model values of type `Type`.
142 ///
143 /// `Prev` and `Current` must be assigned to the same storage location in
144 /// `PrevEnv` and `CurrentEnv`, respectively.
145 virtual Value *widen(QualType Type, Value &Prev, const Environment &PrevEnv,
146 Value &Current, Environment &CurrentEnv) {
147 // The default implementation reduces to just comparison, since comparison
148 // is required by the API, even if no widening is performed.
149 switch (compare(Type, Prev, PrevEnv, Current, CurrentEnv)) {
151 return &Prev;
153 return &Current;
155 return nullptr;
156 }
157 llvm_unreachable("all cases in switch covered");
158 }
159 };
160
161 /// Creates an environment that uses `DACtx` to store objects that encompass
162 /// the state of a program.
163 explicit Environment(DataflowAnalysisContext &DACtx);
164
165 Environment(const Environment &Other);
166 Environment &operator=(const Environment &Other);
167
168 Environment(Environment &&Other) = default;
169 Environment &operator=(Environment &&Other) = default;
170
171 /// Creates an environment that uses `DACtx` to store objects that encompass
172 /// the state of a program.
173 ///
174 /// If `DeclCtx` is a function, initializes the environment with symbolic
175 /// representations of the function parameters.
176 ///
177 /// If `DeclCtx` is a non-static member function, initializes the environment
178 /// with a symbolic representation of the `this` pointee.
179 Environment(DataflowAnalysisContext &DACtx, const DeclContext &DeclCtx);
180
182 return DACtx->getOptions();
183 }
184
185 Logger &logger() const { return *DACtx->getOptions().Log; }
186
187 /// Creates and returns an environment to use for an inline analysis of the
188 /// callee. Uses the storage location from each argument in the `Call` as the
189 /// storage location for the corresponding parameter in the callee.
190 ///
191 /// Requirements:
192 ///
193 /// The callee of `Call` must be a `FunctionDecl`.
194 ///
195 /// The body of the callee must not reference globals.
196 ///
197 /// The arguments of `Call` must map 1:1 to the callee's parameters.
198 Environment pushCall(const CallExpr *Call) const;
199 Environment pushCall(const CXXConstructExpr *Call) const;
200
201 /// Moves gathered information back into `this` from a `CalleeEnv` created via
202 /// `pushCall`.
203 void popCall(const Environment &CalleeEnv);
204
205 /// Returns true if and only if the environment is equivalent to `Other`, i.e
206 /// the two environments:
207 /// - have the same mappings from declarations to storage locations,
208 /// - have the same mappings from expressions to storage locations,
209 /// - have the same or equivalent (according to `Model`) values assigned to
210 /// the same storage locations.
211 ///
212 /// Requirements:
213 ///
214 /// `Other` and `this` must use the same `DataflowAnalysisContext`.
215 bool equivalentTo(const Environment &Other,
216 Environment::ValueModel &Model) const;
217
218 /// Joins the environment with `Other` by taking the intersection of storage
219 /// locations and values that are stored in them. Distinct values that are
220 /// assigned to the same storage locations in the environment and `Other` are
221 /// merged using `Model`.
222 ///
223 /// Requirements:
224 ///
225 /// `Other` and `this` must use the same `DataflowAnalysisContext`.
228
229
230 /// Widens the environment point-wise, using `PrevEnv` as needed to inform the
231 /// approximation.
232 ///
233 /// Requirements:
234 ///
235 /// `PrevEnv` must be the immediate previous version of the environment.
236 /// `PrevEnv` and `this` must use the same `DataflowAnalysisContext`.
237 LatticeJoinEffect widen(const Environment &PrevEnv,
239
240 // FIXME: Rename `createOrGetStorageLocation` to `getOrCreateStorageLocation`,
241 // `getStableStorageLocation`, or something more appropriate.
242
243 /// Creates a storage location appropriate for `Type`. Does not assign a value
244 /// to the returned storage location in the environment.
245 ///
246 /// Requirements:
247 ///
248 /// `Type` must not be null.
250
251 /// Creates a storage location for `D`. Does not assign the returned storage
252 /// location to `D` in the environment. Does not assign a value to the
253 /// returned storage location in the environment.
255
256 /// Creates a storage location for `E`. Does not assign the returned storage
257 /// location to `E` in the environment. Does not assign a value to the
258 /// returned storage location in the environment.
260
261 /// Assigns `Loc` as the storage location of `D` in the environment.
262 ///
263 /// Requirements:
264 ///
265 /// `D` must not be assigned a storage location in the environment.
266 void setStorageLocation(const ValueDecl &D, StorageLocation &Loc);
267
268 /// Returns the storage location assigned to `D` in the environment, applying
269 /// the `SP` policy for skipping past indirections, or null if `D` isn't
270 /// assigned a storage location in the environment.
272
273 /// Assigns `Loc` as the storage location of `E` in the environment.
274 ///
275 /// Requirements:
276 ///
277 /// `E` must not be assigned a storage location in the environment.
278 void setStorageLocation(const Expr &E, StorageLocation &Loc);
279
280 /// Returns the storage location assigned to `E` in the environment, applying
281 /// the `SP` policy for skipping past indirections, or null if `E` isn't
282 /// assigned a storage location in the environment.
283 StorageLocation *getStorageLocation(const Expr &E, SkipPast SP) const;
284
285 /// Returns the storage location assigned to the `this` pointee in the
286 /// environment or null if the `this` pointee has no assigned storage location
287 /// in the environment.
289
290 /// Returns the storage location of the return value or null, if unset.
292
293 /// Returns a pointer value that represents a null pointer. Calls with
294 /// `PointeeType` that are canonically equivalent will return the same result.
296
297 /// Creates a value appropriate for `Type`, if `Type` is supported, otherwise
298 /// return null. If `Type` is a pointer or reference type, creates all the
299 /// necessary storage locations and values for indirections until it finds a
300 /// non-pointer/non-reference type.
301 ///
302 /// Requirements:
303 ///
304 /// `Type` must not be null.
306
307 /// Assigns `Val` as the value of `Loc` in the environment.
308 void setValue(const StorageLocation &Loc, Value &Val);
309
310 /// Returns the value assigned to `Loc` in the environment or null if `Loc`
311 /// isn't assigned a value in the environment.
312 Value *getValue(const StorageLocation &Loc) const;
313
314 /// Equivalent to `getValue(getStorageLocation(D, SP), SkipPast::None)` if `D`
315 /// is assigned a storage location in the environment, otherwise returns null.
316 Value *getValue(const ValueDecl &D, SkipPast SP) const;
317
318 /// Equivalent to `getValue(getStorageLocation(E, SP), SkipPast::None)` if `E`
319 /// is assigned a storage location in the environment, otherwise returns null.
320 Value *getValue(const Expr &E, SkipPast SP) const;
321
322 /// Transfers ownership of `Loc` to the analysis context and returns a
323 /// reference to it.
324 ///
325 /// Requirements:
326 ///
327 /// `Loc` must not be null.
328 template <typename T>
329 std::enable_if_t<std::is_base_of<StorageLocation, T>::value, T &>
330 takeOwnership(std::unique_ptr<T> Loc) {
331 return DACtx->takeOwnership(std::move(Loc));
332 }
333
334 /// Transfers ownership of `Val` to the analysis context and returns a
335 /// reference to it.
336 ///
337 /// Requirements:
338 ///
339 /// `Val` must not be null.
340 template <typename T>
341 std::enable_if_t<std::is_base_of<Value, T>::value, T &>
342 takeOwnership(std::unique_ptr<T> Val) {
343 return DACtx->takeOwnership(std::move(Val));
344 }
345
346 /// Returns a symbolic boolean value that models a boolean literal equal to
347 /// `Value`
349 return DACtx->getBoolLiteralValue(Value);
350 }
351
352 /// Returns an atomic boolean value.
354 return DACtx->createAtomicBoolValue();
355 }
356
357 /// Returns a unique instance of boolean Top.
359 return DACtx->createTopBoolValue();
360 }
361
362 /// Returns a boolean value that represents the conjunction of `LHS` and
363 /// `RHS`. Subsequent calls with the same arguments, regardless of their
364 /// order, will return the same result. If the given boolean values represent
365 /// the same value, the result will be the value itself.
367 return DACtx->getOrCreateConjunction(LHS, RHS);
368 }
369
370 /// Returns a boolean value that represents the disjunction of `LHS` and
371 /// `RHS`. Subsequent calls with the same arguments, regardless of their
372 /// order, will return the same result. If the given boolean values represent
373 /// the same value, the result will be the value itself.
374 BoolValue &makeOr(BoolValue &LHS, BoolValue &RHS) const {
375 return DACtx->getOrCreateDisjunction(LHS, RHS);
376 }
377
378 /// Returns a boolean value that represents the negation of `Val`. Subsequent
379 /// calls with the same argument will return the same result.
381 return DACtx->getOrCreateNegation(Val);
382 }
383
384 /// Returns a boolean value represents `LHS` => `RHS`. Subsequent calls with
385 /// the same arguments, will return the same result. If the given boolean
386 /// values represent the same value, the result will be a value that
387 /// represents the true boolean literal.
389 return DACtx->getOrCreateImplication(LHS, RHS);
390 }
391
392 /// Returns a boolean value represents `LHS` <=> `RHS`. Subsequent calls with
393 /// the same arguments, regardless of their order, will return the same
394 /// result. If the given boolean values represent the same value, the result
395 /// will be a value that represents the true boolean literal.
397 return DACtx->getOrCreateIff(LHS, RHS);
398 }
399
400 /// Returns the token that identifies the flow condition of the environment.
401 AtomicBoolValue &getFlowConditionToken() const { return *FlowConditionToken; }
402
403 /// Builds and returns the logical formula defining the flow condition
404 /// identified by `Token`. If a value in the formula is present as a key in
405 /// `Substitutions`, it will be substituted with the value it maps to.
408 llvm::DenseMap<AtomicBoolValue *, BoolValue *> Substitutions) {
410 std::move(Substitutions));
411 }
412
413 /// Adds `Val` to the set of clauses that constitute the flow condition.
414 void addToFlowCondition(BoolValue &Val);
415
416 /// Returns true if and only if the clauses that constitute the flow condition
417 /// imply that `Val` is true.
418 bool flowConditionImplies(BoolValue &Val) const;
419
420 /// Returns the `DeclContext` of the block being analysed, if any. Otherwise,
421 /// returns null.
422 const DeclContext *getDeclCtx() const { return CallStack.back(); }
423
424 /// Returns whether this `Environment` can be extended to analyze the given
425 /// `Callee` (i.e. if `pushCall` can be used), with recursion disallowed and a
426 /// given `MaxDepth`.
427 bool canDescend(unsigned MaxDepth, const DeclContext *Callee) const;
428
429 /// Returns the `ControlFlowContext` registered for `F`, if any. Otherwise,
430 /// returns null.
432 return DACtx->getControlFlowContext(F);
433 }
434
435 LLVM_DUMP_METHOD void dump() const;
436 LLVM_DUMP_METHOD void dump(raw_ostream &OS) const;
437
438private:
439 /// Creates a value appropriate for `Type`, if `Type` is supported, otherwise
440 /// return null.
441 ///
442 /// Recursively initializes storage locations and values until it sees a
443 /// self-referential pointer or reference type. `Visited` is used to track
444 /// which types appeared in the reference/pointer chain in order to avoid
445 /// creating a cyclic dependency with self-referential pointers/references.
446 ///
447 /// Requirements:
448 ///
449 /// `Type` must not be null.
450 Value *createValueUnlessSelfReferential(QualType Type,
452 int Depth, int &CreatedValuesCount);
453
454 StorageLocation &skip(StorageLocation &Loc, SkipPast SP) const;
455 const StorageLocation &skip(const StorageLocation &Loc, SkipPast SP) const;
456
457 /// Shared implementation of `pushCall` overloads. Note that unlike
458 /// `pushCall`, this member is invoked on the environment of the callee, not
459 /// of the caller.
460 void pushCallInternal(const FunctionDecl *FuncDecl,
462
463 /// Assigns storage locations and values to all variables in `Vars`.
464 void initVars(llvm::DenseSet<const VarDecl *> Vars);
465
466 // `DACtx` is not null and not owned by this object.
468
469
470 // FIXME: move the fields `CallStack`, `ReturnLoc` and `ThisPointeeLoc` into a
471 // separate call-context object, shared between environments in the same call.
472 // https://github.com/llvm/llvm-project/issues/59005
473
474 // `DeclContext` of the block being analysed if provided.
475 std::vector<const DeclContext *> CallStack;
476
477 // In a properly initialized `Environment`, `ReturnLoc` should only be null if
478 // its `DeclContext` could not be cast to a `FunctionDecl`.
479 StorageLocation *ReturnLoc = nullptr;
480 // The storage location of the `this` pointee. Should only be null if the
481 // function being analyzed is only a function and not a method.
482 StorageLocation *ThisPointeeLoc = nullptr;
483
484 // Maps from program declarations and statements to storage locations that are
485 // assigned to them. Unlike the maps in `DataflowAnalysisContext`, these
486 // include only storage locations that are in scope for a particular basic
487 // block.
488 llvm::DenseMap<const ValueDecl *, StorageLocation *> DeclToLoc;
489 llvm::DenseMap<const Expr *, StorageLocation *> ExprToLoc;
490
491 llvm::DenseMap<const StorageLocation *, Value *> LocToVal;
492
493 // Maps locations of struct members to symbolic values of the structs that own
494 // them and the decls of the struct members.
495 llvm::DenseMap<const StorageLocation *,
496 std::pair<StructValue *, const ValueDecl *>>
497 MemberLocToStruct;
498
499 AtomicBoolValue *FlowConditionToken;
500};
501
502} // namespace dataflow
503} // namespace clang
504
505#endif // LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWENVIRONMENT_H
llvm::raw_ostream & OS
Definition: Logger.cpp:24
C Language Family Type Representation.
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1518
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2812
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1393
This represents one expression.
Definition: Expr.h:110
Represents a function declaration or definition.
Definition: Decl.h:1917
A (possibly-)qualified type.
Definition: Type.h:736
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
The base class of the type hierarchy.
Definition: Type.h:1566
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:701
Represents a variable declaration or definition.
Definition: Decl.h:913
Models an atomic boolean.
Definition: Value.h:120
Models a boolean.
Definition: Value.h:93
Holds CFG and other derived context that is needed to perform dataflow analysis.
Owns objects that encompass the state of a program and stores context that is used during dataflow an...
BoolValue & buildAndSubstituteFlowCondition(AtomicBoolValue &Token, llvm::DenseMap< AtomicBoolValue *, BoolValue * > Substitutions)
Builds and returns the logical formula defining the flow condition identified by Token.
BoolValue & getOrCreateImplication(BoolValue &LHS, BoolValue &RHS)
Returns a boolean value that represents LHS => RHS.
std::enable_if_t< std::is_base_of< StorageLocation, T >::value, T & > takeOwnership(std::unique_ptr< T > Loc)
Takes ownership of Loc and returns a reference to it.
TopBoolValue & createTopBoolValue()
Creates a Top value for booleans.
AtomicBoolValue & getBoolLiteralValue(bool Value) const
Returns a symbolic boolean value that models a boolean literal equal to Value.
AtomicBoolValue & createAtomicBoolValue()
Creates an atomic boolean value.
BoolValue & getOrCreateNegation(BoolValue &Val)
Returns a boolean value that represents the negation of Val.
BoolValue & getOrCreateConjunction(BoolValue &LHS, BoolValue &RHS)
Returns a boolean value that represents the conjunction of LHS and RHS.
BoolValue & getOrCreateDisjunction(BoolValue &LHS, BoolValue &RHS)
Returns a boolean value that represents the disjunction of LHS and RHS.
BoolValue & getOrCreateIff(BoolValue &LHS, BoolValue &RHS)
Returns a boolean value that represents LHS <=> RHS.
const ControlFlowContext * getControlFlowContext(const FunctionDecl *F)
Returns the ControlFlowContext registered for F, if any.
Supplements Environment with non-standard comparison and join operations.
virtual ComparisonResult compare(QualType Type, const Value &Val1, const Environment &Env1, const Value &Val2, const Environment &Env2)
Returns: Same: Val1 is equivalent to Val2, according to the model.
virtual Value * widen(QualType Type, Value &Prev, const Environment &PrevEnv, Value &Current, Environment &CurrentEnv)
This function may widen the current value – replace it with an approximation that can reach a fixed p...
virtual bool merge(QualType Type, const Value &Val1, const Environment &Env1, const Value &Val2, const Environment &Env2, Value &MergedVal, Environment &MergedEnv)
Modifies MergedVal to approximate both Val1 and Val2.
Holds the state of the program (store and heap) at a given program point.
StorageLocation * getStorageLocation(const ValueDecl &D, SkipPast SP) const
Returns the storage location assigned to D in the environment, applying the SP policy for skipping pa...
const ControlFlowContext * getControlFlowContext(const FunctionDecl *F)
Returns the ControlFlowContext registered for F, if any.
std::enable_if_t< std::is_base_of< StorageLocation, T >::value, T & > takeOwnership(std::unique_ptr< T > Loc)
Transfers ownership of Loc to the analysis context and returns a reference to it.
PointerValue & getOrCreateNullPointerValue(QualType PointeeType)
Returns a pointer value that represents a null pointer.
BoolValue & makeAnd(BoolValue &LHS, BoolValue &RHS) const
Returns a boolean value that represents the conjunction of LHS and RHS.
std::enable_if_t< std::is_base_of< Value, T >::value, T & > takeOwnership(std::unique_ptr< T > Val)
Transfers ownership of Val to the analysis context and returns a reference to it.
LatticeJoinEffect widen(const Environment &PrevEnv, Environment::ValueModel &Model)
Widens the environment point-wise, using PrevEnv as needed to inform the approximation.
BoolValue & makeIff(BoolValue &LHS, BoolValue &RHS) const
Returns a boolean value represents LHS <=> RHS.
void addToFlowCondition(BoolValue &Val)
Adds Val to the set of clauses that constitute the flow condition.
BoolValue & buildAndSubstituteFlowCondition(AtomicBoolValue &Token, llvm::DenseMap< AtomicBoolValue *, BoolValue * > Substitutions)
Builds and returns the logical formula defining the flow condition identified by Token.
Environment pushCall(const CallExpr *Call) const
Creates and returns an environment to use for an inline analysis of the callee.
LLVM_DUMP_METHOD void dump() const
Environment(Environment &&Other)=default
StorageLocation * getThisPointeeStorageLocation() const
Returns the storage location assigned to the this pointee in the environment or null if the this poin...
BoolValue & makeTopBoolValue() const
Returns a unique instance of boolean Top.
StorageLocation & createStorageLocation(QualType Type)
Creates a storage location appropriate for Type.
bool equivalentTo(const Environment &Other, Environment::ValueModel &Model) const
Returns true if and only if the environment is equivalent to Other, i.e the two environments:
BoolValue & makeAtomicBoolValue() const
Returns an atomic boolean value.
Value * getValue(const StorageLocation &Loc) const
Returns the value assigned to Loc in the environment or null if Loc isn't assigned a value in the env...
bool canDescend(unsigned MaxDepth, const DeclContext *Callee) const
Returns whether this Environment can be extended to analyze the given Callee (i.e.
void setStorageLocation(const ValueDecl &D, StorageLocation &Loc)
Assigns Loc as the storage location of D in the environment.
Value * createValue(QualType Type)
Creates a value appropriate for Type, if Type is supported, otherwise return null.
void popCall(const Environment &CalleeEnv)
Moves gathered information back into this from a CalleeEnv created via pushCall.
void setValue(const StorageLocation &Loc, Value &Val)
Assigns Val as the value of Loc in the environment.
Environment & operator=(Environment &&Other)=default
BoolValue & makeNot(BoolValue &Val) const
Returns a boolean value that represents the negation of Val.
const DeclContext * getDeclCtx() const
Returns the DeclContext of the block being analysed, if any.
AtomicBoolValue & getFlowConditionToken() const
Returns the token that identifies the flow condition of the environment.
BoolValue & makeOr(BoolValue &LHS, BoolValue &RHS) const
Returns a boolean value that represents the disjunction of LHS and RHS.
LatticeJoinEffect join(const Environment &Other, Environment::ValueModel &Model)
Joins the environment with Other by taking the intersection of storage locations and values that are ...
bool flowConditionImplies(BoolValue &Val) const
Returns true if and only if the clauses that constitute the flow condition imply that Val is true.
StorageLocation * getReturnStorageLocation() const
Returns the storage location of the return value or null, if unset.
AtomicBoolValue & getBoolLiteralValue(bool Value) const
Returns a symbolic boolean value that models a boolean literal equal to Value
const DataflowAnalysisContext::Options & getAnalysisOptions() const
Environment & operator=(const Environment &Other)
BoolValue & makeImplication(BoolValue &LHS, BoolValue &RHS) const
Returns a boolean value represents LHS => RHS.
A logger is notified as the analysis progresses.
Definition: Logger.h:27
Models a symbolic pointer. Specifically, any value of type T*.
Definition: Value.h:269
Base class for elements of the local variable store and of the heap.
Base class for all values computed by abstract interpretation.
Definition: Value.h:33
ComparisonResult
Indicates the result of a tentative comparison.
LatticeJoinEffect
Effect indicating whether a lattice join operation resulted in a new value.
SkipPast
Indicates what kind of indirections should be skipped past when retrieving storage locations or value...
@ ReferenceThenPointer
An optional reference should be skipped past, then an optional pointer should be skipped past.
@ Reference
An optional reference should be skipped past.
@ None
No indirections should be skipped past.
Logger * Log
If provided, analysis details will be recorded here.