Skip to content

Commit b3e2b1a

Browse files
authored
[clang-tidy][NFC] fix typo in ExceptionAnalyzer; replace count()>0 with contains (#116635)
1 parent 51ad290 commit b3e2b1a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace {
2020

2121
AST_MATCHER_P(FunctionDecl, isEnabled, llvm::StringSet<>,
2222
FunctionsThatShouldNotThrow) {
23-
return FunctionsThatShouldNotThrow.count(Node.getNameAsString()) > 0;
23+
return FunctionsThatShouldNotThrow.contains(Node.getNameAsString());
2424
}
2525

2626
AST_MATCHER(FunctionDecl, isExplicitThrow) {

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ ExceptionAnalyzer::ExceptionInfo::filterIgnoredExceptions(
418418
if (TD->getDeclName().isIdentifier()) {
419419
if ((IgnoreBadAlloc &&
420420
(TD->getName() == "bad_alloc" && TD->isInStdNamespace())) ||
421-
(IgnoredTypes.count(TD->getName()) > 0))
421+
(IgnoredTypes.contains(TD->getName())))
422422
TypesToDelete.push_back(T);
423423
}
424424
}
@@ -449,7 +449,8 @@ void ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
449449
ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
450450
const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught,
451451
llvm::SmallSet<const FunctionDecl *, 32> &CallStack) {
452-
if (!Func || CallStack.count(Func) || (!CallStack.empty() && !canThrow(Func)))
452+
if (!Func || CallStack.contains(Func) ||
453+
(!CallStack.empty() && !canThrow(Func)))
453454
return ExceptionInfo::createNonThrowing();
454455

455456
if (const Stmt *Body = Func->getBody()) {
@@ -507,7 +508,7 @@ ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
507508
for (unsigned I = 0; I < Try->getNumHandlers(); ++I) {
508509
const CXXCatchStmt *Catch = Try->getHandler(I);
509510

510-
// Everything is catched through 'catch(...)'.
511+
// Everything is caught through 'catch(...)'.
511512
if (!Catch->getExceptionDecl()) {
512513
ExceptionInfo Rethrown = throwsException(
513514
Catch->getHandlerBlock(), Uncaught.getExceptionTypes(), CallStack);

clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class ExceptionAnalyzer {
101101
/// Recalculate the 'Behaviour' for example after filtering.
102102
void reevaluateBehaviour();
103103

104-
/// Keep track if the entity related to this 'ExceptionInfo' can in princple
105-
/// throw, if it's unknown or if it won't throw.
104+
/// Keep track if the entity related to this 'ExceptionInfo' can in
105+
/// principle throw, if it's unknown or if it won't throw.
106106
State Behaviour;
107107

108108
/// Keep track if the entity contains any unknown elements to keep track

0 commit comments

Comments
 (0)