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);
70 const CFGBlock *
Block) {
74 "Dst is non-null but Src is null. List must have the same length");
75 assert(Dst->getLength() == Src->getLength() &&
76 "Lists must have the same length");
79 Fact *F = FactMgr.createFact<OriginFlowFact>(Dst->getOuterOriginID(),
80 Src->getOuterOriginID(), Kill);
82 FactMgr.appendBlockFact(
Block, F);
84 CurrentBlockFacts.push_back(F);
85 Dst = Dst->peelOuterOrigin();
86 Src = Src->peelOuterOrigin();
119 llvm::TimeTraceScope TimeProfile(
"FactGenerator");
120 const CFG &Cfg = *AC.getCFG();
125 CurrentBlockFacts.clear();
126 EscapesInCurrentBlock.clear();
127 CurrentBlock =
Block;
129 CurrentBlockFacts.append(PlaceholderLoanFacts.begin(),
130 PlaceholderLoanFacts.end());
131 for (
unsigned I = 0; I <
Block->size(); ++I) {
133 if (std::optional<CFGStmt> CS = Element.
getAs<
CFGStmt>())
134 Visit(CS->getStmt());
135 else if (std::optional<CFGInitializer>
Initializer =
137 handleCXXCtorInitializer(
Initializer->getInitializer());
138 else if (std::optional<CFGLifetimeEnds> LifetimeEnds =
140 handleLifetimeEnds(*LifetimeEnds);
141 else if (std::optional<CFGFullExprCleanup> FullExprCleanup =
143 handleFullExprCleanup(*FullExprCleanup);
149 CurrentBlockFacts.append(EscapesInCurrentBlock.begin(),
150 EscapesInCurrentBlock.end());
151 FactMgr.addBlockFacts(
Block, CurrentBlockFacts);
170 if (
const auto *VD = dyn_cast<VarDecl>(D))
171 if (
const Expr *InitExpr = VD->getInit()) {
175 OriginList *InitList = getOriginsList(*InitExpr);
176 assert(InitList &&
"VarDecl had origins but InitExpr did not");
177 flow(VDList, InitList,
true);
200 "gl-value DRE of non-pointer type should have an origin list");
203 CurrentBlockFacts.push_back(
210 handleGSLPointerConstruction(CCE);
221 flow(getOriginsList(*CCE), ArgList,
true);
231 flow(getOriginsList(*CCE), ArgList,
true);
236 {CCE->getArgs(), CCE->getNumArgs()},
242 killAndFlowOrigin(*DIE, *
Init);
249 killAndFlowOrigin(*FD, *CII->
getInit());
260 {MCE->getImplicitObjectArgument()},
271 handleFunctionCall(MCE,
Method, Args,
false);
278 assert(ME->
isGLValue() &&
"Field member should be GL value");
280 assert(Dst &&
"Field member should have an origin list as it is GL value");
282 assert(Src &&
"Base expression should be a pointer/reference type");
293 {CE->getArgs(), CE->getNumArgs()});
311 case CK_LValueToRValue:
315 assert(Src &&
"LValue being cast to RValue has no origin list");
323 case CK_NullToPointer:
328 case CK_ConstructorConversion:
329 case CK_UserDefinedConversion:
330 flow(Dest, Src,
true);
332 case CK_UncheckedDerivedToBase:
333 case CK_DerivedToBase:
337 flow(Dest, Src,
true);
339 case CK_ArrayToPointerDecay:
344 assert(Src &&
"Array expression should have origins as it is GL value");
348 case CK_FunctionToPointerDecay:
349 case CK_BuiltinFnToFnPtr:
356 flow(Dest, Src,
true);
358 case CK_LValueToRValueBitCast:
359 case CK_NonAtomicToAtomic:
360 case CK_AtomicToNonAtomic: {
369 flow(Dest, RVSrc,
true);
389 "Taking address of void is not valid in C++");
394 killAndFlowOrigin(*UO, *SubExpr);
399 killAndFlowOrigin(*UO, *SubExpr);
409 flow(getOriginsList(*UO),
424 flow(getOriginsList(*UO),
435 if (
OriginList *List = getOriginsList(*RetExpr))
438 L->getOuterOriginID(), RetExpr));
442void FactsGenerator::handleAssignment(
const Expr *TargetExpr,
444 const Expr *RHSExpr) {
448 if (
const auto *DRE_LHS = dyn_cast<DeclRefExpr>(LHSExpr)) {
449 LHSList = getOriginsList(*DRE_LHS);
450 assert(LHSList &&
"LHS is a DRE and should have an origin list");
455 if (
const auto *ME_LHS = dyn_cast<MemberExpr>(LHSExpr)) {
456 LHSList = getOriginsList(*ME_LHS);
457 assert(LHSList &&
"LHS is a MemberExpr and should have an origin list");
461 OriginList *RHSList = getOriginsList(*RHSExpr);
469 if (
const auto *DRE_LHS = dyn_cast<DeclRefExpr>(LHSExpr)) {
470 QualType QT = DRE_LHS->getDecl()->getType();
477 if (UseFact *UF = UseFacts.lookup(DRE_LHS)) {
478 const OriginList *FullList = UF->getUsedOrigins();
481 FullList->getOuterOriginID()));
482 if (
const OriginList *InnerList = FullList->peelOuterOrigin()) {
483 UseFact *WriteUF = FactMgr.
createFact<UseFact>(DRE_LHS, InnerList);
484 WriteUF->markAsWritten();
485 CurrentBlockFacts.push_back(WriteUF);
490 markUseAsWrite(DRE_LHS);
497 CurrentBlockFacts.push_back(
498 FactMgr.createFact<KillOriginFact>(LHSInner->getOuterOriginID()));
509 flow(getOriginsList(*TargetExpr), LHSList,
true);
512void FactsGenerator::handlePointerArithmetic(
const BinaryOperator *BO) {
513 if (Expr *RHS = BO->getRHS(); RHS->getType()->isPointerType()) {
514 killAndFlowOrigin(*BO, *RHS);
517 Expr *LHS = BO->getLHS();
518 assert(LHS->getType()->isPointerType() &&
519 "Pointer arithmetic must have a pointer operand");
520 killAndFlowOrigin(*BO, *LHS);
537 ? getOriginsList(*BO->
getLHS())
546 killAndFlowOrigin(*BO, *BO->
getRHS());
555 flow(getOriginsList(*BO), IsCMode ? LHSList->
peelOuterOrigin() : LHSList,
561 handlePointerArithmetic(BO);
569 const Expr *ArmExpr) {
573 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(
Target))
574 if (
const Expr *Src = OVE->getSourceExpr())
575 Target = Src->IgnoreParenImpCasts();
581 if (
auto CS = Elt.getAs<
CFGStmt>())
582 if (
const auto *E = dyn_cast<Expr>(CS->getStmt()))
583 if (E->IgnoreParenImpCasts() ==
Target)
605 flow(getOriginsList(*CO), getOriginsList(*TrueExpr),
true, TBPred);
607 flow(getOriginsList(*CO), getOriginsList(*FalseExpr),
true,
634 MD && MD->isDefaulted()) {
644 Args = Args.slice(1);
652 if (handleTestPoint(FCE))
658 if (!hasOrigins(ILE))
665 if (!hasOrigins(ILE->
getInit(0)))
667 killAndFlowOrigin(*ILE, *ILE->
getInit(0));
683 assert((!SubExprList ||
685 "MTE top level origin should contain a loan to the MTE itself");
688 flow(RValMTEList, SubExprList,
true);
693 CurrentBlockFacts.push_back(
706 for (
const Expr *
Init : LE->capture_inits()) {
727 assert(ASE->
isGLValue() &&
"Array subscript should be a GL value");
729 assert(Dst &&
"Array subscript should have origins as it is a GL value");
731 assert(Src &&
"Base of array subscript should have origins");
736bool FactsGenerator::handlePlacementNew(
const CXXNewExpr *NE,
742 if (NE->getNumPlacementArgs() != 1)
746 if (OperatorNew->getNumParams() <= 1)
750 OperatorNew->getParamDecl(1)->getType()->getAs<
PointerType>();
751 if (!Arg || !Arg->isVoidPointerType())
756 const Expr *PlacementArg = NE->getPlacementArg(0);
757 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(PlacementArg);
758 ICE && ICE->getCastKind() == CK_BitCast &&
759 PlacementArg->getType()->isVoidPointerType())
760 PlacementArg = ICE->getSubExpr();
761 OriginList *PlacementList = getOriginsList(*PlacementArg);
775 const Expr *
Init = NE->getInitializer();
777 bool HandledAsPlacementNew =
false;
778 if (NE->getNumPlacementArgs() == 1)
779 HandledAsPlacementNew = handlePlacementNew(NE, NewList);
784 if (!HandledAsPlacementNew &&
785 (NE->getNumPlacementArgs() == 0 ||
786 (OperatorNew && OperatorNew->isReplaceableGlobalAllocationFunction()))) {
788 CurrentBlockFacts.push_back(
794 if (!NewList || !
Init)
800 flow(NewList, InitList,
true);
805 CurrentBlockFacts.push_back(
814 if (!CS || CS->body_empty())
816 const auto *
Last = dyn_cast<Expr>(CS->body_back());
821 flow(Dst, Src,
true);
824bool FactsGenerator::escapesViaReturn(
OriginID OID)
const {
825 return llvm::any_of(EscapesInCurrentBlock, [OID](
const Fact *F) {
827 return EF->getEscapedOriginID() == OID;
832void FactsGenerator::handleLifetimeEnds(
const CFGLifetimeEnds &LifetimeEnds) {
838 std::optional<OriginID> ExpiredOID;
839 if (OriginList *List = getOriginsList(*LifetimeEndsVD)) {
840 OriginID OID = List->getOuterOriginID();
843 if (!escapesViaReturn(OID))
846 CurrentBlockFacts.push_back(FactMgr.
createFact<ExpireFact>(
851void FactsGenerator::handleFullExprCleanup(
852 const CFGFullExprCleanup &FullExprCleanup) {
853 for (
const auto *MTE : FullExprCleanup.getExpiringMTEs())
854 CurrentBlockFacts.push_back(FactMgr.createFact<ExpireFact>(
855 AccessPath(MTE), FullExprCleanup.getCleanupLoc()));
858void FactsGenerator::handleExitBlock() {
859 for (
const Origin &O : FactMgr.getOriginMgr().getOrigins())
860 if (
auto *FD = dyn_cast_if_present<FieldDecl>(O.getDecl()))
862 EscapesInCurrentBlock.push_back(
863 FactMgr.createFact<FieldEscapeFact>(O.ID, FD));
864 else if (
auto *VD = dyn_cast_if_present<VarDecl>(O.getDecl())) {
867 if (VD->hasGlobalStorage()) {
868 EscapesInCurrentBlock.push_back(
869 FactMgr.createFact<GlobalEscapeFact>(O.ID, VD));
874void FactsGenerator::handleGSLPointerConstruction(
const CXXConstructExpr *CCE) {
876 if (CCE->getNumArgs() != 1)
879 const Expr *Arg = CCE->getArg(0);
881 OriginList *ArgList = getOriginsList(*Arg);
882 assert(ArgList &&
"GSL pointer argument should have an origin list");
888 flow(getOriginsList(*CCE), ArgList,
true);
889 }
else if (Arg->getType()->isPointerType()) {
894 OriginList *ArgList = getOriginsList(*Arg);
895 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
896 getOriginsList(*CCE)->getOuterOriginID(), ArgList->getOuterOriginID(),
901 handleFunctionCall(CCE, CCE->getConstructor(),
902 {CCE->getArgs(), CCE->getNumArgs()},
907void FactsGenerator::handleMovedArgsInCall(
const FunctionDecl *FD,
908 ArrayRef<const Expr *> Args) {
909 unsigned IsInstance = 0;
910 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
917 const Expr *UniquePtrExpr = Args[0];
918 OriginList *MovedOrigins = getOriginsList(*UniquePtrExpr);
920 CurrentBlockFacts.push_back(FactMgr.createFact<MovedOriginFact>(
921 UniquePtrExpr, MovedOrigins->getOuterOriginID()));
926 for (
unsigned I = IsInstance;
927 I < Args.size() && I < FD->getNumParams() + IsInstance; ++I) {
928 const ParmVarDecl *PVD = FD->getParamDecl(I - IsInstance);
929 if (!PVD->getType()->isRValueReferenceType())
934 if (PVD->hasAttr<LifetimeBoundAttr>() ||
935 PVD->hasAttr<LifetimeCaptureByAttr>())
937 const Expr *Arg = Args[I];
938 OriginList *MovedOrigins = getOriginsList(*Arg);
939 assert(MovedOrigins->getLength() >= 1 &&
940 "unexpected length for r-value reference param");
942 CurrentBlockFacts.push_back(FactMgr.createFact<MovedOriginFact>(
943 Arg, MovedOrigins->getOuterOriginID()));
947void FactsGenerator::handleInvalidatingCall(
const Expr *
Call,
948 const FunctionDecl *FD,
949 ArrayRef<const Expr *> Args) {
950 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
951 if (!MD || !MD->isInstance())
963 OriginList *ThisList = getOriginsList(*Args[0]);
965 CurrentBlockFacts.push_back(FactMgr.createFact<InvalidateOriginFact>(
966 ThisList->getOuterOriginID(),
Call));
969void FactsGenerator::handleDestructiveCall(
const Expr *
Call,
970 const FunctionDecl *FD,
971 ArrayRef<const Expr *> Args) {
974 OriginList *ArgList = getOriginsList(*Args[0]);
976 CurrentBlockFacts.push_back(FactMgr.createFact<InvalidateOriginFact>(
977 ArgList->getOuterOriginID(),
Call));
980void FactsGenerator::handleImplicitObjectFieldUses(
const Expr *
Call,
981 const FunctionDecl *FD) {
982 const auto *MemberCall = dyn_cast_or_null<CXXMemberCallExpr>(
Call);
986 if (!isa_and_present<CXXThisExpr>(
987 MemberCall->getImplicitObjectArgument()->IgnoreImpCasts()))
990 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
991 assert(MD &&
"Function must be a CXXMethodDecl for member calls");
993 const auto *ClassDecl = MD->getParent()->getDefinition();
997 const auto UseFields = [&](
const CXXRecordDecl *RD) {
998 for (
const auto *Field : RD->fields())
999 if (
auto *FieldList = getOriginsList(*Field))
1000 CurrentBlockFacts.push_back(
1001 FactMgr.createFact<UseFact>(
Call, FieldList));
1004 UseFields(ClassDecl);
1006 ClassDecl->forallBases([&](
const CXXRecordDecl *Base) {
1012void FactsGenerator::handleLifetimeCaptureBy(
const FunctionDecl *FD,
1013 ArrayRef<const Expr *> Args) {
1019 const auto *
Method = dyn_cast<CXXMethodDecl>(FD);
1022 auto getArgCaptureBy = [FD,
1023 IsInstance](
unsigned I) -> LifetimeCaptureByAttr * {
1024 const ParmVarDecl *PVD =
nullptr;
1027 if (I > 0 && I - 1 < FD->getNumParams())
1028 PVD = FD->getParamDecl(I - 1);
1030 if (I < FD->getNumParams())
1031 PVD = FD->getParamDecl(I);
1033 return PVD ? PVD->getAttr<LifetimeCaptureByAttr>() :
nullptr;
1035 for (
unsigned I = 0; I < Args.size(); ++I) {
1036 const LifetimeCaptureByAttr *Attr = getArgCaptureBy(I);
1039 OriginList *CapturedOriginList = getOriginsList(*Args[I]);
1040 if (!CapturedOriginList)
1042 if (!CapturedOriginList)
1044 for (
int CapturingArgIdx : Attr->params()) {
1046 if (CapturingArgIdx == LifetimeCaptureByAttr::Global ||
1047 CapturingArgIdx == LifetimeCaptureByAttr::Unknown ||
1048 CapturingArgIdx == LifetimeCaptureByAttr::Invalid)
1050 ArrayRef<const Expr *> CallArgs = IsInstance ? Args.drop_front() : Args;
1051 const Expr *CapturedByArg =
1052 (CapturingArgIdx == LifetimeCaptureByAttr::This)
1054 : CallArgs[CapturingArgIdx];
1055 assert(CapturedByArg &&
"Capturer expression must be valid");
1057 OriginList *CapturingOriginList = getOriginsList(*CapturedByArg);
1065 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
1066 Dest->getOuterOriginID(), CapturedOriginList->getOuterOriginID(),
1072void FactsGenerator::handleFunctionCall(
const Expr *
Call,
1073 const FunctionDecl *FD,
1074 ArrayRef<const Expr *> Args,
1075 bool IsGslConstruction) {
1076 OriginList *CallList = getOriginsList(*
Call);
1082 for (
const Expr *Arg : Args)
1084 handleInvalidatingCall(
Call, FD, Args);
1085 handleDestructiveCall(
Call, FD, Args);
1086 handleMovedArgsInCall(FD, Args);
1087 handleImplicitObjectFieldUses(
Call, FD);
1088 handleLifetimeCaptureBy(FD, Args);
1092 assert(Args.size() == 1 &&
1093 "std reference cast builtins take exactly one argument");
1096 flow(CallList, getOriginsList(*Args[0]),
true);
1099 auto IsArgLifetimeBound = [FD, &Args](
unsigned I) ->
bool {
1100 const ParmVarDecl *PVD =
nullptr;
1101 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FD);
1108 if ((I - 1) <
Method->getNumParams())
1111 PVD =
Method->getParamDecl(I - 1);
1116 }
else if (I < FD->getNumParams()) {
1118 PVD = FD->getParamDecl(I);
1120 return PVD ? PVD->hasAttr<clang::LifetimeBoundAttr>() :
false;
1122 auto shouldTrackPointerImplicitObjectArg = [FD, &Args](
unsigned I) ->
bool {
1123 const auto *
Method = dyn_cast<CXXMethodDecl>(FD);
1133 bool KillSrc =
true;
1134 for (
unsigned I = 0; I < Args.size(); ++I) {
1135 OriginList *ArgList = getOriginsList(*Args[I]);
1138 if (IsGslConstruction) {
1142 assert(!Args[I]->isGLValue() || ArgList->getLength() >= 2);
1149 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
1150 CallList->getOuterOriginID(), ArgList->getOuterOriginID(),
1153 }
else if (IsArgLifetimeBound(I)) {
1160 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
1161 CallList->getOuterOriginID(), ArgList->getOuterOriginID(),
1165 }
else if (shouldTrackPointerImplicitObjectArg(I)) {
1166 assert(ArgList->getLength() >= 2 &&
1167 "Object arg of pointer type should have at least two origins");
1169 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
1170 CallList->getOuterOriginID(),
1171 ArgList->peelOuterOrigin()->getOuterOriginID(), KillSrc));
1173 }
else if (IsArgLifetimeBound(I)) {
1177 CurrentBlockFacts.push_back(FactMgr.createFact<OriginFlowFact>(
1178 CallList->getOuterOriginID(), ArgList->getOuterOriginID(), KillSrc));
1186bool FactsGenerator::handleTestPoint(
const CXXFunctionalCastExpr *FCE) {
1187 if (!FCE->getType()->isVoidType())
1190 const auto *SubExpr = FCE->getSubExpr()->IgnoreParenImpCasts();
1191 if (
const auto *SL = dyn_cast<StringLiteral>(SubExpr)) {
1192 llvm::StringRef LiteralValue = SL->getString();
1193 const std::string Prefix =
"__lifetime_test_point_";
1195 if (LiteralValue.starts_with(Prefix)) {
1196 StringRef Annotation = LiteralValue.drop_front(Prefix.length());
1197 CurrentBlockFacts.push_back(
1198 FactMgr.createFact<TestPointFact>(Annotation));
1205void FactsGenerator::handleUse(
const Expr *E) {
1206 OriginList *List = getOriginsList(*E);
1212 if (
auto *DRE = dyn_cast<DeclRefExpr>(E);
1213 DRE && !DRE->getDecl()->
getType()->isReferenceType())
1218 if (!UseFacts.contains(E)) {
1219 UseFact *UF = FactMgr.createFact<UseFact>(E, List);
1220 CurrentBlockFacts.push_back(UF);
1225void FactsGenerator::markUseAsWrite(
const DeclRefExpr *DRE) {
1226 if (UseFacts.contains(DRE))
1227 UseFacts[DRE]->markAsWritten();
1232llvm::SmallVector<Fact *> FactsGenerator::issuePlaceholderLoans() {
1233 const auto *FD = dyn_cast<FunctionDecl>(AC.getDecl());
1237 llvm::SmallVector<Fact *> PlaceholderLoanFacts;
1238 if (
auto ThisOrigins = FactMgr.getOriginMgr().getThisOrigins()) {
1239 OriginList *List = *ThisOrigins;
1240 const Loan *L = FactMgr.getLoanMgr().createLoan(
1243 PlaceholderLoanFacts.push_back(
1244 FactMgr.createFact<IssueFact>(L->getID(), List->getOuterOriginID()));
1246 for (
const ParmVarDecl *PVD : FD->parameters()) {
1247 OriginList *List = getOriginsList(*PVD);
1250 const Loan *L = FactMgr.getLoanMgr().createLoan(
1252 PlaceholderLoanFacts.push_back(
1253 FactMgr.createFact<IssueFact>(L->getID(), List->getOuterOriginID()));
1255 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.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
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 VarDecl * getVarDecl() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const Stmt * getTriggerStmt() 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
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...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
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;.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CompoundStmt * getSubStmt()
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 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
bool isFunctionType() 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 VisitAbstractConditionalOperator(const AbstractConditionalOperator *CO)
Visits conditional operators (e.g., cond ?
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 VisitStmtExpr(const StmtExpr *SE)
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 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...
static const CFGBlock * findPredBlockForExpr(const CFGBlock *MergeBlock, const Expr *ArmExpr)
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 shouldTrackFirstArgument(const FunctionDecl *FD)
bool shouldTrackImplicitObjectArg(const Expr &ImplicitObjectArgument, const CXXMethodDecl *Callee, bool RunningUnderLifetimeSafety)
bool isUniquePtrRelease(const CXXMethodDecl &MD)
bool isStdReferenceCast(const FunctionDecl *FD)
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)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ SD_FullExpression
Full-expression storage duration (for temporaries).
U cast(CodeGen::Address addr)