clang-tools 22.0.0git
|
Checks whether a call to the size()/length() method can be replaced with a call to empty(). More...
#include <ContainerSizeEmptyCheck.h>
Public Member Functions | |
ContainerSizeEmptyCheck (StringRef Name, ClangTidyContext *Context) | |
bool | isLanguageVersionSupported (const LangOptions &LangOpts) const override |
void | registerMatchers (ast_matchers::MatchFinder *Finder) override |
void | check (const ast_matchers::MatchFinder::MatchResult &Result) override |
void | storeOptions (ClangTidyOptions::OptionMap &Opts) override |
std::optional< TraversalKind > | getCheckTraversalKind () const override |
Checks whether a call to the size()/length() method can be replaced with a call to empty().
The emptiness of a container should be checked using the empty() method instead of the size()/length() method. It shows clearer intent to use empty(). Furthermore some containers (for example, a std::forward_list) may implement the empty() method but not implement the size() or length() method. Using empty() whenever possible makes it easier to switch to another container in the future.
Definition at line 26 of file ContainerSizeEmptyCheck.h.
clang::tidy::readability::ContainerSizeEmptyCheck::ContainerSizeEmptyCheck | ( | StringRef | Name, |
ClangTidyContext * | Context ) |
Definition at line 132 of file ContainerSizeEmptyCheck.cpp.
|
override |
Definition at line 242 of file ContainerSizeEmptyCheck.cpp.
References clang::tidy::readability::isBinaryOrTernary().
|
inlineoverride |
Definition at line 35 of file ContainerSizeEmptyCheck.h.
|
inlineoverride |
Definition at line 29 of file ContainerSizeEmptyCheck.h.
|
override |
Definition at line 143 of file ContainerSizeEmptyCheck.cpp.
References clang::tidy::matchers::matchesAnyListedName().
|
override |
Definition at line 138 of file ContainerSizeEmptyCheck.cpp.
References clang::tidy::utils::options::serializeStringList().