clang-tools 22.0.0git
clang::tidy::utils::TransformerClangTidyCheck Class Reference

A base class for defining a ClangTidy check based on a RewriteRule. More...

#include <TransformerClangTidyCheck.h>

Inheritance diagram for clang::tidy::utils::TransformerClangTidyCheck:
[legend]

Public Member Functions

 TransformerClangTidyCheck (StringRef Name, ClangTidyContext *Context)
 TransformerClangTidyCheck (std::function< std::optional< transformer::RewriteRuleWith< std::string > >(const LangOptions &, const OptionsView &)> MakeRule, StringRef Name, ClangTidyContext *Context)
 DEPRECATED: prefer the two argument constructor in conjunction with setRule.
 TransformerClangTidyCheck (transformer::RewriteRuleWith< std::string > R, StringRef Name, ClangTidyContext *Context)
 Convenience overload of the constructor when the rule doesn't have any dependencies.
void registerPPCallbacks (const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
void registerMatchers (ast_matchers::MatchFinder *Finder) final
void check (const ast_matchers::MatchFinder::MatchResult &Result) final
void storeOptions (ClangTidyOptions::OptionMap &Opts) override
 Derived classes that override this function should call this method from the overridden method.
void setRule (transformer::RewriteRuleWith< std::string > R)
 Set the rule that this check implements.

Detailed Description

A base class for defining a ClangTidy check based on a RewriteRule.

Definition at line 38 of file TransformerClangTidyCheck.h.

Constructor & Destructor Documentation

◆ TransformerClangTidyCheck() [1/3]

◆ TransformerClangTidyCheck() [2/3]

clang::tidy::utils::TransformerClangTidyCheck::TransformerClangTidyCheck ( std::function< std::optional< transformer::RewriteRuleWith< std::string > >(const LangOptions &, const OptionsView &)> MakeRule,
StringRef Name,
ClangTidyContext * Context )

DEPRECATED: prefer the two argument constructor in conjunction with setRule.

MakeRule generates the rewrite rule to be used by the check, based on the given language and clang-tidy options. It can return std::nullopt to handle cases where the options disable the check.

See setRule for constraints on the rule.

◆ TransformerClangTidyCheck() [3/3]

clang::tidy::utils::TransformerClangTidyCheck::TransformerClangTidyCheck ( transformer::RewriteRuleWith< std::string > R,
StringRef Name,
ClangTidyContext * Context )

Convenience overload of the constructor when the rule doesn't have any dependencies.

Member Function Documentation

◆ check()

void clang::tidy::utils::TransformerClangTidyCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
final

◆ registerMatchers()

void clang::tidy::utils::TransformerClangTidyCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
final

Definition at line 96 of file TransformerClangTidyCheck.cpp.

◆ registerPPCallbacks()

void clang::tidy::utils::TransformerClangTidyCheck::registerPPCallbacks ( const SourceManager & SM,
Preprocessor * PP,
Preprocessor * ModuleExpanderPP )
override

Definition at line 91 of file TransformerClangTidyCheck.cpp.

◆ setRule()

void clang::tidy::utils::TransformerClangTidyCheck::setRule ( transformer::RewriteRuleWith< std::string > R)

Set the rule that this check implements.

All cases in the rule must have a non-null Explanation, even though Explanation is optional for RewriteRule in general. Because the primary purpose of clang-tidy checks is to provide users with diagnostics, we assume that a missing explanation is a bug. If no explanation is desired, indicate that explicitly (for example, by passing text("no explanation") to makeRule as the Explanation argument).

Definition at line 85 of file TransformerClangTidyCheck.cpp.

References clang::tidy::utils::verifyRule().

Referenced by clang::tidy::abseil::StringFindStrContainsCheck::StringFindStrContainsCheck().

◆ storeOptions()

void clang::tidy::utils::TransformerClangTidyCheck::storeOptions ( ClangTidyOptions::OptionMap & Opts)
override

Derived classes that override this function should call this method from the overridden method.

Definition at line 153 of file TransformerClangTidyCheck.cpp.


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