clang-tools 22.0.0git
|
Finds function definitions where parameters of convertible types follow each other directly, making call sites prone to calling the function with swapped (or badly ordered) arguments. More...
#include <EasilySwappableParametersCheck.h>
Public Member Functions | |
EasilySwappableParametersCheck (StringRef Name, ClangTidyContext *Context) | |
void | registerMatchers (ast_matchers::MatchFinder *Finder) override |
void | check (const ast_matchers::MatchFinder::MatchResult &Result) override |
void | storeOptions (ClangTidyOptions::OptionMap &Opts) override |
Public Attributes | |
const std::size_t | MinimumLength |
The minimum length of an adjacent swappable parameter range required for a diagnostic. | |
const std::vector< StringRef > | IgnoredParameterNames |
The parameter names (as written in the source text) to be ignored. | |
const std::vector< StringRef > | IgnoredParameterTypeSuffixes |
The parameter typename suffixes (as written in the source code) to be ignored. | |
const bool | QualifiersMix |
Whether to consider differently qualified versions of the same type mixable. | |
const bool | ModelImplicitConversions |
Whether to model implicit conversions "in full" (conditions apply) during analysis and consider types that are implicitly convertible to one another mixable. | |
const bool | SuppressParametersUsedTogether |
If enabled, diagnostics for parameters that are used together in a similar way are not emitted. | |
const std::size_t | NamePrefixSuffixSilenceDissimilarityThreshold |
The number of characters two parameter names might be dissimilar at either end for the report about the parameters to be silenced. |
Finds function definitions where parameters of convertible types follow each other directly, making call sites prone to calling the function with swapped (or badly ordered) arguments.
For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/easily-swappable-parameters.html
Definition at line 22 of file EasilySwappableParametersCheck.h.
clang::tidy::bugprone::EasilySwappableParametersCheck::EasilySwappableParametersCheck | ( | StringRef | Name, |
ClangTidyContext * | Context ) |
Definition at line 2095 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::clampMinimumLength(), DefaultIgnoredParameterNames, DefaultIgnoredParameterTypeSuffixes, DefaultMinimumLength, DefaultModelImplicitConversions, DefaultNamePrefixSuffixSilenceDissimilarityTreshold, DefaultQualifiersMix, DefaultSuppressParametersUsedTogether, IgnoredParameterNames, IgnoredParameterTypeSuffixes, MinimumLength, ModelImplicitConversions, NamePrefixSuffixSilenceDissimilarityThreshold, QualifiersMix, and SuppressParametersUsedTogether.
|
override |
Definition at line 2148 of file EasilySwappableParametersCheck.cpp.
References clang::tidy::bugprone::model::Mix::commonUnderlyingType(), clang::tidy::bugprone::model::Mix::First, clang::tidy::bugprone::model::Mix::flags(), clang::tidy::bugprone::getName(), clang::tidy::bugprone::getNameOrUnnamed(), clang::tidy::bugprone::model::ConversionSequence::getUserDefinedConversionFunction(), clang::tidy::bugprone::model::ConversionSequence::getUserDefinedConversionHighlight(), clang::tidy::bugprone::model::Mix::leftToRightConversionSequence(), MinimumLength, clang::tidy::bugprone::model::Mix::mixable(), clang::tidy::bugprone::needsToElaborateImplicitConversion(), clang::tidy::bugprone::needsToPrintTypeInDiagnostic(), clang::tidy::bugprone::PP, clang::tidy::bugprone::model::Mix::rightToLeftConversionSequence(), clang::tidy::bugprone::model::Mix::Second, SuppressParametersUsedTogether, and clang::tidy::bugprone::model::ConversionSequence::UDConvKind.
|
override |
Definition at line 2130 of file EasilySwappableParametersCheck.cpp.
References MinimumLength.
|
override |
Definition at line 2115 of file EasilySwappableParametersCheck.cpp.
References IgnoredParameterNames, IgnoredParameterTypeSuffixes, MinimumLength, ModelImplicitConversions, NamePrefixSuffixSilenceDissimilarityThreshold, QualifiersMix, clang::tidy::utils::options::serializeStringList(), and SuppressParametersUsedTogether.
const std::vector<StringRef> clang::tidy::bugprone::EasilySwappableParametersCheck::IgnoredParameterNames |
The parameter names (as written in the source text) to be ignored.
Definition at line 34 of file EasilySwappableParametersCheck.h.
Referenced by EasilySwappableParametersCheck(), clang::tidy::bugprone::filter::isIgnoredParameter(), and storeOptions().
const std::vector<StringRef> clang::tidy::bugprone::EasilySwappableParametersCheck::IgnoredParameterTypeSuffixes |
The parameter typename suffixes (as written in the source code) to be ignored.
Definition at line 38 of file EasilySwappableParametersCheck.h.
Referenced by EasilySwappableParametersCheck(), clang::tidy::bugprone::filter::isIgnoredParameter(), and storeOptions().
const std::size_t clang::tidy::bugprone::EasilySwappableParametersCheck::MinimumLength |
The minimum length of an adjacent swappable parameter range required for a diagnostic.
Definition at line 31 of file EasilySwappableParametersCheck.h.
Referenced by check(), EasilySwappableParametersCheck(), registerMatchers(), and storeOptions().
const bool clang::tidy::bugprone::EasilySwappableParametersCheck::ModelImplicitConversions |
Whether to model implicit conversions "in full" (conditions apply) during analysis and consider types that are implicitly convertible to one another mixable.
Definition at line 47 of file EasilySwappableParametersCheck.h.
Referenced by EasilySwappableParametersCheck(), clang::tidy::bugprone::model::modelMixingRange(), and storeOptions().
const std::size_t clang::tidy::bugprone::EasilySwappableParametersCheck::NamePrefixSuffixSilenceDissimilarityThreshold |
The number of characters two parameter names might be dissimilar at either end for the report about the parameters to be silenced.
E.g. the names "LHS" and "RHS" are 1-dissimilar suffixes of each other, while "Text1" and "Text2" are 1-dissimilar prefixes of each other.
Definition at line 57 of file EasilySwappableParametersCheck.h.
Referenced by EasilySwappableParametersCheck(), clang::tidy::bugprone::model::modelMixingRange(), and storeOptions().
const bool clang::tidy::bugprone::EasilySwappableParametersCheck::QualifiersMix |
Whether to consider differently qualified versions of the same type mixable.
Definition at line 42 of file EasilySwappableParametersCheck.h.
Referenced by clang::tidy::bugprone::model::calculateMixability(), EasilySwappableParametersCheck(), and storeOptions().
const bool clang::tidy::bugprone::EasilySwappableParametersCheck::SuppressParametersUsedTogether |
If enabled, diagnostics for parameters that are used together in a similar way are not emitted.
Definition at line 51 of file EasilySwappableParametersCheck.h.
Referenced by check(), EasilySwappableParametersCheck(), and storeOptions().