@@ -300,37 +300,6 @@ bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) {
300300 return RT && CFPointees.contains (RT);
301301}
302302
303- std::optional<bool > isUnretained (const QualType T, bool IsARCEnabled) {
304- if (auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T)) {
305- if (auto *Decl = Subst->getAssociatedDecl ()) {
306- if (isRetainPtrOrOSPtr (safeGetName (Decl)))
307- return false ;
308- }
309- }
310- if ((ento::cocoa::isCocoaObjectRef (T) && !IsARCEnabled) ||
311- ento::coreFoundation::isCFObjectRef (T))
312- return true ;
313-
314- // RetainPtr strips typedef for CF*Ref. Manually check for struct __CF* types.
315- auto CanonicalType = T.getCanonicalType ();
316- auto *Type = CanonicalType.getTypePtrOrNull ();
317- if (!Type)
318- return false ;
319- auto Pointee = Type->getPointeeType ();
320- auto *PointeeType = Pointee.getTypePtrOrNull ();
321- if (!PointeeType)
322- return false ;
323- auto *Record = PointeeType->getAsStructureType ();
324- if (!Record)
325- return false ;
326- auto *Decl = Record->getDecl ();
327- if (!Decl)
328- return false ;
329- auto TypeName = Decl->getName ();
330- return TypeName.starts_with (" __CF" ) || TypeName.starts_with (" __CG" ) ||
331- TypeName.starts_with (" __CM" );
332- }
333-
334303std::optional<bool > isUncounted (const CXXRecordDecl* Class)
335304{
336305 // Keep isRefCounted first as it's cheaper.
@@ -366,25 +335,6 @@ std::optional<bool> isUncheckedPtr(const QualType T) {
366335 return false ;
367336}
368337
369- std::optional<bool > isUnsafePtr (const QualType T, bool IsArcEnabled) {
370- if (T->isPointerType () || T->isReferenceType ()) {
371- if (auto *CXXRD = T->getPointeeCXXRecordDecl ()) {
372- auto isUncountedPtr = isUncounted (CXXRD);
373- auto isUncheckedPtr = isUnchecked (CXXRD);
374- auto isUnretainedPtr = isUnretained (T, IsArcEnabled);
375- std::optional<bool > result;
376- if (isUncountedPtr)
377- result = *isUncountedPtr;
378- if (isUncheckedPtr)
379- result = result ? *result || *isUncheckedPtr : *isUncheckedPtr;
380- if (isUnretainedPtr)
381- result = result ? *result || *isUnretainedPtr : *isUnretainedPtr;
382- return result;
383- }
384- }
385- return false ;
386- }
387-
388338std::optional<bool > isGetterOfSafePtr (const CXXMethodDecl *M) {
389339 assert (M);
390340
0 commit comments