File indexing completed on 2026-05-10 08:36:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_VALUE_PARAM_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_VALUE_PARAM_H
0011
0012 #include "../ClangTidyCheck.h"
0013 #include "../utils/IncludeInserter.h"
0014 #include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
0015
0016 namespace clang::tidy::performance {
0017
0018
0019
0020
0021
0022
0023 class UnnecessaryValueParamCheck : public ClangTidyCheck {
0024 public:
0025 UnnecessaryValueParamCheck(StringRef Name, ClangTidyContext *Context);
0026 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0027 return LangOpts.CPlusPlus;
0028 }
0029 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0030 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0031 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
0032 Preprocessor *ModuleExpanderPP) override;
0033 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0034 void onEndOfTranslationUnit() override;
0035
0036 protected:
0037
0038
0039 virtual void handleMoveFix(const ParmVarDecl &Param,
0040 const DeclRefExpr &CopyArgument,
0041 ASTContext &Context);
0042 virtual void handleConstRefFix(const FunctionDecl &Function,
0043 const ParmVarDecl &Param, ASTContext &Context);
0044
0045 private:
0046 ExprMutationAnalyzer::Memoized MutationAnalyzerCache;
0047 utils::IncludeInserter Inserter;
0048 const std::vector<StringRef> AllowedTypes;
0049 };
0050
0051 }
0052
0053 #endif