clang-tools 20.0.0git
EasilySwappableParametersCheck.h
Go to the documentation of this file.
1//===--- EasilySwappableParametersCheck.h - clang-tidy ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EASILYSWAPPABLEPARAMETERSCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EASILYSWAPPABLEPARAMETERSCHECK_H
11
12#include "../ClangTidyCheck.h"
13
14namespace clang::tidy::bugprone {
15
16/// Finds function definitions where parameters of convertible types follow
17/// each other directly, making call sites prone to calling the function with
18/// swapped (or badly ordered) arguments.
19///
20/// For the user-facing documentation see:
21/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/easily-swappable-parameters.html
23public:
25 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
26 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
27 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
28
29 /// The minimum length of an adjacent swappable parameter range required for
30 /// a diagnostic.
31 const std::size_t MinimumLength;
32
33 /// The parameter names (as written in the source text) to be ignored.
34 const std::vector<StringRef> IgnoredParameterNames;
35
36 /// The parameter typename suffixes (as written in the source code) to be
37 /// ignored.
38 const std::vector<StringRef> IgnoredParameterTypeSuffixes;
39
40 /// Whether to consider differently qualified versions of the same type
41 /// mixable.
42 const bool QualifiersMix;
43
44 /// Whether to model implicit conversions "in full" (conditions apply)
45 /// during analysis and consider types that are implicitly convertible to
46 /// one another mixable.
48
49 /// If enabled, diagnostics for parameters that are used together in a
50 /// similar way are not emitted.
52
53 /// The number of characters two parameter names might be dissimilar at
54 /// either end for the report about the parameters to be silenced.
55 /// E.g. the names "LHS" and "RHS" are 1-dissimilar suffixes of each other,
56 /// while "Text1" and "Text2" are 1-dissimilar prefixes of each other.
58};
59
60} // namespace clang::tidy::bugprone
61
62#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_EASILYSWAPPABLEPARAMETERSCHECK_H
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Finds function definitions where parameters of convertible types follow each other directly,...
const std::size_t MinimumLength
The minimum length of an adjacent swappable parameter range required for a diagnostic.
const bool ModelImplicitConversions
Whether to model implicit conversions "in full" (conditions apply) during analysis and consider types...
const bool QualifiersMix
Whether to consider differently qualified versions of the same type mixable.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
const bool SuppressParametersUsedTogether
If enabled, diagnostics for parameters that are used together in a similar way are not emitted.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
const std::vector< StringRef > IgnoredParameterNames
The parameter names (as written in the source text) to be ignored.
const std::size_t NamePrefixSuffixSilenceDissimilarityTreshold
The number of characters two parameter names might be dissimilar at either end for the report about t...
const std::vector< StringRef > IgnoredParameterTypeSuffixes
The parameter typename suffixes (as written in the source code) to be ignored.
llvm::StringMap< ClangTidyValue > OptionMap