24#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SMARTPOINTERACCESSORCACHING_H
25#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SMARTPOINTERACCESSORCACHING_H
36#include "llvm/ADT/STLFunctionalExtras.h"
86template <
typename LatticeT>
88 const CallExpr *DerefExpr, RecordStorageLocation *SmartPointerLoc,
89 TransferState<LatticeT> &State,
90 llvm::function_ref<
void(StorageLocation &)> InitializeLoc);
98template <
typename LatticeT>
100 const CallExpr *GetExpr, RecordStorageLocation *SmartPointerLoc,
101 TransferState<LatticeT> &State,
102 llvm::function_ref<
void(StorageLocation &)> InitializeLoc);
104template <
typename LatticeT>
109 if (State.Env.getStorageLocation(*DerefExpr) !=
nullptr)
111 if (SmartPointerLoc ==
nullptr)
115 if (Callee ==
nullptr)
120 assert(CanonicalCallee !=
nullptr);
121 if (CanonicalCallee != Callee) {
125 Callee->getReturnType()->isReferenceType());
129 Callee->getReturnType()
130 .getNonReferenceType()
131 ->getCanonicalTypeUnqualified());
135 State.Lattice.getOrCreateConstMethodReturnStorageLocation(
136 *SmartPointerLoc, CanonicalCallee, State.Env, InitializeLoc);
137 State.Env.setStorageLocation(*DerefExpr, LocForValue);
140template <
typename LatticeT>
145 if (SmartPointerLoc ==
nullptr)
151 if (CanonicalCallee !=
nullptr) {
153 State.Lattice.getOrCreateConstMethodReturnStorageLocation(
154 *SmartPointerLoc, CanonicalCallee, State.Env, InitializeLoc);
155 State.Env.setValue(*GetExpr,
156 State.Env.template create<PointerValue>(LocForValue));
159 Value *Val = State.Lattice.getOrCreateConstMethodReturnValue(
160 *SmartPointerLoc, GetExpr, State.Env);
163 State.Env.setValue(*GetExpr, *Val);
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.
QualType getReturnType() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
CanQualType getCanonicalTypeUnqualified() const
bool isReferenceType() const
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.
internal::Matcher< Stmt > StatementMatcher
Dataflow Directional Tag Classes.
void transferSmartPointerLikeCachedDeref(const CallExpr *DerefExpr, RecordStorageLocation *SmartPointerLoc, TransferState< LatticeT > &State, llvm::function_ref< void(StorageLocation &)> InitializeLoc)
A transfer function for operator* (and value) calls that can be cached.
void transferSmartPointerLikeCachedGet(const CallExpr *GetExpr, RecordStorageLocation *SmartPointerLoc, TransferState< LatticeT > &State, llvm::function_ref< void(StorageLocation &)> InitializeLoc)
A transfer function for operator-> (and get) calls that can be cached.
ast_matchers::StatementMatcher isSmartPointerLikeGetMethodCall()
ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall()
ast_matchers::StatementMatcher isSmartPointerLikeOperatorArrow()
const FunctionDecl * getCanonicalSmartPointerLikeOperatorCallee(const CallExpr *CE)
Returns the "canonical" callee for smart pointer operators (* and ->) as a key for caching.
ast_matchers::StatementMatcher isSmartPointerLikeOperatorStar()
Matchers: For now, these match on any class with an operator* or operator-> where the return types ha...
A common form of state shared between the cases of a transfer function.