9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_USERANGESCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_USERANGESCHECK_H
12#include "../ClangTidyCheck.h"
14#include "clang/AST/Decl.h"
15#include "clang/AST/Expr.h"
16#include "clang/Basic/Diagnostic.h"
17#include "llvm/ADT/IntrusiveRefCntPtr.h"
18#include "llvm/ADT/StringMap.h"
19#include "llvm/ADT/StringRef.h"
44 class Replacer :
public llvm::RefCountedBase<Replacer> {
48 virtual std::optional<std::string>
53 virtual std::optional<std::string>
62 using ReplacerMap = llvm::StringMap<llvm::IntrusiveRefCntPtr<Replacer>>;
69 virtual DiagnosticBuilder
createDiag(
const CallExpr &Call);
76 virtual ArrayRef<std::pair<StringRef, StringRef>>
80 Preprocessor *ModuleExpanderPP)
final;
82 void check(
const ast_matchers::MatchFinder::MatchResult &Result)
final;
88 std::vector<llvm::IntrusiveRefCntPtr<Replacer>> Replacers;
89 std::optional<ReverseIteratorDescriptor> ReverseDescriptor;
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Produces fixes to insert specified includes to source files, if not yet present.
virtual ArrayRef< Signature > getReplacementSignatures() const =0
Gets an array of all the possible overloads for a function with indexes where begin and end arguments...
virtual std::optional< std::string > getHeaderInclusion(const NamedDecl &OriginalName) const
Gets the header needed to access the replaced function Return std::nullopt if no new header is needed...
virtual std::optional< std::string > getReplaceName(const NamedDecl &OriginalName) const =0
Gets the name to replace a function with, return std::nullopt for a replacement where we just call a ...
virtual ~Replacer()=default
Base class for handling converting std iterator algorithms to a range equivalent.
virtual DiagnosticBuilder createDiag(const CallExpr &Call)
Create a diagnostic for the CallExpr Override this to support custom diagnostic messages.
void registerMatchers(ast_matchers::MatchFinder *Finder) final
Override this to register AST matchers with Finder.
std::optional< TraversalKind > getCheckTraversalKind() const override
void check(const ast_matchers::MatchFinder::MatchResult &Result) final
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) final
Override this to register PPCallbacks in the preprocessor.
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
virtual ReplacerMap getReplacerMap() const =0
Gets a map of function to replace and methods to create the replacements.
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
llvm::StringMap< llvm::IntrusiveRefCntPtr< Replacer > > ReplacerMap
virtual std::optional< ReverseIteratorDescriptor > getReverseDescriptor() const
virtual ArrayRef< std::pair< StringRef, StringRef > > getFreeBeginEndMethods() const
Gets the fully qualified names of begin and end functions.
SmallVector< Indexes, 2 > Signature
llvm::StringMap< ClangTidyValue > OptionMap
ArrayRef< std::pair< StringRef, StringRef > > FreeReverseNames
std::optional< StringRef > ReverseHeader
StringRef ReverseAdaptorName