13#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CACHED_CONST_ACCESSORS_LATTICE_H
14#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_CACHED_CONST_ACCESSORS_LATTICE_H
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/STLFunctionalExtras.h"
79 ConstMethodReturnValues.erase(&
RecordLoc);
84 ConstMethodReturnStorageLocations.erase(&
RecordLoc);
88 return Base::operator==(
Other);
96 using ConstMethodReturnValuesType =
98 llvm::SmallDenseMap<const FunctionDecl *, Value *>>;
99 ConstMethodReturnValuesType ConstMethodReturnValues;
103 using ConstMethodReturnStorageLocationsType = llvm::SmallDenseMap<
105 llvm::SmallDenseMap<const FunctionDecl *, StorageLocation *>>;
106 ConstMethodReturnStorageLocationsType ConstMethodReturnStorageLocations;
112llvm::SmallDenseMap<
const RecordStorageLocation *,
113 llvm::SmallDenseMap<const FunctionDecl *, T *>>
116 llvm::SmallDenseMap<const FunctionDecl *, T *>>
119 llvm::SmallDenseMap<const FunctionDecl *, T *>>
123 llvm::SmallDenseMap<const FunctionDecl *, T *>>
125 for (
auto &[
Loc, DeclToT] : Map1) {
126 auto It = Map2.find(
Loc);
127 if (It == Map2.end()) {
131 const auto &OtherDeclToT = It->second;
133 for (
auto [
Func, Var] : DeclToT) {
134 T *OtherVar = OtherDeclToT.lookup(
Func);
135 if (OtherVar ==
nullptr || OtherVar != Var) {
139 JoinedDeclToT.insert({
Func, Var});
147template <
typename Base>
157 ConstMethodReturnValues =
158 clang::dataflow::internal::joinConstMethodMap<dataflow::Value>(
159 ConstMethodReturnValues,
Other.ConstMethodReturnValues, Effect);
161 ConstMethodReturnStorageLocations =
162 clang::dataflow::internal::joinConstMethodMap<dataflow::StorageLocation>(
163 ConstMethodReturnStorageLocations,
164 Other.ConstMethodReturnStorageLocations, Effect);
169template <
typename Base>
174 assert(!
Type.isNull());
178 auto &ObjMap = ConstMethodReturnValues[&
RecordLoc];
180 if (DirectCallee ==
nullptr)
182 auto it = ObjMap.find(DirectCallee);
183 if (it != ObjMap.end())
188 ObjMap.insert({DirectCallee, Val});
192template <
typename Base>
199 auto &ObjMap = ConstMethodReturnStorageLocations[&
RecordLoc];
201 if (DirectCallee ==
nullptr)
203 auto it = ObjMap.find(DirectCallee);
204 if (it != ObjMap.end())
211 ObjMap.insert({DirectCallee, &
Loc});
llvm::MachO::RecordLoc RecordLoc
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.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
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)
bool operator==(const CachedConstAccessorsLattice &Other) const
StorageLocation * getOrCreateConstMethodReturnStorageLocation(const RecordStorageLocation &RecordLoc, const CallExpr *CE, Environment &Env, llvm::function_ref< void(StorageLocation &)> Initialize)
Creates or returns a previously created StorageLocation associated with a const method call obj....
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.