Lines Matching +full:class +full:- +full:dg

1 //===--- ObjCMT.cpp - ObjC Migrate Tool -----------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
42 class ObjCMigrateASTConsumer : public ASTConsumer {
137 bool HandleTopLevelDecl(DeclGroupRef DG) override { in HandleTopLevelDecl() argument
138 for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) in HandleTopLevelDecl()
142 void HandleInterestingDecl(DeclGroupRef DG) override { in HandleInterestingDecl() argument
145 void HandleTopLevelDeclInObjCContainer(DeclGroupRef DG) override { in HandleTopLevelDeclInObjCContainer() argument
146 ObjCMigrateASTConsumer::HandleTopLevelDecl(DG); in HandleTopLevelDeclInObjCContainer()
159 return canModifyFile(FE->getName()); in canModifyFile()
171 return canModify(CatImpl->getCategoryDecl()); in canModify()
173 return canModify(Impl->getClassInterface()); in canModify()
175 return canModify(cast<Decl>(MD->getDeclContext())); in canModify()
177 FileID FID = PP.getSourceManager().getFileID(D->getLocation()); in canModify()
196 PPRec = new PPConditionalDirectiveRecord(CompInst->getSourceManager()); in CreateASTConsumer()
201 MigrateDir, ObjCMigAction, Remapper, CompInst->getFileManager(), PPRec, in CreateASTConsumer()
202 CompInst->getPreprocessor(), false, std::nullopt)); in CreateASTConsumer()
217 const Expr* Expr = FullExpr->IgnoreImpCasts(); in subscriptOperatorNeedsParens()
229 /// - Rewrite message expression for Objective-C setter and getters into
230 /// property-dot syntax.
235 if (!Msg || Msg->isImplicit() || in rewriteToPropertyDotSyntax()
236 (Msg->getReceiverKind() != ObjCMessageExpr::Instance && in rewriteToPropertyDotSyntax()
237 Msg->getReceiverKind() != ObjCMessageExpr::SuperInstance)) in rewriteToPropertyDotSyntax()
239 if (const Expr *Receiver = Msg->getInstanceReceiver()) in rewriteToPropertyDotSyntax()
240 if (Receiver->getType()->isObjCBuiltinType()) in rewriteToPropertyDotSyntax()
243 const ObjCMethodDecl *Method = Msg->getMethodDecl(); in rewriteToPropertyDotSyntax()
246 if (!Method->isPropertyAccessor()) in rewriteToPropertyDotSyntax()
249 const ObjCPropertyDecl *Prop = Method->findPropertyDecl(); in rewriteToPropertyDotSyntax()
253 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToPropertyDotSyntax()
255 (Msg->getReceiverKind() == ObjCMessageExpr::SuperInstance); in rewriteToPropertyDotSyntax()
257 const Expr *receiver = Msg->getInstanceReceiver(); in rewriteToPropertyDotSyntax()
260 bool IsGetter = (Msg->getNumArgs() == 0); in rewriteToPropertyDotSyntax()
264 ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc(); in rewriteToPropertyDotSyntax()
266 SourceLocation EndLoc = Msg->getSelectorLoc(0); in rewriteToPropertyDotSyntax()
272 commit.insertBefore(receiver->getBeginLoc(), "("); in rewriteToPropertyDotSyntax()
277 PropertyDotString += Prop->getName(); in rewriteToPropertyDotSyntax()
285 commit.insertWrap("(", receiver->getSourceRange(), ")"); in rewriteToPropertyDotSyntax()
287 PropertyDotString += Prop->getName(); in rewriteToPropertyDotSyntax()
289 const Expr*const* Args = Msg->getArgs(); in rewriteToPropertyDotSyntax()
294 ReceiverIsSuper ? Msg->getSuperLoc() : receiver->getEndLoc(); in rewriteToPropertyDotSyntax()
296 SourceLocation EndLoc = RHS->getBeginLoc(); in rewriteToPropertyDotSyntax()
297 EndLoc = EndLoc.getLocWithOffset(-1); in rewriteToPropertyDotSyntax()
311 class ObjCMigrator : public RecursiveASTVisitor<ObjCMigrator> {
326 Consumer.Editor->commit(commit); in VisitObjCMessageExpr()
332 Consumer.Editor->commit(commit); in VisitObjCMessageExpr()
339 Consumer.Editor->commit(commit); in VisitObjCMessageExpr()
348 for (Stmt *SubStmt : E->children()) in TraverseObjCMessageExpr()
356 class BodyMigrator : public RecursiveASTVisitor<BodyMigrator> {
408 paren--; in MigrateBlockOrFunctionPointerTypeVariable()
428 bool RetainableObject = ArgType->isObjCRetainableType(); in PropertyMemoryAttribute()
433 ArgType->getAs<ObjCObjectPointerType>()) { in PropertyMemoryAttribute()
434 ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface(); in PropertyMemoryAttribute()
436 IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying"))) in PropertyMemoryAttribute()
441 else if (ArgType->isBlockPointerType()) in PropertyMemoryAttribute()
448 return ArgType->isBlockPointerType() ? "copy" : "strong"; in PropertyMemoryAttribute()
469 std::string PropertyNameString = Getter->getNameAsString(); in rewriteToObjCProperty()
489 QualType QT = Getter->getReturnType(); in rewriteToObjCProperty()
490 if (!QT->isRealType()) in rewriteToObjCProperty()
493 QualType ResType = Context.getCanonicalType(Getter->getReturnType()); in rewriteToObjCProperty()
497 const ParmVarDecl *argDecl = *Setter->param_begin(); in rewriteToObjCProperty()
498 QualType ArgType = Context.getCanonicalType(argDecl->getType()); in rewriteToObjCProperty()
504 QualType RT = Getter->getReturnType(); in rewriteToObjCProperty()
505 if (!RT->getAs<TypedefType>()) { in rewriteToObjCProperty()
531 if (RT->isBlockPointerType() || RT->isFunctionPointerType()) in rewriteToObjCProperty()
536 char LastChar = TypeString[TypeString.size()-1]; in rewriteToObjCProperty()
542 SourceLocation StartGetterSelectorLoc = Getter->getSelectorStartLoc(); in rewriteToObjCProperty()
543 Selector GetterSelector = Getter->getSelector(); in rewriteToObjCProperty()
547 commit.replace(CharSourceRange::getCharRange(Getter->getBeginLoc(), in rewriteToObjCProperty()
551 SourceLocation EndLoc = Setter->getDeclaratorEndLoc(); in rewriteToObjCProperty()
554 SourceLocation BeginOfSetterDclLoc = Setter->getBeginLoc(); in rewriteToObjCProperty()
557 BeginOfSetterDclLoc = BeginOfSetterDclLoc.getLocWithOffset(-1); in rewriteToObjCProperty()
564 StringRef Name = CatDecl->getName(); in IsCategoryNameWithDeprecatedSuffix()
572 if (D->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(D)) in migrateObjCContainerDecl()
575 for (auto *Method : D->methods()) { in migrateObjCContainerDecl()
576 if (Method->isDeprecated()) in migrateObjCContainerDecl()
581 // to do unless -objcmt-returns-innerpointer-property option is on. in migrateObjCContainerDecl()
590 for (auto *Prop : D->instance_properties()) { in migrateObjCContainerDecl()
592 !Prop->isDeprecated()) in migrateObjCContainerDecl()
602 // In auto-synthesis, protocol properties are not synthesized. So, in ClassImplementsAllMethodsAndProperties()
604 // in class interface. in ClassImplementsAllMethodsAndProperties()
606 if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition()) in ClassImplementsAllMethodsAndProperties()
607 for (const auto *Property : PDecl->instance_properties()) { in ClassImplementsAllMethodsAndProperties()
608 if (Property->getPropertyImplementation() == ObjCPropertyDecl::Optional) in ClassImplementsAllMethodsAndProperties()
611 DeclContext::lookup_result R = IDecl->lookup(Property->getDeclName()); in ClassImplementsAllMethodsAndProperties()
613 // Relax the rule and look into class's implementation for a synthesize in ClassImplementsAllMethodsAndProperties()
614 // or dynamic declaration. Class is implementing a property coming from in ClassImplementsAllMethodsAndProperties()
616 if (!ImpDecl->FindPropertyImplDecl( in ClassImplementsAllMethodsAndProperties()
617 Property->getDeclName().getAsIdentifierInfo(), in ClassImplementsAllMethodsAndProperties()
618 Property->getQueryKind())) in ClassImplementsAllMethodsAndProperties()
621 if ((ClassProperty->getPropertyAttributes() != in ClassImplementsAllMethodsAndProperties()
622 Property->getPropertyAttributes()) || in ClassImplementsAllMethodsAndProperties()
623 !Ctx.hasSameType(ClassProperty->getType(), Property->getType())) in ClassImplementsAllMethodsAndProperties()
630 // declared in the class. in ClassImplementsAllMethodsAndProperties()
631 // Check that class implements the required methods of the protocol too. in ClassImplementsAllMethodsAndProperties()
633 if (const ObjCProtocolDecl *PDecl = Protocol->getDefinition()) { in ClassImplementsAllMethodsAndProperties()
634 if (PDecl->meth_begin() == PDecl->meth_end()) in ClassImplementsAllMethodsAndProperties()
636 for (const auto *MD : PDecl->methods()) { in ClassImplementsAllMethodsAndProperties()
637 if (MD->isImplicit()) in ClassImplementsAllMethodsAndProperties()
639 if (MD->getImplementationControl() == ObjCImplementationControl::Optional) in ClassImplementsAllMethodsAndProperties()
641 DeclContext::lookup_result R = ImpDecl->lookup(MD->getDeclName()); in ClassImplementsAllMethodsAndProperties()
662 const ObjCList<ObjCProtocolDecl> &Protocols = IDecl->getReferencedProtocols(); in rewriteToObjCInterfaceDecl()
665 IDecl->getSuperClass() ? IDecl->getSuperClassLoc() : IDecl->getLocation(); in rewriteToObjCInterfaceDecl()
670 ClassString += ConformingProtocols[i]->getNameAsString(); in rewriteToObjCInterfaceDecl()
671 if (i != (e-1)) in rewriteToObjCInterfaceDecl()
679 ClassString += ConformingProtocols[i]->getNameAsString(); in rewriteToObjCInterfaceDecl()
680 if (i != (e-1)) in rewriteToObjCInterfaceDecl()
683 ObjCInterfaceDecl::protocol_loc_iterator PL = IDecl->protocol_loc_end() - 1; in rewriteToObjCInterfaceDecl()
718 ClassString += TypedefDcl->getIdentifier()->getName(); in rewriteToNSEnumDecl()
720 SourceRange R(EnumDcl->getBeginLoc(), EnumDcl->getBeginLoc()); in rewriteToNSEnumDecl()
722 SourceLocation EndOfEnumDclLoc = EnumDcl->getEndLoc(); in rewriteToNSEnumDecl()
726 SourceRange EnumDclRange(EnumDcl->getBeginLoc(), EndOfEnumDclLoc); in rewriteToNSEnumDecl()
727 commit.insertFromRange(TypedefDcl->getBeginLoc(), EnumDclRange); in rewriteToNSEnumDecl()
732 SourceLocation EndTypedefDclLoc = TypedefDcl->getEndLoc(); in rewriteToNSEnumDecl()
736 SourceRange TDRange(TypedefDcl->getBeginLoc(), EndTypedefDclLoc); in rewriteToNSEnumDecl()
743 trans::findLocationAfterSemi(EnumDcl->getEndLoc(), NS.getASTContext(), in rewriteToNSEnumDecl()
746 SourceLocation BeginOfEnumDclLoc = EnumDcl->getBeginLoc(); in rewriteToNSEnumDecl()
749 BeginOfEnumDclLoc = BeginOfEnumDclLoc.getLocWithOffset(-1); in rewriteToNSEnumDecl()
761 QualType DesignatedEnumType = EnumDcl->getIntegerType(); in rewriteToNSMacroDecl()
763 && "rewriteToNSMacroDecl - underlying enum type is null"); in rewriteToNSMacroDecl()
771 ClassString += TypedefDcl->getIdentifier()->getName(); in rewriteToNSMacroDecl()
773 SourceLocation EndLoc = EnumDcl->getBraceRange().getBegin(); in rewriteToNSMacroDecl()
777 CharSourceRange::getCharRange(EnumDcl->getBeginLoc(), EndLoc); in rewriteToNSMacroDecl()
780 SourceLocation StartTypedefLoc = EnumDcl->getEndLoc(); in rewriteToNSMacroDecl()
782 SourceLocation EndTypedefLoc = TypedefDcl->getEndLoc(); in rewriteToNSMacroDecl()
792 for (auto *Enumerator : EnumDcl->enumerators()) { in UseNSOptionsMacro()
793 const Expr *InitExpr = Enumerator->getInitExpr(); in UseNSOptionsMacro()
799 InitExpr = InitExpr->IgnoreParenCasts(); in UseNSOptionsMacro()
801 if (BO->isShiftOp() || BO->isBitwiseOp()) in UseNSOptionsMacro()
804 uint64_t EnumVal = Enumerator->getInitVal().getZExtValue(); in UseNSOptionsMacro()
813 SourceLocation EndLoc = Enumerator->getEndLoc(); in UseNSOptionsMacro()
830 const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface(); in migrateProtocolConformance()
831 if (!IDecl || ObjCProtocolDecls.empty() || IDecl->isDeprecated()) in migrateProtocolConformance()
833 // Find all implicit conforming protocols for this class in migrateProtocolConformance()
846 // go through list of non-optional methods and properties in each protocol in migrateProtocolConformance()
847 // in the PotentialImplicitProtocols list. If class implements every one of the in migrateProtocolConformance()
848 // methods and properties, then this class conforms to this protocol. in migrateProtocolConformance()
868 if (PDecl->lookupProtocolNamed( in migrateProtocolConformance()
869 TargetPDecl->getDeclName().getAsIdentifierInfo())) { in migrateProtocolConformance()
882 Editor->commit(commit); in migrateProtocolConformance()
888 QualType qt = TypedefDcl->getTypeSourceInfo()->getType(); in CacheObjCNSIntegerTypedefed()
889 if (NSAPIObj->isObjCNSIntegerType(qt)) in CacheObjCNSIntegerTypedefed()
891 else if (NSAPIObj->isObjCNSUIntegerType(qt)) in CacheObjCNSIntegerTypedefed()
898 if (!EnumDcl->isCompleteDefinition() || EnumDcl->getIdentifier() || in migrateNSEnumDecl()
899 EnumDcl->isDeprecated()) in migrateNSEnumDecl()
913 PP.getSourceManager().getFileID(TypedefDcl->getLocation()); in migrateNSEnumDecl()
915 PP.getSourceManager().getFileID(EnumDcl->getLocation()); in migrateNSEnumDecl()
919 if (TypedefDcl->isDeprecated()) in migrateNSEnumDecl()
922 QualType qt = TypedefDcl->getTypeSourceInfo()->getType(); in migrateNSEnumDecl()
923 StringRef NSIntegerName = NSAPIObj->GetNSIntegralKind(qt); in migrateNSEnumDecl()
927 if (const EnumType *EnumTy = qt->getAs<EnumType>()) { in migrateNSEnumDecl()
928 if (EnumTy->getDecl() == EnumDcl) { in migrateNSEnumDecl()
930 if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc())) in migrateNSEnumDecl()
934 Editor->commit(commit); in migrateNSEnumDecl()
943 if (!InsertFoundation(Ctx, TypedefDcl->getBeginLoc())) in migrateNSEnumDecl()
948 Editor->commit(commit); in migrateNSEnumDecl()
955 if (OM->getReturnType() == Ctx.getObjCInstanceType()) in ReplaceWithInstancetype()
960 if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) { in ReplaceWithInstancetype()
961 TypeLoc TL = TSInfo->getTypeLoc(); in ReplaceWithInstancetype()
966 R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc()); in ReplaceWithInstancetype()
967 ClassString = OM->isInstanceMethod() ? '-' : '+'; in ReplaceWithInstancetype()
972 ASTC.Editor->commit(commit); in ReplaceWithInstancetype()
977 ObjCInterfaceDecl *IDecl = OM->getClassInterface(); in ReplaceWithClasstype()
980 if (TypeSourceInfo *TSInfo = OM->getReturnTypeSourceInfo()) { in ReplaceWithClasstype()
981 TypeLoc TL = TSInfo->getTypeLoc(); in ReplaceWithClasstype()
983 ClassString = std::string(IDecl->getName()); in ReplaceWithClasstype()
988 R = SourceRange(OM->getBeginLoc(), OM->getBeginLoc()); in ReplaceWithClasstype()
990 ClassString += IDecl->getName(); ClassString += "*)"; in ReplaceWithClasstype()
994 ASTC.Editor->commit(commit); in ReplaceWithClasstype()
1001 Selector::getInstTypeMethodFamily(OM->getSelector()); in migrateMethodInstanceType()
1018 if (OM->getReturnType()->isObjCIdType()) in migrateMethodInstanceType()
1025 if (!OM->getReturnType()->isObjCIdType()) in migrateMethodInstanceType()
1031 IDecl = CatDecl->getClassInterface(); in migrateMethodInstanceType()
1033 IDecl = ImpDecl->getClassInterface(); in migrateMethodInstanceType()
1036 !IDecl->lookupInheritedClass(&Ctx.Idents.get(ClassName))) { in migrateMethodInstanceType()
1044 if (!T->isAnyPointerType()) in TypeIsInnerPointer()
1046 if (T->isObjCObjectPointerType() || T->isObjCBuiltinType() || in TypeIsInnerPointer()
1047 T->isBlockPointerType() || T->isFunctionPointerType() || in TypeIsInnerPointer()
1050 // Also, typedef-of-pointer-to-incomplete-struct is something that we assume in TypeIsInnerPointer()
1053 while (const auto *TD = T->getAs<TypedefType>()) in TypeIsInnerPointer()
1054 T = TD->getDecl()->getUnderlyingType(); in TypeIsInnerPointer()
1055 if (OrigT == T || !T->isPointerType()) in TypeIsInnerPointer()
1057 const PointerType* PT = T->getAs<PointerType>(); in TypeIsInnerPointer()
1058 QualType UPointeeT = PT->getPointeeType().getUnqualifiedType(); in TypeIsInnerPointer()
1059 if (UPointeeT->isRecordType()) { in TypeIsInnerPointer()
1060 const RecordType *RecordTy = UPointeeT->getAs<RecordType>(); in TypeIsInnerPointer()
1061 if (!RecordTy->getDecl()->isCompleteDefinition()) in TypeIsInnerPointer()
1072 /// AvailabilityAttrsMatch - This routine checks that if comparing two
1083 VersionTuple Introduced1 = AA1->getIntroduced(); in AvailabilityAttrsMatch()
1084 VersionTuple Deprecated1 = AA1->getDeprecated(); in AvailabilityAttrsMatch()
1085 VersionTuple Obsoleted1 = AA1->getObsoleted(); in AvailabilityAttrsMatch()
1086 bool IsUnavailable1 = AA1->getUnavailable(); in AvailabilityAttrsMatch()
1087 VersionTuple Introduced2 = AA2->getIntroduced(); in AvailabilityAttrsMatch()
1088 VersionTuple Deprecated2 = AA2->getDeprecated(); in AvailabilityAttrsMatch()
1089 VersionTuple Obsoleted2 = AA2->getObsoleted(); in AvailabilityAttrsMatch()
1090 bool IsUnavailable2 = AA2->getUnavailable(); in AvailabilityAttrsMatch()
1106 if (Attrs1[i]->getKind() == Attrs2[j]->getKind()) { in MatchTwoAttributeLists()
1119 /// AttributesMatch - This routine checks list of attributes for two
1128 if (!Decl1->hasAttrs() || !Decl2->hasAttrs()) { in AttributesMatch()
1129 AvailabilityArgsMatch = (Decl1->hasAttrs() == Decl2->hasAttrs()); in AttributesMatch()
1133 const AttrVec &Attrs1 = Decl1->getAttrs(); in AttributesMatch()
1134 const AttrVec &Attrs2 = Decl2->getAttrs(); in AttributesMatch()
1148 return II->getTokenID() == tok::identifier; in IsValidIdentifier()
1154 if (Method->isPropertyAccessor() || !Method->isInstanceMethod() || in migrateProperty()
1155 Method->param_size() != 0) in migrateProperty()
1158 QualType GRT = Method->getReturnType(); in migrateProperty()
1159 if (GRT->isVoidType()) in migrateProperty()
1162 Selector GetterSelector = Method->getSelector(); in migrateProperty()
1174 ObjCMethodDecl *SetterMethod = D->getInstanceMethod(SetterSelector); in migrateProperty()
1178 StringRef getterNameString = getterName->getName(); in migrateProperty()
1182 if (IsPrefix && GRT->isObjCRetainableType()) in migrateProperty()
1197 SetterMethod = D->getInstanceMethod(SetterSelector); in migrateProperty()
1206 if (SetterMethod->isDeprecated() || in migrateProperty()
1211 QualType SRT = SetterMethod->getReturnType(); in migrateProperty()
1212 if (!SRT->isVoidType()) in migrateProperty()
1214 const ParmVarDecl *argDecl = *SetterMethod->param_begin(); in migrateProperty()
1215 QualType ArgType = argDecl->getType(); in migrateProperty()
1226 Editor->commit(commit); in migrateProperty()
1230 // Try a non-void method with no argument (and no setter or property of same name in migrateProperty()
1240 Editor->commit(commit); in migrateProperty()
1248 if (OM->isImplicit() || in migrateNsReturnsInnerPointer()
1249 !OM->isInstanceMethod() || in migrateNsReturnsInnerPointer()
1250 OM->hasAttr<ObjCReturnsInnerPointerAttr>()) in migrateNsReturnsInnerPointer()
1253 QualType RT = OM->getReturnType(); in migrateNsReturnsInnerPointer()
1255 !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER")) in migrateNsReturnsInnerPointer()
1259 commit.insertBefore(OM->getEndLoc(), " NS_RETURNS_INNER_POINTER"); in migrateNsReturnsInnerPointer()
1260 Editor->commit(commit); in migrateNsReturnsInnerPointer()
1265 QualType T = P->getType(); in migratePropertyNsReturnsInnerPointer()
1268 !NSAPIObj->isMacroDefined("NS_RETURNS_INNER_POINTER")) in migratePropertyNsReturnsInnerPointer()
1271 commit.insertBefore(P->getEndLoc(), " NS_RETURNS_INNER_POINTER "); in migratePropertyNsReturnsInnerPointer()
1272 Editor->commit(commit); in migratePropertyNsReturnsInnerPointer()
1277 if (CDecl->isDeprecated() || IsCategoryNameWithDeprecatedSuffix(CDecl)) in migrateAllMethodInstaceType()
1281 for (auto *Method : CDecl->methods()) { in migrateAllMethodInstaceType()
1282 if (Method->isDeprecated()) in migrateAllMethodInstaceType()
1292 if (OM->isInstanceMethod() || in migrateFactoryMethod()
1293 OM->getReturnType() == Ctx.getObjCInstanceType() || in migrateFactoryMethod()
1294 !OM->getReturnType()->isObjCIdType()) in migrateFactoryMethod()
1297 // Candidate factory methods are + (id) NaMeXXX : ... which belong to a class in migrateFactoryMethod()
1302 IDecl = CatDecl->getClassInterface(); in migrateFactoryMethod()
1304 IDecl = ImpDecl->getClassInterface(); in migrateFactoryMethod()
1309 std::string StringClassName = std::string(IDecl->getName()); in migrateFactoryMethod()
1315 OM->getSelector().getIdentifierInfoForSlot(0); in migrateFactoryMethod()
1320 std::string MethodName = std::string(MethodIdName->getName()); in migrateFactoryMethod()
1354 if (!Ty->isPointerType()) in IsVoidStarType()
1358 const PointerType* PT = Ty->castAs<PointerType>(); in IsVoidStarType()
1359 if (PT->getPointeeType().getUnqualifiedType()->isVoidType()) in IsVoidStarType()
1361 return IsVoidStarType(PT->getPointeeType()); in IsVoidStarType()
1364 /// AuditedType - This routine audits the type AT and returns false if it is one of known
1366 /// such as a non-pointer or pointers which have no ownership issues (such as "int *").
1368 if (!AT->isAnyPointerType() && !AT->isBlockPointerType()) in AuditedType()
1374 // that it is an un-audited function. in AuditedType()
1375 AT->isObjCObjectPointerType() || AT->isObjCBuiltinType()) in AuditedType()
1384 if (!NSAPIObj->isMacroDefined("CF_IMPLICIT_BRIDGING_ENABLED")) { in AnnotateImplicitBridging()
1392 CFFunctionIBCandidates[CFFunctionIBCandidates.size()-1]; in AnnotateImplicitBridging()
1395 commit.insertBefore(FirstFD->getBeginLoc(), PragmaString); in AnnotateImplicitBridging()
1397 SourceLocation EndLoc = LastFD->getEndLoc(); in AnnotateImplicitBridging()
1410 Editor->commit(commit); in AnnotateImplicitBridging()
1416 if (Decl->isDeprecated()) in migrateCFAnnotation()
1419 if (Decl->hasAttr<CFAuditedTransferAttr>()) { in migrateCFAnnotation()
1432 FileId = PP.getSourceManager().getFileID(Decl->getLocation()); in migrateCFAnnotation()
1438 FileId = PP.getSourceManager().getFileID(Decl->getLocation()); in migrateCFAnnotation()
1456 RetEffect Ret = RS->getRetEffect(); in AddCFAnnotations()
1459 if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED")) in AddCFAnnotations()
1462 NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED")) in AddCFAnnotations()
1466 if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED")) in AddCFAnnotations()
1472 commit.insertAfterToken(FuncDecl->getEndLoc(), AnnotationString); in AddCFAnnotations()
1473 Editor->commit(commit); in AddCFAnnotations()
1477 for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(), in AddCFAnnotations()
1478 pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { in AddCFAnnotations()
1480 ArgEffect AE = RS->getArg(i); in AddCFAnnotations()
1482 !pd->hasAttr<CFConsumedAttr>() && in AddCFAnnotations()
1483 NSAPIObj->isMacroDefined("CF_CONSUMED")) { in AddCFAnnotations()
1485 commit.insertBefore(pd->getLocation(), "CF_CONSUMED "); in AddCFAnnotations()
1486 Editor->commit(commit); in AddCFAnnotations()
1488 !pd->hasAttr<NSConsumedAttr>() && in AddCFAnnotations()
1489 NSAPIObj->isMacroDefined("NS_CONSUMED")) { in AddCFAnnotations()
1491 commit.insertBefore(pd->getLocation(), "NS_CONSUMED "); in AddCFAnnotations()
1492 Editor->commit(commit); in AddCFAnnotations()
1501 if (FuncDecl->hasBody()) in migrateAddFunctionAnnotation()
1506 bool FuncIsReturnAnnotated = (FuncDecl->hasAttr<CFReturnsRetainedAttr>() || in migrateAddFunctionAnnotation()
1507 FuncDecl->hasAttr<CFReturnsNotRetainedAttr>() || in migrateAddFunctionAnnotation()
1508 FuncDecl->hasAttr<NSReturnsRetainedAttr>() || in migrateAddFunctionAnnotation()
1509 FuncDecl->hasAttr<NSReturnsNotRetainedAttr>() || in migrateAddFunctionAnnotation()
1510 FuncDecl->hasAttr<NSReturnsAutoreleasedAttr>()); in migrateAddFunctionAnnotation()
1513 if (FuncIsReturnAnnotated && FuncDecl->getNumParams() == 0) in migrateAddFunctionAnnotation()
1518 RetEffect Ret = RS->getRetEffect(); in migrateAddFunctionAnnotation()
1522 else if (!AuditedType(FuncDecl->getReturnType())) in migrateAddFunctionAnnotation()
1529 for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(), in migrateAddFunctionAnnotation()
1530 pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { in migrateAddFunctionAnnotation()
1532 ArgEffect AE = RS->getArg(i); in migrateAddFunctionAnnotation()
1535 if (AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) in migrateAddFunctionAnnotation()
1540 QualType AT = pd->getType(); in migrateAddFunctionAnnotation()
1555 if (!isa<ObjCInterfaceDecl>(CDecl) || CDecl->isDeprecated()) in migrateARCSafeAnnotation()
1559 for (const auto *Method : CDecl->methods()) in migrateARCSafeAnnotation()
1569 RetEffect Ret = RS->getRetEffect(); in AddCFAnnotations()
1572 if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED")) in AddCFAnnotations()
1575 NSAPIObj->isMacroDefined("CF_RETURNS_NOT_RETAINED")) in AddCFAnnotations()
1579 ObjCMethodFamily OMF = MethodDecl->getMethodFamily(); in AddCFAnnotations()
1589 if (Ret.isOwned() && NSAPIObj->isMacroDefined("NS_RETURNS_RETAINED")) in AddCFAnnotations()
1597 commit.insertBefore(MethodDecl->getEndLoc(), AnnotationString); in AddCFAnnotations()
1598 Editor->commit(commit); in AddCFAnnotations()
1602 for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(), in AddCFAnnotations()
1603 pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { in AddCFAnnotations()
1605 ArgEffect AE = RS->getArg(i); in AddCFAnnotations()
1608 && !pd->hasAttr<CFConsumedAttr>() && in AddCFAnnotations()
1609 NSAPIObj->isMacroDefined("CF_CONSUMED")) { in AddCFAnnotations()
1611 commit.insertBefore(pd->getLocation(), "CF_CONSUMED "); in AddCFAnnotations()
1612 Editor->commit(commit); in AddCFAnnotations()
1620 if (MethodDecl->hasBody() || MethodDecl->isImplicit()) in migrateAddMethodAnnotation()
1627 (MethodDecl->hasAttr<CFReturnsRetainedAttr>() || in migrateAddMethodAnnotation()
1628 MethodDecl->hasAttr<CFReturnsNotRetainedAttr>() || in migrateAddMethodAnnotation()
1629 MethodDecl->hasAttr<NSReturnsRetainedAttr>() || in migrateAddMethodAnnotation()
1630 MethodDecl->hasAttr<NSReturnsNotRetainedAttr>() || in migrateAddMethodAnnotation()
1631 MethodDecl->hasAttr<NSReturnsAutoreleasedAttr>()); in migrateAddMethodAnnotation()
1633 if (RS->getReceiverEffect().getKind() == DecRef && in migrateAddMethodAnnotation()
1634 !MethodDecl->hasAttr<NSConsumesSelfAttr>() && in migrateAddMethodAnnotation()
1635 MethodDecl->getMethodFamily() != OMF_init && in migrateAddMethodAnnotation()
1636 MethodDecl->getMethodFamily() != OMF_release && in migrateAddMethodAnnotation()
1637 NSAPIObj->isMacroDefined("NS_CONSUMES_SELF")) { in migrateAddMethodAnnotation()
1639 commit.insertBefore(MethodDecl->getEndLoc(), " NS_CONSUMES_SELF"); in migrateAddMethodAnnotation()
1640 Editor->commit(commit); in migrateAddMethodAnnotation()
1645 (MethodDecl->param_begin() == MethodDecl->param_end())) in migrateAddMethodAnnotation()
1649 RetEffect Ret = RS->getRetEffect(); in migrateAddMethodAnnotation()
1655 } else if (!AuditedType(MethodDecl->getReturnType())) in migrateAddMethodAnnotation()
1661 for (ObjCMethodDecl::param_const_iterator pi = MethodDecl->param_begin(), in migrateAddMethodAnnotation()
1662 pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { in migrateAddMethodAnnotation()
1664 ArgEffect AE = RS->getArg(i); in migrateAddMethodAnnotation()
1665 if ((AE.getKind() == DecRef && !pd->hasAttr<CFConsumedAttr>()) || in migrateAddMethodAnnotation()
1666 AE.getKind() == IncRef || !AuditedType(pd->getType())) { in migrateAddMethodAnnotation()
1674 class SuperInitChecker : public RecursiveASTVisitor<SuperInitChecker> {
1680 if (E->getReceiverKind() == ObjCMessageExpr::SuperInstance) { in VisitObjCMessageExpr()
1681 if (E->getMethodFamily() == OMF_init) in VisitObjCMessageExpr()
1690 return !SuperInitChecker().TraverseStmt(MD->getBody()); in hasSuperInitCall()
1697 const ObjCInterfaceDecl *IFace = ImplD->getClassInterface(); in inferDesignatedInitializers()
1698 if (!IFace || IFace->hasDesignatedInitializers()) in inferDesignatedInitializers()
1700 if (!NSAPIObj->isMacroDefined("NS_DESIGNATED_INITIALIZER")) in inferDesignatedInitializers()
1703 for (const auto *MD : ImplD->instance_methods()) { in inferDesignatedInitializers()
1704 if (MD->isDeprecated() || in inferDesignatedInitializers()
1705 MD->getMethodFamily() != OMF_init || in inferDesignatedInitializers()
1706 MD->isDesignatedInitializerForTheInterface()) in inferDesignatedInitializers()
1708 const ObjCMethodDecl *IFaceM = IFace->getMethod(MD->getSelector(), in inferDesignatedInitializers()
1714 commit.insert(IFaceM->getEndLoc(), " NS_DESIGNATED_INITIALIZER"); in inferDesignatedInitializers()
1715 Editor->commit(commit); in inferDesignatedInitializers()
1736 Editor->commit(commit); in InsertFoundation()
1743 class RewritesReceiver : public edit::EditsReceiver {
1757 class JSONEditWriter : public edit::EditsReceiver {
1787 StringRef(SourceMgr.getFileEntryRefForID(FID)->getName()); in writeLoc()
1802 unsigned Length = End.second - Begin.second; in writeRemove()
1839 for (DeclContext::decl_iterator D = TU->decls_begin(), DEnd = TU->decls_end(); in HandleTranslationUnit()
1841 FileID FID = PP.getSourceManager().getFileID((*D)->getLocation()); in HandleTranslationUnit()
1856 ObjCProtocolDecls.insert(PDecl->getCanonicalDecl()); in HandleTranslationUnit()
1892 // prefer typedef-follows-enum to enum-follows-typedef pattern. in HandleTranslationUnit()
1947 Editor->applyRewrites(Writer); in HandleTranslationUnit()
1953 Editor->applyRewrites(Rec); in HandleTranslationUnit()
1957 FileID FID = I->first; in HandleTranslationUnit()
1958 RewriteBuffer &buf = I->second; in HandleTranslationUnit()
1966 llvm::MemoryBuffer::getMemBufferCopy(newText.str(), file->getName())); in HandleTranslationUnit()
1967 SmallString<64> filePath(file->getName()); in HandleTranslationUnit()
1996 if (is_regular_file(DI->path())) in getAllowListFilenames()
1997 Filenames.push_back(std::string(filename(DI->path()))); in getAllowListFilenames()
2040 Entry.Offset = unsigned(-1); in getEmptyKey()
2045 Entry.Offset = unsigned(-2); in getTombstoneKey()
2062 class RemapFileParser {
2077 Stream YAMLStream(FileBufOrErr.get()->getMemBufferRef(), SM); in parse()
2081 Node *Root = I->getRoot(); in parse()
2090 AI = SeqNode->begin(), AE = SeqNode->end(); AI != AE; ++AI) { in parse()
2108 KVI = Node->begin(), KVE = Node->end(); KVI != KVE; ++KVI) { in parseEdit()
2113 StringRef Key = KeyString->getValue(KeyStorage); in parseEdit()
2119 StringRef Val = ValueString->getValue(ValueStorage); in parseEdit()
2189 Buf->write(OS); in applyEditsToTemp()
2250 std::string TempFile = applyEditsToTemp(I->first, I->second, in getFileRemappingsFromFileList()
2257 remap.emplace_back(std::string(I->first.getName()), TempFile); in getFileRemappingsFromFileList()