Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===--- UnconventionalAssignOperatorCheck.h - clang-tidy -------*- C++ -*-===//
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_ASSIGNOPERATORSIGNATURECHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGNOPERATORSIGNATURECHECK_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 
0014 namespace clang::tidy::misc {
0015 
0016 /// Finds declarations of assignment operators with the wrong return and/or
0017 /// argument types and definitions with good return type but wrong return
0018 /// statements.
0019 ///
0020 ///   * The return type must be `Class&`.
0021 ///   * Works with move-assign and assign by value.
0022 ///   * Private and deleted operators are ignored.
0023 ///   * The operator must always return ``*this``.
0024 ///
0025 /// For the user-facing documentation see:
0026 /// http://clang.llvm.org/extra/clang-tidy/checks/misc/unconventional-assign-operator.html
0027 class UnconventionalAssignOperatorCheck : public ClangTidyCheck {
0028 public:
0029   UnconventionalAssignOperatorCheck(StringRef Name, ClangTidyContext *Context)
0030       : ClangTidyCheck(Name, Context) {}
0031   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
0032     return LangOpts.CPlusPlus;
0033   }
0034   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0035   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0036 };
0037 
0038 } // namespace clang::tidy::misc
0039 
0040 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSIGNOPERATORSIGNATURECHECK_H