59 return new (ListAllocator.Allocate<OriginList>()) OriginList(NewID);
62OriginList *OriginManager::createNode(
const Expr *E,
QualType QT) {
65 return new (ListAllocator.Allocate<OriginList>()) OriginList(NewID);
69OriginList *OriginManager::buildListForType(QualType QT,
const T *Node) {
70 assert(
hasOrigins(QT) &&
"buildListForType called for non-pointer type");
71 OriginList *Head = createNode(Node, QT);
73 if (QT->isPointerOrReferenceType()) {
74 QualType PointeeTy = QT->getPointeeType();
78 Head->setInnerOriginList(buildListForType(PointeeTy, Node));
86 auto It = DeclToList.find(D);
87 if (It != DeclToList.end())
89 return DeclToList[D] = buildListForType(D->
getType(), D);
93 if (
auto *ParenIgnored = E->
IgnoreParens(); ParenIgnored != E)
99 auto It = ExprToList.find(E);
100 if (It != ExprToList.end())
106 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
125 return ExprToList[E] = Head;
132 Type = AST.getLValueReferenceType(
Type);
133 return ExprToList[E] = buildListForType(
Type, E);
140 OS <<
"Decl: " << VD->getNameAsString();
143 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
144 if (
const ValueDecl *VD = DRE->getDecl())
145 OS <<
", Decl: " << VD->getNameAsString();
156 assert(ID.Value < AllOrigins.size());
157 return AllOrigins[ID.Value];
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
C Language Family Type Representation.
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
A (possibly-)qualified type.
const Type * getTypePtrOrNull() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const char * getStmtClassName() const
The base class of the type hierarchy.
bool isReferenceType() const
bool isPointerOrReferenceType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
A list of origins representing levels of indirection for pointer-like types.
void setInnerOriginList(OriginList *Inner)
OriginList * getOrCreateList(const ValueDecl *D)
Gets or creates the OriginList for a given ValueDecl.
const Origin & getOrigin(OriginID ID) const
void dump(OriginID OID, llvm::raw_ostream &OS) const
utils::ID< struct OriginTag > OriginID
bool doesDeclHaveStorage(const ValueDecl *D)
Returns true if the declaration has its own storage that can be borrowed.
bool hasOrigins(QualType QT)
bool isGslPointerType(QualType QT)
An Origin is a symbolic identifier that represents the set of possible loans a pointer-like object co...
const clang::Expr * getExpr() const
const clang::ValueDecl * getDecl() const
const Type * Ty
The type at this indirection level.