clang-tools 19.0.0git
MoveConstArgCheck.h
Go to the documentation of this file.
1//===--- MoveConstArgCheck.h - clang-tidy -------------------------===//
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_MISC_MOVECONSTANTARGUMENTCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
11
12#include "../ClangTidyCheck.h"
13#include "llvm/ADT/DenseSet.h"
14
16
17/// Find casts of calculation results to bigger type. Typically from int to
18///
19/// The options are
20///
21/// - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable
22// types as their objects are not moved but copied. Enabled by default.
23// - `CheckMoveToConstRef`: Whether to check if a `std::move()` is passed
24// as a const reference argument.
26public:
28 : ClangTidyCheck(Name, Context), CheckTriviallyCopyableMove(Options.get(
29 "CheckTriviallyCopyableMove", true)),
30 CheckMoveToConstRef(Options.get("CheckMoveToConstRef", true)) {}
31 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
32 return LangOpts.CPlusPlus;
33 }
34 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
35 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
36 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37
38private:
39 const bool CheckTriviallyCopyableMove;
40 const bool CheckMoveToConstRef;
41 llvm::DenseSet<const CallExpr *> AlreadyCheckedMoves;
42};
43
44} // namespace clang::tidy::performance
45
46#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Find casts of calculation results to bigger type.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
MoveConstArgCheck(StringRef Name, ClangTidyContext *Context)
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
llvm::StringMap< ClangTidyValue > OptionMap