Author: Kazu Hirata Date: 2021-10-17T13:50:29-07:00 New Revision: d245f2e8597bfb52c34810a328d42b990e4af1a4
URL: https://github.com/llvm/llvm-project/commit/d245f2e8597bfb52c34810a328d42b990e4af1a4 DIFF: https://github.com/llvm/llvm-project/commit/d245f2e8597bfb52c34810a328d42b990e4af1a4.diff LOG: [clang] Use llvm::erase_if (NFC) Added: Modified: clang/include/clang/ASTMatchers/ASTMatchersInternal.h clang/include/clang/Analysis/CloneDetection.h clang/lib/AST/ASTContext.cpp clang/lib/AST/CXXInheritance.cpp clang/lib/AST/CommentSema.cpp clang/lib/AST/DeclCXX.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/ExternalASTMerger.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Driver/Multilib.cpp clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/CompilerInstance.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Serialization/ModuleManager.cpp clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp Removed: ################################################################################ diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index 1a4137cb3628f..f84582c06f780 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -312,8 +312,7 @@ class BoundNodesTreeBuilder { template <typename ExcludePredicate> bool removeBindings(const ExcludePredicate &Predicate) { - Bindings.erase(std::remove_if(Bindings.begin(), Bindings.end(), Predicate), - Bindings.end()); + llvm::erase_if(Bindings, Predicate); return !Bindings.empty(); } diff --git a/clang/include/clang/Analysis/CloneDetection.h b/clang/include/clang/Analysis/CloneDetection.h index db827c3a6d6ff..0b86c7fd86dd6 100644 --- a/clang/include/clang/Analysis/CloneDetection.h +++ b/clang/include/clang/Analysis/CloneDetection.h @@ -235,9 +235,7 @@ class CloneConstraint { static void filterGroups( std::vector<CloneDetector::CloneGroup> &CloneGroups, llvm::function_ref<bool(const CloneDetector::CloneGroup &)> Filter) { - CloneGroups.erase( - std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter), - CloneGroups.end()); + llvm::erase_if(CloneGroups, Filter); } /// Splits the given CloneGroups until the given Compare function returns true diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 1292cb6eb557c..84b09dcf16a0e 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -9199,13 +9199,9 @@ void getIntersectionOfProtocols(ASTContext &Context, // Remove any implied protocols from the list of inherited protocols. if (!ImpliedProtocols.empty()) { - IntersectionSet.erase( - std::remove_if(IntersectionSet.begin(), - IntersectionSet.end(), - [&](ObjCProtocolDecl *proto) -> bool { - return ImpliedProtocols.count(proto) > 0; - }), - IntersectionSet.end()); + llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool { + return ImpliedProtocols.count(proto) > 0; + }); } // Sort the remaining protocols by name. @@ -11719,13 +11715,9 @@ ASTContext::filterFunctionTargetAttrs(const TargetAttr *TD) const { assert(TD != nullptr); ParsedTargetAttr ParsedAttr = TD->parse(); - ParsedAttr.Features.erase( - llvm::remove_if(ParsedAttr.Features, - [&](const std::string &Feat) { - return !Target->isValidFeatureName( - StringRef{Feat}.substr(1)); - }), - ParsedAttr.Features.end()); + llvm::erase_if(ParsedAttr.Features, [&](const std::string &Feat) { + return !Target->isValidFeatureName(StringRef{Feat}.substr(1)); + }); return ParsedAttr; } diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index cc787eddad2fc..96a6f344be7c9 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -671,9 +671,7 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const { // FIXME: IsHidden reads from Overriding from the middle of a remove_if // over the same sequence! Is this guaranteed to work? - Overriding.erase( - std::remove_if(Overriding.begin(), Overriding.end(), IsHidden), - Overriding.end()); + llvm::erase_if(Overriding, IsHidden); } } } diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index 7642e73fa1714..e385c5817ef23 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -236,9 +236,7 @@ void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command, if (Direction == -1) { // Try again with whitespace removed. - ArgLower.erase( - std::remove_if(ArgLower.begin(), ArgLower.end(), clang::isWhitespace), - ArgLower.end()); + llvm::erase_if(ArgLower, clang::isWhitespace); Direction = getParamPassDirection(ArgLower); SourceRange ArgRange(ArgLocBegin, ArgLocEnd); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 016d28879227d..945c935640d54 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2156,12 +2156,9 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD, } // Other candidate final overriders might be overridden by this function. - FinalOverriders.erase( - std::remove_if(FinalOverriders.begin(), FinalOverriders.end(), - [&](CXXMethodDecl *OtherD) { - return recursivelyOverrides(D, OtherD); - }), - FinalOverriders.end()); + llvm::erase_if(FinalOverriders, [&](CXXMethodDecl *OtherD) { + return recursivelyOverrides(D, OtherD); + }); FinalOverriders.push_back(D); }; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index d8b96ce10a1ab..59943d19a3e42 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -1084,14 +1084,10 @@ namespace { void performLifetimeExtension() { // Disable the cleanups for lifetime-extended temporaries. - CleanupStack.erase(std::remove_if(CleanupStack.begin(), - CleanupStack.end(), - [](Cleanup &C) { - return !C.isDestroyedAtEndOf( - ScopeKind::FullExpression); - }), - CleanupStack.end()); - } + llvm::erase_if(CleanupStack, [](Cleanup &C) { + return !C.isDestroyedAtEndOf(ScopeKind::FullExpression); + }); + } /// Throw away any remaining cleanups at the end of evaluation. If any /// cleanups would have had a side-effect, note that as an unmodeled diff --git a/clang/lib/AST/ExternalASTMerger.cpp b/clang/lib/AST/ExternalASTMerger.cpp index c7789b707b219..a2ef270d7a9c5 100644 --- a/clang/lib/AST/ExternalASTMerger.cpp +++ b/clang/lib/AST/ExternalASTMerger.cpp @@ -425,16 +425,14 @@ void ExternalASTMerger::RemoveSources(llvm::ArrayRef<ImporterSource> Sources) { logs() << "(ExternalASTMerger*)" << (void *)this << " removing source (ASTContext*)" << (void *)&S.getASTContext() << "\n"; - Importers.erase( - std::remove_if(Importers.begin(), Importers.end(), - [&Sources](std::unique_ptr<ASTImporter> &Importer) -> bool { - for (const ImporterSource &S : Sources) { - if (&Importer->getFromContext() == &S.getASTContext()) - return true; - } - return false; - }), - Importers.end()); + llvm::erase_if(Importers, + [&Sources](std::unique_ptr<ASTImporter> &Importer) -> bool { + for (const ImporterSource &S : Sources) { + if (&Importer->getFromContext() == &S.getASTContext()) + return true; + } + return false; + }); for (OriginMap::iterator OI = Origins.begin(), OE = Origins.end(); OI != OE; ) { std::pair<const DeclContext *, DCOrigin> Origin = *OI; bool Erase = false; diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 9fa5e9cf1b79c..57454a59563a2 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3417,10 +3417,9 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) { Target.getCPUSpecificCPUDispatchFeatures(II->getName(), Features); llvm::transform(Features, Features.begin(), [](StringRef Str) { return Str.substr(1); }); - Features.erase(std::remove_if( - Features.begin(), Features.end(), [&Target](StringRef Feat) { - return !Target.validateCpuSupports(Feat); - }), Features.end()); + llvm::erase_if(Features, [&Target](StringRef Feat) { + return !Target.validateCpuSupports(Feat); + }); Options.emplace_back(cast<llvm::Function>(Func), StringRef{}, Features); ++Index; } diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp index 5dd55553bcb5f..ab44ba50b5d52 100644 --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -299,7 +299,7 @@ MultilibSet::multilib_list MultilibSet::filterCopy(FilterCallback F, } void MultilibSet::filterInPlace(FilterCallback F, multilib_list &Ms) { - Ms.erase(std::remove_if(Ms.begin(), Ms.end(), F), Ms.end()); + llvm::erase_if(Ms, F); } raw_ostream &clang::driver::operator<<(raw_ostream &OS, const MultilibSet &MS) { diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 50b965d29de46..52589677ca28c 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1069,9 +1069,7 @@ static void checkAndRemoveNonDriverDiags(SmallVectorImpl<StoredDiagnostic> &StoredDiags) { // Get rid of stored diagnostics except the ones from the driver which do not // have a source location. - StoredDiags.erase( - std::remove_if(StoredDiags.begin(), StoredDiags.end(), isNonDriverDiag), - StoredDiags.end()); + llvm::erase_if(StoredDiags, isNonDriverDiag); } static void checkAndSanitizeDiags(SmallVectorImpl<StoredDiagnostic> & diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 0e43fa404da70..20de9174740ac 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -1151,14 +1151,12 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc, // Remove any macro definitions that are explicitly ignored by the module. // They aren't supposed to affect how the module is built anyway. HeaderSearchOptions &HSOpts = Invocation->getHeaderSearchOpts(); - PPOpts.Macros.erase( - std::remove_if(PPOpts.Macros.begin(), PPOpts.Macros.end(), - [&HSOpts](const std::pair<std::string, bool> &def) { + llvm::erase_if( + PPOpts.Macros, [&HSOpts](const std::pair<std::string, bool> &def) { StringRef MacroDef = def.first; return HSOpts.ModulesIgnoreMacros.count( llvm::CachedHashString(MacroDef.split('=').first)) > 0; - }), - PPOpts.Macros.end()); + }); // If the original compiler invocation had -fmodule-name, pass it through. Invocation->getLangOpts()->ModuleName = diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 5a0fa5184e38b..cfee7a3c25137 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -155,11 +155,8 @@ ModuleMacro *Preprocessor::addModuleMacro(Module *Mod, IdentifierInfo *II, // If we were the first overrider for any macro, it's no longer a leaf. auto &LeafMacros = LeafModuleMacros[II]; if (HidAny) { - LeafMacros.erase(std::remove_if(LeafMacros.begin(), LeafMacros.end(), - [](ModuleMacro *MM) { - return MM->NumOverriddenBy != 0; - }), - LeafMacros.end()); + llvm::erase_if(LeafMacros, + [](ModuleMacro *MM) { return MM->NumOverriddenBy != 0; }); } // The new macro is always a leaf macro. diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp index 40ffa6cfee8fc..2fe88cc4d35d2 100644 --- a/clang/lib/Serialization/ModuleManager.cpp +++ b/clang/lib/Serialization/ModuleManager.cpp @@ -270,8 +270,7 @@ void ModuleManager::removeModules(ModuleIterator First, ModuleMap *modMap) { I->Imports.remove_if(IsVictim); I->ImportedBy.remove_if(IsVictim); } - Roots.erase(std::remove_if(Roots.begin(), Roots.end(), IsVictim), - Roots.end()); + llvm::erase_if(Roots, IsVictim); // Remove the modules from the PCH chain. for (auto I = First; I != Last; ++I) { diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp index 7f1d0ac354f9b..4888efec30ede 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp @@ -153,8 +153,7 @@ class CheckOverflowOps : return getDecl(CheckDR) == getDecl(DR) && Pred(Check); return false; }; - toScanFor.erase(std::remove_if(toScanFor.begin(), toScanFor.end(), P), - toScanFor.end()); + llvm::erase_if(toScanFor, P); } void CheckExpr(const Expr *E_p) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits