24#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SMARTPOINTERACCESSORCACHING_H
25#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_SMARTPOINTERACCESSORCACHING_H
36#include "llvm/ADT/STLFunctionalExtras.h"
90template <
typename LatticeT>
102template <
typename LatticeT>
108template <
typename LatticeT>
113 if (State.Env.getStorageLocation(*DerefExpr) !=
nullptr)
115 if (SmartPointerLoc ==
nullptr)
119 if (Callee ==
nullptr)
124 assert(CanonicalCallee !=
nullptr);
125 if (CanonicalCallee != Callee) {
129 Callee->getReturnType()->isReferenceType());
133 Callee->getReturnType()
134 .getNonReferenceType()
135 ->getCanonicalTypeUnqualified());
139 State.Lattice.getOrCreateConstMethodReturnStorageLocation(
140 *SmartPointerLoc, CanonicalCallee, State.Env, InitializeLoc);
141 State.Env.setStorageLocation(*DerefExpr, LocForValue);
144template <
typename LatticeT>
149 if (SmartPointerLoc ==
nullptr)
155 if (CanonicalCallee !=
nullptr) {
157 State.Lattice.getOrCreateConstMethodReturnStorageLocation(
158 *SmartPointerLoc, CanonicalCallee, State.Env, InitializeLoc);
159 State.Env.setValue(*GetExpr,
160 State.Env.template create<PointerValue>(LocForValue));
163 Value *Val = State.Lattice.getOrCreateConstMethodReturnValue(
164 *SmartPointerLoc, GetExpr, State.Env);
167 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.
ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall(clang::StringRef MethodName="value")
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.
ast_matchers::StatementMatcher isPointerLikeOperatorStar()
Matchers: For now, these match on any class with an operator* or operator-> where the return types ha...
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 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()
ast_matchers::StatementMatcher isSmartPointerLikeGetMethodCall(clang::StringRef MethodName="get")
ast_matchers::StatementMatcher isPointerLikeOperatorArrow()
A common form of state shared between the cases of a transfer function.