diff options
author | Piotr Zegar <me@piotrzegar.pl> | 2023-08-26 17:59:45 +0000 |
---|---|---|
committer | Piotr Zegar <me@piotrzegar.pl> | 2023-08-27 08:52:10 +0000 |
commit | c5a4f29ef02a48caddca3ab82dbd364ca9db558b (patch) | |
tree | ab23b84035b9f50078f5c7b06c161a8e2d1c9233 /clang-tools-extra/clang-tidy | |
parent | c8644b18f570be9d26d83cdeeb2369cd3cbddaf1 (diff) | |
download | llvm-c5a4f29ef02a48caddca3ab82dbd364ca9db558b.zip llvm-c5a4f29ef02a48caddca3ab82dbd364ca9db558b.tar.gz llvm-c5a4f29ef02a48caddca3ab82dbd364ca9db558b.tar.bz2 |
[clang-tidy][NFC] Fix readability-container-size-empty findings
Fix issues found by clang-tidy in clang-tidy source directory.
Diffstat (limited to 'clang-tools-extra/clang-tidy')
7 files changed, 16 insertions, 16 deletions
diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp index cba29b9..1b1fbe9 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp @@ -177,7 +177,7 @@ static bool isDestBasedOnGivenLength(const MatchFinder::MatchResult &Result) { StringRef LengthExprStr = exprToStr(Result.Nodes.getNodeAs<Expr>(LengthExprName), Result).trim(); - return DestCapacityExprStr != "" && LengthExprStr != "" && + return !DestCapacityExprStr.empty() && !LengthExprStr.empty() && DestCapacityExprStr.contains(LengthExprStr); } diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp index fb04e6e..6eefde3 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp @@ -104,7 +104,7 @@ static std::optional<std::string> getUnderscoreCapitalFixup(StringRef Name) { static bool startsWithUnderscoreInGlobalNamespace(StringRef Name, bool IsInGlobalNamespace, bool IsMacro) { - return !IsMacro && IsInGlobalNamespace && Name.size() >= 1 && Name[0] == '_'; + return !IsMacro && IsInGlobalNamespace && !Name.empty() && Name[0] == '_'; } static std::optional<std::string> diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp index 49293ab..43d53f0 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp @@ -101,7 +101,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective( for (const auto &HFE : Check.HeaderFileExtensions) { SmallString<128> GuessedFileName(FileName); llvm::sys::path::replace_extension(GuessedFileName, - (HFE.size() ? "." : "") + HFE); + (!HFE.empty() ? "." : "") + HFE); OptionalFileEntryRef File = PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr, diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp index 138f4bf6..87e1b05 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp @@ -50,7 +50,7 @@ static std::string createReplacementText(const LambdaExpr *Lambda) { llvm::raw_string_ostream Stream(Replacement); auto AppendName = [&](llvm::StringRef Name) { - if (Replacement.size() != 0) { + if (!Replacement.empty()) { Stream << ", "; } if (Lambda->getCaptureDefault() == LCD_ByRef && Name != "this") { @@ -68,7 +68,7 @@ static std::string createReplacementText(const LambdaExpr *Lambda) { AppendName("this"); } } - if (Replacement.size() && + if (!Replacement.empty() && Lambda->explicit_capture_begin() != Lambda->explicit_capture_end()) { // Add back separator if we are adding explicit capture variables. Stream << ", "; diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp index 951cc2f..7407418 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp @@ -353,7 +353,7 @@ static std::vector<FixItHint> handleReturnType(const FunctionDecl *Function, SmallVector<const Expr *, 3> ExistingConstraints; Function->getAssociatedConstraints(ExistingConstraints); - if (ExistingConstraints.size() > 0) { + if (!ExistingConstraints.empty()) { // FIXME - Support adding new constraints to existing ones. Do we need to // consider subsumption? return {}; @@ -401,7 +401,7 @@ handleTrailingTemplateType(const FunctionTemplateDecl *FunctionTemplate, SmallVector<const Expr *, 3> ExistingConstraints; Function->getAssociatedConstraints(ExistingConstraints); - if (ExistingConstraints.size() > 0) { + if (!ExistingConstraints.empty()) { // FIXME - Support adding new constraints to existing ones. Do we need to // consider subsumption? return {}; diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index d240d8d..7d4c7d4 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -672,13 +672,13 @@ std::string IdentifierNamingCheck::HungarianNotation::getEnumPrefix( if (!Splitter.match(Substr, &Groups)) break; - if (Groups[2].size() > 0) { + if (!Groups[2].empty()) { Words.push_back(Groups[1]); Substr = Substr.substr(Groups[0].size()); - } else if (Groups[3].size() > 0) { + } else if (!Groups[3].empty()) { Words.push_back(Groups[3]); Substr = Substr.substr(Groups[0].size() - Groups[4].size()); - } else if (Groups[5].size() > 0) { + } else if (!Groups[5].empty()) { Words.push_back(Groups[5]); Substr = Substr.substr(Groups[0].size() - Groups[6].size()); } @@ -913,13 +913,13 @@ std::string IdentifierNamingCheck::fixupWithCase( if (!Splitter.match(Substr, &Groups)) break; - if (Groups[2].size() > 0) { + if (!Groups[2].empty()) { Words.push_back(Groups[1]); Substr = Substr.substr(Groups[0].size()); - } else if (Groups[3].size() > 0) { + } else if (!Groups[3].empty()) { Words.push_back(Groups[3]); Substr = Substr.substr(Groups[0].size() - Groups[4].size()); - } else if (Groups[5].size() > 0) { + } else if (!Groups[5].empty()) { Words.push_back(Groups[5]); Substr = Substr.substr(Groups[0].size() - Groups[6].size()); } diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp index f1f1cc3..6ae46e2 100644 --- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp +++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp @@ -19,7 +19,7 @@ void ExceptionAnalyzer::ExceptionInfo::registerException( void ExceptionAnalyzer::ExceptionInfo::registerExceptions( const Throwables &Exceptions) { - if (Exceptions.size() == 0) + if (Exceptions.empty()) return; Behaviour = State::Throwing; ThrownExceptions.insert(Exceptions.begin(), Exceptions.end()); @@ -404,7 +404,7 @@ bool ExceptionAnalyzer::ExceptionInfo::filterByCatch( ThrownExceptions.erase(T); reevaluateBehaviour(); - return TypesToDelete.size() > 0; + return !TypesToDelete.empty(); } ExceptionAnalyzer::ExceptionInfo & @@ -437,7 +437,7 @@ void ExceptionAnalyzer::ExceptionInfo::clear() { } void ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() { - if (ThrownExceptions.size() == 0) + if (ThrownExceptions.empty()) if (ContainsUnknown) Behaviour = State::Unknown; else |