Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===--- ImplicitConversionInLoopCheck.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_PERFORMANCE_IMPLICIT_CONVERSION_IN_LOOP_CHECK_H_
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_IMPLICIT_CONVERSION_IN_LOOP_CHECK_H_
0011 
0012 #include "../ClangTidyCheck.h"
0013 
0014 namespace clang::tidy::performance {
0015 
0016 // Checks that in a for range loop, if the provided type is a reference, then
0017 // the underlying type is the one returned by the iterator (i.e. that there
0018 // isn't any implicit conversion).
0019 class ImplicitConversionInLoopCheck : public ClangTidyCheck {
0020 public:
0021   ImplicitConversionInLoopCheck(StringRef Name, ClangTidyContext *Context)
0022       : ClangTidyCheck(Name, Context) {}
0023       bool isLanguageVersionSupported(const LangOptions &LangOpts) const override{
0024         return LangOpts.CPlusPlus11;
0025       }
0026   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0027   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0028 
0029 private:
0030   void reportAndFix(const ASTContext *Context, const VarDecl *VD,
0031                     const Expr *OperatorCall);
0032 };
0033 
0034 } // namespace clang::tidy::performance
0035 
0036 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_IMPLICIT_CONVERSION_IN_LOOP_CHECK_H_