24#include "llvm/ADT/ArrayRef.h"
25#include "llvm/ADT/STLExtras.h"
26#include "llvm/Support/Casting.h"
27#include "llvm/Support/Signals.h"
28#include "llvm/Support/TimeProfiler.h"
31using llvm::isa_and_present;
33OriginList *FactsGenerator::getOriginsList(
const ValueDecl &D) {
34 return FactMgr.getOriginMgr().getOrCreateList(&D);
36OriginList *FactsGenerator::getOriginsList(
const Expr &E) {
37 return FactMgr.getOriginMgr().getOrCreateList(&E);
40bool FactsGenerator::hasOrigins(QualType QT)
const {
41 return FactMgr.getOriginMgr().hasOrigins(QT);
44bool FactsGenerator::hasOrigins(
const Expr *E)
const {
45 return FactMgr.getOriginMgr().hasOrigins(E);
65 "Dst is non-null but Src is null. List must have the same length");
66 assert(Dst->getLength() == Src->getLength() &&
67 "Lists must have the same length");
70 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
71 Dst->getOuterOriginID(), Src->getOuterOriginID(), Kill));
72 Dst = Dst->peelOuterOrigin();
73 Src = Src->peelOuterOrigin();
106 llvm::TimeTraceScope TimeProfile(
"FactGenerator");
107 const CFG &Cfg = *AC.getCFG();
112 CurrentBlockFacts.clear();
113 EscapesInCurrentBlock.clear();
114 CurrentBlock =
Block;
116 CurrentBlockFacts.append(PlaceholderLoanFacts.begin(),
117 PlaceholderLoanFacts.end());
118 for (
unsigned I = 0; I <
Block->size(); ++I) {
120 if (std::optional<CFGStmt> CS = Element.
getAs<
CFGStmt>())
121 Visit(CS->getStmt());
122 else if (std::optional<CFGInitializer>
Initializer =
124 handleCXXCtorInitializer(
Initializer->getInitializer());
125 else if (std::optional<CFGLifetimeEnds> LifetimeEnds =
127 handleLifetimeEnds(*LifetimeEnds);
128 else if (std::optional<CFGFullExprCleanup> FullExprCleanup =
130 handleFullExprCleanup(*FullExprCleanup);
136 CurrentBlockFacts.append(EscapesInCurrentBlock.begin(),
137 EscapesInCurrentBlock.end());
138 FactMgr.addBlockFacts(
Block, CurrentBlockFacts);
157 if (
const auto *VD = dyn_cast<VarDecl>(D))
158 if (
const Expr *InitExpr = VD->getInit()) {
162 OriginList *InitList = getOriginsList(*InitExpr);
163 assert(InitList &&
"VarDecl had origins but InitExpr did not");
164 flow(VDList, InitList,
true);
187 "gl-value DRE of non-pointer type should have an origin list");
190 CurrentBlockFacts.push_back(
197 handleGSLPointerConstruction(CCE);
208 flow(getOriginsList(*CCE), ArgList,
true);
218 flow(getOriginsList(*CCE), ArgList,
true);
223 {CCE->getArgs(), CCE->getNumArgs()},
229 killAndFlowOrigin(*DIE, *
Init);
236 killAndFlowOrigin(*FD, *CII->
getInit());
247 {MCE->getImplicitObjectArgument()},
258 handleFunctionCall(MCE,
Method, Args,
false);
265 assert(ME->
isGLValue() &&
"Field member should be GL value");
267 assert(Dst &&
"Field member should have an origin list as it is GL value");
269 assert(Src &&
"Base expression should be a pointer/reference type");
280 {CE->getArgs(), CE->getNumArgs()});
298 case CK_LValueToRValue:
302 assert(Src &&
"LValue being cast to RValue has no origin list");
310 case CK_NullToPointer:
315 case CK_ConstructorConversion:
316 case CK_UserDefinedConversion:
317 flow(Dest, Src,
true);
319 case CK_UncheckedDerivedToBase:
320 case CK_DerivedToBase:
324 flow(Dest, Src,
true);
326 case CK_ArrayToPointerDecay:
327 assert(Src &&
"Array expression should have origins as it is GL value");
331 case CK_FunctionToPointerDecay:
332 case CK_BuiltinFnToFnPtr:
339 flow(Dest, Src,
true);
354 killAndFlowOrigin(*UO, *SubExpr);
359 killAndFlowOrigin(*UO, *SubExpr);
369 if (
OriginList *List = getOriginsList(*RetExpr))
372 L->getOuterOriginID(), RetExpr));
376void FactsGenerator::handleAssignment(
const Expr *LHSExpr,
377 const Expr *RHSExpr) {
381 if (
const auto *DRE_LHS = dyn_cast<DeclRefExpr>(LHSExpr)) {
382 LHSList = getOriginsList(*DRE_LHS);
383 assert(LHSList &&
"LHS is a DRE and should have an origin list");
388 if (
const auto *ME_LHS = dyn_cast<MemberExpr>(LHSExpr)) {
389 LHSList = getOriginsList(*ME_LHS);
390 assert(LHSList &&
"LHS is a MemberExpr and should have an origin list");
394 OriginList *RHSList = getOriginsList(*RHSExpr);
402 if (
const auto *DRE_LHS = dyn_cast<DeclRefExpr>(LHSExpr)) {
403 QualType QT = DRE_LHS->getDecl()->getType();
410 if (UseFact *UF = UseFacts.lookup(DRE_LHS)) {
411 const OriginList *FullList = UF->getUsedOrigins();
414 FullList->getOuterOriginID()));
415 if (
const OriginList *InnerList = FullList->peelOuterOrigin()) {
416 UseFact *WriteUF = FactMgr.
createFact<UseFact>(DRE_LHS, InnerList);
417 WriteUF->markAsWritten();
418 CurrentBlockFacts.push_back(WriteUF);
423 markUseAsWrite(DRE_LHS);
430 CurrentBlockFacts.push_back(
431 FactMgr.createFact<KillOriginFact>(LHSInner->getOuterOriginID()));
439void FactsGenerator::handlePointerArithmetic(
const BinaryOperator *BO) {
440 if (Expr *RHS = BO->getRHS(); RHS->getType()->isPointerType()) {
441 killAndFlowOrigin(*BO, *RHS);
444 Expr *LHS = BO->getLHS();
445 assert(LHS->getType()->isPointerType() &&
446 "Pointer arithmetic must have a pointer operand");
447 killAndFlowOrigin(*BO, *LHS);
454 handlePointerArithmetic(BO);
468 const auto Preds = CurrentBlock->preds();
472 bool TBHasEdge =
true;
473 bool FBHasEdge =
true;
475 switch (CurrentBlock->pred_size()) {
479 TBHasEdge = llvm::any_of(**Preds.begin(),
482 if (auto CS = Elt.getAs<CFGStmt>())
483 return CS->getStmt() == ExpectedStmt;
486 FBHasEdge = !TBHasEdge;
490 const auto *It = Preds.begin();
491 TBHasEdge = It->isReachable();
492 FBHasEdge = (++It)->isReachable();
496 llvm_unreachable(
"expected at most 2 predecessors");
500 bool FirstFlow =
true;
501 auto HandleFlow = [&](
const Expr *E) {
503 killAndFlowOrigin(*CO, *E);
511 HandleFlow(TrueExpr);
513 HandleFlow(FalseExpr);
539 MD && MD->isDefaulted()) {
549 Args = Args.slice(1);
557 if (handleTestPoint(FCE))
563 if (!hasOrigins(ILE))
568 killAndFlowOrigin(*ILE, *ILE->
getInit(0));
583 assert((!SubExprList ||
585 "MTE top level origin should contain a loan to the MTE itself");
588 flow(RValMTEList, SubExprList,
true);
593 CurrentBlockFacts.push_back(
606 for (
const Expr *
Init : LE->capture_inits()) {
623 assert(ASE->
isGLValue() &&
"Array subscript should be a GL value");
625 assert(Dst &&
"Array subscript should have origins as it is a GL value");
627 assert(Src &&
"Base of array subscript should have origins");
634 const Expr *
Init = NE->getInitializer();
640 if (NE->getNumPlacementArgs() == 1) {
641 if (
const auto *Arg = NE->getOperatorNew()
648 const Expr *PlacementArg = NE->getPlacementArg(0);
649 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(PlacementArg);
650 ICE && ICE->getCastKind() == CK_BitCast &&
651 PlacementArg->getType()->isVoidPointerType())
652 PlacementArg = ICE->getSubExpr();
653 OriginList *PlacementList = getOriginsList(*PlacementArg);
666 CurrentBlockFacts.push_back(
672 if (!NewList || !
Init)
678 flow(NewList, InitList,
true);
683 CurrentBlockFacts.push_back(
687bool FactsGenerator::escapesViaReturn(
OriginID OID)
const {
688 return llvm::any_of(EscapesInCurrentBlock, [OID](
const Fact *F) {
690 return EF->getEscapedOriginID() == OID;
695void FactsGenerator::handleLifetimeEnds(
const CFGLifetimeEnds &LifetimeEnds) {
701 std::optional<OriginID> ExpiredOID;
702 if (OriginList *List = getOriginsList(*LifetimeEndsVD)) {
703 OriginID OID = List->getOuterOriginID();
706 if (!escapesViaReturn(OID))
709 CurrentBlockFacts.push_back(FactMgr.
createFact<ExpireFact>(
714void FactsGenerator::handleFullExprCleanup(
715 const CFGFullExprCleanup &FullExprCleanup) {
716 for (
const auto *MTE : FullExprCleanup.getExpiringMTEs())
717 CurrentBlockFacts.push_back(
718 FactMgr.createFact<ExpireFact>(AccessPath(MTE), MTE->getEndLoc()));
721void FactsGenerator::handleExitBlock() {
722 for (
const Origin &O : FactMgr.getOriginMgr().getOrigins())
723 if (
auto *FD = dyn_cast_if_present<FieldDecl>(O.getDecl()))
725 EscapesInCurrentBlock.push_back(
726 FactMgr.createFact<FieldEscapeFact>(O.ID, FD));
727 else if (
auto *VD = dyn_cast_if_present<VarDecl>(O.getDecl())) {
730 if (VD->hasGlobalStorage()) {
731 EscapesInCurrentBlock.push_back(
732 FactMgr.createFact<GlobalEscapeFact>(O.ID, VD));
737void FactsGenerator::handleGSLPointerConstruction(
const CXXConstructExpr *CCE) {
739 if (CCE->getNumArgs() != 1)
742 const Expr *Arg = CCE->getArg(0);
744 OriginList *ArgList = getOriginsList(*Arg);
745 assert(ArgList &&
"GSL pointer argument should have an origin list");
751 flow(getOriginsList(*CCE), ArgList,
true);
752 }
else if (Arg->getType()->isPointerType()) {
757 OriginList *ArgList = getOriginsList(*Arg);
758 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
759 getOriginsList(*CCE)->getOuterOriginID(), ArgList->getOuterOriginID(),
764 handleFunctionCall(CCE, CCE->getConstructor(),
765 {CCE->getArgs(), CCE->getNumArgs()},
770void FactsGenerator::handleMovedArgsInCall(
const FunctionDecl *FD,
771 ArrayRef<const Expr *> Args) {
772 unsigned IsInstance = 0;
773 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
780 const Expr *UniquePtrExpr = Args[0];
781 OriginList *MovedOrigins = getOriginsList(*UniquePtrExpr);
783 CurrentBlockFacts.push_back(FactMgr.createFact<MovedOriginFact>(
784 UniquePtrExpr, MovedOrigins->getOuterOriginID()));
789 for (
unsigned I = IsInstance;
790 I < Args.size() && I < FD->getNumParams() + IsInstance; ++I) {
791 const ParmVarDecl *PVD = FD->getParamDecl(I - IsInstance);
792 if (!PVD->getType()->isRValueReferenceType())
794 const Expr *Arg = Args[I];
795 OriginList *MovedOrigins = getOriginsList(*Arg);
796 assert(MovedOrigins->getLength() >= 1 &&
797 "unexpected length for r-value reference param");
799 CurrentBlockFacts.push_back(FactMgr.createFact<MovedOriginFact>(
800 Arg, MovedOrigins->getOuterOriginID()));
804void FactsGenerator::handleInvalidatingCall(
const Expr *
Call,
805 const FunctionDecl *FD,
806 ArrayRef<const Expr *> Args) {
807 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
808 if (!MD || !MD->isInstance())
814 auto *DRE = dyn_cast<DeclRefExpr>(Args[0]);
815 if (!DRE || DRE->getDecl()->getType()->isReferenceType())
818 OriginList *ThisList = getOriginsList(*Args[0]);
820 CurrentBlockFacts.push_back(FactMgr.createFact<InvalidateOriginFact>(
821 ThisList->getOuterOriginID(),
Call));
824void FactsGenerator::handleDestructiveCall(
const Expr *
Call,
825 const FunctionDecl *FD,
826 ArrayRef<const Expr *> Args) {
829 OriginList *ArgList = getOriginsList(*Args[0]);
831 CurrentBlockFacts.push_back(FactMgr.createFact<InvalidateOriginFact>(
832 ArgList->getOuterOriginID(),
Call));
835void FactsGenerator::handleImplicitObjectFieldUses(
const Expr *
Call,
836 const FunctionDecl *FD) {
837 const auto *MemberCall = dyn_cast_or_null<CXXMemberCallExpr>(
Call);
841 if (!isa_and_present<CXXThisExpr>(
842 MemberCall->getImplicitObjectArgument()->IgnoreImpCasts()))
845 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
846 assert(MD &&
"Function must be a CXXMethodDecl for member calls");
848 const auto *ClassDecl = MD->getParent()->getDefinition();
852 const auto UseFields = [&](
const CXXRecordDecl *RD) {
853 for (
const auto *Field : RD->fields())
854 if (
auto *FieldList = getOriginsList(*Field))
855 CurrentBlockFacts.push_back(
856 FactMgr.createFact<UseFact>(
Call, FieldList));
859 UseFields(ClassDecl);
861 ClassDecl->forallBases([&](
const CXXRecordDecl *Base) {
867void FactsGenerator::handleFunctionCall(
const Expr *
Call,
868 const FunctionDecl *FD,
869 ArrayRef<const Expr *> Args,
870 bool IsGslConstruction) {
871 OriginList *CallList = getOriginsList(*
Call);
877 for (
const Expr *Arg : Args)
879 handleInvalidatingCall(
Call, FD, Args);
880 handleDestructiveCall(
Call, FD, Args);
881 handleMovedArgsInCall(FD, Args);
882 handleImplicitObjectFieldUses(
Call, FD);
885 auto IsArgLifetimeBound = [FD](
unsigned I) ->
bool {
886 const ParmVarDecl *PVD =
nullptr;
887 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FD);
894 if ((I - 1) <
Method->getNumParams())
897 PVD =
Method->getParamDecl(I - 1);
902 }
else if (I < FD->getNumParams()) {
904 PVD = FD->getParamDecl(I);
906 return PVD ? PVD->hasAttr<clang::LifetimeBoundAttr>() :
false;
908 auto shouldTrackPointerImplicitObjectArg = [FD](
unsigned I) ->
bool {
909 const auto *
Method = dyn_cast<CXXMethodDecl>(FD);
920 for (
unsigned I = 0; I < Args.size(); ++I) {
921 OriginList *ArgList = getOriginsList(*Args[I]);
924 if (IsGslConstruction) {
928 assert(!Args[I]->isGLValue() || ArgList->getLength() >= 2);
935 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
936 CallList->getOuterOriginID(), ArgList->getOuterOriginID(),
939 }
else if (IsArgLifetimeBound(I)) {
946 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
947 CallList->getOuterOriginID(), ArgList->getOuterOriginID(),
951 }
else if (shouldTrackPointerImplicitObjectArg(I)) {
952 assert(ArgList->getLength() >= 2 &&
953 "Object arg of pointer type should have atleast two origins");
955 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
956 CallList->getOuterOriginID(),
957 ArgList->peelOuterOrigin()->getOuterOriginID(), KillSrc));
959 }
else if (IsArgLifetimeBound(I)) {
963 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
964 CallList->getOuterOriginID(), ArgList->getOuterOriginID(), KillSrc));
972bool FactsGenerator::handleTestPoint(
const CXXFunctionalCastExpr *FCE) {
973 if (!FCE->getType()->isVoidType())
976 const auto *SubExpr = FCE->getSubExpr()->IgnoreParenImpCasts();
977 if (
const auto *SL = dyn_cast<StringLiteral>(SubExpr)) {
978 llvm::StringRef LiteralValue = SL->getString();
979 const std::string Prefix =
"__lifetime_test_point_";
981 if (LiteralValue.starts_with(Prefix)) {
982 StringRef Annotation = LiteralValue.drop_front(Prefix.length());
983 CurrentBlockFacts.push_back(
984 FactMgr.createFact<TestPointFact>(Annotation));
991void FactsGenerator::handleUse(
const Expr *E) {
992 OriginList *List = getOriginsList(*E);
998 if (
auto *DRE = dyn_cast<DeclRefExpr>(E);
999 DRE && !DRE->getDecl()->
getType()->isReferenceType())
1004 if (!UseFacts.contains(E)) {
1005 UseFact *UF = FactMgr.createFact<UseFact>(E, List);
1006 CurrentBlockFacts.push_back(UF);
1011void FactsGenerator::markUseAsWrite(
const DeclRefExpr *DRE) {
1012 if (UseFacts.contains(DRE))
1013 UseFacts[DRE]->markAsWritten();
1018llvm::SmallVector<Fact *> FactsGenerator::issuePlaceholderLoans() {
1019 const auto *FD = dyn_cast<FunctionDecl>(AC.getDecl());
1023 llvm::SmallVector<Fact *> PlaceholderLoanFacts;
1024 if (
auto ThisOrigins = FactMgr.getOriginMgr().getThisOrigins()) {
1025 OriginList *List = *ThisOrigins;
1026 const Loan *L = FactMgr.getLoanMgr().createLoan(
1029 PlaceholderLoanFacts.push_back(
1030 FactMgr.createFact<IssueFact>(L->getID(), List->getOuterOriginID()));
1032 for (
const ParmVarDecl *PVD : FD->parameters()) {
1033 OriginList *List = getOriginsList(*PVD);
1036 const Loan *L = FactMgr.getLoanMgr().createLoan(
1038 PlaceholderLoanFacts.push_back(
1039 FactMgr.createFact<IssueFact>(L->getID(), List->getOuterOriginID()));
1041 return PlaceholderLoanFacts;
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines an enumeration for C++ overloaded operators.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
A builtin binary operation expression such as "x + y" or "x <= y".
static bool isAdditiveOp(Opcode Opc)
static bool isAssignmentOp(Opcode Opc)
static bool isCompoundAssignmentOp(Opcode Opc)
Represents a single basic block in a source-level CFG.
Represents a top-level expression in a basic block.
std::optional< T > getAs() const
Convert to the specified CFGElement type, returning std::nullopt if this CFGElement is not of the des...
Represents C++ base or member initializer from constructor's initialization list.
Represents the point where the lifetime of an automatic object ends.
const Stmt * getTriggerStmt() const
const VarDecl * getVarDecl() const
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt.
Represents binding an expression to a temporary.
const Expr * getSubExpr() const
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
Represents a C++ base or member initializer.
Expr * getInit() const
Get the initializer.
FieldDecl * getAnyMember() const
A use of a default initializer in a constructor or in aggregate initialization.
Expr * getExpr()
Get the initialization expression that will be used.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Represents a call to a member function that may be written either with member call syntax (e....
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Expr * getImplicitObjectArgument() const
Retrieve the implicit object argument for the member call.
Represents a static or instance method of a struct/union/class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
The null pointer literal (C++11 [lex.nullptr])
A call to an overloaded operator written using operator syntax.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Expr ** getArgs()
Retrieve the call arguments.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
ConditionalOperator - The ?
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
This represents one expression.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Represents a member of a struct/union/class.
bool isDefaulted() const
Whether this function is defaulted.
Describes an C or C++ initializer list.
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
RetTy Visit(PTR(Stmt) S, ParamTys... P)
SourceLocation getEndLoc() const LLVM_READONLY
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isVoidPointerType() const
bool isPointerType() const
bool isReferenceType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isPointerOrReferenceType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Represents the storage location being borrowed, e.g., a specific stack variable or a field within it:...
static AccessPath Placeholder(const ParmVarDecl *PVD)
FactType * createFact(Args &&...args)
OriginManager & getOriginMgr()
LoanManager & getLoanMgr()
An abstract base class for a single, atomic lifetime-relevant event.
void VisitDeclRefExpr(const DeclRefExpr *DRE)
void VisitBinaryOperator(const BinaryOperator *BO)
void VisitCallExpr(const CallExpr *CE)
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *MTE)
void VisitCastExpr(const CastExpr *CE)
void VisitReturnStmt(const ReturnStmt *RS)
void VisitCXXConstructExpr(const CXXConstructExpr *CCE)
void VisitMemberExpr(const MemberExpr *ME)
void VisitCXXDeleteExpr(const CXXDeleteExpr *DE)
void VisitCXXNewExpr(const CXXNewExpr *NE)
void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *FCE)
void VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *DIE)
void VisitInitListExpr(const InitListExpr *ILE)
void VisitLambdaExpr(const LambdaExpr *LE)
void VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *N)
void VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *OCE)
void VisitArraySubscriptExpr(const ArraySubscriptExpr *ASE)
void VisitUnaryOperator(const UnaryOperator *UO)
void VisitDeclStmt(const DeclStmt *DS)
void VisitConditionalOperator(const ConditionalOperator *CO)
void VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE)
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE)
Represents that an origin's storage has been invalidated by a container operation (e....
Loan * createLoan(AccessPath Path, const Expr *IssueExpr)
Represents lending a storage location.
A list of origins representing levels of indirection for pointer-like types.
OriginID getOuterOriginID() const
OriginList * peelOuterOrigin() const
OriginList * createSingleOriginList(OriginID OID)
Wraps an existing OriginID in a new single-element OriginList, so a fact can refer to a single level ...
Represents that an origin escapes via a return statement.
utils::ID< struct OriginTag > OriginID
static OriginList * getRValueOrigins(const Expr *E, OriginList *List)
Simulates LValueToRValue conversion by peeling the outer lvalue origin if the expression is a GLValue...
bool doesDeclHaveStorage(const ValueDecl *D)
Returns true if the declaration has its own storage that can be borrowed.
static const Loan * createLoan(FactManager &FactMgr, const DeclRefExpr *DRE)
Creates a loan for the storage path of a given declaration reference.
bool isGslPointerType(QualType QT)
bool isStdCallableWrapperType(const CXXRecordDecl *RD)
bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee, bool RunningUnderLifetimeSafety)
bool shouldTrackFirstArgument(const FunctionDecl *FD)
bool isUniquePtrRelease(const CXXMethodDecl &MD)
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
const FunctionDecl * getDeclWithMergedLifetimeBoundAttrs(const FunctionDecl *FD)
bool isInvalidationMethod(const CXXMethodDecl &MD)
bool destructsFirstArg(const FunctionDecl &FD)
bool isGslOwnerType(QualType QT)
bool shouldTrackSecondArgument(const FunctionDecl *FD)
bool isa(CodeGen::Address addr)
@ SD_FullExpression
Full-expression storage duration (for temporaries).
U cast(CodeGen::Address addr)
llvm::Expected< Stmt * > ExpectedStmt