Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===--- EasilySwappableParametersCheck.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_BUGPRONE_EASILYSWAPPABLEPARAMETERSCHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EASILYSWAPPABLEPARAMETERSCHECK_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 
0014 namespace clang::tidy::bugprone {
0015 
0016 /// Finds function definitions where parameters of convertible types follow
0017 /// each other directly, making call sites prone to calling the function with
0018 /// swapped (or badly ordered) arguments.
0019 ///
0020 /// For the user-facing documentation see:
0021 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/easily-swappable-parameters.html
0022 class EasilySwappableParametersCheck : public ClangTidyCheck {
0023 public:
0024   EasilySwappableParametersCheck(StringRef Name, ClangTidyContext *Context);
0025   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0026   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0027   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0028 
0029   /// The minimum length of an adjacent swappable parameter range required for
0030   /// a diagnostic.
0031   const std::size_t MinimumLength;
0032 
0033   /// The parameter names (as written in the source text) to be ignored.
0034   const std::vector<StringRef> IgnoredParameterNames;
0035 
0036   /// The parameter typename suffixes (as written in the source code) to be
0037   /// ignored.
0038   const std::vector<StringRef> IgnoredParameterTypeSuffixes;
0039 
0040   /// Whether to consider differently qualified versions of the same type
0041   /// mixable.
0042   const bool QualifiersMix;
0043 
0044   /// Whether to model implicit conversions "in full" (conditions apply)
0045   /// during analysis and consider types that are implicitly convertible to
0046   /// one another mixable.
0047   const bool ModelImplicitConversions;
0048 
0049   /// If enabled, diagnostics for parameters that are used together in a
0050   /// similar way are not emitted.
0051   const bool SuppressParametersUsedTogether;
0052 
0053   /// The number of characters two parameter names might be dissimilar at
0054   /// either end for the report about the parameters to be silenced.
0055   /// E.g. the names "LHS" and "RHS" are 1-dissimilar suffixes of each other,
0056   /// while "Text1" and "Text2" are 1-dissimilar prefixes of each other.
0057   const std::size_t NamePrefixSuffixSilenceDissimilarityTreshold;
0058 };
0059 
0060 } // namespace clang::tidy::bugprone
0061 
0062 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EASILYSWAPPABLEPARAMETERSCHECK_H