23 using namespace clang;
33 template <
class T,
class P,
class... ToCompare>
35 return std::is_same<T, P>::value ||
isOneOf<T, ToCompare...>();
41 struct GeneralizedReturnsRetainedAttr {
43 if (
auto AA = dyn_cast<AnnotateAttr>(A))
44 return AA->getAnnotation() ==
"rc_ownership_returns_retained";
49 struct GeneralizedReturnsNotRetainedAttr {
51 if (
auto AA = dyn_cast<AnnotateAttr>(A))
52 return AA->getAnnotation() ==
"rc_ownership_returns_not_retained";
57 struct GeneralizedConsumedAttr {
59 if (
auto AA = dyn_cast<AnnotateAttr>(A))
60 return AA->getAnnotation() ==
"rc_ownership_consumed";
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");
108 template <
class T1,
class T2,
class... Others>
111 if (
auto Out = hasAnyEnabledAttrOf<T1>(D, QT))
113 return hasAnyEnabledAttrOf<T2, Others...>(D, QT);
116 const RetainSummary *
117 RetainSummaryManager::getPersistentSummary(
const RetainSummary &OldSumm) {
119 if (OldSumm.isSimple()) {
120 ::llvm::FoldingSetNodeID
ID;
124 CachedSummaryNode *N = SimpleSummaries.FindNodeOrInsertPos(ID, Pos);
127 N = (CachedSummaryNode *) BPAlloc.Allocate<CachedSummaryNode>();
128 new (N) CachedSummaryNode(OldSumm);
129 SimpleSummaries.InsertNode(N, Pos);
132 return &N->getValue();
135 RetainSummary *Summ = (RetainSummary *) BPAlloc.Allocate<RetainSummary>();
136 new (Summ) RetainSummary(OldSumm);
141 StringRef ClassName) {
152 return S ==
"safeMetaCast";
156 return S ==
"requiredMetaCast";
160 return S ==
"metaCast";
169 return StringRef(Ty.
getAsString()).startswith(
"isl_");
178 if (Ann->getAnnotation() == rcAnnotation)
185 return FName.startswith_lower(
"retain") || FName.endswith_lower(
"retain");
189 return FName.startswith_lower(
"release") || FName.endswith_lower(
"release");
193 return FName.startswith_lower(
"autorelease") ||
194 FName.endswith_lower(
"autorelease");
198 return FName.contains_lower(
"MakeCollectable");
219 RetainSummaryManager::isKnownSmartPointer(
QualType QT) {
225 if (II && II->
getName() ==
"smart_ptr")
226 if (
const auto *ND = dyn_cast<NamespaceDecl>(RD->getDeclContext()))
227 if (ND->getNameAsString() ==
"os")
232 const RetainSummary *
233 RetainSummaryManager::getSummaryForOSObject(
const FunctionDecl *FD,
235 assert(TrackOSObjects &&
236 "Requesting a summary for an OSObject but OSObjects are not tracked");
243 return getDefaultSummary();
248 if (FName.endswith(
"Matching")) {
249 return getPersistentStopSummary();
254 if ((!FName.startswith(
"get") && !FName.startswith(
"Get")) ||
256 return getOSSummaryCreateRule(FD);
258 return getOSSummaryGetRule(FD);
263 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
266 if (FName ==
"release" || FName ==
"taggedRelease")
267 return getOSSummaryReleaseRule(FD);
269 if (FName ==
"retain" || FName ==
"taggedRetain")
270 return getOSSummaryRetainRule(FD);
273 return getOSSummaryFreeRule(FD);
275 if (MD->getOverloadedOperator() == OO_New)
276 return getOSSummaryCreateRule(MD);
283 const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
288 bool &AllowAnnotations) {
290 ArgEffects ScratchArgs(AF.getEmptyMap());
293 if (FName ==
"pthread_create" || FName ==
"pthread_setspecific") {
296 return getPersistentStopSummary();
297 }
else if(FName ==
"NSMakeCollectable") {
299 AllowAnnotations =
false;
301 : getPersistentStopSummary();
302 }
else if (FName ==
"CMBufferQueueDequeueAndRetain" ||
303 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
309 }
else if (FName ==
"CFPlugInInstanceCreate") {
311 }
else if (FName ==
"IORegistryEntrySearchCFProperty" ||
312 (RetTyName ==
"CFMutableDictionaryRef" &&
313 (FName ==
"IOBSDNameMatching" || FName ==
"IOServiceMatching" ||
314 FName ==
"IOServiceNameMatching" ||
315 FName ==
"IORegistryEntryIDMatching" ||
316 FName ==
"IOOpenFirmwarePathMatching"))) {
321 }
else if (FName ==
"IOServiceGetMatchingService" ||
322 FName ==
"IOServiceGetMatchingServices") {
330 }
else if (FName ==
"IOServiceAddNotification" ||
331 FName ==
"IOServiceAddMatchingNotification") {
338 }
else if (FName ==
"CVPixelBufferCreateWithBytes") {
349 }
else if (FName ==
"CGBitmapContextCreateWithData") {
357 }
else if (FName ==
"CVPixelBufferCreateWithPlanarBytes") {
367 }
else if (FName ==
"VTCompressionSessionEncodeFrame") {
377 }
else if (FName ==
"dispatch_set_context" ||
378 FName ==
"xpc_connection_set_context") {
389 }
else if (FName.startswith(
"NSLog")) {
390 return getDoNothingSummary();
391 }
else if (FName.startswith(
"NS") &&
392 (FName.find(
"Insert") != StringRef::npos)) {
411 AllowAnnotations =
false;
413 return getUnarySummary(FT,
IncRef);
417 AllowAnnotations =
false;
421 AllowAnnotations =
false;
424 return getCFCreateGetRuleSummary(FD);
432 return getUnarySummary(FT,
IncRef);
434 return getCFCreateGetRuleSummary(FD);
441 return getCFCreateGetRuleSummary(FD);
444 if (FD->
hasAttr<CFAuditedTransferAttr>()) {
445 return getCFCreateGetRuleSummary(FD);
451 if (FName.startswith(
"CG") || FName.startswith(
"CF")) {
453 FName = FName.substr(FName.startswith(
"CGCF") ? 4 : 2);
456 return getUnarySummary(FT,
DecRef);
458 assert(ScratchArgs.isEmpty());
475 (StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
476 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
477 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
478 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
479 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos)
491 const RetainSummary *
492 RetainSummaryManager::generateSummary(
const FunctionDecl *FD,
493 bool &AllowAnnotations) {
496 return getPersistentStopSummary();
500 StringRef FName = II ? II->
getName() :
"";
504 FName = FName.substr(FName.find_first_not_of(
'_'));
511 if (
const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
514 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
517 ArgEffects(AF.getEmptyMap()),
522 if (TrackObjCAndCFObjects)
523 if (
const RetainSummary *S =
524 getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
527 return getDefaultSummary();
530 const RetainSummary *
531 RetainSummaryManager::getFunctionSummary(
const FunctionDecl *FD) {
534 return getDefaultSummary();
537 FuncSummariesTy::iterator I = FuncSummaries.find(FD);
538 if (I != FuncSummaries.end())
542 bool AllowAnnotations =
true;
543 const RetainSummary *S = generateSummary(FD, AllowAnnotations);
546 if (AllowAnnotations)
547 updateSummaryFromAnnotations(S, FD);
549 FuncSummaries[FD] = S;
578 llvm_unreachable(
"Unknown ArgEffect kind");
581 const RetainSummary *
582 RetainSummaryManager::updateSummaryForNonZeroCallbackArg(
const RetainSummary *S,
587 ArgEffects ScratchArgs(AF.getEmptyMap());
588 ArgEffects CustomArgEffects = S->getArgEffects();
589 for (ArgEffects::iterator I = CustomArgEffects.begin(),
590 E = CustomArgEffects.end();
593 if (Translated.
getKind() != DefEffect.getKind())
594 ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
607 if (Name->isStr(
"CGBitmapContextCreateWithData") ||
608 Name->isStr(
"dispatch_data_create"))
609 RE = S->getRetEffect();
612 return getPersistentSummary(RE, ScratchArgs, RecEffect, DefEffect);
615 void RetainSummaryManager::updateSummaryForReceiverUnconsumedSelf(
616 const RetainSummary *&S) {
618 RetainSummaryTemplate Template(S, *
this);
625 void RetainSummaryManager::updateSummaryForArgumentTypes(
626 const AnyCall &C,
const RetainSummary *&RS) {
627 RetainSummaryTemplate Template(RS, *
this);
629 unsigned parm_idx = 0;
630 for (
auto pi = C.param_begin(), pe = C.param_end(); pi != pe;
635 if (RS->getArgEffects().contains(parm_idx))
651 Template->addArg(AF, parm_idx,
652 ArgEffect(RS->getDefaultArgEffect().getKind(), K));
656 const RetainSummary *
658 bool HasNonZeroCallbackArg,
659 bool IsReceiverUnconsumedSelf,
661 const RetainSummary *Summ;
662 switch (C.getKind()) {
664 case AnyCall::Constructor:
665 case AnyCall::Allocator:
666 case AnyCall::Deallocator:
667 Summ = getFunctionSummary(cast_or_null<FunctionDecl>(C.getDecl()));
670 case AnyCall::Destructor:
672 return getPersistentStopSummary();
673 case AnyCall::ObjCMethod: {
674 const auto *ME = cast_or_null<ObjCMessageExpr>(C.getExpr());
676 Summ = getMethodSummary(cast<ObjCMethodDecl>(C.getDecl()));
677 }
else if (ME->isInstanceMessage()) {
678 Summ = getInstanceMethodSummary(ME, ReceiverType);
680 Summ = getClassMethodSummary(ME);
686 if (HasNonZeroCallbackArg)
687 Summ = updateSummaryForNonZeroCallbackArg(Summ, C);
689 if (IsReceiverUnconsumedSelf)
690 updateSummaryForReceiverUnconsumedSelf(Summ);
692 updateSummaryForArgumentTypes(C, Summ);
694 assert(Summ &&
"Unknown call type?");
699 const RetainSummary *
700 RetainSummaryManager::getCFCreateGetRuleSummary(
const FunctionDecl *FD) {
702 return getCFSummaryCreateRule(FD);
704 return getCFSummaryGetRule(FD);
707 bool RetainSummaryManager::isTrustedReferenceCountImplementation(
714 bool &hasTrustedImplementationAnnotation) {
720 StringRef FName = II->
getName();
721 FName = FName.substr(FName.find_first_not_of(
'_'));
725 if (II->
isStr(
"NSMakeCollectable"))
726 return BehaviorSummary::Identity;
731 if (FName ==
"CMBufferQueueDequeueAndRetain" ||
732 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
743 return BehaviorSummary::Identity;
750 if (TrackOSObjects) {
752 return BehaviorSummary::IdentityOrZero;
754 return BehaviorSummary::Identity;
756 !cast<CXXMethodDecl>(FD)->isStatic()) {
757 return BehaviorSummary::IdentityThis;
762 if (FDD && isTrustedReferenceCountImplementation(FDD)) {
763 hasTrustedImplementationAnnotation =
true;
764 return BehaviorSummary::Identity;
768 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
771 if (FName ==
"release" || FName ==
"retain")
772 return BehaviorSummary::NoOp;
778 const RetainSummary *
779 RetainSummaryManager::getUnarySummary(
const FunctionType* FT,
783 ArgEffects ScratchArgs(AF.getEmptyMap());
788 if (!FTP || FTP->getNumParams() != 1)
789 return getPersistentStopSummary();
793 ScratchArgs = AF.add(ScratchArgs, 0, Effect);
799 const RetainSummary *
800 RetainSummaryManager::getOSSummaryRetainRule(
const FunctionDecl *FD) {
808 const RetainSummary *
809 RetainSummaryManager::getOSSummaryReleaseRule(
const FunctionDecl *FD) {
817 const RetainSummary *
818 RetainSummaryManager::getOSSummaryFreeRule(
const FunctionDecl *FD) {
826 const RetainSummary *
827 RetainSummaryManager::getOSSummaryCreateRule(
const FunctionDecl *FD) {
832 const RetainSummary *
833 RetainSummaryManager::getOSSummaryGetRule(
const FunctionDecl *FD) {
838 const RetainSummary *
839 RetainSummaryManager::getCFSummaryCreateRule(
const FunctionDecl *FD) {
841 ArgEffects(AF.getEmptyMap()));
844 const RetainSummary *
845 RetainSummaryManager::getCFSummaryGetRule(
const FunctionDecl *FD) {
847 ArgEffects(AF.getEmptyMap()),
859 RetainSummaryManager::getRetEffectFromAnnotations(
QualType RetTy,
861 if (hasAnyEnabledAttrOf<NSReturnsRetainedAttr>(D, RetTy))
862 return ObjCAllocRetE;
864 if (
auto K = hasAnyEnabledAttrOf<CFReturnsRetainedAttr, OSReturnsRetainedAttr,
865 GeneralizedReturnsRetainedAttr>(D, RetTy))
868 if (
auto K = hasAnyEnabledAttrOf<
869 CFReturnsNotRetainedAttr, OSReturnsNotRetainedAttr,
870 GeneralizedReturnsNotRetainedAttr, NSReturnsNotRetainedAttr,
871 NSReturnsAutoreleasedAttr>(D, RetTy))
874 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
875 for (
const auto *PD : MD->overridden_methods())
876 if (
auto RE = getRetEffectFromAnnotations(RetTy, PD))
884 static bool hasTypedefNamed(
QualType QT,
886 while (
auto *T = dyn_cast<TypedefType>(QT)) {
887 const auto &Context = T->getDecl()->getASTContext();
888 if (T->getDecl()->getIdentifier() == &Context.
Idents.
get(Name))
890 QT = T->getDecl()->getUnderlyingType();
896 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
898 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(ND)) {
899 return MD->getReturnType();
901 llvm_unreachable(
"Unexpected decl");
905 bool RetainSummaryManager::applyParamAnnotationEffect(
907 RetainSummaryTemplate &Template) {
910 hasAnyEnabledAttrOf<NSConsumedAttr, CFConsumedAttr, OSConsumedAttr,
911 GeneralizedConsumedAttr>(pd, QT)) {
914 }
else if (
auto K = hasAnyEnabledAttrOf<
915 CFReturnsRetainedAttr, OSReturnsRetainedAttr,
916 OSReturnsRetainedOnNonZeroAttr, OSReturnsRetainedOnZeroAttr,
917 GeneralizedReturnsRetainedAttr>(pd, QT)) {
922 QualType QT = getCallableReturnType(FD);
924 bool HasRetainedOnZero = pd->
hasAttr<OSReturnsRetainedOnZeroAttr>();
925 bool HasRetainedOnNonZero = pd->
hasAttr<OSReturnsRetainedOnNonZeroAttr>();
933 (hasTypedefNamed(QT,
"kern_return_t") && !HasRetainedOnNonZero);
936 if (ShouldSplit && SuccessOnZero) {
938 }
else if (ShouldSplit && (!SuccessOnZero || HasRetainedOnNonZero)) {
949 }
else if (
auto K = hasAnyEnabledAttrOf<CFReturnsNotRetainedAttr,
950 OSReturnsNotRetainedAttr,
951 GeneralizedReturnsNotRetainedAttr>(
957 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
958 for (
const auto *OD : MD->overridden_methods()) {
959 const ParmVarDecl *OP = OD->parameters()[parm_idx];
960 if (applyParamAnnotationEffect(OP, parm_idx, OD, Template))
969 RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
974 assert(Summ &&
"Must have a summary to add annotations to.");
975 RetainSummaryTemplate Template(Summ, *
this);
978 unsigned parm_idx = 0;
980 pe = FD->
param_end(); pi != pe; ++pi, ++parm_idx)
981 applyParamAnnotationEffect(*pi, parm_idx, FD, Template);
985 Template->setRetEffect(*RetE);
987 if (hasAnyEnabledAttrOf<OSConsumesThisAttr>(FD, RetTy))
992 RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
997 assert(Summ &&
"Must have a valid summary to add annotations to");
998 RetainSummaryTemplate Template(Summ, *
this);
1001 if (hasAnyEnabledAttrOf<NSConsumesSelfAttr>(MD, MD->
getReturnType()))
1005 unsigned parm_idx = 0;
1008 applyParamAnnotationEffect(*pi, parm_idx, MD, Template);
1012 Template->setRetEffect(*RetE);
1015 const RetainSummary *
1016 RetainSummaryManager::getStandardMethodSummary(
const ObjCMethodDecl *MD,
1055 ResultEff = ObjCInitRetE;
1063 ResultEff = ObjCAllocRetE;
1095 if (Slot.substr(Slot.size() - 8).equals_lower(
"delegate")) {
1096 if (ResultEff == ObjCInitRetE)
1106 return getDefaultSummary();
1108 return getPersistentSummary(ResultEff, ArgEffects(AF.getEmptyMap()),
1112 const RetainSummary *
1113 RetainSummaryManager::getClassMethodSummary(
const ObjCMessageExpr *ME) {
1118 ME->
getType(), ObjCClassMethodSummaries);
1121 const RetainSummary *RetainSummaryManager::getInstanceMethodSummary(
1128 if (!ReceiverType.
isNull())
1130 ReceiverClass = PT->getInterfaceDecl();
1142 if (!Method && ReceiverClass)
1145 return getMethodSummary(S, ReceiverClass, Method, ME->
getType(),
1146 ObjCMethodSummaries);
1149 const RetainSummary *
1150 RetainSummaryManager::getMethodSummary(
Selector S,
1153 ObjCMethodSummariesTy &CachedSummaries) {
1156 if (!TrackObjCAndCFObjects)
1157 return getDefaultSummary();
1160 const RetainSummary *Summ = CachedSummaries.find(ID, S);
1163 Summ = getStandardMethodSummary(MD, S, RetTy);
1166 updateSummaryFromAnnotations(Summ, MD);
1175 void RetainSummaryManager::InitializeClassMethodSummaries() {
1176 ArgEffects ScratchArgs = AF.getEmptyMap();
1179 addClassMethSummary(
"NSAssertionHandler",
"currentHandler",
1185 addClassMethSummary(
"NSAutoreleasePool",
"addObject",
1191 void RetainSummaryManager::InitializeMethodSummaries() {
1193 ArgEffects ScratchArgs = AF.getEmptyMap();
1196 const RetainSummary *InitSumm = getPersistentSummary(
1206 const RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE,
1208 const RetainSummary *CFAllocSumm =
1213 const RetainSummary *Summ = getPersistentSummary(
1218 Summ = getPersistentSummary(NoRet, ScratchArgs,
1238 const RetainSummary *NoTrackYet =
1242 addClassMethSummary(
"NSWindow",
"alloc", NoTrackYet);
1248 addClassMethSummary(
"NSPanel",
"alloc", NoTrackYet);
1253 addClassMethSummary(
"NSNull",
"null", NoTrackYet);
1257 addClassMethSummary(
"NSAutoreleasePool",
"alloc", NoTrackYet);
1258 addClassMethSummary(
"NSAutoreleasePool",
"allocWithZone", NoTrackYet,
false);
1259 addClassMethSummary(
"NSAutoreleasePool",
"new", NoTrackYet);
1262 addInstMethSummary(
"QCRenderer", AllocSumm,
"createSnapshotImageOfType");
1263 addInstMethSummary(
"QCView", AllocSumm,
"createSnapshotImageOfType");
1268 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect");
1269 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect",
1270 "format",
"colorSpace");
1271 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGLayerWithSize",
"info");
1274 const RetainSummary *
1275 RetainSummaryManager::getMethodSummary(
const ObjCMethodDecl *MD) {
1280 ObjCMethodSummariesTy *CachedSummaries;
1282 CachedSummaries = &ObjCMethodSummaries;
1284 CachedSummaries = &ObjCClassMethodSummaries;
1286 return getMethodSummary(S, ID, MD, ResultTy, *CachedSummaries);
Indicates that the tracked object is a generalized object.
Indicates that the tracked object is a CF object.
FunctionDecl * getDefinition()
Get the definition for this declaration.
Represents a function declaration or definition.
Smart pointer class that efficiently represents Objective-C method names.
ObjKind
Determines the object kind of a tracked object.
A (possibly-)qualified type.
Selector getSelector() const
ObjCInterfaceDecl * getClassInterface()
static bool isOSObjectDynamicCast(StringRef S)
Indicates that the tracked object could be a CF or Objective-C object.
The argument has its reference count decreased by 1 to model a transferred bridge cast under ARC...
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
All typestate tracking of the object ceases.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
static RetEffect MakeOwned(ObjKind o)
Decl - This represents one declaration (or definition), e.g.
The argument has its reference count increased by 1.
bool isCocoaObjectRef(QualType T)
The argument is treated as if an -autorelease message had been sent to the referenced object...
constexpr XRayInstrMask Function
Indicates that no retain count information is tracked for the return value.
param_const_iterator param_end() const
size_t param_size() const
static RetEffect MakeNoRet()
QualType getReturnType() const
const T * getAs() const
Member-template getAs<specific type>'.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a parameter to a function.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
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.
bool isObjCIdType() const
static bool isAutorelease(const FunctionDecl *FD, StringRef FName)
ArrayRef< ParmVarDecl * > parameters() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
The argument has its reference count decreased by 1.
bool followsCreateRule(const FunctionDecl *FD)
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +0 v...
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +1 v...
static bool isOSObjectSubclass(const Decl *D)
static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation)
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
Represents an ObjC class declaration.
QualType getReturnType() const
param_iterator param_begin()
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
static const RetainSummary * getSummary(RetainSummaryManager &Summaries, const CallEvent &Call, QualType ReceiverType)
The argument is treated as potentially escaping, meaning that even when its reference count hits 0 it...
static bool isOSObjectPtr(QualType QT)
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
static constexpr bool isOneOf()
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
static bool isOSObjectRelated(const CXXMethodDecl *MD)
A function is OSObject related if it is declared on a subclass of OSObject, or any of the parameters ...
The argument is treated as if the referenced object was deallocated.
static bool isRelease(const FunctionDecl *FD, StringRef FName)
bool isCFObjectRef(QualType T)
An expression that sends a message to the given Objective-C object or class.
static RetEffect MakeNotOwned(ObjKind o)
bool isInstanceMethod() const
unsigned getNumArgs() const
Selector getSelector() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
ArgEffectKind getKind() const
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
static bool isOSObjectRequiredCast(StringRef S)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
Indicates that the tracked object is an Objective-C object.
ASTContext & getASTContext() const LLVM_READONLY
Represents a static or instance method of a struct/union/class.
static bool isMakeCollectable(StringRef FName)
Performs the combined functionality of DecRef and StopTrackingHard.
const ObjCMethodDecl * getMethodDecl() const
A key identifying a summary.
StringRef getName() const
Return the actual identifier string.
Dataflow Directional Tag Classes.
bool isRefType(QualType RetTy, StringRef Prefix, StringRef Name=StringRef())
static RetEffect MakeNoRetHard()
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isKeywordSelector() const
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
param_iterator param_end()
Represents a pointer to an Objective C object.
static ArgEffect getStopTrackingHardEquivalent(ArgEffect E)
Indicates that the tracking object is a descendant of a referenced-counted OSObject, used in the Darwin kernel.
static bool classof(const OMPClause *T)
static bool isRetain(const FunctionDecl *FD, StringRef FName)
param_const_iterator param_begin() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
ArgEffect withKind(ArgEffectKind NewK)
No particular method family.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
All typestate tracking of the object ceases.
Represents a C++ struct/union/class.
Selector GetUnarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing an unary selector.
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +1 v...
static bool isOSObjectThisCast(StringRef S)
static bool isOSIteratorSubclass(const Decl *D)
static bool isISLObjectRef(QualType Ty)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static bool isSubclass(const Decl *D, StringRef ClassName)
The argument is a pointer to a retain-counted object; on exit, the new value of the pointer is a +1 v...
bool isPointerType() const
An ArgEffect summarizes the retain count behavior on an argument or receiver to a function or method...
This represents a decl that may have a name.
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
Attr - This represents one attribute.
internal::Matcher< Decl > DeclarationMatcher
Types of matchers for the top-level classes in the AST class hierarchy.
RetEffect summarizes a call's retain/release behavior with respect to its return value.