Lines Matching +full:bool +full:- +full:property

1 //===- IvarInvalidationChecker.cpp ------------------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // - (void) foo
17 // to invalidate the ivar. An ivar or property are considered to be
28 //===----------------------------------------------------------------------===//
48 bool check_MissingInvalidationMethod = false;
50 bool check_InstanceVariableInvalidation = false;
67 bool IsInvalidated = false;
77 bool needsInvalidation() const { in needsInvalidation()
81 bool hasMethod(const ObjCMethodDecl *MD) { in hasMethod()
97 /// referenced in it (either directly or via property).
104 bool &CalledAnotherInvalidationMethod;
106 /// Property setter to ivar mapping.
109 /// Property getter to ivar mapping.
112 /// Property to ivar mapping.
124 bool isZero(const Expr *E) const;
146 bool &InCalledAnotherInvalidationMethod, in MethodCrawler()
166 for (const auto *Child : S->children()) { in VisitChildren()
168 this->Visit(Child); in VisitChildren()
181 bool LookForPartial);
185 static bool trackIvar(const ObjCIvarDecl *Iv, IvarSet &TrackedIvars,
188 /// Given the property declaration, and the list of tracked ivars, finds
189 /// the ivar backing the property when possible. Returns '0' when no such
197 /// Print ivar name or the property if the given ivar backs a property.
206 bool MissingDeclaration) const;
226 static bool isInvalidationMethod(const ObjCMethodDecl *M, bool LookForPartial) { in isInvalidationMethod()
227 for (const auto *Ann : M->specific_attrs<AnnotateAttr>()) { in isInvalidationMethod()
229 Ann->getAnnotation() == "objc_instance_variable_invalidator") in isInvalidationMethod()
232 Ann->getAnnotation() == "objc_instance_variable_invalidator_partial") in isInvalidationMethod()
239 const ObjCContainerDecl *D, InvalidationInfo &OutInfo, bool Partial) { in containsInvalidationMethod()
248 for (const auto *MDI : D->methods()) in containsInvalidationMethod()
251 cast<ObjCMethodDecl>(MDI->getCanonicalDecl())); in containsInvalidationMethod()
257 for (const auto *I : InterfD->protocols()) in containsInvalidationMethod()
258 containsInvalidationMethod(I->getDefinition(), OutInfo, Partial); in containsInvalidationMethod()
262 for (const auto *Ext : InterfD->visible_extensions()) in containsInvalidationMethod()
265 containsInvalidationMethod(InterfD->getSuperClass(), OutInfo, Partial); in containsInvalidationMethod()
271 for (const auto *I : ProtD->protocols()) { in containsInvalidationMethod()
272 containsInvalidationMethod(I->getDefinition(), OutInfo, Partial); in containsInvalidationMethod()
278 bool IvarInvalidationCheckerImpl::trackIvar(const ObjCIvarDecl *Iv, in trackIvar()
281 QualType IvQTy = Iv->getType(); in trackIvar()
282 const ObjCObjectPointerType *IvTy = IvQTy->getAs<ObjCObjectPointerType>(); in trackIvar()
285 const ObjCInterfaceDecl *IvInterf = IvTy->getInterfaceDecl(); in trackIvar()
290 const ObjCIvarDecl *I = cast<ObjCIvarDecl>(Iv->getCanonicalDecl()); in trackIvar()
307 IvarD = Prop->getPropertyIvarDecl(); in findPropertyBackingIvar()
310 if (IvarD && IvarD->getContainingInterface() == InterfaceD) { in findPropertyBackingIvar()
320 StringRef PropName = Prop->getIdentifier()->getName(); in findPropertyBackingIvar()
322 StringRef IvarName = Iv->getName(); in findPropertyBackingIvar()
338 // the property name. in findPropertyBackingIvar()
345 if (IvarDecl->getSynthesize()) { in printIvar()
348 os << "Property "<< PD->getName() << " "; in printIvar()
350 os << "Instance variable "<< IvarDecl->getName() << " "; in printIvar()
364 const ObjCInterfaceDecl *InterfaceD = ImplD->getClassInterface(); in visit()
368 for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv; in visit()
369 Iv= Iv->getNextIvar()) in visit()
372 // Construct Property/Property Accessor to Ivar maps to assist checking if an in visit()
373 // ivar which is backing a property has been reset. in visit()
380 InterfaceD->collectPropertiesToImplement(PropMap); in visit()
383 if (PD->isClassProperty()) in visit()
392 PD = cast<ObjCPropertyDecl>(PD->getCanonicalDecl()); in visit()
397 const ObjCMethodDecl *SetterD = PD->getSetterMethodDecl(); in visit()
399 SetterD = SetterD->getCanonicalDecl(); in visit()
403 const ObjCMethodDecl *GetterD = PD->getGetterMethodDecl(); in visit()
405 GetterD = GetterD->getCanonicalDecl(); in visit()
420 bool AtImplementationContainsAtLeastOnePartialInvalidationMethod = false; in visit()
423 const ObjCMethodDecl *D = ImplD->getMethod(InterfD->getSelector(), in visit()
424 InterfD->isInstanceMethod()); in visit()
425 if (D && D->hasBody()) { in visit()
428 bool CalledAnotherInvalidationMethod = false; in visit()
435 BR.getContext()).VisitStmt(D->getBody()); in visit()
469 bool AtImplementationContainsAtLeastOneInvalidationMethod = false; in visit()
472 const ObjCMethodDecl *D = ImplD->getMethod(InterfD->getSelector(), in visit()
473 InterfD->isInstanceMethod()); in visit()
474 if (D && D->hasBody()) { in visit()
480 bool CalledAnotherInvalidationMethod = false; in visit()
486 BR.getContext()).VisitStmt(D->getBody()); in visit()
517 const ObjCInterfaceDecl *InterfaceD, bool MissingDeclaration) const { in reportNoInvalidationMethod()
527 os << InterfaceD->getName(); in reportNoInvalidationMethod()
547 PathDiagnosticLocation::createEnd(MethodD->getBody(), in reportIvarNeedsInvalidation()
570 if (!InvalidationMethod || I->second.hasMethod(InvalidationMethod)) in markInvalidated()
576 E = E->IgnoreParenCasts(); in peel()
578 E = POE->getSyntacticForm()->IgnoreParenCasts(); in peel()
580 E = OVE->getSourceExpr()->IgnoreParenCasts(); in peel()
586 if (const Decl *D = IvarRef->getDecl()) in checkObjCIvarRefExpr()
587 markInvalidated(cast<ObjCIvarDecl>(D->getCanonicalDecl())); in checkObjCIvarRefExpr()
592 const ObjCMethodDecl *MD = ME->getMethodDecl(); in checkObjCMessageExpr()
594 MD = MD->getCanonicalDecl(); in checkObjCMessageExpr()
597 markInvalidated(IvI->second); in checkObjCMessageExpr()
604 if (PA->isExplicitProperty()) { in checkObjCPropertyRefExpr()
605 const ObjCPropertyDecl *PD = PA->getExplicitProperty(); in checkObjCPropertyRefExpr()
607 PD = cast<ObjCPropertyDecl>(PD->getCanonicalDecl()); in checkObjCPropertyRefExpr()
610 markInvalidated(IvI->second); in checkObjCPropertyRefExpr()
615 if (PA->isImplicitProperty()) { in checkObjCPropertyRefExpr()
616 const ObjCMethodDecl *MD = PA->getImplicitPropertySetter(); in checkObjCPropertyRefExpr()
618 MD = MD->getCanonicalDecl(); in checkObjCPropertyRefExpr()
621 markInvalidated(IvI->second); in checkObjCPropertyRefExpr()
627 bool IvarInvalidationCheckerImpl::MethodCrawler::isZero(const Expr *E) const { in isZero()
630 return (E->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull) in isZero()
659 BinaryOperatorKind Opcode = BO->getOpcode(); in VisitBinaryOperator()
665 if (isZero(BO->getRHS())) { in VisitBinaryOperator()
666 check(BO->getLHS()); in VisitBinaryOperator()
670 if (Opcode != BO_Assign && isZero(BO->getLHS())) { in VisitBinaryOperator()
671 check(BO->getRHS()); in VisitBinaryOperator()
678 const ObjCMethodDecl *MD = ME->getMethodDecl(); in VisitObjCMessageExpr()
679 const Expr *Receiver = ME->getInstanceReceiver(); in VisitObjCMessageExpr()
683 if (Receiver->isObjCSelfExpr()) { in VisitObjCMessageExpr()
688 // Check if we call a setter and set the property to 'nil'. in VisitObjCMessageExpr()
689 if (MD && (ME->getNumArgs() == 1) && isZero(ME->getArg(0))) { in VisitObjCMessageExpr()
690 MD = MD->getCanonicalDecl(); in VisitObjCMessageExpr()
693 markInvalidated(IvI->second); in VisitObjCMessageExpr()
701 check(Receiver->IgnoreParenCasts()); in VisitObjCMessageExpr()
728 bool ento::shouldRegisterIvarInvalidationModeling(const CheckerManager &mgr) { in shouldRegisterIvarInvalidationModeling()
736 checker->Filter.check_##name = true; \
737 checker->Filter.checkName_##name = mgr.getCurrentCheckerName(); \
740 bool ento::shouldRegister##name(const CheckerManager &mgr) { return true; }