9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_USERANGESCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_USERANGESCHECK_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;
90 IncludeInserter Inserter;
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
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
llvm::StringMap< llvm::IntrusiveRefCntPtr< Replacer > > ReplacerMap
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
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
std::optional< TraversalKind > getCheckTraversalKind() const override
void check(const ast_matchers::MatchFinder::MatchResult &Result) final
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) final
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
UseRangesCheck(StringRef Name, ClangTidyContext *Context)
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