9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SUSPICIOUSCALLARGUMENTCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SUSPICIOUSCALLARGUMENTCHECK_H
12#include "../ClangTidyCheck.h"
13#include "llvm/ADT/StringSet.h"
25 enum class Heuristic {
39 enum class BoundKind {
53 static_cast<std::size_t
>(Heuristic::Dice) + 1;
58 void check(
const ast_matchers::MatchFinder::MatchResult &Result)
override;
61 const std::size_t MinimumIdentifierNameLength;
64 SmallVector<Heuristic, HeuristicCount> AppliedHeuristics;
67 SmallVector<std::pair<int8_t, int8_t>,
HeuristicCount> ConfiguredBounds;
70 llvm::StringMap<std::string> AbbreviationDictionary;
72 bool isHeuristicEnabled(Heuristic H)
const;
73 std::optional<int8_t> getBound(Heuristic H, BoundKind BK)
const;
76 SmallVector<QualType, SmallVectorSize> ArgTypes;
77 SmallVector<StringRef, SmallVectorSize> ArgNames;
78 SmallVector<QualType, SmallVectorSize> ParamTypes;
79 SmallVector<StringRef, SmallVectorSize> ParamNames;
81 void setParamNamesAndTypes(
const FunctionDecl *CalleeFuncDecl);
83 void setArgNamesAndTypes(
const CallExpr *MatchedCallExpr,
84 std::size_t InitialArgIndex);
86 bool areParamAndArgComparable(std::size_t Position1, std::size_t Position2,
87 const ASTContext &Ctx)
const;
89 bool areArgsSwapped(std::size_t Position1, std::size_t Position2)
const;
91 bool areNamesSimilar(StringRef Arg, StringRef Param, Heuristic H,
llvm::SmallString< 256U > Name
const int8_t SimilarAbove
The lower bound of % of similarity the two string must have to be considered similar.
const int8_t DissimilarBelow
The upper bound of % of similarity the two strings might have to be considered dissimilar.
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Finds function calls where the arguments passed are provided out of order, based on the difference be...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
static constexpr std::size_t HeuristicCount
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
static constexpr std::size_t SmallVectorSize
llvm::StringMap< ClangTidyValue > OptionMap