clang 20.0.0git
|
A mixin for a lattice that additionally maintains a cache of stable method call return values to model const accessors methods. More...
#include "clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h"
Public Member Functions | |
Value * | getOrCreateConstMethodReturnValue (const RecordStorageLocation &RecordLoc, const CallExpr *CE, Environment &Env) |
Creates or returns a previously created Value associated with a const method call obj.getFoo() where RecordLoc is the RecordStorageLocation of obj . | |
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.getFoo() where RecordLoc is the RecordStorageLocation of obj . | |
void | clearConstMethodReturnValues (const RecordStorageLocation &RecordLoc) |
void | clearConstMethodReturnStorageLocations (const RecordStorageLocation &RecordLoc) |
bool | operator== (const CachedConstAccessorsLattice &Other) const |
LatticeJoinEffect | join (const CachedConstAccessorsLattice &Other) |
A mixin for a lattice that additionally maintains a cache of stable method call return values to model const accessors methods.
When a non-const method is called, the cache should be cleared causing the next call to a const method to be considered a different value. NOTE: The user is responsible for clearing the cache.
For example:
class Bar { public: const std::optional<Foo>& getFoo() const; void clear(); }; void func(Bar& s) { if (s.getFoo().has_value()) { use(s.getFoo().value()); // safe (checked earlier getFoo()) s.clear(); use(s.getFoo().value()); // unsafe (invalidate cache for s) } }
Definition at line 48 of file CachedConstAccessorsLattice.h.
|
inline |
Definition at line 82 of file CachedConstAccessorsLattice.h.
|
inline |
Definition at line 78 of file CachedConstAccessorsLattice.h.
StorageLocation * clang::dataflow::CachedConstAccessorsLattice< Base >::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.getFoo()
where RecordLoc
is the RecordStorageLocation
of obj
.
The callback Initialize
runs on the storage location if newly created. Returns nullptr if unable to find or create a value.
Requirements:
CE
should return a location (GLValue or a record type). Definition at line 194 of file CachedConstAccessorsLattice.h.
References clang::dataflow::Environment::createStorageLocation(), Env, clang::CallExpr::getDirectCallee(), clang::QualType::getNonReferenceType(), clang::Expr::getType(), clang::Expr::isGLValue(), clang::QualType::isNull(), clang::Type::isRecordType(), and Loc.
Value * clang::dataflow::CachedConstAccessorsLattice< Base >::getOrCreateConstMethodReturnValue | ( | const RecordStorageLocation & | RecordLoc, |
const CallExpr * | CE, | ||
Environment & | Env | ||
) |
Creates or returns a previously created Value
associated with a const method call obj.getFoo()
where RecordLoc
is the RecordStorageLocation
of obj
.
Returns nullptr if unable to find or create a value.
Requirements:
CE
should return a value (not a reference or record type) Definition at line 170 of file CachedConstAccessorsLattice.h.
References clang::dataflow::Environment::createValue(), Env, clang::CallExpr::getDirectCallee(), clang::Expr::getType(), clang::Type::isRecordType(), and clang::Type::isReferenceType().
LatticeEffect clang::dataflow::CachedConstAccessorsLattice< Base >::join | ( | const CachedConstAccessorsLattice< Base > & | Other | ) |
Definition at line 148 of file CachedConstAccessorsLattice.h.
References clang::Other.
|
inline |
Definition at line 87 of file CachedConstAccessorsLattice.h.
References clang::Other.