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;
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();
141 StringRef ClassName) {
142 using namespace ast_matchers;
149 using namespace ast_matchers;
162 return S ==
"requiredMetaCast";
166 return S ==
"metaCast";
175 return StringRef(Ty.
getAsString()).starts_with(
"isl_");
184 if (Ann->getAnnotation() == rcAnnotation)
191 return FName.starts_with_insensitive(
"retain") ||
192 FName.ends_with_insensitive(
"retain");
196 return FName.starts_with_insensitive(
"release") ||
197 FName.ends_with_insensitive(
"release");
201 return FName.starts_with_insensitive(
"autorelease") ||
202 FName.ends_with_insensitive(
"autorelease");
206 return FName.contains_insensitive(
"MakeCollectable");
233 if (II && II->
getName() ==
"smart_ptr")
234 if (
const auto *ND = dyn_cast<NamespaceDecl>(RD->getDeclContext()))
235 if (ND->getNameAsString() ==
"os")
241RetainSummaryManager::getSummaryForOSObject(
const FunctionDecl *FD,
243 assert(TrackOSObjects &&
244 "Requesting a summary for an OSObject but OSObjects are not tracked");
251 return getDefaultSummary();
256 if (FName.ends_with(
"Matching")) {
257 return getPersistentStopSummary();
262 if ((!FName.starts_with(
"get") && !FName.starts_with(
"Get")) ||
264 return getOSSummaryCreateRule(FD);
266 return getOSSummaryGetRule(FD);
271 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
274 if (FName ==
"release" || FName ==
"taggedRelease")
275 return getOSSummaryReleaseRule(FD);
277 if (FName ==
"retain" || FName ==
"taggedRetain")
278 return getOSSummaryRetainRule(FD);
281 return getOSSummaryFreeRule(FD);
283 if (MD->getOverloadedOperator() == OO_New)
284 return getOSSummaryCreateRule(MD);
291const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
296 bool &AllowAnnotations) {
301 if (FName ==
"pthread_create" || FName ==
"pthread_setspecific") {
305 return getPersistentStopSummary();
306 }
else if(FName ==
"NSMakeCollectable") {
308 AllowAnnotations =
false;
310 : getPersistentStopSummary();
311 }
else if (FName ==
"CMBufferQueueDequeueAndRetain" ||
312 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
319 }
else if (FName ==
"CFPlugInInstanceCreate") {
321 }
else if (FName ==
"IORegistryEntrySearchCFProperty" ||
322 (RetTyName ==
"CFMutableDictionaryRef" &&
323 (FName ==
"IOBSDNameMatching" || FName ==
"IOServiceMatching" ||
324 FName ==
"IOServiceNameMatching" ||
325 FName ==
"IORegistryEntryIDMatching" ||
326 FName ==
"IOOpenFirmwarePathMatching"))) {
331 }
else if (FName ==
"IOServiceGetMatchingService" ||
332 FName ==
"IOServiceGetMatchingServices") {
339 }
else if (FName ==
"IOServiceAddNotification" ||
340 FName ==
"IOServiceAddMatchingNotification") {
347 }
else if (FName ==
"CVPixelBufferCreateWithBytes") {
358 }
else if (FName ==
"CGBitmapContextCreateWithData") {
366 }
else if (FName ==
"CVPixelBufferCreateWithPlanarBytes") {
372 }
else if (FName ==
"VTCompressionSessionEncodeFrame" ||
373 FName ==
"VTCompressionSessionEncodeMultiImageFrame") {
383 }
else if (FName ==
"dispatch_set_context" ||
384 FName ==
"xpc_connection_set_context") {
393 }
else if (FName.starts_with(
"NSLog")) {
394 return getDoNothingSummary();
395 }
else if (FName.starts_with(
"NS") && FName.contains(
"Insert")) {
414 AllowAnnotations =
false;
416 return getUnarySummary(FT,
IncRef);
420 AllowAnnotations =
false;
424 AllowAnnotations =
false;
427 return getCFCreateGetRuleSummary(FD);
435 return getUnarySummary(FT,
IncRef);
437 return getCFCreateGetRuleSummary(FD);
444 return getCFCreateGetRuleSummary(FD);
447 if (FD->
hasAttr<CFAuditedTransferAttr>()) {
448 return getCFCreateGetRuleSummary(FD);
454 if (FName.starts_with(
"CG") || FName.starts_with(
"CF")) {
456 FName = FName.substr(FName.starts_with(
"CGCF") ? 4 : 2);
459 return getUnarySummary(FT,
DecRef);
461 assert(ScratchArgs.isEmpty());
478 (StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
479 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
480 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
481 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
482 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos)
495RetainSummaryManager::generateSummary(
const FunctionDecl *FD,
496 bool &AllowAnnotations) {
499 return getPersistentStopSummary();
503 StringRef FName = II ? II->
getName() :
"";
507 FName = FName.substr(FName.find_first_not_of(
'_'));
514 if (
const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
517 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
525 if (TrackObjCAndCFObjects)
527 getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
530 return getDefaultSummary();
534RetainSummaryManager::getFunctionSummary(
const FunctionDecl *FD) {
537 return getDefaultSummary();
540 FuncSummariesTy::iterator I = FuncSummaries.find(FD);
541 if (I != FuncSummaries.end())
545 bool AllowAnnotations =
true;
546 const RetainSummary *S = generateSummary(FD, AllowAnnotations);
549 if (AllowAnnotations)
550 updateSummaryFromAnnotations(S, FD);
552 FuncSummaries[FD] = S;
561 switch (
E.getKind()) {
581 llvm_unreachable(
"Unknown ArgEffect kind");
585RetainSummaryManager::updateSummaryForNonZeroCallbackArg(
const RetainSummary *S,
591 ArgEffects CustomArgEffects = S->getArgEffects();
592 for (ArgEffects::iterator I = CustomArgEffects.begin(),
593 E = CustomArgEffects.end();
597 ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
610 if (Name->isStr(
"CGBitmapContextCreateWithData") ||
611 Name->isStr(
"dispatch_data_create"))
612 RE = S->getRetEffect();
615 return getPersistentSummary(RE, ScratchArgs, RecEffect, DefEffect);
618void RetainSummaryManager::updateSummaryForReceiverUnconsumedSelf(
628void RetainSummaryManager::updateSummaryForArgumentTypes(
632 unsigned parm_idx = 0;
633 for (
auto pi =
C.param_begin(), pe =
C.param_end(); pi != pe;
661 bool HasNonZeroCallbackArg,
662 bool IsReceiverUnconsumedSelf,
665 switch (
C.getKind()) {
671 Summ = getFunctionSummary(cast_or_null<FunctionDecl>(
C.getDecl()));
676 return getPersistentStopSummary();
678 const auto *ME = cast_or_null<ObjCMessageExpr>(
C.getExpr());
680 Summ = getMethodSummary(cast<ObjCMethodDecl>(
C.getDecl()));
681 }
else if (ME->isInstanceMessage()) {
682 Summ = getInstanceMethodSummary(ME, ReceiverType);
684 Summ = getClassMethodSummary(ME);
690 if (HasNonZeroCallbackArg)
691 Summ = updateSummaryForNonZeroCallbackArg(Summ,
C);
693 if (IsReceiverUnconsumedSelf)
694 updateSummaryForReceiverUnconsumedSelf(Summ);
696 updateSummaryForArgumentTypes(
C, Summ);
698 assert(Summ &&
"Unknown call type?");
704RetainSummaryManager::getCFCreateGetRuleSummary(
const FunctionDecl *FD) {
706 return getCFSummaryCreateRule(FD);
708 return getCFSummaryGetRule(FD);
716std::optional<RetainSummaryManager::BehaviorSummary>
718 bool &hasTrustedImplementationAnnotation) {
724 StringRef FName = II->
getName();
725 FName = FName.substr(FName.find_first_not_of(
'_'));
729 if (II->
isStr(
"NSMakeCollectable"))
735 if (FName ==
"CMBufferQueueDequeueAndRetain" ||
736 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
754 if (TrackOSObjects) {
760 !cast<CXXMethodDecl>(FD)->isStatic()) {
767 hasTrustedImplementationAnnotation =
true;
772 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
775 if (FName ==
"release" || FName ==
"retain")
783RetainSummaryManager::getUnarySummary(
const FunctionType* FT,
793 return getPersistentStopSummary();
797 ScratchArgs = AF.add(ScratchArgs, 0, Effect);
804RetainSummaryManager::getOSSummaryRetainRule(
const FunctionDecl *FD) {
813RetainSummaryManager::getOSSummaryReleaseRule(
const FunctionDecl *FD) {
822RetainSummaryManager::getOSSummaryFreeRule(
const FunctionDecl *FD) {
831RetainSummaryManager::getOSSummaryCreateRule(
const FunctionDecl *FD) {
837RetainSummaryManager::getOSSummaryGetRule(
const FunctionDecl *FD) {
843RetainSummaryManager::getCFSummaryCreateRule(
const FunctionDecl *FD) {
849RetainSummaryManager::getCFSummaryGetRule(
const FunctionDecl *FD) {
862std::optional<RetEffect>
863RetainSummaryManager::getRetEffectFromAnnotations(
QualType RetTy,
865 if (hasAnyEnabledAttrOf<NSReturnsRetainedAttr>(
D, RetTy))
866 return ObjCAllocRetE;
868 if (
auto K = hasAnyEnabledAttrOf<CFReturnsRetainedAttr, OSReturnsRetainedAttr,
869 GeneralizedReturnsRetainedAttr>(
D, RetTy))
872 if (
auto K = hasAnyEnabledAttrOf<
873 CFReturnsNotRetainedAttr, OSReturnsNotRetainedAttr,
874 GeneralizedReturnsNotRetainedAttr, NSReturnsNotRetainedAttr,
875 NSReturnsAutoreleasedAttr>(
D, RetTy))
878 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D))
879 for (
const auto *PD : MD->overridden_methods())
880 if (
auto RE = getRetEffectFromAnnotations(RetTy, PD))
891 const auto &Context =
T->getDecl()->getASTContext();
892 if (
T->getDecl()->getIdentifier() == &Context.
Idents.
get(Name))
894 QT =
T->getDecl()->getUnderlyingType();
900 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
902 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(ND)) {
903 return MD->getReturnType();
905 llvm_unreachable(
"Unexpected decl");
909bool RetainSummaryManager::applyParamAnnotationEffect(
914 hasAnyEnabledAttrOf<NSConsumedAttr, CFConsumedAttr, OSConsumedAttr,
915 GeneralizedConsumedAttr>(pd, QT)) {
918 }
else if (
auto K = hasAnyEnabledAttrOf<
919 CFReturnsRetainedAttr, OSReturnsRetainedAttr,
920 OSReturnsRetainedOnNonZeroAttr, OSReturnsRetainedOnZeroAttr,
921 GeneralizedReturnsRetainedAttr>(pd, QT)) {
928 bool HasRetainedOnZero = pd->
hasAttr<OSReturnsRetainedOnZeroAttr>();
929 bool HasRetainedOnNonZero = pd->
hasAttr<OSReturnsRetainedOnNonZeroAttr>();
940 if (ShouldSplit && SuccessOnZero) {
942 }
else if (ShouldSplit && (!SuccessOnZero || HasRetainedOnNonZero)) {
953 }
else if (
auto K = hasAnyEnabledAttrOf<CFReturnsNotRetainedAttr,
954 OSReturnsNotRetainedAttr,
955 GeneralizedReturnsNotRetainedAttr>(
961 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
962 for (
const auto *OD : MD->overridden_methods()) {
963 const ParmVarDecl *OP = OD->parameters()[parm_idx];
964 if (applyParamAnnotationEffect(OP, parm_idx, OD,
Template))
973RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
978 assert(Summ &&
"Must have a summary to add annotations to.");
982 unsigned parm_idx = 0;
984 pe = FD->
param_end(); pi != pe; ++pi, ++parm_idx)
985 applyParamAnnotationEffect(*pi, parm_idx, FD,
Template);
988 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, FD))
991 if (hasAnyEnabledAttrOf<OSConsumesThisAttr>(FD, RetTy))
996RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
1001 assert(Summ &&
"Must have a valid summary to add annotations to");
1005 if (hasAnyEnabledAttrOf<NSConsumesSelfAttr>(MD, MD->
getReturnType()))
1009 unsigned parm_idx = 0;
1012 applyParamAnnotationEffect(*pi, parm_idx, MD,
Template);
1015 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, MD))
1020RetainSummaryManager::getStandardMethodSummary(
const ObjCMethodDecl *MD,
1042 switch (S.getMethodFamily()) {
1059 ResultEff = ObjCInitRetE;
1067 ResultEff = ObjCAllocRetE;
1096 if (S.isKeywordSelector()) {
1097 for (
unsigned i = 0, e = S.getNumArgs(); i != e; ++i) {
1098 StringRef Slot = S.getNameForSlot(i);
1099 if (Slot.ends_with_insensitive(
"delegate")) {
1100 if (ResultEff == ObjCInitRetE)
1110 return getDefaultSummary();
1112 return getPersistentSummary(ResultEff,
ArgEffects(AF.getEmptyMap()),
1117RetainSummaryManager::getClassMethodSummary(
const ObjCMessageExpr *ME) {
1122 ME->
getType(), ObjCClassMethodSummaries);
1125const RetainSummary *RetainSummaryManager::getInstanceMethodSummary(
1132 if (!ReceiverType.
isNull())
1134 ReceiverClass = PT->getInterfaceDecl();
1146 if (!
Method && ReceiverClass)
1149 return getMethodSummary(S, ReceiverClass,
Method, ME->
getType(),
1150 ObjCMethodSummaries);
1154RetainSummaryManager::getMethodSummary(
Selector S,
1157 ObjCMethodSummariesTy &CachedSummaries) {
1160 if (!TrackObjCAndCFObjects)
1161 return getDefaultSummary();
1167 Summ = getStandardMethodSummary(MD, S, RetTy);
1170 updateSummaryFromAnnotations(Summ, MD);
1179void RetainSummaryManager::InitializeClassMethodSummaries() {
1183 addClassMethSummary(
"NSAssertionHandler",
"currentHandler",
1189 addClassMethSummary(
"NSAutoreleasePool",
"addObject",
1195void RetainSummaryManager::InitializeMethodSummaries() {
1210 const RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE,
1222 Summ = getPersistentSummary(NoRet, ScratchArgs,
1244 addClassMethSummary(
"NSWindow",
"alloc", NoTrackYet);
1250 addClassMethSummary(
"NSPanel",
"alloc", NoTrackYet);
1254 addClassMethSummary(
"NSNull",
"null", NoTrackYet);
1258 addClassMethSummary(
"NSAutoreleasePool",
"alloc", NoTrackYet);
1259 addClassMethSummary(
"NSAutoreleasePool",
"allocWithZone", NoTrackYet,
false);
1260 addClassMethSummary(
"NSAutoreleasePool",
"new", NoTrackYet);
1263 addInstMethSummary(
"QCRenderer", AllocSumm,
"createSnapshotImageOfType");
1264 addInstMethSummary(
"QCView", AllocSumm,
"createSnapshotImageOfType");
1269 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect");
1270 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect",
1271 "format",
"colorSpace");
1272 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGLayerWithSize",
"info");
1276RetainSummaryManager::getMethodSummary(
const ObjCMethodDecl *MD) {
1281 ObjCMethodSummariesTy *CachedSummaries;
1283 CachedSummaries = &ObjCMethodSummaries;
1285 CachedSummaries = &ObjCClassMethodSummaries;
1287 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 isOSObjectRelated(const CXXMethodDecl *MD)
A function is OSObject related if it is declared on a subclass of OSObject, or any of the parameters ...
static bool isISLObjectRef(QualType Ty)
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 isOSObjectPtr(QualType QT)
static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation)
static bool isOSObjectSubclass(const Decl *D)
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.
Attr - This represents one attribute.
Represents a static or instance method of a struct/union/class.
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.
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.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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
Represents an ObjC class declaration.
An expression that sends a message to the given Objective-C object or class.
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
ObjCMethodDecl - Represents an instance or class method declaration.
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()
Represents a pointer to an Objective C object.
Represents a parameter to a function.
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)
Smart pointer class that efficiently represents Objective-C method names.
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.
ArgEffectKind getKind() const
A key identifying a summary.
RetEffect summarizes a call's retain/release behavior with respect to its return value.
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={})
Summary for a function with respect to ownership changes.
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.
bool NoRet(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
@ 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.
const FunctionProtoType * T
@ Class
The "class" keyword introduces the elaborated-type-specifier.