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;
157 return D &&
isSubclass(D,
"OSMetaClassBase") &&
164 return S ==
"requiredMetaCast";
168 return S ==
"metaCast";
177 return StringRef(Ty.
getAsString()).startswith(
"isl_");
186 if (Ann->getAnnotation() == rcAnnotation)
193 return FName.startswith_insensitive(
"retain") ||
194 FName.endswith_insensitive(
"retain");
198 return FName.startswith_insensitive(
"release") ||
199 FName.endswith_insensitive(
"release");
203 return FName.startswith_insensitive(
"autorelease") ||
204 FName.endswith_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.endswith(
"Matching")) {
259 return getPersistentStopSummary();
264 if ((!FName.startswith(
"get") && !FName.startswith(
"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") {
306 return getPersistentStopSummary();
307 }
else if(FName ==
"NSMakeCollectable") {
309 AllowAnnotations =
false;
311 : getPersistentStopSummary();
312 }
else if (FName ==
"CMBufferQueueDequeueAndRetain" ||
313 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") {
340 }
else if (FName ==
"IOServiceAddNotification" ||
341 FName ==
"IOServiceAddMatchingNotification") {
348 }
else if (FName ==
"CVPixelBufferCreateWithBytes") {
359 }
else if (FName ==
"CGBitmapContextCreateWithData") {
367 }
else if (FName ==
"CVPixelBufferCreateWithPlanarBytes") {
377 }
else if (FName ==
"VTCompressionSessionEncodeFrame") {
387 }
else if (FName ==
"dispatch_set_context" ||
388 FName ==
"xpc_connection_set_context") {
399 }
else if (FName.startswith(
"NSLog")) {
400 return getDoNothingSummary();
401 }
else if (FName.startswith(
"NS") && FName.contains(
"Insert")) {
420 AllowAnnotations =
false;
422 return getUnarySummary(FT,
IncRef);
426 AllowAnnotations =
false;
430 AllowAnnotations =
false;
433 return getCFCreateGetRuleSummary(FD);
441 return getUnarySummary(FT,
IncRef);
443 return getCFCreateGetRuleSummary(FD);
450 return getCFCreateGetRuleSummary(FD);
453 if (FD->
hasAttr<CFAuditedTransferAttr>()) {
454 return getCFCreateGetRuleSummary(FD);
460 if (FName.startswith(
"CG") || FName.startswith(
"CF")) {
462 FName = FName.substr(FName.startswith(
"CGCF") ? 4 : 2);
465 return getUnarySummary(FT,
DecRef);
467 assert(ScratchArgs.isEmpty());
484 (StrInStrNoCase(FName,
"InsertValue") != StringRef::npos ||
485 StrInStrNoCase(FName,
"AddValue") != StringRef::npos ||
486 StrInStrNoCase(FName,
"SetValue") != StringRef::npos ||
487 StrInStrNoCase(FName,
"AppendValue") != StringRef::npos ||
488 StrInStrNoCase(FName,
"SetAttribute") != StringRef::npos)
501RetainSummaryManager::generateSummary(
const FunctionDecl *FD,
502 bool &AllowAnnotations) {
505 return getPersistentStopSummary();
509 StringRef FName = II ? II->
getName() :
"";
513 FName = FName.substr(FName.find_first_not_of(
'_'));
520 if (
const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
523 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
531 if (TrackObjCAndCFObjects)
533 getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
536 return getDefaultSummary();
540RetainSummaryManager::getFunctionSummary(
const FunctionDecl *FD) {
543 return getDefaultSummary();
546 FuncSummariesTy::iterator I = FuncSummaries.find(FD);
547 if (I != FuncSummaries.end())
551 bool AllowAnnotations =
true;
552 const RetainSummary *S = generateSummary(FD, AllowAnnotations);
555 if (AllowAnnotations)
556 updateSummaryFromAnnotations(S, FD);
558 FuncSummaries[FD] = S;
587 llvm_unreachable(
"Unknown ArgEffect kind");
591RetainSummaryManager::updateSummaryForNonZeroCallbackArg(
const RetainSummary *S,
597 ArgEffects CustomArgEffects = S->getArgEffects();
598 for (ArgEffects::iterator I = CustomArgEffects.begin(),
599 E = CustomArgEffects.end();
603 ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
616 if (Name->isStr(
"CGBitmapContextCreateWithData") ||
617 Name->isStr(
"dispatch_data_create"))
618 RE = S->getRetEffect();
621 return getPersistentSummary(RE, ScratchArgs, RecEffect, DefEffect);
624void RetainSummaryManager::updateSummaryForReceiverUnconsumedSelf(
634void RetainSummaryManager::updateSummaryForArgumentTypes(
638 unsigned parm_idx = 0;
639 for (
auto pi =
C.param_begin(), pe =
C.param_end(); pi != pe;
660 Template->addArg(AF, parm_idx,
667 bool HasNonZeroCallbackArg,
668 bool IsReceiverUnconsumedSelf,
671 switch (
C.getKind()) {
677 Summ = getFunctionSummary(cast_or_null<FunctionDecl>(
C.getDecl()));
682 return getPersistentStopSummary();
684 const auto *ME = cast_or_null<ObjCMessageExpr>(
C.getExpr());
686 Summ = getMethodSummary(cast<ObjCMethodDecl>(
C.getDecl()));
687 }
else if (ME->isInstanceMessage()) {
688 Summ = getInstanceMethodSummary(ME, ReceiverType);
690 Summ = getClassMethodSummary(ME);
696 if (HasNonZeroCallbackArg)
697 Summ = updateSummaryForNonZeroCallbackArg(Summ,
C);
699 if (IsReceiverUnconsumedSelf)
700 updateSummaryForReceiverUnconsumedSelf(Summ);
702 updateSummaryForArgumentTypes(
C, Summ);
704 assert(Summ &&
"Unknown call type?");
710RetainSummaryManager::getCFCreateGetRuleSummary(
const FunctionDecl *FD) {
712 return getCFSummaryCreateRule(FD);
714 return getCFSummaryGetRule(FD);
722std::optional<RetainSummaryManager::BehaviorSummary>
724 bool &hasTrustedImplementationAnnotation) {
730 StringRef FName = II->
getName();
731 FName = FName.substr(FName.find_first_not_of(
'_'));
735 if (II->
isStr(
"NSMakeCollectable"))
741 if (FName ==
"CMBufferQueueDequeueAndRetain" ||
742 FName ==
"CMBufferQueueDequeueIfDataReadyAndRetain") {
760 if (TrackOSObjects) {
766 !cast<CXXMethodDecl>(FD)->isStatic()) {
773 hasTrustedImplementationAnnotation =
true;
778 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
781 if (FName ==
"release" || FName ==
"retain")
789RetainSummaryManager::getUnarySummary(
const FunctionType* FT,
799 return getPersistentStopSummary();
803 ScratchArgs = AF.add(ScratchArgs, 0, Effect);
810RetainSummaryManager::getOSSummaryRetainRule(
const FunctionDecl *FD) {
819RetainSummaryManager::getOSSummaryReleaseRule(
const FunctionDecl *FD) {
828RetainSummaryManager::getOSSummaryFreeRule(
const FunctionDecl *FD) {
837RetainSummaryManager::getOSSummaryCreateRule(
const FunctionDecl *FD) {
843RetainSummaryManager::getOSSummaryGetRule(
const FunctionDecl *FD) {
849RetainSummaryManager::getCFSummaryCreateRule(
const FunctionDecl *FD) {
855RetainSummaryManager::getCFSummaryGetRule(
const FunctionDecl *FD) {
868std::optional<RetEffect>
869RetainSummaryManager::getRetEffectFromAnnotations(
QualType RetTy,
871 if (hasAnyEnabledAttrOf<NSReturnsRetainedAttr>(D, RetTy))
872 return ObjCAllocRetE;
874 if (
auto K = hasAnyEnabledAttrOf<CFReturnsRetainedAttr, OSReturnsRetainedAttr,
875 GeneralizedReturnsRetainedAttr>(D, RetTy))
878 if (
auto K = hasAnyEnabledAttrOf<
879 CFReturnsNotRetainedAttr, OSReturnsNotRetainedAttr,
880 GeneralizedReturnsNotRetainedAttr, NSReturnsNotRetainedAttr,
881 NSReturnsAutoreleasedAttr>(D, RetTy))
884 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
885 for (
const auto *PD : MD->overridden_methods())
886 if (
auto RE = getRetEffectFromAnnotations(RetTy, PD))
897 const auto &Context = T->getDecl()->getASTContext();
898 if (T->getDecl()->getIdentifier() == &Context.
Idents.
get(Name))
900 QT = T->getDecl()->getUnderlyingType();
906 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
908 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(ND)) {
909 return MD->getReturnType();
911 llvm_unreachable(
"Unexpected decl");
915bool RetainSummaryManager::applyParamAnnotationEffect(
920 hasAnyEnabledAttrOf<NSConsumedAttr, CFConsumedAttr, OSConsumedAttr,
921 GeneralizedConsumedAttr>(pd, QT)) {
924 }
else if (
auto K = hasAnyEnabledAttrOf<
925 CFReturnsRetainedAttr, OSReturnsRetainedAttr,
926 OSReturnsRetainedOnNonZeroAttr, OSReturnsRetainedOnZeroAttr,
927 GeneralizedReturnsRetainedAttr>(pd, QT)) {
934 bool HasRetainedOnZero = pd->
hasAttr<OSReturnsRetainedOnZeroAttr>();
935 bool HasRetainedOnNonZero = pd->
hasAttr<OSReturnsRetainedOnNonZeroAttr>();
946 if (ShouldSplit && SuccessOnZero) {
948 }
else if (ShouldSplit && (!SuccessOnZero || HasRetainedOnNonZero)) {
959 }
else if (
auto K = hasAnyEnabledAttrOf<CFReturnsNotRetainedAttr,
960 OSReturnsNotRetainedAttr,
961 GeneralizedReturnsNotRetainedAttr>(
967 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
968 for (
const auto *OD : MD->overridden_methods()) {
969 const ParmVarDecl *OP = OD->parameters()[parm_idx];
970 if (applyParamAnnotationEffect(OP, parm_idx, OD, Template))
979RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
984 assert(Summ &&
"Must have a summary to add annotations to.");
988 unsigned parm_idx = 0;
990 pe = FD->
param_end(); pi != pe; ++pi, ++parm_idx)
991 applyParamAnnotationEffect(*pi, parm_idx, FD, Template);
994 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, FD))
997 if (hasAnyEnabledAttrOf<OSConsumesThisAttr>(FD, RetTy))
1002RetainSummaryManager::updateSummaryFromAnnotations(
const RetainSummary *&Summ,
1007 assert(Summ &&
"Must have a valid summary to add annotations to");
1011 if (hasAnyEnabledAttrOf<NSConsumesSelfAttr>(MD, MD->
getReturnType()))
1015 unsigned parm_idx = 0;
1018 applyParamAnnotationEffect(*pi, parm_idx, MD, Template);
1021 if (std::optional<RetEffect> RetE = getRetEffectFromAnnotations(RetTy, MD))
1026RetainSummaryManager::getStandardMethodSummary(
const ObjCMethodDecl *MD,
1048 switch (S.getMethodFamily()) {
1065 ResultEff = ObjCInitRetE;
1073 ResultEff = ObjCAllocRetE;
1102 if (S.isKeywordSelector()) {
1103 for (
unsigned i = 0, e = S.getNumArgs(); i != e; ++i) {
1104 StringRef Slot = S.getNameForSlot(i);
1105 if (Slot.substr(Slot.size() - 8).equals_insensitive(
"delegate")) {
1106 if (ResultEff == ObjCInitRetE)
1116 return getDefaultSummary();
1118 return getPersistentSummary(ResultEff,
ArgEffects(AF.getEmptyMap()),
1123RetainSummaryManager::getClassMethodSummary(
const ObjCMessageExpr *ME) {
1128 ME->
getType(), ObjCClassMethodSummaries);
1131const RetainSummary *RetainSummaryManager::getInstanceMethodSummary(
1138 if (!ReceiverType.
isNull())
1140 ReceiverClass = PT->getInterfaceDecl();
1152 if (!Method && ReceiverClass)
1155 return getMethodSummary(S, ReceiverClass, Method, ME->
getType(),
1156 ObjCMethodSummaries);
1160RetainSummaryManager::getMethodSummary(
Selector S,
1163 ObjCMethodSummariesTy &CachedSummaries) {
1166 if (!TrackObjCAndCFObjects)
1167 return getDefaultSummary();
1173 Summ = getStandardMethodSummary(MD, S, RetTy);
1176 updateSummaryFromAnnotations(Summ, MD);
1185void RetainSummaryManager::InitializeClassMethodSummaries() {
1189 addClassMethSummary(
"NSAssertionHandler",
"currentHandler",
1195 addClassMethSummary(
"NSAutoreleasePool",
"addObject",
1201void RetainSummaryManager::InitializeMethodSummaries() {
1216 const RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE,
1228 Summ = getPersistentSummary(NoRet, ScratchArgs,
1252 addClassMethSummary(
"NSWindow",
"alloc", NoTrackYet);
1258 addClassMethSummary(
"NSPanel",
"alloc", NoTrackYet);
1263 addClassMethSummary(
"NSNull",
"null", NoTrackYet);
1267 addClassMethSummary(
"NSAutoreleasePool",
"alloc", NoTrackYet);
1268 addClassMethSummary(
"NSAutoreleasePool",
"allocWithZone", NoTrackYet,
false);
1269 addClassMethSummary(
"NSAutoreleasePool",
"new", NoTrackYet);
1272 addInstMethSummary(
"QCRenderer", AllocSumm,
"createSnapshotImageOfType");
1273 addInstMethSummary(
"QCView", AllocSumm,
"createSnapshotImageOfType");
1278 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect");
1279 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGImage",
"fromRect",
1280 "format",
"colorSpace");
1281 addInstMethSummary(
"CIContext", CFAllocSumm,
"createCGLayerWithSize",
"info");
1285RetainSummaryManager::getMethodSummary(
const ObjCMethodDecl *MD) {
1290 ObjCMethodSummariesTy *CachedSummaries;
1292 CachedSummaries = &ObjCMethodSummaries;
1294 CachedSummaries = &ObjCClassMethodSummaries;
1296 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, 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.
ArgEffect withKind(ArgEffectKind NewK)
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)
@ OMF_None
No particular method family.
@ C
Languages that the frontend can parse and compile.
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.