clang-tools 22.0.0git
clang::tidy::modernize::ShrinkToFitCheck Class Reference

Replace copy and swap tricks on shrinkable containers with the shrink_to_fit() method call. More...

#include <ShrinkToFitCheck.h>

Inheritance diagram for clang::tidy::modernize::ShrinkToFitCheck:
[legend]

Public Member Functions

 ShrinkToFitCheck (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

Replace copy and swap tricks on shrinkable containers with the shrink_to_fit() method call.

The shrink_to_fit() method is more readable and more effective than the copy and swap trick to reduce the capacity of a shrinkable container. Note that, the shrink_to_fit() method is only available in C++11 and up.

Definition at line 22 of file ShrinkToFitCheck.h.

Constructor & Destructor Documentation

◆ ShrinkToFitCheck()

clang::tidy::modernize::ShrinkToFitCheck::ShrinkToFitCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Definition at line 24 of file ShrinkToFitCheck.h.

Member Function Documentation

◆ check()

void clang::tidy::modernize::ShrinkToFitCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

Definition at line 44 of file ShrinkToFitCheck.cpp.

◆ getCheckTraversalKind()

std::optional< TraversalKind > clang::tidy::modernize::ShrinkToFitCheck::getCheckTraversalKind ( ) const
inlineoverride

Definition at line 31 of file ShrinkToFitCheck.h.

◆ isLanguageVersionSupported()

bool clang::tidy::modernize::ShrinkToFitCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 26 of file ShrinkToFitCheck.h.

◆ registerMatchers()

void clang::tidy::modernize::ShrinkToFitCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 19 of file ShrinkToFitCheck.cpp.


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