13#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CACHED_CONST_ACCESSORS_LATTICE_H
14#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CACHED_CONST_ACCESSORS_LATTICE_H
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/STLFunctionalExtras.h"
81 ConstMethodReturnValues.erase(&
RecordLoc);
86 ConstMethodReturnStorageLocations.erase(&
RecordLoc);
90 return Base::operator==(
Other);
98 using ConstMethodReturnValuesType =
100 llvm::SmallDenseMap<const FunctionDecl *, Value *>>;
101 ConstMethodReturnValuesType ConstMethodReturnValues;
105 using ConstMethodReturnStorageLocationsType = llvm::SmallDenseMap<
107 llvm::SmallDenseMap<const FunctionDecl *, StorageLocation *>>;
108 ConstMethodReturnStorageLocationsType ConstMethodReturnStorageLocations;
115 llvm::SmallDenseMap<const FunctionDecl *, T *>>
118 llvm::SmallDenseMap<const FunctionDecl *, T *>>
121 llvm::SmallDenseMap<const FunctionDecl *, T *>>
126 llvm::SmallDenseMap<const FunctionDecl *, T *>>
128 for (
auto &[Loc, DeclToT] : Map1) {
129 auto It = Map2.find(Loc);
130 if (It == Map2.end()) {
134 const auto &OtherDeclToT = It->second;
135 auto &JoinedDeclToT =
Result[Loc];
136 for (
auto [
Func, Var] : DeclToT) {
137 T *OtherVar = OtherDeclToT.lookup(
Func);
138 if (OtherVar ==
nullptr || OtherVar != Var) {
142 JoinedDeclToT.insert({
Func, Var});
150template <
typename Base>
160 ConstMethodReturnValues =
162 ConstMethodReturnValues,
Other.ConstMethodReturnValues, Effect);
164 ConstMethodReturnStorageLocations =
166 ConstMethodReturnStorageLocations,
167 Other.ConstMethodReturnStorageLocations, Effect);
172template <
typename Base>
177 assert(!
Type.isNull());
181 auto &ObjMap = ConstMethodReturnValues[&
RecordLoc];
183 if (DirectCallee ==
nullptr)
185 auto it = ObjMap.find(DirectCallee);
186 if (it != ObjMap.end())
191 ObjMap.insert({DirectCallee, Val});
195template <
typename Base>
200 assert(Callee !=
nullptr);
202 assert(!
Type.isNull());
204 auto &ObjMap = ConstMethodReturnStorageLocations[&
RecordLoc];
205 auto it = ObjMap.find(Callee);
206 if (it != ObjMap.end())
212 ObjMap.insert({Callee, &Loc});
llvm::MachO::RecordLoc RecordLoc
C Language Family Type Representation.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Represents a function declaration or definition.
A (possibly-)qualified type.
The base class of the type hierarchy.
bool isReferenceType() const
bool isRecordType() const
A mixin for a lattice that additionally maintains a cache of stable method call return values to mode...
LatticeEffect join(const CachedConstAccessorsLattice &Other)
void clearConstMethodReturnStorageLocations(const RecordStorageLocation &RecordLoc)
StorageLocation & getOrCreateConstMethodReturnStorageLocation(const RecordStorageLocation &RecordLoc, const FunctionDecl *Callee, Environment &Env, llvm::function_ref< void(StorageLocation &)> Initialize)
Creates or returns a previously created StorageLocation associated with a const method call obj....
bool operator==(const CachedConstAccessorsLattice &Other) const
void clearConstMethodReturnValues(const RecordStorageLocation &RecordLoc)
Value * getOrCreateConstMethodReturnValue(const RecordStorageLocation &RecordLoc, const CallExpr *CE, Environment &Env)
Creates or returns a previously created Value associated with a const method call obj....
Holds the state of the program (store and heap) at a given program point.
StorageLocation & createStorageLocation(QualType Type)
Creates a storage location appropriate for Type.
Value * createValue(QualType Type)
Creates a value appropriate for Type, if Type is supported, otherwise returns null.
A storage location for a record (struct, class, or union).
Base class for elements of the local variable store and of the heap.
Base class for all values computed by abstract interpretation.
llvm::SmallDenseMap< const RecordStorageLocation *, llvm::SmallDenseMap< const FunctionDecl *, T * > > joinConstMethodMap(const llvm::SmallDenseMap< const RecordStorageLocation *, llvm::SmallDenseMap< const FunctionDecl *, T * > > &Map1, const llvm::SmallDenseMap< const RecordStorageLocation *, llvm::SmallDenseMap< const FunctionDecl *, T * > > &Map2, LatticeEffect &Effect)
Dataflow Directional Tag Classes.
LatticeEffect
Effect indicating whether a lattice operation resulted in a new value.
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ Other
Other implicit parameter.