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"
98 ConstMethodReturnValues.erase(&
RecordLoc);
103 ConstMethodReturnStorageLocations.erase(&
RecordLoc);
107 return Base::operator==(
Other);
115 using ConstMethodReturnValuesType =
117 llvm::SmallDenseMap<const FunctionDecl *, Value *>>;
118 ConstMethodReturnValuesType ConstMethodReturnValues;
122 using ConstMethodReturnStorageLocationsType = llvm::SmallDenseMap<
124 llvm::SmallDenseMap<const FunctionDecl *, StorageLocation *>>;
125 ConstMethodReturnStorageLocationsType ConstMethodReturnStorageLocations;
131llvm::SmallDenseMap<
const RecordStorageLocation *,
132 llvm::SmallDenseMap<const FunctionDecl *, T *>>
135 llvm::SmallDenseMap<const FunctionDecl *, T *>>
138 llvm::SmallDenseMap<const FunctionDecl *, T *>>
142 llvm::SmallDenseMap<const FunctionDecl *, T *>>
144 for (
auto &[
Loc, DeclToT] : Map1) {
145 auto It = Map2.find(
Loc);
146 if (It == Map2.end()) {
150 const auto &OtherDeclToT = It->second;
152 for (
auto [
Func, Var] : DeclToT) {
153 T *OtherVar = OtherDeclToT.lookup(
Func);
154 if (OtherVar ==
nullptr || OtherVar != Var) {
158 JoinedDeclToT.insert({
Func, Var});
166template <
typename Base>
176 ConstMethodReturnValues =
177 clang::dataflow::internal::joinConstMethodMap<dataflow::Value>(
178 ConstMethodReturnValues,
Other.ConstMethodReturnValues, Effect);
180 ConstMethodReturnStorageLocations =
181 clang::dataflow::internal::joinConstMethodMap<dataflow::StorageLocation>(
182 ConstMethodReturnStorageLocations,
183 Other.ConstMethodReturnStorageLocations, Effect);
188template <
typename Base>
193 assert(!
Type.isNull());
197 auto &ObjMap = ConstMethodReturnValues[&
RecordLoc];
199 if (DirectCallee ==
nullptr)
201 auto it = ObjMap.find(DirectCallee);
202 if (it != ObjMap.end())
207 ObjMap.insert({DirectCallee, Val});
211template <
typename Base>
218 auto &ObjMap = ConstMethodReturnStorageLocations[&
RecordLoc];
220 if (DirectCallee ==
nullptr)
222 auto it = ObjMap.find(DirectCallee);
223 if (it != ObjMap.end())
230 ObjMap.insert({DirectCallee, &
Loc});
234template <
typename Base>
239 assert(Callee !=
nullptr);
241 assert(!
Type.isNull());
243 auto &ObjMap = ConstMethodReturnStorageLocations[&
RecordLoc];
244 auto it = ObjMap.find(Callee);
245 if (it != ObjMap.end())
251 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.
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.