33template <
class T,
class P,
class... ToCompare>
35 return std::is_same_v<T, P> ||
isOneOf<T, ToCompare...>();
41struct GeneralizedReturnsRetainedAttr {
42 static bool classof(
const Attr *A) {
43 if (
auto AA = dyn_cast<AnnotateAttr>(A))
44 return AA->getAnnotation() ==
"rc_ownership_returns_retained";
49struct GeneralizedReturnsNotRetainedAttr {
50 static bool classof(
const Attr *A) {
51 if (
auto AA = dyn_cast<AnnotateAttr>(A))
52 return AA->getAnnotation() ==
"rc_ownership_returns_not_retained";
57struct GeneralizedConsumedAttr {
58 static bool classof(
const Attr *A) {
59 if (
auto AA = dyn_cast<AnnotateAttr>(A))
60 return AA->getAnnotation() ==
"rc_ownership_consumed";
68std::optional<ObjKind> RetainSummaryManager::hasAnyEnabledAttrOf(
const Decl *D,
71 if (
isOneOf<T, CFConsumedAttr, CFReturnsRetainedAttr,
72 CFReturnsNotRetainedAttr>()) {
73 if (!TrackObjCAndCFObjects)
77 }
else if (
isOneOf<T, NSConsumedAttr, NSConsumesSelfAttr,
78 NSReturnsAutoreleasedAttr, NSReturnsRetainedAttr,
79 NSReturnsNotRetainedAttr, NSConsumesSelfAttr>()) {
81 if (!TrackObjCAndCFObjects)
84 if (
isOneOf<T, NSReturnsRetainedAttr, NSReturnsAutoreleasedAttr,
85 NSReturnsNotRetainedAttr>() &&
89 }
else if (
isOneOf<T, OSConsumedAttr, OSConsumesThisAttr,
90 OSReturnsNotRetainedAttr, OSReturnsRetainedAttr,
91 OSReturnsRetainedOnZeroAttr,
92 OSReturnsRetainedOnNonZeroAttr>()) {
96 }
else if (
isOneOf<T, GeneralizedReturnsNotRetainedAttr,
97 GeneralizedReturnsRetainedAttr,
98 GeneralizedConsumedAttr>()) {
101 llvm_unreachable(
"Unexpected attribute");
108template <
class T1,
class T2,
class... Others>
109std::optional<ObjKind> RetainSummaryManager::hasAnyEnabledAttrOf(
const Decl *D,
111 if (
auto Out = hasAnyEnabledAttrOf<T1>(D, QT))
113 return hasAnyEnabledAttrOf<T2, Others...>(D, QT);
117RetainSummaryManager::getPersistentSummary(
const RetainSummary &OldSumm) {
120 ::llvm::FoldingSetNodeID
ID;
123 llvm::FoldingSetInsertToken InsertToken;
124 CachedSummaryNode *N = SimpleSummaries.lookup(ID, InsertToken);
127 N = (CachedSummaryNode *) BPAlloc.Allocate<CachedSummaryNode>();
128 new (N) CachedSummaryNode(OldSumm);
129 SimpleSummaries.insert(N, InsertToken);
132 return &N->getValue();
135 RetainSummary *Summ = (RetainSummary *) BPAlloc.Allocate<RetainSummary>();
136 new (Summ) RetainSummary(OldSumm);
141 StringRef ClassName) {
154bool RetainSummaryManager::isOSObjectSubclass(
const Decl *D)
const {
155 return MayHaveOSObjects && D &&
isSubclass(D,
"OSMetaClassBase") &&
162 return S ==
"requiredMetaCast";
166 return S ==
"metaCast";
169bool RetainSummaryManager::isOSObjectPtr(QualType QT)
const {
173bool RetainSummaryManager::isISLObjectRef(QualType Ty)
const {
174 return MayHaveISLTypes && StringRef(Ty.
getAsString()).starts_with(
"isl_");
177bool RetainSummaryManager::hasISLIdentifiers(
const IdentifierTable &Idents) {
178 return llvm::any_of(Idents, [](
const auto &Entry) {
179 return Entry.getKey().starts_with(
"isl_");
189 if (Ann->getAnnotation() == rcAnnotation)
196 return FName.starts_with_insensitive(
"retain") ||
197 FName.ends_with_insensitive(
"retain");
201 return FName.starts_with_insensitive(
"release") ||
202 FName.ends_with_insensitive(
"release");
206 return FName.starts_with_insensitive(
"autorelease") ||
207 FName.ends_with_insensitive(
"autorelease");
211 return FName.contains_insensitive(
"MakeCollectable");
216bool RetainSummaryManager::isOSObjectRelated(
const CXXMethodDecl *MD)
const {
221 QualType PT = Param->getType()->getPointeeType();
224 if (isOSObjectSubclass(RD))
238 if (II && II->
getName() ==
"smart_ptr")
239 if (
const auto *ND = dyn_cast<NamespaceDecl>(RD->getDeclContext()))
240 if (ND->getNameAsString() ==
"os")
246RetainSummaryManager::getSummaryForOSObject(
const FunctionDecl *FD,
248 assert(TrackOSObjects &&
249 "Requesting a summary for an OSObject but OSObjects are not tracked");
253 if (PD && isOSObjectSubclass(PD)) {
256 return getDefaultSummary();
261 if (FName.ends_with(
"Matching")) {
262 return getPersistentStopSummary();
267 if ((!FName.starts_with(
"get") && !FName.starts_with(
"Get")) ||
269 return getOSSummaryCreateRule(FD);
271 return getOSSummaryGetRule(FD);
276 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
277 const CXXRecordDecl *Parent = MD->
getParent();
278 if (Parent && isOSObjectSubclass(Parent)) {
279 if (FName ==
"release" || FName ==
"taggedRelease")
280 return getOSSummaryReleaseRule(FD);
282 if (FName ==
"retain" || FName ==
"taggedRetain")
283 return getOSSummaryRetainRule(FD);
286 return getOSSummaryFreeRule(FD);
289 return getOSSummaryCreateRule(MD);
296const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
297 const FunctionDecl *FD,
300 const FunctionType *FT,
301 bool &AllowAnnotations) {
306 if (FName ==
"pthread_create" || FName ==
"pthread_setspecific") {
310 return getPersistentStopSummary();
311 }
else if(FName ==
"NSMakeCollectable") {
313 AllowAnnotations =
false;
315 : getPersistentStopSummary();
316 }
else if (FName ==
"CMBufferQueueDequeueAndRetain" ||
317 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
324 }
else if (FName ==
"CFPlugInInstanceCreate") {
326 }
else if (FName ==
"IORegistryEntrySearchCFProperty" ||
327 (RetTyName ==
"CFMutableDictionaryRef" &&
328 (FName ==
"IOBSDNameMatching" || FName ==
"IOServiceMatching" ||
329 FName ==
"IOServiceNameMatching" ||
330 FName ==
"IORegistryEntryIDMatching" ||
331 FName ==
"IOOpenFirmwarePathMatching"))) {
336 }
else if (FName ==
"IOServiceGetMatchingService" ||
337 FName ==
"IOServiceGetMatchingServices") {
344 }
else if (FName ==
"IOServiceAddNotification" ||
345 FName ==
"IOServiceAddMatchingNotification") {
352 }
else if (FName ==
"CVPixelBufferCreateWithBytes") {
359 ScratchArgs = AF.add(ScratchArgs, 7, ArgEffect(
StopTracking));
363 }
else if (FName ==
"CGBitmapContextCreateWithData") {
368 ScratchArgs = AF.add(ScratchArgs, 8, ArgEffect(ArgEffect(
StopTracking)));
371 }
else if (FName ==
"CVPixelBufferCreateWithPlanarBytes") {
373 ScratchArgs = AF.add(ScratchArgs, 12, ArgEffect(
StopTracking));
377 }
else if (FName ==
"VTCompressionSessionEncodeFrame" ||
378 FName ==
"VTCompressionSessionEncodeMultiImageFrame") {
384 ScratchArgs = AF.add(ScratchArgs, 5, ArgEffect(
StopTracking));
388 }
else if (FName ==
"dispatch_set_context" ||
389 FName ==
"xpc_connection_set_context") {
394 ScratchArgs = AF.add(ScratchArgs, 1, ArgEffect(
StopTracking));
398 }
else if (FName.starts_with(
"NSLog")) {
399 return getDoNothingSummary();
400 }
else if (FName.starts_with(
"NS") && FName.contains(
"Insert")) {
403 ScratchArgs = AF.add(ScratchArgs, 1, ArgEffect(
StopTracking));
404 ScratchArgs = AF.add(ScratchArgs, 2, ArgEffect(
StopTracking));
419 AllowAnnotations =
false;
421 return getUnarySummary(FT,
IncRef);
425 AllowAnnotations =
false;
429 AllowAnnotations =
false;
432 return getCFCreateGetRuleSummary(FD);
440 return getUnarySummary(FT,
IncRef);
442 return getCFCreateGetRuleSummary(FD);
449 return getCFCreateGetRuleSummary(FD);
452 if (FD->
hasAttr<CFAuditedTransferAttr>()) {
453 return getCFCreateGetRuleSummary(FD);
459 if (FName.starts_with(
"CG") || FName.starts_with(
"CF")) {
461 FName = FName.substr(FName.starts_with(
"CGCF") ? 4 : 2);
464 return getUnarySummary(FT,
DecRef);
466 assert(ScratchArgs.isEmpty());
482 ArgEffectKind E = (FName.contains_insensitive(
"InsertValue") ||
483 FName.contains_insensitive(
"AddValue") ||
484 FName.contains_insensitive(
"SetValue") ||
485 FName.contains_insensitive(
"AppendValue") ||
486 FName.contains_insensitive(
"SetAttribute"))
499RetainSummaryManager::generateSummary(
const FunctionDecl *FD,
500 bool &AllowAnnotations) {
503 return getPersistentStopSummary();
507 StringRef FName = II ? II->
getName() :
"";
511 FName = FName.substr(FName.find_first_not_of(
'_'));
518 if (
const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
521 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
522 if (!isOSObjectRelated(MD))
529 if (TrackObjCAndCFObjects)
530 if (
const RetainSummary *S =
531 getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
534 return getDefaultSummary();
538RetainSummaryManager::getFunctionSummary(
const FunctionDecl *FD) {
541 return getDefaultSummary();
544 FuncSummariesTy::iterator I = FuncSummaries.find(FD);
545 if (I != FuncSummaries.end())
549 bool AllowAnnotations =
true;
550 const RetainSummary *S = generateSummary(FD, AllowAnnotations);
553 if (AllowAnnotations)
554 updateSummaryFromAnnotations(S, FD);
556 FuncSummaries[FD] = S;
585 llvm_unreachable(
"Unknown ArgEffect kind");
589RetainSummaryManager::updateSummaryForNonZeroCallbackArg(
const RetainSummary *S,
596 for (ArgEffects::iterator I = CustomArgEffects.begin(),
597 E = CustomArgEffects.end();
601 ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
609 if (
const IdentifierInfo *Name =
C.getIdentifier()) {
614 if (Name->isStr(
"CGBitmapContextCreateWithData") ||
615 Name->isStr(
"dispatch_data_create"))
619 return getPersistentSummary(RE, ScratchArgs, RecEffect, DefEffect);
622void RetainSummaryManager::updateSummaryForReceiverUnconsumedSelf(
632void RetainSummaryManager::updateSummaryForArgumentTypes(
636 unsigned parm_idx = 0;
637 for (
auto pi =
C.param_begin(), pe =
C.param_end(); pi != pe;
639 QualType QT = (*pi)->getType();
647 if (isISLObjectRef(QT)) {
649 }
else if (isOSObjectPtr(QT)) {
659 ArgEffect(RS->getDefaultArgEffect().
getKind(), K));
665 bool HasNonZeroCallbackArg,
666 bool IsReceiverUnconsumedSelf,
669 switch (
C.getKind()) {
675 Summ = getFunctionSummary(cast_or_null<FunctionDecl>(
C.getDecl()));
680 return getPersistentStopSummary();
682 const auto *ME = cast_or_null<ObjCMessageExpr>(
C.getExpr());
685 }
else if (ME->isInstanceMessage()) {
686 Summ = getInstanceMethodSummary(ME, ReceiverType);
688 Summ = getClassMethodSummary(ME);
694 if (HasNonZeroCallbackArg)
695 Summ = updateSummaryForNonZeroCallbackArg(Summ,
C);
697 if (IsReceiverUnconsumedSelf)
698 updateSummaryForReceiverUnconsumedSelf(Summ);
700 updateSummaryForArgumentTypes(
C, Summ);
702 assert(Summ &&
"Unknown call type?");
708RetainSummaryManager::getCFCreateGetRuleSummary(
const FunctionDecl *FD) {
710 return getCFSummaryCreateRule(FD);
712 return getCFSummaryGetRule(FD);
720std::optional<RetainSummaryManager::BehaviorSummary>
722 bool &hasTrustedImplementationAnnotation) {
728 StringRef FName = II->
getName();
729 FName = FName.substr(FName.find_first_not_of(
'_'));
733 if (II->
isStr(
"NSMakeCollectable"))
739 if (FName ==
"CMBufferQueueDequeueAndRetain" ||
740 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
758 if (TrackOSObjects) {
771 hasTrustedImplementationAnnotation =
true;
776 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
778 if (TrackOSObjects && Parent && isOSObjectSubclass(Parent))
779 if (FName ==
"release" || FName ==
"retain")
787RetainSummaryManager::getUnarySummary(
const FunctionType* FT,
797 return getPersistentStopSummary();
801 ScratchArgs = AF.add(ScratchArgs, 0, Effect);
808RetainSummaryManager::getOSSummaryRetainRule(
const FunctionDecl *FD) {
817RetainSummaryManager::getOSSummaryReleaseRule(
const FunctionDecl *FD) {
826RetainSummaryManager::getOSSummaryFreeRule(
const FunctionDecl *FD) {
835RetainSummaryManager::getOSSummaryCreateRule(
const FunctionDecl *FD) {
841RetainSummaryManager::getOSSummaryGetRule(
const FunctionDecl *FD) {
847RetainSummaryManager::getCFSummaryCreateRule(
const FunctionDecl *FD) {
853RetainSummaryManager::getCFSummaryGetRule(
const FunctionDecl *FD) {
866std::optional<RetEffect>
867RetainSummaryManager::getRetEffectFromAnnotations(QualType RetTy,
869 if (hasAnyEnabledAttrOf<NSReturnsRetainedAttr>(D, RetTy))
870 return ObjCAllocRetE;
872 if (
auto K = hasAnyEnabledAttrOf<CFReturnsRetainedAttr, OSReturnsRetainedAttr,
873 GeneralizedReturnsRetainedAttr>(D, RetTy))
876 if (
auto K = hasAnyEnabledAttrOf<
877 CFReturnsNotRetainedAttr, OSReturnsNotRetainedAttr,
878 GeneralizedReturnsNotRetainedAttr, NSReturnsNotRetainedAttr,
879 NSReturnsAutoreleasedAttr>(D, RetTy))
882 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
884 if (
auto RE = getRetEffectFromAnnotations(RetTy, PD))
895 const auto &Context = T->getDecl()->getASTContext();
896 if (T->getDecl()->getIdentifier() == &Context.Idents.get(Name))
898 QT = T->getDecl()->getUnderlyingType();
904 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
906 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(ND)) {
909 llvm_unreachable(
"Unexpected decl");
913bool RetainSummaryManager::applyParamAnnotationEffect(
914 const ParmVarDecl *pd,
unsigned parm_idx,
const NamedDecl *FD,
918 hasAnyEnabledAttrOf<NSConsumedAttr, CFConsumedAttr, OSConsumedAttr,
919 GeneralizedConsumedAttr>(pd, QT)) {
922 }
else if (
auto K = hasAnyEnabledAttrOf<
923 CFReturnsRetainedAttr, OSReturnsRetainedAttr,
924 OSReturnsRetainedOnNonZeroAttr, OSReturnsRetainedOnZeroAttr,
925 GeneralizedReturnsRetainedAttr>(pd, QT)) {
932 bool HasRetainedOnZero = pd->
hasAttr<OSReturnsRetainedOnZeroAttr>();
933 bool HasRetainedOnNonZero = pd->
hasAttr<OSReturnsRetainedOnNonZeroAttr>();
944 if (ShouldSplit && SuccessOnZero) {
946 }
else if (ShouldSplit && (!SuccessOnZero || HasRetainedOnNonZero)) {
957 }
else if (
auto K = hasAnyEnabledAttrOf<CFReturnsNotRetainedAttr,
958 OSReturnsNotRetainedAttr,
959 GeneralizedReturnsNotRetainedAttr>(
965 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
967 const ParmVarDecl *OP = OD->parameters()[parm_idx];
968 if (applyParamAnnotationEffect(OP, parm_idx, OD,
Template))
977RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
978 const FunctionDecl *FD) {
982 assert(Summ &&
"Must have a summary to add annotations to.");
986 unsigned parm_idx = 0;
988 pe = FD->
param_end(); pi != pe; ++pi, ++parm_idx)
989 applyParamAnnotationEffect(*pi, parm_idx, FD,
Template);
992 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, FD))
995 if (hasAnyEnabledAttrOf<OSConsumesThisAttr>(FD, RetTy))
1000RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
1001 const ObjCMethodDecl *MD) {
1005 assert(Summ &&
"Must have a valid summary to add annotations to");
1009 if (hasAnyEnabledAttrOf<NSConsumesSelfAttr>(MD, MD->
getReturnType()))
1013 unsigned parm_idx = 0;
1016 applyParamAnnotationEffect(*pi, parm_idx, MD,
Template);
1019 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, MD))
1024RetainSummaryManager::getStandardMethodSummary(
const ObjCMethodDecl *MD,
1025 Selector S, QualType RetTy) {
1063 ResultEff = ObjCInitRetE;
1071 ResultEff = ObjCAllocRetE;
1101 for (
unsigned i = 0, e = S.
getNumArgs(); i != e; ++i) {
1103 if (Slot.ends_with_insensitive(
"delegate")) {
1104 if (ResultEff == ObjCInitRetE)
1114 return getDefaultSummary();
1116 return getPersistentSummary(ResultEff,
ArgEffects(AF.getEmptyMap()),
1117 ArgEffect(ReceiverEff), ArgEffect(
MayEscape));
1121RetainSummaryManager::getClassMethodSummary(
const ObjCMessageExpr *ME) {
1126 ME->
getType(), ObjCClassMethodSummaries);
1129const RetainSummary *RetainSummaryManager::getInstanceMethodSummary(
1130 const ObjCMessageExpr *ME,
1131 QualType ReceiverType) {
1132 const ObjCInterfaceDecl *ReceiverClass =
nullptr;
1136 if (!ReceiverType.
isNull())
1137 if (
const auto *PT = ReceiverType->
getAs<ObjCObjectPointerType>())
1138 ReceiverClass = PT->getInterfaceDecl();
1150 if (!
Method && ReceiverClass)
1153 return getMethodSummary(S, ReceiverClass,
Method, ME->
getType(),
1154 ObjCMethodSummaries);
1158RetainSummaryManager::getMethodSummary(Selector S,
1159 const ObjCInterfaceDecl *ID,
1160 const ObjCMethodDecl *MD, QualType RetTy,
1161 ObjCMethodSummariesTy &CachedSummaries) {
1164 if (!TrackObjCAndCFObjects)
1165 return getDefaultSummary();
1168 const RetainSummary *Summ = CachedSummaries.find(ID, S);
1171 Summ = getStandardMethodSummary(MD, S, RetTy);
1174 updateSummaryFromAnnotations(Summ, MD);
1177 CachedSummaries[ObjCSummaryKey(ID, S)] = Summ;
1183void RetainSummaryManager::InitializeClassMethodSummaries() {
1187 addClassMethSummary(
"NSAssertionHandler",
"currentHandler",
1192 ScratchArgs = AF.add(ScratchArgs, 0, ArgEffect(
Autorelease));
1193 addClassMethSummary(
"NSAutoreleasePool",
"addObject",
1199void RetainSummaryManager::InitializeMethodSummaries() {
1204 const RetainSummary *InitSumm = getPersistentSummary(
1214 const RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE,
1216 const RetainSummary *CFAllocSumm =
1221 const RetainSummary *Summ = getPersistentSummary(
1226 Summ = getPersistentSummary(NoRet, ScratchArgs,
1231 Summ = getPersistentSummary(NoRet, ScratchArgs, ArgEffect(
Dealloc,
1236 Summ = getPersistentSummary(NoRet, ScratchArgs, ArgEffect(
Autorelease,
1244 const RetainSummary *NoTrackYet =
1248 addClassMethSummary(
"NSWindow",
"alloc", NoTrackYet);
1254 addClassMethSummary(
"NSPanel",
"alloc", NoTrackYet);
1258 addClassMethSummary(
"NSNull",
"null", NoTrackYet);
1262 addClassMethSummary(
"NSAutoreleasePool",
"alloc", NoTrackYet);
1263 addClassMethSummary(
"NSAutoreleasePool",
"allocWithZone", NoTrackYet,
false);
1264 addClassMethSummary(
"NSAutoreleasePool",
"new", NoTrackYet);
1267 addInstMethSummary(
"QCRenderer", AllocSumm,
"createSnapshotImageOfType");
1268 addInstMethSummary(
"QCView", AllocSumm,
"createSnapshotImageOfType");
1273 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect");
1274 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect",
1275 "format",
"colorSpace");
1276 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGLayerWithSize",
"info");
1280RetainSummaryManager::getMethodSummary(
const ObjCMethodDecl *MD) {
1285 ObjCMethodSummariesTy *CachedSummaries;
1287 CachedSummaries = &ObjCMethodSummaries;
1289 CachedSummaries = &ObjCClassMethodSummaries;
1291 return getMethodSummary(S, ID, MD, ResultTy, *CachedSummaries);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static bool isSubclass(const ObjCInterfaceDecl *Class, const IdentifierInfo *II)
static bool isRelease(const FunctionDecl *FD, StringRef FName)
static bool hasTypedefNamed(QualType QT, StringRef Name)
static bool isOSObjectRequiredCast(StringRef S)
static ArgEffect getStopTrackingHardEquivalent(ArgEffect E)
static constexpr bool isOneOf()
static bool isOSIteratorSubclass(const Decl *D)
static QualType getCallableReturnType(const NamedDecl *ND)
static bool isAutorelease(const FunctionDecl *FD, StringRef FName)
static bool isExactClass(const Decl *D, StringRef ClassName)
static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation)
static bool isOSObjectThisCast(StringRef S)
static bool isMakeCollectable(StringRef FName)
static bool isOSObjectDynamicCast(StringRef S)
static bool isRetain(const FunctionDecl *FD, StringRef FName)
An instance of this class corresponds to a call.
@ Destructor
An implicit C++ destructor call (called implicitly or by operator 'delete')
@ ObjCMethod
A call to an Objective-C method.
@ Deallocator
A C++ deallocation function call (operator delete), via C++ delete-expression.
@ Function
A function, function pointer, or a C++ method call.
@ Allocator
A C++ allocation function call (operator new), via C++ new-expression.
@ Constructor
An implicit or explicit C++ constructor call.
@ InheritedConstructor
A C++ inherited constructor produced by a "using T::T" directive.
@ Block
A call to an Objective-C block.
overridden_method_range overridden_methods() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Represents a function declaration or definition.
param_iterator param_end()
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
param_iterator param_begin()
FunctionDecl * getDefinition()
Get the definition for this declaration.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
size_t param_size() const
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Selector getSelector() const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
const ObjCMethodDecl * getMethodDecl() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
Selector getSelector() const
bool isInstanceMethod() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
QualType getReturnType() const
ObjCInterfaceDecl * getClassInterface()
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isKeywordSelector() const
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
unsigned getNumArgs() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isObjCIdType() const
const T * getAs() const
Member-template getAs<specific type>'.
An ArgEffect summarizes the retain count behavior on an argument or receiver to a function or method.
ArgEffect withKind(ArgEffectKind NewK)
ArgEffectKind getKind() const
static RetEffect MakeNotOwned(ObjKind o)
static RetEffect MakeOwned(ObjKind o)
@ NoRet
Indicates that no retain count information is tracked for the return value.
static RetEffect MakeNoRet()
static RetEffect MakeNoRetHard()
bool isTrustedReferenceCountImplementation(const Decl *FD)
std::optional< BehaviorSummary > canEval(const CallExpr *CE, const FunctionDecl *FD, bool &hasTrustedImplementationAnnotation)
static bool isKnownSmartPointer(QualType QT)
const RetainSummary * getSummary(AnyCall C, bool HasNonZeroCallbackArg=false, bool IsReceiverUnconsumedSelf=false, QualType ReceiverType={})
friend class RetainSummaryTemplate
Summary for a function with respect to ownership changes.
ArgEffect getReceiverEffect() const
getReceiverEffect - Returns the effect on the receiver of the call.
RetEffect getRetEffect() const
getRetEffect - Returns the effect on the return value of the call.
bool isSimple() const
A retain summary is simple if it has no ArgEffects other than the default.
ArgEffects getArgEffects() const
void Profile(llvm::FoldingSetNodeID &ID) const
Profile this summary for inclusion in a FoldingSet.
internal::Matcher< Decl > DeclarationMatcher
Types of matchers for the top-level classes in the AST class hierarchy.
internal::Matcher< NamedDecl > hasName(StringRef Name)
Matches NamedDecl nodes that have the specified name.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
bool isCocoaObjectRef(QualType T)
bool isRefType(QualType RetTy, StringRef Prefix, StringRef Name=StringRef())
bool followsCreateRule(const FunctionDecl *FD)
bool isCFObjectRef(QualType T)
llvm::ImmutableMap< unsigned, ArgEffect > ArgEffects
ArgEffects summarizes the effects of a function/method call on all of its arguments.
ObjKind
Determines the object kind of a tracked object.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
@ Generalized
Indicates that the tracked object is a generalized object.
@ CF
Indicates that the tracked object is a CF object.
@ AnyObj
Indicates that the tracked object could be a CF or Objective-C object.
@ ObjC
Indicates that the tracked object is an Objective-C object.
@ IncRef
The argument has its reference count increased by 1.
@ UnretainedOutParameter
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +0 v...
@ DoNothing
There is no effect.
@ RetainedOutParameter
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +1 v...
@ RetainedOutParameterOnZero
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +1 v...
@ MayEscape
The argument is treated as potentially escaping, meaning that even when its reference count hits 0 it...
@ StopTracking
All typestate tracking of the object ceases.
@ Dealloc
The argument is treated as if the referenced object was deallocated.
@ Autorelease
The argument is treated as if an -autorelease message had been sent to the referenced object.
@ RetainedOutParameterOnNonZero
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +1 v...
@ DecRef
The argument has its reference count decreased by 1.
@ StopTrackingHard
All typestate tracking of the object ceases.
@ DecRefAndStopTrackingHard
Performs the combined functionality of DecRef and StopTrackingHard.
@ DecRefBridgedTransferred
The argument has its reference count decreased by 1 to model a transferred bridge cast under ARC.
PRESERVE_NONE bool NoRet(InterpState &S)
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
static bool classof(const OMPClause *T)
@ OMF_None
No particular method family.
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
@ Template
We are parsing a template declaration.
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
U cast(CodeGen::Address addr)
@ Class
The "class" keyword introduces the elaborated-type-specifier.