@@ -287,37 +287,6 @@ bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) {
287287 return RecordlessTypes.contains (QT.getTypePtr ());
288288}
289289
290- std::optional<bool > isUnretained (const QualType T, bool IsARCEnabled) {
291- if (auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T)) {
292- if (auto *Decl = Subst->getAssociatedDecl ()) {
293- if (isRetainPtrOrOSPtr (safeGetName (Decl)))
294- return false ;
295- }
296- }
297- if ((ento::cocoa::isCocoaObjectRef (T) && !IsARCEnabled) ||
298- ento::coreFoundation::isCFObjectRef (T))
299- return true ;
300-
301- // RetainPtr strips typedef for CF*Ref. Manually check for struct __CF* types.
302- auto CanonicalType = T.getCanonicalType ();
303- auto *Type = CanonicalType.getTypePtrOrNull ();
304- if (!Type)
305- return false ;
306- auto Pointee = Type->getPointeeType ();
307- auto *PointeeType = Pointee.getTypePtrOrNull ();
308- if (!PointeeType)
309- return false ;
310- auto *Record = PointeeType->getAsStructureType ();
311- if (!Record)
312- return false ;
313- auto *Decl = Record->getDecl ();
314- if (!Decl)
315- return false ;
316- auto TypeName = Decl->getName ();
317- return TypeName.starts_with (" __CF" ) || TypeName.starts_with (" __CG" ) ||
318- TypeName.starts_with (" __CM" );
319- }
320-
321290std::optional<bool > isUncounted (const CXXRecordDecl* Class)
322291{
323292 // Keep isRefCounted first as it's cheaper.
@@ -353,25 +322,6 @@ std::optional<bool> isUncheckedPtr(const QualType T) {
353322 return false ;
354323}
355324
356- std::optional<bool > isUnsafePtr (const QualType T, bool IsArcEnabled) {
357- if (T->isPointerType () || T->isReferenceType ()) {
358- if (auto *CXXRD = T->getPointeeCXXRecordDecl ()) {
359- auto isUncountedPtr = isUncounted (CXXRD);
360- auto isUncheckedPtr = isUnchecked (CXXRD);
361- auto isUnretainedPtr = isUnretained (T, IsArcEnabled);
362- std::optional<bool > result;
363- if (isUncountedPtr)
364- result = *isUncountedPtr;
365- if (isUncheckedPtr)
366- result = result ? *result || *isUncheckedPtr : *isUncheckedPtr;
367- if (isUnretainedPtr)
368- result = result ? *result || *isUnretainedPtr : *isUnretainedPtr;
369- return result;
370- }
371- }
372- return false ;
373- }
374-
375325std::optional<bool > isGetterOfSafePtr (const CXXMethodDecl *M) {
376326 assert (M);
377327
0 commit comments