Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC)

This commit is contained in:
Kazu Hirata 2021-12-24 21:43:06 -08:00
parent 62e48ed10f
commit 76f0f1cc5c
9 changed files with 15 additions and 15 deletions

View File

@ -9272,7 +9272,7 @@ void getIntersectionOfProtocols(ASTContext &Context,
// Remove any implied protocols from the list of inherited protocols.
if (!ImpliedProtocols.empty()) {
llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool {
return ImpliedProtocols.count(proto) > 0;
return ImpliedProtocols.contains(proto);
});
}

View File

@ -12788,7 +12788,7 @@ void CGOpenMPRuntime::checkAndEmitSharedLastprivateConditional(
const CapturedStmt *CS = D.getCapturedStmt(CaptureRegions.back());
for (const auto &Pair : It->DeclToUniqueName) {
const auto *VD = cast<VarDecl>(Pair.first->getCanonicalDecl());
if (!CS->capturesVariable(VD) || IgnoredDecls.count(VD) > 0)
if (!CS->capturesVariable(VD) || IgnoredDecls.contains(VD))
continue;
auto I = LPCI->getSecond().find(Pair.first);
assert(I != LPCI->getSecond().end() &&

View File

@ -1154,12 +1154,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();
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;
});
llvm::erase_if(PPOpts.Macros,
[&HSOpts](const std::pair<std::string, bool> &def) {
StringRef MacroDef = def.first;
return HSOpts.ModulesIgnoreMacros.contains(
llvm::CachedHashString(MacroDef.split('=').first));
});
// If the original compiler invocation had -fmodule-name, pass it through.
Invocation->getLangOpts()->ModuleName =

View File

@ -293,7 +293,7 @@ public:
NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
// Check if we already completed this type.
if (m_decls_already_completed.count(to_named_decl) != 0)
if (m_decls_already_completed.contains(to_named_decl))
return;
// Queue this type to be completed.
m_decls_to_complete.insert(to_named_decl);

View File

@ -4647,7 +4647,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
// Add symbols from the trie to the symbol table.
for (auto &e : external_sym_trie_entries) {
if (symbols_added.find(e.entry.address) != symbols_added.end())
if (symbols_added.contains(e.entry.address))
continue;
// Find the section that this trie address is in, use that to annotate

View File

@ -874,7 +874,7 @@ void NativeProcessLinux::MonitorSignal(const siginfo_t &info,
// Check if debugger should stop at this signal or just ignore it and resume
// the inferior.
if (m_signals_to_ignore.find(signo) != m_signals_to_ignore.end()) {
if (m_signals_to_ignore.contains(signo)) {
ResumeThread(thread, thread.GetState(), signo);
return;
}

View File

@ -2963,7 +2963,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr,
// poison-generating flags (nuw/nsw, exact, inbounds, etc.). The scalarized
// instruction could feed a poison value to the base address of the widen
// load/store.
if (State.MayGeneratePoisonRecipes.count(RepRecipe) > 0)
if (State.MayGeneratePoisonRecipes.contains(RepRecipe))
Cloned->dropPoisonGeneratingFlags();
State.Builder.SetInsertPoint(Builder.GetInsertBlock(),
@ -9533,7 +9533,7 @@ void VPWidenRecipe::execute(VPTransformState &State) {
// exact, etc.). The control flow has been linearized and the
// instruction is no longer guarded by the predicate, which could make
// the flag properties to no longer hold.
if (State.MayGeneratePoisonRecipes.count(this) > 0)
if (State.MayGeneratePoisonRecipes.contains(this))
VecOp->dropPoisonGeneratingFlags();
}

View File

@ -472,7 +472,7 @@ public:
// are strictly not necessary by tracking the invariant load as a
// scalar.
LoadInst *LI = dyn_cast<LoadInst>(Inst);
if (LI && ILS.count(LI) > 0)
if (LI && ILS.contains(LI))
return false;
}

View File

@ -84,7 +84,7 @@ public:
ScopDetection &SD = FAM.getResult<ScopAnalysis>(*F);
const bool HasScopAsTopLevelRegion =
SD.ValidRegions.count(RI.getTopLevelRegion()) > 0;
SD.ValidRegions.contains(RI.getTopLevelRegion());
bool Changed = false;
if (HasScopAsTopLevelRegion) {