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

Add [[nodiscard]] to non-void const-member functions with no arguments or pass-by-value or pass by const-reference arguments. More...

#include <UseNodiscardCheck.h>

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

Public Member Functions

 UseNodiscardCheck (StringRef Name, ClangTidyContext *Context)
bool isLanguageVersionSupported (const LangOptions &LangOpts) const override
void storeOptions (ClangTidyOptions::OptionMap &Opts) override
void registerMatchers (ast_matchers::MatchFinder *Finder) override
void check (const ast_matchers::MatchFinder::MatchResult &Result) override

Detailed Description

Add [[nodiscard]] to non-void const-member functions with no arguments or pass-by-value or pass by const-reference arguments.

bool empty() const;
bool empty(const Bar &) const;
bool empty(int bar) const;
static bool empty(SourceRange Range)
Definition sample.cpp:5

Is converted to:

[[nodiscard]] bool empty() const;
[[nodiscard]] bool empty(const Bar &) const;
[[nodiscard]] bool empty(int bar) const;

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-nodiscard.html

Definition at line 32 of file UseNodiscardCheck.h.

Constructor & Destructor Documentation

◆ UseNodiscardCheck()

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

Definition at line 76 of file UseNodiscardCheck.cpp.

Member Function Documentation

◆ check()

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

◆ isLanguageVersionSupported()

bool clang::tidy::modernize::UseNodiscardCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
override

Definition at line 135 of file UseNodiscardCheck.cpp.

◆ registerMatchers()

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

Definition at line 84 of file UseNodiscardCheck.cpp.

◆ storeOptions()

void clang::tidy::modernize::UseNodiscardCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

Definition at line 80 of file UseNodiscardCheck.cpp.


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