[clang-tools-extra] 4db2e4c - Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 30 19:00:52 PDT 2021
Author: Kazu Hirata
Date: 2021-10-30T19:00:19-07:00
New Revision: 4db2e4cebe9c542b58aee26c556c84bd12aa6780
URL: https://github.com/llvm/llvm-project/commit/4db2e4cebe9c542b58aee26c556c84bd12aa6780
DIFF: https://github.com/llvm/llvm-project/commit/4db2e4cebe9c542b58aee26c556c84bd12aa6780.diff
LOG: Use {DenseSet,SetVector,SmallPtrSet}::contains (NFC)
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Sema/Scope.h
clang/lib/AST/ASTImporterLookupTable.cpp
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/AST/VTableBuilder.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
llvm/tools/llvm-objcopy/COFF/Object.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
index 7f851f0ba0237..c98a1ab7104fb 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
@@ -123,7 +123,7 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
if (CurDecl->hasDefinition() || CurDecl->isReferenced()) {
continue; // Skip forward declarations that are used/referenced.
}
- if (FriendTypes.count(CurDecl->getTypeForDecl()) != 0) {
+ if (FriendTypes.contains(CurDecl->getTypeForDecl())) {
continue; // Skip forward declarations referenced as friend.
}
if (CurDecl->getLocation().isMacroID() ||
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index 0c220e865ff48..aa9a0ca80458d 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -209,7 +209,7 @@ computeInsertions(const CXXConstructorDecl::init_const_range &Inits,
// Add all fields between current field up until the next initializer.
for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
if (const auto *D = dyn_cast<T>(*Decl)) {
- if (DeclsToInit.count(D) > 0)
+ if (DeclsToInit.contains(D))
Insertions.back().Initializers.emplace_back(getName(D));
}
}
@@ -221,7 +221,7 @@ computeInsertions(const CXXConstructorDecl::init_const_range &Inits,
// Add remaining decls that require initialization.
for (; Decl != std::end(OrderedDecls); ++Decl) {
if (const auto *D = dyn_cast<T>(*Decl)) {
- if (DeclsToInit.count(D) > 0)
+ if (DeclsToInit.contains(D))
Insertions.back().Initializers.emplace_back(getName(D));
}
}
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index ca96ab67090cc..04dff8dfefe06 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -172,7 +172,7 @@ void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {
//
// FIXME: Use a more efficient way to find a matching context.
for (auto &Context : Contexts) {
- if (Context.UsingTargetDecls.count(D->getCanonicalDecl()) > 0)
+ if (Context.UsingTargetDecls.contains(D->getCanonicalDecl()))
Context.IsUsed = true;
}
}
diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
index 9d467e54a98d8..1fcd1b76af852 100644
--- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
@@ -303,7 +303,7 @@ void InconsistentDeclarationParameterNameCheck::check(
const auto *OriginalDeclaration =
Result.Nodes.getNodeAs<FunctionDecl>("functionDecl");
- if (VisitedDeclarations.count(OriginalDeclaration) > 0)
+ if (VisitedDeclarations.contains(OriginalDeclaration))
return; // Avoid multiple warnings.
const FunctionDecl *ParameterSourceDeclaration =
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index 98a4f4a4343f8..77a510462a65e 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1013,8 +1013,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
}
bool isValidAsmImmediate(const llvm::APInt &Value) const {
if (!ImmSet.empty())
- return Value.isSignedIntN(32) &&
- ImmSet.count(Value.getZExtValue()) != 0;
+ return Value.isSignedIntN(32) && ImmSet.contains(Value.getZExtValue());
return !ImmRange.isConstrained ||
(Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
}
diff --git a/clang/include/clang/Sema/Scope.h b/clang/include/clang/Sema/Scope.h
index b499ba1e7c2af..872951a0829b4 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -337,7 +337,7 @@ class Scope {
/// isDeclScope - Return true if this is the scope that the specified decl is
/// declared in.
- bool isDeclScope(const Decl *D) const { return DeclsInScope.count(D) != 0; }
+ bool isDeclScope(const Decl *D) const { return DeclsInScope.contains(D); }
/// Get the entity corresponding to this scope.
DeclContext *getEntity() const {
diff --git a/clang/lib/AST/ASTImporterLookupTable.cpp b/clang/lib/AST/ASTImporterLookupTable.cpp
index b78cc0c053f60..bf772c20d32ee 100644
--- a/clang/lib/AST/ASTImporterLookupTable.cpp
+++ b/clang/lib/AST/ASTImporterLookupTable.cpp
@@ -145,7 +145,7 @@ ASTImporterLookupTable::lookup(DeclContext *DC, DeclarationName Name) const {
}
bool ASTImporterLookupTable::contains(DeclContext *DC, NamedDecl *ND) const {
- return 0 < lookup(DC, ND->getDeclName()).count(ND);
+ return lookup(DC, ND->getDeclName()).contains(ND);
}
void ASTImporterLookupTable::dump(DeclContext *DC) const {
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 35c0e92038a74..3e39ec1c718d1 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -3091,7 +3091,7 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) {
for (const CXXBaseSpecifier &VBase : RD->vbases()) {
const CXXRecordDecl *BaseDecl = VBase.getType()->getAsCXXRecordDecl();
const ASTRecordLayout &BaseLayout = Context.getASTRecordLayout(BaseDecl);
- bool HasVtordisp = HasVtorDispSet.count(BaseDecl) > 0;
+ bool HasVtordisp = HasVtorDispSet.contains(BaseDecl);
// Insert padding between two bases if the left first one is zero sized or
// contains a zero sized subobject and the right is zero sized or one leads
// with a zero sized base. The padding between virtual bases is 4
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index 2c3aa36af195e..ab18d2f9e1f2e 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -3454,7 +3454,7 @@ static void removeRedundantPaths(std::list<FullPathTy> &FullPaths) {
if (&SpecificPath == &OtherPath)
continue;
if (llvm::all_of(SpecificPath, [&](const BaseSubobject &BSO) {
- return OtherPath.count(BSO) != 0;
+ return OtherPath.contains(BSO);
})) {
return true;
}
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 5188ebc896007..9f4e0f12e0232 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -12373,7 +12373,7 @@ bool CGOpenMPRuntime::isNontemporalDecl(const ValueDecl *VD) const {
return llvm::any_of(
CGM.getOpenMPRuntime().NontemporalDeclsStack,
- [VD](const NontemporalDeclsSet &Set) { return Set.count(VD) > 0; });
+ [VD](const NontemporalDeclsSet &Set) { return Set.contains(VD); });
}
void CGOpenMPRuntime::LastprivateConditionalRAII::tryToDisableInnerAnalysis(
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 51ac96f6b2892..f8cf8a3d5dc8b 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -2711,8 +2711,7 @@ static void CheckProtocolMethodDefs(Sema &S,
ProtocolsExplictImpl.reset(new ProtocolNameSet);
findProtocolsWithExplicitImpls(Super, *ProtocolsExplictImpl);
}
- if (ProtocolsExplictImpl->find(PDecl->getIdentifier()) !=
- ProtocolsExplictImpl->end())
+ if (ProtocolsExplictImpl->contains(PDecl->getIdentifier()))
return;
// If no super class conforms to the protocol, we should not search
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index fa55f925d117b..888113cf93d8c 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -515,7 +515,7 @@ class DSAStackTy {
/// Checks if the specified declaration was used in the inner scan directive.
bool isUsedInScanDirective(ValueDecl *D) const {
if (const SharingMapTy *Stack = getTopOfStackOrNull())
- return Stack->UsedInScanDirective.count(D) > 0;
+ return Stack->UsedInScanDirective.contains(D);
return false;
}
@@ -1040,7 +1040,7 @@ class DSAStackTy {
// Return set of mapped classes types
bool isClassPreviouslyMapped(QualType QT) const {
const SharingMapTy &StackElem = getTopOfStack();
- return StackElem.MappedClassesQualTypes.count(QT) != 0;
+ return StackElem.MappedClassesQualTypes.contains(QT);
}
/// Adds global declare target to the parent target region.
@@ -1079,7 +1079,7 @@ class DSAStackTy {
}
/// Checks if the decl is implicitly firstprivate in the task-based region.
bool isImplicitTaskFirstprivate(Decl *D) const {
- return getTopOfStack().ImplicitTaskFirstprivates.count(D) > 0;
+ return getTopOfStack().ImplicitTaskFirstprivates.contains(D);
}
/// Marks decl as used in uses_allocators clause as the allocator.
diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
index 94ab9ad3b2153..b57c5dc6de562 100644
--- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -949,7 +949,7 @@ void NonLocalizedStringChecker::checkPostCall(const CallEvent &Call,
const IdentifierInfo *Identifier = Call.getCalleeIdentifier();
SVal sv = Call.getReturnValue();
- if (isAnnotatedAsReturningLocalized(D) || LSF.count(Identifier) != 0) {
+ if (isAnnotatedAsReturningLocalized(D) || LSF.contains(Identifier)) {
setLocalizedState(sv, C);
} else if (isNSStringType(RT, C.getASTContext()) &&
!hasLocalizedState(sv, C)) {
diff --git a/llvm/tools/llvm-objcopy/COFF/Object.cpp b/llvm/tools/llvm-objcopy/COFF/Object.cpp
index 1c17b8408ee7b..ec2628c7eca9e 100644
--- a/llvm/tools/llvm-objcopy/COFF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/COFF/Object.cpp
@@ -107,7 +107,7 @@ void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
// section,
// remove those as well as nothing will include them (and we can't
// leave them dangling).
- if (RemovedSections.count(Sym.AssociativeComdatTargetSectionId) == 1)
+ if (RemovedSections.contains(Sym.AssociativeComdatTargetSectionId))
AssociatedSections.insert(Sym.TargetSectionId);
return RemovedSections.contains(Sym.TargetSectionId);
});
More information about the cfe-commits
mailing list