Use llvm::is_contained. NFC

llvm-svn: 353635
This commit is contained in:
Fangrui Song 2019-02-10 05:54:57 +00:00
parent 609d676aab
commit 9ac13a1244
9 changed files with 12 additions and 14 deletions

View File

@ -35,7 +35,7 @@ bool CapturedDiagList::clearDiagnostic(ArrayRef<unsigned> IDs,
while (I != List.end()) { while (I != List.end()) {
FullSourceLoc diagLoc = I->getLocation(); FullSourceLoc diagLoc = I->getLocation();
if ((IDs.empty() || // empty means clear all diagnostics in the range. 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.isBeforeInTranslationUnitThan(range.getBegin()) &&
(diagLoc == range.getEnd() || (diagLoc == range.getEnd() ||
diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) { diagLoc.isBeforeInTranslationUnitThan(range.getEnd()))) {

View File

@ -254,7 +254,7 @@ void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD,
// If we have empty structures inside a union, we can assign both // If we have empty structures inside a union, we can assign both
// the same offset. Just avoid pushing them twice in the list. // the same offset. Just avoid pushing them twice in the list.
ClassVectorTy &Classes = EmptyClassOffsets[Offset]; ClassVectorTy &Classes = EmptyClassOffsets[Offset];
if (std::find(Classes.begin(), Classes.end(), RD) != Classes.end()) if (llvm::is_contained(Classes, RD))
return; return;
Classes.push_back(RD); Classes.push_back(RD);

View File

@ -456,7 +456,7 @@ bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
} }
// Check register names. // Check register names.
if (std::find(Names.begin(), Names.end(), Name) != Names.end()) if (llvm::is_contained(Names, Name))
return true; return true;
// Check any additional names that we have. // Check any additional names that we have.

View File

@ -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 // We want to show cc1-only options only when clang is invoked with -cc1 or
// -Xclang. // -Xclang.
if (std::find(Flags.begin(), Flags.end(), "-Xclang") != Flags.end() || if (llvm::is_contained(Flags, "-Xclang") || llvm::is_contained(Flags, "-cc1"))
std::find(Flags.begin(), Flags.end(), "-cc1") != Flags.end())
DisableFlags &= ~options::NoDriverOption; DisableFlags &= ~options::NoDriverOption;
StringRef Cur; StringRef Cur;

View File

@ -207,7 +207,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
// TargetParser rewrite. // TargetParser rewrite.
const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), "-fullfp16"); const auto ItRNoFullFP16 = std::find(Features.rbegin(), Features.rend(), "-fullfp16");
const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), "+fp16fml"); 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"); const auto ItRFullFP16 = std::find(Features.rbegin(), Features.rend(), "+fullfp16");
if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) { if (ItRFullFP16 < ItRNoFullFP16 && ItRFullFP16 < ItRFP16FML) {
// Only entangled feature that can be to the right of this +fullfp16 is -fp16fml. // 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 else
goto fp16_fml_fallthrough; goto fp16_fml_fallthrough;
} } else {
else {
fp16_fml_fallthrough: fp16_fml_fallthrough:
// In both of these cases, putting the 'other' feature on the end of the vector will // 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. // result in the same effect as placing it immediately after the current feature.

View File

@ -170,7 +170,7 @@ static void getExtensionFeatures(const Driver &D,
} }
// Check if duplicated extension. // Check if duplicated extension.
if (std::find(AllExts.begin(), AllExts.end(), Ext) != AllExts.end()) { if (llvm::is_contained(AllExts, Ext)) {
std::string Error = "duplicated "; std::string Error = "duplicated ";
Error += Desc; Error += Desc;
D.Diag(diag::err_drv_invalid_riscv_ext_arch_name) D.Diag(diag::err_drv_invalid_riscv_ext_arch_name)

View File

@ -273,7 +273,7 @@ std::string HTMLDiagnostics::GenerateHTML(const PathDiagnostic& D, Rewriter &R,
std::vector<FileID> FileIDs; std::vector<FileID> FileIDs;
for (auto I : path) { for (auto I : path) {
FileID FID = I->getLocation().asLocation().getExpansionLoc().getFileID(); FileID FID = I->getLocation().asLocation().getExpansionLoc().getFileID();
if (std::find(FileIDs.begin(), FileIDs.end(), FID) != FileIDs.end()) if (llvm::is_contained(FileIDs, FID))
continue; continue;
FileIDs.push_back(FID); FileIDs.push_back(FID);

View File

@ -382,7 +382,7 @@ TEST(ClangToolTest, ArgumentAdjusters) {
ArgumentsAdjuster CheckSyntaxOnlyAdjuster = ArgumentsAdjuster CheckSyntaxOnlyAdjuster =
[&Found, &Ran](const CommandLineArguments &Args, StringRef /*unused*/) { [&Found, &Ran](const CommandLineArguments &Args, StringRef /*unused*/) {
Ran = true; Ran = true;
if (std::find(Args.begin(), Args.end(), "-fsyntax-only") != Args.end()) if (llvm::is_contained(Args, "-fsyntax-only"))
Found = true; Found = true;
return Args; return Args;
}; };

View File

@ -2471,7 +2471,7 @@ void NeonEmitter::run(raw_ostream &OS) {
I != Defs.end(); /*No step*/) { I != Defs.end(); /*No step*/) {
bool DependenciesSatisfied = true; bool DependenciesSatisfied = true;
for (auto *II : (*I)->getDependencies()) { for (auto *II : (*I)->getDependencies()) {
if (std::find(Defs.begin(), Defs.end(), II) != Defs.end()) if (llvm::is_contained(Defs, II))
DependenciesSatisfied = false; DependenciesSatisfied = false;
} }
if (!DependenciesSatisfied) { if (!DependenciesSatisfied) {
@ -2580,7 +2580,7 @@ void NeonEmitter::runFP16(raw_ostream &OS) {
I != Defs.end(); /*No step*/) { I != Defs.end(); /*No step*/) {
bool DependenciesSatisfied = true; bool DependenciesSatisfied = true;
for (auto *II : (*I)->getDependencies()) { for (auto *II : (*I)->getDependencies()) {
if (std::find(Defs.begin(), Defs.end(), II) != Defs.end()) if (llvm::is_contained(Defs, II))
DependenciesSatisfied = false; DependenciesSatisfied = false;
} }
if (!DependenciesSatisfied) { if (!DependenciesSatisfied) {