clang-tools 6.0.0

UnnecessaryValueParamCheck.h
Go to the documentation of this file.
1 //===--- UnnecessaryValueParamCheck.h - clang-tidy---------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_VALUE_PARAM_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_VALUE_PARAM_H
12
13 #include "../ClangTidy.h"
14 #include "../utils/IncludeInserter.h"
15
16 namespace clang {
17 namespace tidy {
18 namespace performance {
19
20 /// \brief A check that flags value parameters of expensive to copy types that
21 /// can safely be converted to const references.
22 ///
23 /// For the user-facing documentation see:
24 /// http://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-value-param.html
25 class UnnecessaryValueParamCheck : public ClangTidyCheck {
26 public:
27 UnnecessaryValueParamCheck(StringRef Name, ClangTidyContext *Context);
28 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
29 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
30 void registerPPCallbacks(CompilerInstance &Compiler) override;
31 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
32
33 private:
34 void handleMoveFix(const ParmVarDecl &Var, const DeclRefExpr &CopyArgument,
35 const ASTContext &Context);
36
37 std::unique_ptr<utils::IncludeInserter> Inserter;
38 const utils::IncludeSorter::IncludeStyle IncludeStyle;
39 };
40
41 } // namespace performance
42 } // namespace tidy
43 } // namespace clang
44
45 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_VALUE_PARAM_H
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::utils::IncludeSorter::IncludeStyle
IncludeStyle
Supported include styles.
Definition: IncludeSorter.h:27
clang::tidy::performance::UnnecessaryValueParamCheck::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: UnnecessaryValueParamCheck.cpp:174
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::performance::UnnecessaryValueParamCheck::UnnecessaryValueParamCheck
UnnecessaryValueParamCheck(StringRef Name, ClangTidyContext *Context)
Definition: UnnecessaryValueParamCheck.cpp:75
clang::tidy::performance::UnnecessaryValueParamCheck
A check that flags value parameters of expensive to copy types that can safely be converted to const ...
Definition: UnnecessaryValueParamCheck.h:25
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:99
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::performance::UnnecessaryValueParamCheck::registerPPCallbacks
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
Definition: UnnecessaryValueParamCheck.cpp:167
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
clang::tidy::performance::UnnecessaryValueParamCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: UnnecessaryValueParamCheck.cpp:94
clang::tidy::performance::UnnecessaryValueParamCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: UnnecessaryValueParamCheck.cpp:81