34template <
class T,
class P,
class... ToCompare>
36 return std::is_same_v<T, P> ||
isOneOf<
T, ToCompare...>();
42struct GeneralizedReturnsRetainedAttr {
43 static bool classof(
const Attr *A) {
44 if (
auto AA = dyn_cast<AnnotateAttr>(A))
45 return AA->getAnnotation() ==
"rc_ownership_returns_retained";
50struct GeneralizedReturnsNotRetainedAttr {
51 static bool classof(
const Attr *A) {
52 if (
auto AA = dyn_cast<AnnotateAttr>(A))
53 return AA->getAnnotation() ==
"rc_ownership_returns_not_retained";
58struct GeneralizedConsumedAttr {
59 static bool classof(
const Attr *A) {
60 if (
auto AA = dyn_cast<AnnotateAttr>(A))
61 return AA->getAnnotation() ==
"rc_ownership_consumed";
69std::optional<ObjKind> RetainSummaryManager::hasAnyEnabledAttrOf(
const Decl *
D,
72 if (
isOneOf<
T, CFConsumedAttr, CFReturnsRetainedAttr,
73 CFReturnsNotRetainedAttr>()) {
74 if (!TrackObjCAndCFObjects)
78 }
else if (
isOneOf<
T, NSConsumedAttr, NSConsumesSelfAttr,
79 NSReturnsAutoreleasedAttr, NSReturnsRetainedAttr,
80 NSReturnsNotRetainedAttr, NSConsumesSelfAttr>()) {
82 if (!TrackObjCAndCFObjects)
85 if (
isOneOf<
T, NSReturnsRetainedAttr, NSReturnsAutoreleasedAttr,
86 NSReturnsNotRetainedAttr>() &&
90 }
else if (
isOneOf<
T, OSConsumedAttr, OSConsumesThisAttr,
91 OSReturnsNotRetainedAttr, OSReturnsRetainedAttr,
92 OSReturnsRetainedOnZeroAttr,
93 OSReturnsRetainedOnNonZeroAttr>()) {
97 }
else if (
isOneOf<
T, GeneralizedReturnsNotRetainedAttr,
98 GeneralizedReturnsRetainedAttr,
99 GeneralizedConsumedAttr>()) {
102 llvm_unreachable(
"Unexpected attribute");
109template <
class T1,
class T2,
class... Others>
110std::optional<ObjKind> RetainSummaryManager::hasAnyEnabledAttrOf(
const Decl *
D,
112 if (
auto Out = hasAnyEnabledAttrOf<T1>(
D, QT))
114 return hasAnyEnabledAttrOf<T2, Others...>(
D, QT);
118RetainSummaryManager::getPersistentSummary(
const RetainSummary &OldSumm) {
121 ::llvm::FoldingSetNodeID
ID;
125 CachedSummaryNode *N = SimpleSummaries.FindNodeOrInsertPos(ID, Pos);
128 N = (CachedSummaryNode *) BPAlloc.Allocate<CachedSummaryNode>();
129 new (N) CachedSummaryNode(OldSumm);
130 SimpleSummaries.InsertNode(N, Pos);
133 return &N->getValue();
142 StringRef ClassName) {
143 using namespace ast_matchers;
150 using namespace ast_matchers;
164 return S ==
"requiredMetaCast";
168 return S ==
"metaCast";
177 return StringRef(Ty.
getAsString()).starts_with(
"isl_");
186 if (Ann->getAnnotation() == rcAnnotation)
193 return FName.starts_with_insensitive(
"retain") ||
194 FName.ends_with_insensitive(
"retain");
198 return FName.starts_with_insensitive(
"release") ||
199 FName.ends_with_insensitive(
"release");
203 return FName.starts_with_insensitive(
"autorelease") ||
204 FName.ends_with_insensitive(
"autorelease");
208 return FName.contains_insensitive(
"MakeCollectable");
235 if (II && II->
getName() ==
"smart_ptr")
236 if (
const auto *ND = dyn_cast<NamespaceDecl>(RD->getDeclContext()))
237 if (ND->getNameAsString() ==
"os")
243RetainSummaryManager::getSummaryForOSObject(
const FunctionDecl *FD,
245 assert(TrackOSObjects &&
246 "Requesting a summary for an OSObject but OSObjects are not tracked");
253 return getDefaultSummary();
258 if (FName.ends_with(
"Matching")) {
259 return getPersistentStopSummary();
264 if ((!FName.starts_with(
"get") && !FName.starts_with(
"Get")) ||
266 return getOSSummaryCreateRule(FD);
268 return getOSSummaryGetRule(FD);
273 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
276 if (FName ==
"release" || FName ==
"taggedRelease")
277 return getOSSummaryReleaseRule(FD);
279 if (FName ==
"retain" || FName ==
"taggedRetain")
280 return getOSSummaryRetainRule(FD);
283 return getOSSummaryFreeRule(FD);
285 if (MD->getOverloadedOperator() == OO_New)
286 return getOSSummaryCreateRule(MD);
293const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
298 bool &AllowAnnotations) {
303 if (FName ==
"pthread_create" || FName ==
"pthread_setspecific") {
307 return getPersistentStopSummary();
308 }
else if(FName ==
"NSMakeCollectable") {
310 AllowAnnotations =
false;
312 : getPersistentStopSummary();
313 }
else if (FName ==
"CMBufferQueueDequeueAndRetain" ||
314 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
321 }
else if (FName ==
"CFPlugInInstanceCreate") {
323 }
else if (FName ==
"IORegistryEntrySearchCFProperty" ||
324 (RetTyName ==
"CFMutableDictionaryRef" &&
325 (FName ==
"IOBSDNameMatching" || FName ==
"IOServiceMatching" ||
326 FName ==
"IOServiceNameMatching" ||
327 FName ==
"IORegistryEntryIDMatching" ||
328 FName ==
"IOOpenFirmwarePathMatching"))) {
333 }
else if (FName ==
"IOServiceGetMatchingService" ||
334 FName ==
"IOServiceGetMatchingServices") {
341 }
else if (FName ==
"IOServiceAddNotification" ||
342 FName ==
"IOServiceAddMatchingNotification") {
349 }
else if (FName ==
"CVPixelBufferCreateWithBytes") {
360 }
else if (FName ==
"CGBitmapContextCreateWithData") {
368 }
else if (FName ==
"CVPixelBufferCreateWithPlanarBytes") {
374 }
else if (FName ==
"VTCompressionSessionEncodeFrame" ||
375 FName ==
"VTCompressionSessionEncodeMultiImageFrame") {
385 }
else if (FName ==
"dispatch_set_context" ||
386 FName ==
"xpc_connection_set_context") {
395 }
else if (FName.starts_with(
"NSLog")) {
396 return getDoNothingSummary();
397 }
else if (FName.starts_with(
"NS") && FName.contains(
"Insert")) {
416 AllowAnnotations =
false;
418 return getUnarySummary(FT,
IncRef);
422 AllowAnnotations =
false;
426 AllowAnnotations =
false;
429 return getCFCreateGetRuleSummary(FD);
437 return getUnarySummary(FT,
IncRef);
439 return getCFCreateGetRuleSummary(FD);
446 return getCFCreateGetRuleSummary(FD);
449 if (FD->
hasAttr<CFAuditedTransferAttr>()) {
450 return getCFCreateGetRuleSummary(FD);
456 if (FName.starts_with(
"CG") || FName.starts_with(
"CF")) {
458 FName = FName.substr(FName.starts_with(
"CGCF") ? 4 : 2);
461 return getUnarySummary(FT,
DecRef);
463 assert(ScratchArgs.isEmpty());
480 (StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
481 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
482 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
483 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
484 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos)
497RetainSummaryManager::generateSummary(
const FunctionDecl *FD,
498 bool &AllowAnnotations) {
501 return getPersistentStopSummary();
505 StringRef FName = II ? II->
getName() :
"";
509 FName = FName.substr(FName.find_first_not_of(
'_'));
516 if (
const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
519 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
527 if (TrackObjCAndCFObjects)
529 getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
532 return getDefaultSummary();
536RetainSummaryManager::getFunctionSummary(
const FunctionDecl *FD) {
539 return getDefaultSummary();
542 FuncSummariesTy::iterator I = FuncSummaries.find(FD);
543 if (I != FuncSummaries.end())
547 bool AllowAnnotations =
true;
548 const RetainSummary *S = generateSummary(FD, AllowAnnotations);
551 if (AllowAnnotations)
552 updateSummaryFromAnnotations(S, FD);
554 FuncSummaries[FD] = S;
563 switch (
E.getKind()) {
583 llvm_unreachable(
"Unknown ArgEffect kind");
587RetainSummaryManager::updateSummaryForNonZeroCallbackArg(
const RetainSummary *S,
593 ArgEffects CustomArgEffects = S->getArgEffects();
594 for (ArgEffects::iterator I = CustomArgEffects.begin(),
595 E = CustomArgEffects.end();
599 ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
612 if (Name->isStr(
"CGBitmapContextCreateWithData") ||
613 Name->isStr(
"dispatch_data_create"))
614 RE = S->getRetEffect();
617 return getPersistentSummary(RE, ScratchArgs, RecEffect, DefEffect);
620void RetainSummaryManager::updateSummaryForReceiverUnconsumedSelf(
630void RetainSummaryManager::updateSummaryForArgumentTypes(
634 unsigned parm_idx = 0;
635 for (
auto pi =
C.param_begin(), pe =
C.param_end(); pi != pe;
656 Template->addArg(AF, parm_idx,
663 bool HasNonZeroCallbackArg,
664 bool IsReceiverUnconsumedSelf,
667 switch (
C.getKind()) {
673 Summ = getFunctionSummary(cast_or_null<FunctionDecl>(
C.getDecl()));
678 return getPersistentStopSummary();
680 const auto *ME = cast_or_null<ObjCMessageExpr>(
C.getExpr());
682 Summ = getMethodSummary(cast<ObjCMethodDecl>(
C.getDecl()));
683 }
else if (ME->isInstanceMessage()) {
684 Summ = getInstanceMethodSummary(ME, ReceiverType);
686 Summ = getClassMethodSummary(ME);
692 if (HasNonZeroCallbackArg)
693 Summ = updateSummaryForNonZeroCallbackArg(Summ,
C);
695 if (IsReceiverUnconsumedSelf)
696 updateSummaryForReceiverUnconsumedSelf(Summ);
698 updateSummaryForArgumentTypes(
C, Summ);
700 assert(Summ &&
"Unknown call type?");
706RetainSummaryManager::getCFCreateGetRuleSummary(
const FunctionDecl *FD) {
708 return getCFSummaryCreateRule(FD);
710 return getCFSummaryGetRule(FD);
718std::optional<RetainSummaryManager::BehaviorSummary>
720 bool &hasTrustedImplementationAnnotation) {
726 StringRef FName = II->
getName();
727 FName = FName.substr(FName.find_first_not_of(
'_'));
731 if (II->
isStr(
"NSMakeCollectable"))
737 if (FName ==
"CMBufferQueueDequeueAndRetain" ||
738 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
756 if (TrackOSObjects) {
762 !cast<CXXMethodDecl>(FD)->isStatic()) {
769 hasTrustedImplementationAnnotation =
true;
774 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
777 if (FName ==
"release" || FName ==
"retain")
785RetainSummaryManager::getUnarySummary(
const FunctionType* FT,
795 return getPersistentStopSummary();
799 ScratchArgs = AF.add(ScratchArgs, 0, Effect);
806RetainSummaryManager::getOSSummaryRetainRule(
const FunctionDecl *FD) {
815RetainSummaryManager::getOSSummaryReleaseRule(
const FunctionDecl *FD) {
824RetainSummaryManager::getOSSummaryFreeRule(
const FunctionDecl *FD) {
833RetainSummaryManager::getOSSummaryCreateRule(
const FunctionDecl *FD) {
839RetainSummaryManager::getOSSummaryGetRule(
const FunctionDecl *FD) {
845RetainSummaryManager::getCFSummaryCreateRule(
const FunctionDecl *FD) {
851RetainSummaryManager::getCFSummaryGetRule(
const FunctionDecl *FD) {
864std::optional<RetEffect>
865RetainSummaryManager::getRetEffectFromAnnotations(
QualType RetTy,
867 if (hasAnyEnabledAttrOf<NSReturnsRetainedAttr>(
D, RetTy))
868 return ObjCAllocRetE;
870 if (
auto K = hasAnyEnabledAttrOf<CFReturnsRetainedAttr, OSReturnsRetainedAttr,
871 GeneralizedReturnsRetainedAttr>(
D, RetTy))
874 if (
auto K = hasAnyEnabledAttrOf<
875 CFReturnsNotRetainedAttr, OSReturnsNotRetainedAttr,
876 GeneralizedReturnsNotRetainedAttr, NSReturnsNotRetainedAttr,
877 NSReturnsAutoreleasedAttr>(
D, RetTy))
880 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D))
881 for (
const auto *PD : MD->overridden_methods())
882 if (
auto RE = getRetEffectFromAnnotations(RetTy, PD))
893 const auto &Context =
T->getDecl()->getASTContext();
894 if (
T->getDecl()->getIdentifier() == &Context.
Idents.
get(Name))
896 QT =
T->getDecl()->getUnderlyingType();
902 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
904 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(ND)) {
905 return MD->getReturnType();
907 llvm_unreachable(
"Unexpected decl");
911bool RetainSummaryManager::applyParamAnnotationEffect(
916 hasAnyEnabledAttrOf<NSConsumedAttr, CFConsumedAttr, OSConsumedAttr,
917 GeneralizedConsumedAttr>(pd, QT)) {
920 }
else if (
auto K = hasAnyEnabledAttrOf<
921 CFReturnsRetainedAttr, OSReturnsRetainedAttr,
922 OSReturnsRetainedOnNonZeroAttr, OSReturnsRetainedOnZeroAttr,
923 GeneralizedReturnsRetainedAttr>(pd, QT)) {
930 bool HasRetainedOnZero = pd->
hasAttr<OSReturnsRetainedOnZeroAttr>();
931 bool HasRetainedOnNonZero = pd->
hasAttr<OSReturnsRetainedOnNonZeroAttr>();
942 if (ShouldSplit && SuccessOnZero) {
944 }
else if (ShouldSplit && (!SuccessOnZero || HasRetainedOnNonZero)) {
955 }
else if (
auto K = hasAnyEnabledAttrOf<CFReturnsNotRetainedAttr,
956 OSReturnsNotRetainedAttr,
957 GeneralizedReturnsNotRetainedAttr>(
963 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
964 for (
const auto *OD : MD->overridden_methods()) {
965 const ParmVarDecl *OP = OD->parameters()[parm_idx];
966 if (applyParamAnnotationEffect(OP, parm_idx, OD, Template))
975RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
980 assert(Summ &&
"Must have a summary to add annotations to.");
984 unsigned parm_idx = 0;
986 pe = FD->
param_end(); pi != pe; ++pi, ++parm_idx)
987 applyParamAnnotationEffect(*pi, parm_idx, FD, Template);
990 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, FD))
993 if (hasAnyEnabledAttrOf<OSConsumesThisAttr>(FD, RetTy))
998RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
1003 assert(Summ &&
"Must have a valid summary to add annotations to");
1007 if (hasAnyEnabledAttrOf<NSConsumesSelfAttr>(MD, MD->
getReturnType()))
1011 unsigned parm_idx = 0;
1014 applyParamAnnotationEffect(*pi, parm_idx, MD, Template);
1017 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, MD))
1022RetainSummaryManager::getStandardMethodSummary(
const ObjCMethodDecl *MD,
1044 switch (S.getMethodFamily()) {
1061 ResultEff = ObjCInitRetE;
1069 ResultEff = ObjCAllocRetE;
1098 if (S.isKeywordSelector()) {
1099 for (
unsigned i = 0, e = S.getNumArgs(); i != e; ++i) {
1100 StringRef Slot = S.getNameForSlot(i);
1101 if (Slot.ends_with_insensitive(
"delegate")) {
1102 if (ResultEff == ObjCInitRetE)
1112 return getDefaultSummary();
1114 return getPersistentSummary(ResultEff,
ArgEffects(AF.getEmptyMap()),
1119RetainSummaryManager::getClassMethodSummary(
const ObjCMessageExpr *ME) {
1124 ME->
getType(), ObjCClassMethodSummaries);
1127const RetainSummary *RetainSummaryManager::getInstanceMethodSummary(
1134 if (!ReceiverType.
isNull())
1136 ReceiverClass = PT->getInterfaceDecl();
1148 if (!Method && ReceiverClass)
1151 return getMethodSummary(S, ReceiverClass, Method, ME->
getType(),
1152 ObjCMethodSummaries);
1156RetainSummaryManager::getMethodSummary(
Selector S,
1159 ObjCMethodSummariesTy &CachedSummaries) {
1162 if (!TrackObjCAndCFObjects)
1163 return getDefaultSummary();
1169 Summ = getStandardMethodSummary(MD, S, RetTy);
1172 updateSummaryFromAnnotations(Summ, MD);
1181void RetainSummaryManager::InitializeClassMethodSummaries() {
1185 addClassMethSummary(
"NSAssertionHandler",
"currentHandler",
1191 addClassMethSummary(
"NSAutoreleasePool",
"addObject",
1197void RetainSummaryManager::InitializeMethodSummaries() {
1212 const RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE,
1224 Summ = getPersistentSummary(NoRet, ScratchArgs,
1246 addClassMethSummary(
"NSWindow",
"alloc", NoTrackYet);
1252 addClassMethSummary(
"NSPanel",
"alloc", NoTrackYet);
1256 addClassMethSummary(
"NSNull",
"null", NoTrackYet);
1260 addClassMethSummary(
"NSAutoreleasePool",
"alloc", NoTrackYet);
1261 addClassMethSummary(
"NSAutoreleasePool",
"allocWithZone", NoTrackYet,
false);
1262 addClassMethSummary(
"NSAutoreleasePool",
"new", NoTrackYet);
1265 addInstMethSummary(
"QCRenderer", AllocSumm,
"createSnapshotImageOfType");
1266 addInstMethSummary(
"QCView", AllocSumm,
"createSnapshotImageOfType");
1271 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect");
1272 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect",
1273 "format",
"colorSpace");
1274 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGLayerWithSize",
"info");
1278RetainSummaryManager::getMethodSummary(
const ObjCMethodDecl *MD) {
1283 ObjCMethodSummariesTy *CachedSummaries;
1285 CachedSummaries = &ObjCMethodSummaries;
1287 CachedSummaries = &ObjCClassMethodSummaries;
1289 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.
void setRetEffect(RetEffect E)
setRetEffect - Set the effect of the return value of the call.
void addArg(ArgEffects::Factory &af, unsigned idx, ArgEffect e)
bool isSimple() const
A retain summary is simple if it has no ArgEffects other than the default.
ArgEffects getArgEffects() const
void setThisEffect(ArgEffect e)
Set the effect of the method on "this".
void setReceiverEffect(ArgEffect e)
Sets the effect on the receiver of the message.
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.
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.