clang-tools
20.0.0git
llvm-project
clang-tools-extra
clang-tidy
modernize
UseNodiscardCheck.h
Go to the documentation of this file.
1
//===--- UseNodiscardCheck.h - clang-tidy -----------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USENODISCARDCHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USENODISCARDCHECK_H
11
12
#include "../ClangTidyCheck.h"
13
14
namespace
clang::tidy::modernize
{
15
16
/// Add ``[[nodiscard]]`` to non-void const-member functions with no
17
/// arguments or pass-by-value or pass by const-reference arguments.
18
/// \code
19
/// bool empty() const;
20
/// bool empty(const Bar &) const;
21
/// bool empty(int bar) const;
22
/// \endcode
23
/// Is converted to:
24
/// \code
25
/// [[nodiscard]] bool empty() const;
26
/// [[nodiscard]] bool empty(const Bar &) const;
27
/// [[nodiscard]] bool empty(int bar) const;
28
/// \endcode
29
///
30
/// For the user-facing documentation see:
31
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-nodiscard.html
32
class
UseNodiscardCheck
:
public
ClangTidyCheck
{
33
public
:
34
UseNodiscardCheck
(StringRef
Name
,
ClangTidyContext
*Context);
35
bool
isLanguageVersionSupported
(
const
LangOptions &LangOpts)
const override
;
36
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
37
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
38
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
39
40
private
:
41
const
StringRef NoDiscardMacro;
42
};
43
44
}
// namespace clang::tidy::modernize
45
46
#endif
// LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USENODISCARDCHECK_H
Name
llvm::SmallString< 256U > Name
Definition:
ChainedComparisonCheck.cpp:42
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:53
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:69
clang::tidy::modernize::UseNodiscardCheck
Add [[nodiscard]] to non-void const-member functions with no arguments or pass-by-value or pass by co...
Definition:
UseNodiscardCheck.h:32
clang::tidy::modernize::UseNodiscardCheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition:
UseNodiscardCheck.cpp:135
clang::tidy::modernize::UseNodiscardCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition:
UseNodiscardCheck.cpp:80
clang::tidy::modernize::UseNodiscardCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
UseNodiscardCheck.cpp:110
clang::tidy::modernize::UseNodiscardCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
UseNodiscardCheck.cpp:84
clang::tidy::modernize
Definition:
AvoidBindCheck.cpp:32
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:126
Generated on Fri Oct 11 2024 00:37:06 for clang-tools by
1.9.6