void RedundantVoidArgCheck::processLambdaExpr( const MatchFinder::MatchResult &Result, const LambdaExpr *Lambda) { if (Lambda->getLambdaClass()->getLambdaCallOperator()->getNumParams() == 0 && Lambda->hasExplicitParameters()) { SourceManager *SM = Result.SourceManager; TypeLoc TL = Lambda->getLambdaClass()->getLambdaTypeInfo()->getTypeLoc(); removeVoidArgumentTokens(Result, {SM->getSpellingLoc(TL.getBeginLoc()), SM->getSpellingLoc(TL.getEndLoc())}, "lambda expression"); } }
void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl, ObjCMethodDecl *OM) { ObjCInstanceTypeFamily OIT_Family = Selector::getInstTypeMethodFamily(OM->getSelector()); if (OIT_Family == OIT_None) return; // TODO. Many more to come switch (OIT_Family) { case OIT_Array: break; case OIT_Dictionary: break; default: return; } if (!OM->getResultType()->isObjCIdType()) return; ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl); if (!IDecl) { if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(CDecl)) IDecl = CatDecl->getClassInterface(); else if (ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(CDecl)) IDecl = ImpDecl->getClassInterface(); } if (!IDecl) return; if (OIT_Family == OIT_Array && !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSArray"))) return; else if (OIT_Family == OIT_Dictionary && !IDecl->lookupInheritedClass(&Ctx.Idents.get("NSDictionary"))) return; TypeSourceInfo *TSInfo = OM->getResultTypeSourceInfo(); TypeLoc TL = TSInfo->getTypeLoc(); SourceRange R = SourceRange(TL.getBeginLoc(), TL.getEndLoc()); edit::Commit commit(*Editor); std::string ClassString = "instancetype"; commit.replace(R, ClassString); Editor->commit(commit); }