[clang] Use *{Set,Map}::contains (NFC)

This commit is contained in:
Kazu Hirata 2023-03-14 19:17:18 -07:00
parent 65fb636bd4
commit ea9d404032
17 changed files with 26 additions and 35 deletions

View File

@ -992,8 +992,7 @@ public:
if (OverriddenFilesInfo) {
if (OverriddenFilesInfo->OverriddenFilesWithBuffer.count(File))
return true;
if (OverriddenFilesInfo->OverriddenFiles.find(File) !=
OverriddenFilesInfo->OverriddenFiles.end())
if (OverriddenFilesInfo->OverriddenFiles.contains(File))
return true;
}
return false;
@ -1686,7 +1685,7 @@ public:
fileinfo_iterator fileinfo_begin() const { return FileInfos.begin(); }
fileinfo_iterator fileinfo_end() const { return FileInfos.end(); }
bool hasFileInfo(const FileEntry *File) const {
return FileInfos.find(File) != FileInfos.end();
return FileInfos.contains(File);
}
/// Print statistics to stderr.

View File

@ -60,9 +60,7 @@ public:
static const auto &getSpelling(Kind ABIKind) {
return getSpellingMap().find(ABIKind)->second;
}
static bool isABI(StringRef Name) {
return getABIMap().find(Name) != getABIMap().end();
}
static bool isABI(StringRef Name) { return getABIMap().contains(Name); }
// Return true if this target should use the relative vtables C++ ABI by
// default.

View File

@ -153,8 +153,7 @@ protected:
bool canModifyFile(StringRef Path) {
if (AllowListFilenames.empty())
return true;
return AllowListFilenames.find(llvm::sys::path::filename(Path)) !=
AllowListFilenames.end();
return AllowListFilenames.contains(llvm::sys::path::filename(Path));
}
bool canModifyFile(OptionalFileEntryRef FE) {
if (!FE)

View File

@ -605,7 +605,7 @@ FunctionParmMutationAnalyzer::FunctionParmMutationAnalyzer(
for (const CXXCtorInitializer *Init : Ctor->inits()) {
ExprMutationAnalyzer InitAnalyzer(*Init->getInit(), Context);
for (const ParmVarDecl *Parm : Ctor->parameters()) {
if (Results.find(Parm) != Results.end())
if (Results.contains(Parm))
continue;
if (const Stmt *S = InitAnalyzer.findMutation(Parm))
Results[Parm] = S;

View File

@ -1163,7 +1163,7 @@ void BeforeSet::checkBeforeAfter(const ValueDecl* StartVd,
}
// Transitively search other before sets, and warn on cycles.
if (traverse(Vdb)) {
if (CycMap.find(Vd) == CycMap.end()) {
if (!CycMap.contains(Vd)) {
CycMap.insert(std::make_pair(Vd, true));
StringRef L1 = Vd->getName();
Analyzer.Handler.handleBeforeAfterCycle(L1, Vd->getLocation());

View File

@ -26,7 +26,7 @@ static const std::pair<StringRef, StringRef> FeatureExtensionMap[] = {
{"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
bool OpenCLOptions::isKnown(llvm::StringRef Ext) const {
return OptMap.find(Ext) != OptMap.end();
return OptMap.contains(Ext);
}
bool OpenCLOptions::isAvailableOption(llvm::StringRef Ext,

View File

@ -660,7 +660,7 @@ parseInvocationList(StringRef FileContent, llvm::sys::path::Style PathStyle) {
StringRef InvocationKey = NativeSourcePath;
if (InvocationList.find(InvocationKey) != InvocationList.end())
if (InvocationList.contains(InvocationKey))
return llvm::make_error<IndexError>(
index_error_code::invocation_list_ambiguous);

View File

@ -961,7 +961,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
} else
TC = &getToolChain(C.getInputArgs(), TT);
C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);
if (DerivedArchs.find(TT.getTriple()) != DerivedArchs.end())
if (DerivedArchs.contains(TT.getTriple()))
KnownArchs[TC] = DerivedArchs[TT.getTriple()];
}
}
@ -4313,7 +4313,7 @@ Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
: "--no-offload-arch");
}
if (KnownArchs.find(TC) != KnownArchs.end())
if (KnownArchs.contains(TC))
return KnownArchs.lookup(TC);
llvm::DenseSet<StringRef> Archs;

View File

@ -63,7 +63,7 @@ bool Multilib::operator==(const Multilib &Other) const {
MyFlags.insert(Flag);
for (const auto &Flag : Other.Flags)
if (MyFlags.find(Flag) == MyFlags.end())
if (!MyFlags.contains(Flag))
return false;
if (osSuffix() != Other.osSuffix())

View File

@ -1232,8 +1232,7 @@ Error OffloadBundler::UnbundleArchive() {
// For inserting <CompatibleTarget, list<CodeObject>> entry in
// OutputArchivesMap.
if (OutputArchivesMap.find(CompatibleTarget) ==
OutputArchivesMap.end()) {
if (!OutputArchivesMap.contains(CompatibleTarget)) {
std::vector<NewArchiveMember> ArchiveMembers;
ArchiveMembers.push_back(NewArchiveMember(MemBufRef));

View File

@ -590,10 +590,8 @@ unsigned BreakableBlockComment::getContentIndent(unsigned LineIndex) const {
ContentWithNoDecoration = ContentWithNoDecoration.substr(1).ltrim(Blanks);
StringRef FirstWord = ContentWithNoDecoration.substr(
0, ContentWithNoDecoration.find_first_of(Blanks));
if (ContentIndentingJavadocAnnotations.find(FirstWord) !=
ContentIndentingJavadocAnnotations.end()) {
if (ContentIndentingJavadocAnnotations.contains(FirstWord))
return Style.ContinuationIndentWidth;
}
return 0;
}

View File

@ -151,18 +151,16 @@ void MacroExpander::parseDefinition(const std::string &Macro) {
}
bool MacroExpander::defined(llvm::StringRef Name) const {
return FunctionLike.find(Name) != FunctionLike.end() ||
ObjectLike.find(Name) != ObjectLike.end();
return FunctionLike.contains(Name) || ObjectLike.contains(Name);
}
bool MacroExpander::objectLike(llvm::StringRef Name) const {
return ObjectLike.find(Name) != ObjectLike.end();
return ObjectLike.contains(Name);
}
bool MacroExpander::hasArity(llvm::StringRef Name, unsigned Arity) const {
auto it = FunctionLike.find(Name);
return it != FunctionLike.end() &&
(it->second.find(Arity) != it->second.end());
return it != FunctionLike.end() && it->second.contains(Arity);
}
llvm::SmallVector<FormatToken *, 8>

View File

@ -87,7 +87,7 @@ void Preprocessor::appendMacroDirective(IdentifierInfo *II, MacroDirective *MD){
// Set up the identifier as having associated macro history.
II->setHasMacroDefinition(true);
if (!MD->isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())
if (!MD->isDefined() && !LeafModuleMacros.contains(II))
II->setHasMacroDefinition(false);
if (II->isFromAST())
II->setChangedSinceDeserialization();
@ -125,7 +125,7 @@ void Preprocessor::setLoadedMacroDirective(IdentifierInfo *II,
// Setup the identifier as having associated macro history.
II->setHasMacroDefinition(true);
if (!MD->isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())
if (!MD->isDefined() && !LeafModuleMacros.contains(II))
II->setHasMacroDefinition(false);
}

View File

@ -488,7 +488,7 @@ ExplodedGraph::trim(ArrayRef<const NodeTy *> Sinks,
const ExplodedNode *N = WL2.pop_back_val();
// Skip this node if we have already processed it.
if (Pass2.find(N) != Pass2.end())
if (Pass2.contains(N))
continue;
// Create the corresponding node in the new graph and record the mapping

View File

@ -398,7 +398,7 @@ void SymbolReaper::markDependentsLive(SymbolRef sym) {
if (const SymbolRefSmallVectorTy *Deps = SymMgr.getDependentSymbols(sym)) {
for (const auto I : *Deps) {
if (TheLiving.find(I) != TheLiving.end())
if (TheLiving.contains(I))
continue;
markLive(I);
}

View File

@ -2053,7 +2053,7 @@ bool PragmaClangAttributeSupport::isAttributedSupported(
for (const auto *Subject : Subjects) {
if (!isSupportedPragmaClangAttributeSubject(*Subject))
continue;
if (SubjectsToRules.find(Subject) == SubjectsToRules.end())
if (!SubjectsToRules.contains(Subject))
return false;
HasAtLeastOneValidSubject = true;
}

View File

@ -369,7 +369,7 @@ void BuiltinNameEmitter::ExtractEnumTypes(std::vector<Record *> &Types,
raw_string_ostream SS(Output);
for (const auto *T : Types) {
if (TypesSeen.find(T->getValueAsString("Name")) == TypesSeen.end()) {
if (!TypesSeen.contains(T->getValueAsString("Name"))) {
SS << " OCLT_" + T->getValueAsString("Name") << ",\n";
// Save the type names in the same order as their enum value. Note that
// the Record can be a VectorType or something else, only the name is
@ -510,7 +510,7 @@ void BuiltinNameEmitter::GetOverloads() {
std::vector<Record *> Builtins = Records.getAllDerivedDefinitions("Builtin");
for (const auto *B : Builtins) {
StringRef BName = B->getValueAsString("Name");
if (FctOverloadMap.find(BName) == FctOverloadMap.end()) {
if (!FctOverloadMap.contains(BName)) {
FctOverloadMap.insert(std::make_pair(
BName, std::vector<std::pair<const Record *, unsigned>>{}));
}
@ -907,10 +907,10 @@ static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
for (const auto *T : Types) {
// Check this is not an image type
if (ImageTypesMap.find(T->getValueAsString("Name")) != ImageTypesMap.end())
if (ImageTypesMap.contains(T->getValueAsString("Name")))
continue;
// Check we have not seen this Type
if (TypesSeen.find(T->getValueAsString("Name")) != TypesSeen.end())
if (TypesSeen.contains(T->getValueAsString("Name")))
continue;
TypesSeen.insert(std::make_pair(T->getValueAsString("Name"), true));
@ -1095,7 +1095,7 @@ void OpenCLBuiltinFileEmitterBase::expandTypesInSignature(
// the full type name to the extension.
StringRef Ext =
Type->getValueAsDef("Extension")->getValueAsString("ExtName");
if (!Ext.empty() && TypeExtMap.find(FullType) == TypeExtMap.end()) {
if (!Ext.empty() && !TypeExtMap.contains(FullType)) {
TypeExtMap.insert({FullType, Ext});
}
}