Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Checks: >
readability-*,
-readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-container-contains,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
const SrcMgr::ContentCache &ContentCache,
llvm::vfs::InMemoryFileSystem &InMemoryFs) {
// Return if we are not interested in the contents of this file.
if (!FilesToRecord.count(File))
if (!FilesToRecord.contains(File))
return;

// FIXME: Why is this happening? We might be losing contents here.
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ bool NoLintDirectiveHandler::Impl::diagHasNoLint(
return false;

// Do we have cached NOLINT block locations for this file?
if (Cache.count(*FileName) == 0)
if (!Cache.contains(*FileName))
// Warning: heavy operation - need to read entire file.
generateCache(SrcMgr, *FileName, File, *Buffer, NoLintErrors);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void UpgradeDurationConversionsCheck::check(

if (!match(isInTemplateInstantiation(), *OuterExpr, *Result.Context)
.empty()) {
if (MatchedTemplateLocations.count(Loc) == 0) {
if (!MatchedTemplateLocations.contains(Loc)) {
// For each location matched in a template instantiation, we check if the
// location can also be found in `MatchedTemplateLocations`. If it is not
// found, that means the expression did not create a match without the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ bool SignalHandlerCheck::isStandardFunctionAsyncSafe(
if (!FD->isInStdNamespace() && !FD->isGlobal())
return false;

if (ConformingFunctions.count(II->getName()))
if (ConformingFunctions.contains(II->getName()))
return true;

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) {

// Only need to check RHS, as LHS has already been covered. We don't want to
// emit two warnings for a single argument.
if (UsedArgs.count(RHS))
if (UsedArgs.contains(RHS))
continue;

const auto *LHSCast = dyn_cast<ImplicitCastExpr>(ignoreNoOpCasts(LHS));
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
std::optional<UseAfterMove>
UseAfterMoveFinder::findInternal(const CFGBlock *Block, const Expr *MovingCall,
const ValueDecl *MovedVariable) {
if (Visited.count(Block))
if (Visited.contains(Block))
return std::nullopt;

// Mark the block as visited (except if this is the block containing the
Expand Down Expand Up @@ -232,7 +232,7 @@ void UseAfterMoveFinder::getUsesAndReinits(
// All references to the variable that aren't reinitializations are uses.
Uses->clear();
for (const DeclRefExpr *DeclRef : DeclRefs) {
if (!ReinitDeclRefs.count(DeclRef))
if (!ReinitDeclRefs.contains(DeclRef))
Uses->push_back(DeclRef);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ toCommaSeparatedString(const R &OrderedDecls,
const SmallPtrSetImpl<const T *> &DeclsToInit) {
SmallVector<StringRef, 16> Names;
for (const T *Decl : OrderedDecls) {
if (DeclsToInit.count(Decl))
if (DeclsToInit.contains(Decl))
Names.emplace_back(getName(Decl));
}
return llvm::join(Names.begin(), Names.end(), ", ");
Expand Down Expand Up @@ -501,7 +501,7 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
AnyMemberHasInitPerUnion = false;
forEachFieldWithFilter(ClassDecl, ClassDecl.fields(),
AnyMemberHasInitPerUnion, [&](const FieldDecl *F) {
if (!FieldsToInit.count(F))
if (!FieldsToInit.contains(F))
return;
// Don't suggest fixes for enums because we don't
// know a good default. Don't suggest fixes for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void UpgradeGoogletestCaseCheck::check(const MatchFinder::MatchResult &Result) {
}

if (IsInInstantiation) {
if (MatchedTemplateLocations.count(ReplacementRange.getBegin()) == 0) {
if (!MatchedTemplateLocations.contains(ReplacementRange.getBegin())) {
// For each location matched in a template instantiation, we check if
// the location can also be found in `MatchedTemplateLocations`. If it
// is not found, that means the expression did not create a match
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ static bool emitCapture(llvm::StringSet<> &CaptureSet, StringRef Delimiter,
return false;

// This capture has already been emitted.
if (CaptureSet.count(Identifier) != 0)
if (CaptureSet.contains(Identifier))
return false;

Stream << Delimiter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void IncludeModernizePPCallbacks::InclusionDirective(
It != CStyledHeaderToCxx.end()) {
IncludesToBeProcessed.emplace_back(IncludeMarker{
It->second, FileName, FilenameRange.getAsRange(), DiagLoc});
} else if (DeleteHeaders.count(FileName) != 0) {
} else if (DeleteHeaders.contains(FileName)) {
IncludesToBeProcessed.emplace_back(
// NOLINTNEXTLINE(modernize-use-emplace) - false-positive
IncludeMarker{std::string{}, FileName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ bool LoopConvertCheck::isConvertible(ASTContext *Context,
// do any further updates on this iteration.
if (areDiagsSelfContained())
TUInfo = std::make_unique<TUTrackingInfo>();
else if (TUInfo->getReplacedVars().count(Loop))
else if (TUInfo->getReplacedVars().contains(Loop))
return false;

// Check that we have exactly one index variable and at most one end variable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void TypePromotionInMathFnCheck::check(const MatchFinder::MatchResult &Result) {
"log1p", "log2", "logb", "lrint", "lround", "nearbyint",
"nextafter", "nexttoward", "remainder", "remquo", "rint", "round",
"scalbln", "scalbn", "tgamma", "trunc"};
bool StdFnRequiresCpp11 = Cpp11OnlyFns.count(OldFnName);
bool StdFnRequiresCpp11 = Cpp11OnlyFns.contains(OldFnName);

std::string NewFnName;
bool FnInCmath = false;
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/utils/ExprSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const Stmt *ExprSequence::getSequenceSuccessor(const Stmt *S) const {
}

const Stmt *ExprSequence::resolveSyntheticStmt(const Stmt *S) const {
if (SyntheticStmtSourceMap.count(S))
if (SyntheticStmtSourceMap.contains(S))
return SyntheticStmtSourceMap.lookup(S);
return S;
}
Expand All @@ -274,7 +274,7 @@ StmtToBlockMap::StmtToBlockMap(const CFG *TheCFG, ASTContext *TheContext)
}

const CFGBlock *StmtToBlockMap::blockContainingStmt(const Stmt *S) const {
while (!Map.count(S)) {
while (!Map.contains(S)) {
SmallVector<const Stmt *, 1> Parents = getParentStmts(S, Context);
if (Parents.empty())
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ getFileExtension(StringRef FileName, const FileExtensionsSet &FileExtensions) {
if (Extension.empty())
return std::nullopt;
// Skip "." prefix.
if (!FileExtensions.count(Extension.substr(1)))
if (!FileExtensions.contains(Extension.substr(1)))
return std::nullopt;
return Extension;
}
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ NamespaceAliaser::createAlias(ASTContext &Context, const Stmt &Statement,
if (!Function || !Function->hasBody())
return std::nullopt;

if (AddedAliases[Function].count(Namespace.str()) != 0)
if (AddedAliases[Function].contains(Namespace.str()))
return std::nullopt;

// FIXME: Doesn't consider the order of declarations.
Expand Down Expand Up @@ -84,7 +84,7 @@ std::string NamespaceAliaser::getNamespaceName(ASTContext &Context,
const auto *Function = getSurroundingFunction(Context, Statement);
auto FunctionAliases = AddedAliases.find(Function);
if (FunctionAliases != AddedAliases.end()) {
if (FunctionAliases->second.count(Namespace) != 0) {
if (FunctionAliases->second.contains(Namespace)) {
return FunctionAliases->second.find(Namespace)->getValue();
}
}
Expand Down