clang-tools 22.0.0git
clang::tidy::bugprone::EasilySwappableParametersCheck Class Reference

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>

Inheritance diagram for clang::tidy::bugprone::EasilySwappableParametersCheck:
[legend]

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ EasilySwappableParametersCheck()

Member Function Documentation

◆ check()

◆ registerMatchers()

void clang::tidy::bugprone::EasilySwappableParametersCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 2130 of file EasilySwappableParametersCheck.cpp.

References MinimumLength.

◆ storeOptions()

Member Data Documentation

◆ IgnoredParameterNames

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().

◆ IgnoredParameterTypeSuffixes

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().

◆ MinimumLength

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().

◆ ModelImplicitConversions

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().

◆ NamePrefixSuffixSilenceDissimilarityThreshold

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().

◆ QualifiersMix

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().

◆ SuppressParametersUsedTogether

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().


The documentation for this class was generated from the following files: