From fdd6b2ea2ac03f09aaf71aa8d3301936cef0fee5 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 10 Feb 2019 05:54:57 +0000 Subject: [PATCH] Use llvm::is_contained. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353635 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ARCMT.cpp | 4 ++-- lib/AST/RecordLayoutBuilder.cpp | 2 +- lib/Basic/TargetInfo.cpp | 2 +- lib/Driver/Driver.cpp | 3 +-- lib/Driver/ToolChains/Arch/AArch64.cpp | 5 ++--- lib/Driver/ToolChains/Arch/RISCV.cpp | 2 +- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp | 2 +- unittests/Tooling/ToolingTest.cpp | 2 +- utils/TableGen/NeonEmitter.cpp | 4 ++-- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index d057dfcdf9..a0b9dc0f2e 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -35,10 +35,10 @@ bool CapturedDiagList::clearDiagnostic(ArrayRef IDs, while (I != List.end()) { FullSourceLoc diagLoc = I->getLocation(); if ((IDs.empty() || // empty means clear all diagnostics in the range. - std::find(IDs.begin(), IDs.end(), I->getID()) != IDs.end()) && + llvm::is_contained(IDs, I->getID())) && !diagLoc.isBeforeInTranslationUnitThan(range.getBegin()) && (diagLoc == range.getEnd() || - diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { + diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { cleared = true; ListTy::iterator eraseS = I++; if (eraseS->getLevel() != DiagnosticsEngine::Note) diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index be759e52a1..99b7cbd022 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -254,7 +254,7 @@ void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD, // If we have empty structures inside a union, we can assign both // the same offset. Just avoid pushing them twice in the list. ClassVectorTy &Classes = EmptyClassOffsets[Offset]; - if (std::find(Classes.begin(), Classes.end(), RD) != Classes.end()) + if (llvm::is_contained(Classes, RD)) return; Classes.push_back(RD); diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 79678ac6ed..5a75b857c2 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -456,7 +456,7 @@ bool TargetInfo::isValidGCCRegisterName(StringRef Name) const { } // Check register names. - if (std::find(Names.begin(), Names.end(), Name) != Names.end()) + if (llvm::is_contained(Names, Name)) return true; // Check any additional names that we have. diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 0a89e2c45e..eb03e6e87c 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1575,8 +1575,7 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const { // We want to show cc1-only options only when clang is invoked with -cc1 or // -Xclang. - if (std::find(Flags.begin(), Flags.end(), "-Xclang") != Flags.end() || - std::find(Flags.begin(), Flags.end(), "-cc1") != Flags.end()) + if (llvm::is_contained(Flags, "-Xclang") || llvm::is_contained(Flags, "-cc1")) DisableFlags &= ~options::NoDriverOption; StringRef Cur; diff --git a/lib/Driver/ToolChains/Arch/AArch64.cpp b/lib/Driver/ToolChains/Arch/AArch64.cpp index 2f1fd29f6f..6a5a6658ec 100644 --- a/lib/Driver/ToolChains/Arch/AArch64.cpp +++ b/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -207,7 +207,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, // TargetParser rewrite. const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), "-fullfp16"); const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), "+fp16fml"); - if (std::find(Features.begin(), Features.end(), "+v8.4a") != Features.end()) { + if (llvm::is_contained(Features, "+v8.4a")) { const auto ItRFullFP16 = std::find(Features.rbegin(), Features.rend(), "+fullfp16"); if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) { // Only entangled feature that can be to the right of this +fullfp16 is -fp16fml. @@ -217,8 +217,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, } else goto fp16_fml_fallthrough; - } - else { + } else { fp16_fml_fallthrough: // In both of these cases, putting the 'other' feature on the end of the vector will // result in the same effect as placing it immediately after the current feature. diff --git a/lib/Driver/ToolChains/Arch/RISCV.cpp b/lib/Driver/ToolChains/Arch/RISCV.cpp index 9bcbcf4b79..e40911f4db 100644 --- a/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -170,7 +170,7 @@ static void getExtensionFeatures(const Driver &D, } // Check if duplicated extension. - if (std::find(AllExts.begin(), AllExts.end(), Ext) != AllExts.end()) { + if (llvm::is_contained(AllExts, Ext)) { std::string Error = "duplicated "; Error += Desc; D.Diag(diag::err_drv_invalid_riscv_ext_arch_name) diff --git a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index 1f9a91c51c..79aaae8cbb 100644 --- a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -273,7 +273,7 @@ std::string HTMLDiagnostics::GenerateHTML(const PathDiagnostic& D, Rewriter &R, std::vector FileIDs; for (auto I : path) { FileID FID = I->getLocation().asLocation().getExpansionLoc().getFileID(); - if (std::find(FileIDs.begin(), FileIDs.end(), FID) != FileIDs.end()) + if (llvm::is_contained(FileIDs, FID)) continue; FileIDs.push_back(FID); diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp index 9601db3ed0..a3c245ba55 100644 --- a/unittests/Tooling/ToolingTest.cpp +++ b/unittests/Tooling/ToolingTest.cpp @@ -382,7 +382,7 @@ TEST(ClangToolTest, ArgumentAdjusters) { ArgumentsAdjuster CheckSyntaxOnlyAdjuster = [&Found, &Ran](const CommandLineArguments &Args, StringRef /*unused*/) { Ran = true; - if (std::find(Args.begin(), Args.end(), "-fsyntax-only") != Args.end()) + if (llvm::is_contained(Args, "-fsyntax-only")) Found = true; return Args; }; diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp index 6965f88621..ecd7c3fde9 100644 --- a/utils/TableGen/NeonEmitter.cpp +++ b/utils/TableGen/NeonEmitter.cpp @@ -2471,7 +2471,7 @@ void NeonEmitter::run(raw_ostream &OS) { I != Defs.end(); /*No step*/) { bool DependenciesSatisfied = true; for (auto *II : (*I)->getDependencies()) { - if (std::find(Defs.begin(), Defs.end(), II) != Defs.end()) + if (llvm::is_contained(Defs, II)) DependenciesSatisfied = false; } if (!DependenciesSatisfied) { @@ -2580,7 +2580,7 @@ void NeonEmitter::runFP16(raw_ostream &OS) { I != Defs.end(); /*No step*/) { bool DependenciesSatisfied = true; for (auto *II : (*I)->getDependencies()) { - if (std::find(Defs.begin(), Defs.end(), II) != Defs.end()) + if (llvm::is_contained(Defs, II)) DependenciesSatisfied = false; } if (!DependenciesSatisfied) { -- 2.40.0