clang-tools 22.0.0git
clang::tidy::bugprone::InaccurateEraseCheck Class Reference

Checks for inaccurate use of the erase() method. More...

#include <InaccurateEraseCheck.h>

Inheritance diagram for clang::tidy::bugprone::InaccurateEraseCheck:
[legend]

Public Member Functions

 InaccurateEraseCheck (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
std::optional< TraversalKind > getCheckTraversalKind () const override

Detailed Description

Checks for inaccurate use of the erase() method.

Algorithms like remove() do not actually remove any element from the container but return an iterator to the first redundant element at the end of the container. These redundant elements must be removed using the erase() method. This check warns when not all of the elements will be removed due to using an inappropriate overload.

Definition at line 23 of file InaccurateEraseCheck.h.

Constructor & Destructor Documentation

◆ InaccurateEraseCheck()

clang::tidy::bugprone::InaccurateEraseCheck::InaccurateEraseCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Definition at line 25 of file InaccurateEraseCheck.h.

Member Function Documentation

◆ check()

void clang::tidy::bugprone::InaccurateEraseCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

Definition at line 37 of file InaccurateEraseCheck.cpp.

◆ getCheckTraversalKind()

std::optional< TraversalKind > clang::tidy::bugprone::InaccurateEraseCheck::getCheckTraversalKind ( ) const
inlineoverride

Definition at line 32 of file InaccurateEraseCheck.h.

◆ isLanguageVersionSupported()

bool clang::tidy::bugprone::InaccurateEraseCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 27 of file InaccurateEraseCheck.h.

◆ registerMatchers()

void clang::tidy::bugprone::InaccurateEraseCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 17 of file InaccurateEraseCheck.cpp.


The documentation for this class was generated from the following files: