Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:21

0001 //===--- MoveConstArgCheck.h - clang-tidy -------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 #include "llvm/ADT/DenseSet.h"
0014 
0015 namespace clang::tidy::performance {
0016 
0017 /// Find casts of calculation results to bigger type. Typically from int to
0018 ///
0019 /// The options are
0020 ///
0021 ///   - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable
0022 //      types as their objects are not moved but copied. Enabled by default.
0023 //    - `CheckMoveToConstRef`: Whether to check if a `std::move()` is passed
0024 //      as a const reference argument.
0025 class MoveConstArgCheck : public ClangTidyCheck {
0026 public:
0027   MoveConstArgCheck(StringRef Name, ClangTidyContext *Context)
0028       : ClangTidyCheck(Name, Context), CheckTriviallyCopyableMove(Options.get(
0029                                            "CheckTriviallyCopyableMove", true)),
0030         CheckMoveToConstRef(Options.get("CheckMoveToConstRef", true)) {}
0031   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0032     return LangOpts.CPlusPlus;
0033   }
0034   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0035   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0036   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0037 
0038 private:
0039   const bool CheckTriviallyCopyableMove;
0040   const bool CheckMoveToConstRef;
0041   llvm::DenseSet<const CallExpr *> AlreadyCheckedMoves;
0042 };
0043 
0044 } // namespace clang::tidy::performance
0045 
0046 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H