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;
114llvm::SmallDenseMap<
const RecordStorageLocation *,
115 llvm::SmallDenseMap<const FunctionDecl *, T *>>
118 llvm::SmallDenseMap<const FunctionDecl *, T *>>
121 llvm::SmallDenseMap<const FunctionDecl *, T *>>
125 llvm::SmallDenseMap<const FunctionDecl *, T *>>
127 for (
auto &[
Loc, DeclToT] : Map1) {
128 auto It = Map2.find(
Loc);
129 if (It == Map2.end()) {
133 const auto &OtherDeclToT = It->second;
135 for (
auto [
Func, Var] : DeclToT) {
136 T *OtherVar = OtherDeclToT.lookup(
Func);
137 if (OtherVar ==
nullptr || OtherVar != Var) {
141 JoinedDeclToT.insert({
Func, Var});
149template <
typename Base>
159 ConstMethodReturnValues =
160 clang::dataflow::internal::joinConstMethodMap<dataflow::Value>(
161 ConstMethodReturnValues,
Other.ConstMethodReturnValues, Effect);
163 ConstMethodReturnStorageLocations =
164 clang::dataflow::internal::joinConstMethodMap<dataflow::StorageLocation>(
165 ConstMethodReturnStorageLocations,
166 Other.ConstMethodReturnStorageLocations, Effect);
171template <
typename Base>
176 assert(!
Type.isNull());
180 auto &ObjMap = ConstMethodReturnValues[&
RecordLoc];
182 if (DirectCallee ==
nullptr)
184 auto it = ObjMap.find(DirectCallee);
185 if (it != ObjMap.end())
190 ObjMap.insert({DirectCallee, Val});
194template <
typename Base>
199 assert(Callee !=
nullptr);
201 assert(!
Type.isNull());
203 auto &ObjMap = ConstMethodReturnStorageLocations[&
RecordLoc];
204 auto it = ObjMap.find(Callee);
205 if (it != ObjMap.end())
211 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...
LatticeJoinEffect 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)
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.