clang-tools  6.0.0svn
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::tidy::ClangTidyCheck Class Reference

Base class for all clang-tidy checks. More...

#include <ClangTidy.h>

Inherits MatchCallback.

Inherited by clang::tidy::android::CloexecCheck, clang::tidy::boost::UseToStringCheck, clang::tidy::bugprone::ArgumentCommentCheck, clang::tidy::bugprone::AssertSideEffectCheck, clang::tidy::bugprone::BoolPointerImplicitConversionCheck, clang::tidy::bugprone::CopyConstructorInitCheck, clang::tidy::bugprone::DanglingHandleCheck, clang::tidy::bugprone::FoldInitTypeCheck, clang::tidy::bugprone::ForwardDeclarationNamespaceCheck, clang::tidy::bugprone::InaccurateEraseCheck, clang::tidy::bugprone::IntegerDivisionCheck, clang::tidy::bugprone::MisplacedOperatorInStrlenInAllocCheck, clang::tidy::bugprone::MoveForwardingReferenceCheck, clang::tidy::bugprone::MultipleStatementMacroCheck, clang::tidy::bugprone::StringConstructorCheck, clang::tidy::bugprone::SuspiciousMemsetUsageCheck, clang::tidy::bugprone::UndefinedMemoryManipulationCheck, clang::tidy::bugprone::UseAfterMoveCheck, clang::tidy::bugprone::VirtualNearMissCheck, clang::tidy::cert::CommandProcessorCheck, clang::tidy::cert::DontModifyStdNamespaceCheck, clang::tidy::cert::FloatLoopCounter, clang::tidy::cert::LimitedRandomnessCheck, clang::tidy::cert::PostfixOperatorCheck, clang::tidy::cert::SetLongJmpCheck, clang::tidy::cert::StaticObjectExceptionCheck, clang::tidy::cert::StrToNumCheck, clang::tidy::cert::ThrownExceptionTypeCheck, clang::tidy::cert::VariadicFunctionDefCheck, clang::tidy::cppcoreguidelines::InterfacesGlobalInitCheck, clang::tidy::cppcoreguidelines::NoMallocCheck, clang::tidy::cppcoreguidelines::OwningMemoryCheck, clang::tidy::cppcoreguidelines::ProBoundsArrayToPointerDecayCheck, clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck, clang::tidy::cppcoreguidelines::ProBoundsPointerArithmeticCheck, clang::tidy::cppcoreguidelines::ProTypeConstCastCheck, clang::tidy::cppcoreguidelines::ProTypeCstyleCastCheck, clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck, clang::tidy::cppcoreguidelines::ProTypeReinterpretCastCheck, clang::tidy::cppcoreguidelines::ProTypeStaticCastDowncastCheck, clang::tidy::cppcoreguidelines::ProTypeUnionAccessCheck, clang::tidy::cppcoreguidelines::ProTypeVarargCheck, clang::tidy::cppcoreguidelines::SlicingCheck, clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck, clang::tidy::fuchsia::DefaultArgumentsCheck, clang::tidy::google::build::ExplicitMakePairCheck, clang::tidy::google::build::UnnamedNamespaceInHeaderCheck, clang::tidy::google::build::UsingNamespaceDirectiveCheck, clang::tidy::google::DefaultArgumentsCheck, clang::tidy::google::ExplicitConstructorCheck, clang::tidy::google::objc::AvoidThrowingObjCExceptionCheck, clang::tidy::google::objc::GlobalVariableDeclarationCheck, clang::tidy::google::readability::AvoidCStyleCastsCheck, clang::tidy::google::readability::GlobalNamesInHeadersCheck, clang::tidy::google::readability::TodoCommentCheck, clang::tidy::google::runtime::IntegerTypesCheck, clang::tidy::google::runtime::NonConstReferences, clang::tidy::google::runtime::OverloadedUnaryAndCheck, clang::tidy::google::runtime::StringReferenceMemberCheck, clang::tidy::hicpp::ExceptionBaseclassCheck, clang::tidy::hicpp::NoAssemblerCheck, clang::tidy::hicpp::SignedBitwiseCheck, clang::tidy::llvm::IncludeOrderCheck, clang::tidy::llvm::TwineLocalCheck, clang::tidy::misc::DefinitionsInHeadersCheck, clang::tidy::misc::ForwardingReferenceOverloadCheck, clang::tidy::misc::IncorrectRoundings, clang::tidy::misc::LambdaFunctionNameCheck, clang::tidy::misc::MacroParenthesesCheck, clang::tidy::misc::MacroRepeatedSideEffectsCheck, clang::tidy::misc::MisplacedConstCheck, clang::tidy::misc::MisplacedWideningCastCheck, clang::tidy::misc::NewDeleteOverloadsCheck, clang::tidy::misc::NonCopyableObjectsCheck, clang::tidy::misc::RedundantExpressionCheck, clang::tidy::misc::SizeofContainerCheck, clang::tidy::misc::SizeofExpressionCheck, clang::tidy::misc::StaticAssertCheck, clang::tidy::misc::StringCompareCheck, clang::tidy::misc::StringIntegerAssignmentCheck, clang::tidy::misc::StringLiteralWithEmbeddedNulCheck, clang::tidy::misc::SuspiciousEnumUsageCheck, clang::tidy::misc::SuspiciousMissingCommaCheck, clang::tidy::misc::SuspiciousSemicolonCheck, clang::tidy::misc::SuspiciousStringCompareCheck, clang::tidy::misc::SwappedArgumentsCheck, clang::tidy::misc::ThrowByValueCatchByReferenceCheck, clang::tidy::misc::UnconventionalAssignOperatorCheck, clang::tidy::misc::UndelegatedConstructorCheck, clang::tidy::misc::UniqueptrResetReleaseCheck, clang::tidy::misc::UnusedAliasDeclsCheck, clang::tidy::misc::UnusedParametersCheck, clang::tidy::misc::UnusedRAIICheck, clang::tidy::misc::UnusedUsingDeclsCheck, clang::tidy::modernize::AvoidBindCheck, clang::tidy::modernize::DeprecatedHeadersCheck, clang::tidy::modernize::LoopConvertCheck, clang::tidy::modernize::MakeSmartPtrCheck, clang::tidy::modernize::PassByValueCheck, clang::tidy::modernize::RawStringLiteralCheck, clang::tidy::modernize::RedundantVoidArgCheck, clang::tidy::modernize::ReplaceAutoPtrCheck, clang::tidy::modernize::ReplaceRandomShuffleCheck, clang::tidy::modernize::ReturnBracedInitListCheck, clang::tidy::modernize::ShrinkToFitCheck, clang::tidy::modernize::UnaryStaticAssertCheck, clang::tidy::modernize::UseAutoCheck, clang::tidy::modernize::UseBoolLiteralsCheck, clang::tidy::modernize::UseDefaultMemberInitCheck, clang::tidy::modernize::UseEmplaceCheck, clang::tidy::modernize::UseEqualsDefaultCheck, clang::tidy::modernize::UseEqualsDeleteCheck, clang::tidy::modernize::UseNoexceptCheck, clang::tidy::modernize::UseNullptrCheck, clang::tidy::modernize::UseOverrideCheck, clang::tidy::modernize::UseTransparentFunctorsCheck, clang::tidy::modernize::UseUsingCheck, clang::tidy::mpi::BufferDerefCheck, clang::tidy::mpi::TypeMismatchCheck, clang::tidy::objc::AvoidNSErrorInitCheck, clang::tidy::objc::AvoidSpinlockCheck, clang::tidy::objc::ForbiddenSubclassingCheck, clang::tidy::objc::PropertyDeclarationCheck, clang::tidy::performance::FasterStringFindCheck, clang::tidy::performance::ForRangeCopyCheck, clang::tidy::performance::ImplicitConversionInLoopCheck, clang::tidy::performance::InefficientAlgorithmCheck, clang::tidy::performance::InefficientStringConcatenationCheck, clang::tidy::performance::InefficientVectorOperationCheck, clang::tidy::performance::MoveConstArgCheck, clang::tidy::performance::MoveConstructorInitCheck, clang::tidy::performance::NoexceptMoveConstructorCheck, clang::tidy::performance::TypePromotionInMathFnCheck, clang::tidy::performance::UnnecessaryCopyInitialization, clang::tidy::performance::UnnecessaryValueParamCheck, clang::tidy::readability::AvoidConstParamsInDecls, clang::tidy::readability::BracesAroundStatementsCheck, clang::tidy::readability::ContainerSizeEmptyCheck, clang::tidy::readability::DeletedDefaultCheck, clang::tidy::readability::DeleteNullPointerCheck, clang::tidy::readability::ElseAfterReturnCheck, clang::tidy::readability::FunctionSizeCheck, clang::tidy::readability::IdentifierNamingCheck, clang::tidy::readability::ImplicitBoolConversionCheck, clang::tidy::readability::InconsistentDeclarationParameterNameCheck, clang::tidy::readability::MisleadingIndentationCheck, clang::tidy::readability::MisplacedArrayIndexCheck, clang::tidy::readability::NamedParameterCheck, clang::tidy::readability::NamespaceCommentCheck, clang::tidy::readability::NonConstParameterCheck, clang::tidy::readability::RedundantControlFlowCheck, clang::tidy::readability::RedundantDeclarationCheck, clang::tidy::readability::RedundantFunctionPtrDereferenceCheck, clang::tidy::readability::RedundantMemberInitCheck, clang::tidy::readability::RedundantSmartptrGetCheck, clang::tidy::readability::RedundantStringCStrCheck, clang::tidy::readability::RedundantStringInitCheck, clang::tidy::readability::SimplifyBooleanExprCheck, clang::tidy::readability::StaticAccessedThroughInstanceCheck, clang::tidy::readability::StaticDefinitionInAnonymousNamespaceCheck, clang::tidy::readability::UniqueptrDeleteReleaseCheck, and clang::tidy::utils::HeaderGuardCheck.

Collaboration diagram for clang::tidy::ClangTidyCheck:
Collaboration graph
[legend]

Public Member Functions

 ClangTidyCheck (StringRef CheckName, ClangTidyContext *Context)
 Initializes the check with CheckName and Context. More...
 
virtual void registerPPCallbacks (CompilerInstance &Compiler)
 Override this to register PPCallbacks with Compiler. More...
 
virtual void registerMatchers (ast_matchers::MatchFinder *Finder)
 Override this to register AST matchers with Finder. More...
 
virtual void check (const ast_matchers::MatchFinder::MatchResult &Result)
 ClangTidyChecks that register ASTMatchers should do the actual work in here. More...
 
DiagnosticBuilder diag (SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
 Add a diagnostic with the check's name. More...
 
virtual void storeOptions (ClangTidyOptions::OptionMap &Options)
 Should store all options supported by this check with their current values or default values for options that haven't been overridden. More...
 

Protected Member Functions

StringRef getCurrentMainFile () const
 Returns the main file name of the current translation unit. More...
 
LangOptions getLangOpts () const
 Returns the language options from the context. More...
 

Protected Attributes

OptionsView Options
 

Detailed Description

Base class for all clang-tidy checks.

To implement a ClangTidyCheck, write a subclass and override some of the base class's methods. E.g. to implement a check that validates namespace declarations, override registerMatchers:

void registerMatchers(ast_matchers::MatchFinder *Finder) override {
Finder->addMatcher(namespaceDecl().bind("namespace"), this);
}

and then override check(const MatchResult &Result) to do the actual check for each match.

A new ClangTidyCheck instance is created per translation unit.

FIXME: Figure out whether carrying information from one TU to another is useful/necessary.

Definition at line 127 of file ClangTidy.h.

Constructor & Destructor Documentation

◆ ClangTidyCheck()

clang::tidy::ClangTidyCheck::ClangTidyCheck ( StringRef  CheckName,
ClangTidyContext Context 
)
inline

Initializes the check with CheckName and Context.

Derived classes must implement the constructor with this signature or delegate it. If a check needs to read options, it can do this in the constructor using the Options.get() methods below.

Definition at line 134 of file ClangTidy.h.

Member Function Documentation

◆ check()

virtual void clang::tidy::ClangTidyCheck::check ( const ast_matchers::MatchFinder::MatchResult &  Result)
inlinevirtual

ClangTidyChecks that register ASTMatchers should do the actual work in here.

Reimplemented in clang::tidy::modernize::ReplaceAutoPtrCheck, clang::tidy::readability::BracesAroundStatementsCheck, clang::tidy::bugprone::ForwardDeclarationNamespaceCheck, clang::tidy::google::runtime::StringReferenceMemberCheck, clang::tidy::cppcoreguidelines::NoMallocCheck, clang::tidy::modernize::UseEqualsDefaultCheck, clang::tidy::modernize::UseEqualsDeleteCheck, clang::tidy::bugprone::MoveForwardingReferenceCheck, clang::tidy::readability::FunctionSizeCheck, clang::tidy::misc::LambdaFunctionNameCheck, clang::tidy::readability::IdentifierNamingCheck, clang::tidy::bugprone::AssertSideEffectCheck, clang::tidy::google::build::UsingNamespaceDirectiveCheck, clang::tidy::bugprone::ArgumentCommentCheck, clang::tidy::cppcoreguidelines::OwningMemoryCheck, clang::tidy::misc::DefinitionsInHeadersCheck, clang::tidy::modernize::RedundantVoidArgCheck, clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck, clang::tidy::google::build::UnnamedNamespaceInHeaderCheck, clang::tidy::modernize::UseNoexceptCheck, clang::tidy::misc::MisplacedWideningCastCheck, clang::tidy::misc::UniqueptrResetReleaseCheck, clang::tidy::performance::TypePromotionInMathFnCheck, clang::tidy::bugprone::BoolPointerImplicitConversionCheck, clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck, clang::tidy::google::readability::GlobalNamesInHeadersCheck, clang::tidy::misc::ForwardingReferenceOverloadCheck, clang::tidy::misc::ThrowByValueCatchByReferenceCheck, clang::tidy::misc::UnconventionalAssignOperatorCheck, clang::tidy::readability::NamedParameterCheck, clang::tidy::google::readability::AvoidCStyleCastsCheck, clang::tidy::android::CloexecOpenCheck, clang::tidy::bugprone::FoldInitTypeCheck, clang::tidy::cppcoreguidelines::SlicingCheck, clang::tidy::google::runtime::IntegerTypesCheck, clang::tidy::modernize::UseUsingCheck, clang::tidy::mpi::BufferDerefCheck, clang::tidy::mpi::TypeMismatchCheck, clang::tidy::objc::PropertyDeclarationCheck, clang::tidy::performance::MoveConstArgCheck, clang::tidy::readability::ContainerSizeEmptyCheck, clang::tidy::readability::InconsistentDeclarationParameterNameCheck, clang::tidy::readability::RedundantSmartptrGetCheck, clang::tidy::readability::StaticAccessedThroughInstanceCheck, clang::tidy::bugprone::VirtualNearMissCheck, clang::tidy::misc::IncorrectRoundings, clang::tidy::modernize::UseEmplaceCheck, clang::tidy::performance::FasterStringFindCheck, clang::tidy::performance::UnnecessaryCopyInitialization, clang::tidy::android::CloexecFopenCheck, clang::tidy::bugprone::InaccurateEraseCheck, clang::tidy::cert::CommandProcessorCheck, clang::tidy::cert::LimitedRandomnessCheck, clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck, clang::tidy::google::objc::AvoidThrowingObjCExceptionCheck, clang::tidy::google::build::ExplicitMakePairCheck, clang::tidy::google::objc::GlobalVariableDeclarationCheck, clang::tidy::modernize::MakeSmartPtrCheck, clang::tidy::modernize::ReplaceRandomShuffleCheck, clang::tidy::objc::ForbiddenSubclassingCheck, clang::tidy::performance::MoveConstructorInitCheck, clang::tidy::performance::NoexceptMoveConstructorCheck, clang::tidy::readability::RedundantControlFlowCheck, clang::tidy::boost::UseToStringCheck, clang::tidy::bugprone::MisplacedOperatorInStrlenInAllocCheck, clang::tidy::bugprone::MultipleStatementMacroCheck, clang::tidy::bugprone::UndefinedMemoryManipulationCheck, clang::tidy::cert::FloatLoopCounter, clang::tidy::cppcoreguidelines::ProBoundsPointerArithmeticCheck, clang::tidy::google::runtime::OverloadedUnaryAndCheck, clang::tidy::misc::NewDeleteOverloadsCheck, clang::tidy::misc::StaticAssertCheck, clang::tidy::misc::UnusedUsingDeclsCheck, clang::tidy::modernize::AvoidBindCheck, clang::tidy::modernize::RawStringLiteralCheck, clang::tidy::modernize::ShrinkToFitCheck, clang::tidy::modernize::UseDefaultMemberInitCheck, clang::tidy::performance::InefficientStringConcatenationCheck, clang::tidy::readability::MisleadingIndentationCheck, clang::tidy::readability::SimplifyBooleanExprCheck, clang::tidy::android::CloexecDupCheck, clang::tidy::bugprone::CopyConstructorInitCheck, clang::tidy::bugprone::IntegerDivisionCheck, clang::tidy::bugprone::UseAfterMoveCheck, clang::tidy::cert::DontModifyStdNamespaceCheck, clang::tidy::cert::PostfixOperatorCheck, clang::tidy::cert::StaticObjectExceptionCheck, clang::tidy::cert::StrToNumCheck, clang::tidy::cppcoreguidelines::ProTypeCstyleCastCheck, clang::tidy::cppcoreguidelines::ProTypeStaticCastDowncastCheck, clang::tidy::cppcoreguidelines::ProTypeUnionAccessCheck, clang::tidy::cppcoreguidelines::ProTypeVarargCheck, clang::tidy::hicpp::SignedBitwiseCheck, clang::tidy::misc::MisplacedConstCheck, clang::tidy::misc::RedundantExpressionCheck, clang::tidy::misc::SizeofContainerCheck, clang::tidy::misc::StringCompareCheck, clang::tidy::misc::SuspiciousMissingCommaCheck, clang::tidy::misc::SuspiciousSemicolonCheck, clang::tidy::misc::UndelegatedConstructorCheck, clang::tidy::modernize::ReturnBracedInitListCheck, clang::tidy::modernize::UnaryStaticAssertCheck, clang::tidy::objc::AvoidNSErrorInitCheck, clang::tidy::objc::AvoidSpinlockCheck, clang::tidy::performance::InefficientAlgorithmCheck, clang::tidy::performance::UnnecessaryValueParamCheck, clang::tidy::readability::DeletedDefaultCheck, clang::tidy::readability::DeleteNullPointerCheck, clang::tidy::readability::ImplicitBoolConversionCheck, clang::tidy::readability::MisplacedArrayIndexCheck, clang::tidy::readability::NamespaceCommentCheck, clang::tidy::readability::RedundantMemberInitCheck, clang::tidy::readability::StaticDefinitionInAnonymousNamespaceCheck, clang::tidy::readability::UniqueptrDeleteReleaseCheck, clang::tidy::android::CloexecAccept4Check, clang::tidy::android::CloexecAcceptCheck, clang::tidy::android::CloexecCreatCheck, clang::tidy::android::CloexecEpollCreate1Check, clang::tidy::android::CloexecEpollCreateCheck, clang::tidy::android::CloexecInotifyInit1Check, clang::tidy::android::CloexecInotifyInitCheck, clang::tidy::android::CloexecMemfdCreateCheck, clang::tidy::android::CloexecSocketCheck, clang::tidy::bugprone::DanglingHandleCheck, clang::tidy::bugprone::StringConstructorCheck, clang::tidy::bugprone::SuspiciousMemsetUsageCheck, clang::tidy::cert::SetLongJmpCheck, clang::tidy::cert::ThrownExceptionTypeCheck, clang::tidy::cert::VariadicFunctionDefCheck, clang::tidy::cppcoreguidelines::InterfacesGlobalInitCheck, clang::tidy::cppcoreguidelines::ProBoundsArrayToPointerDecayCheck, clang::tidy::cppcoreguidelines::ProTypeConstCastCheck, clang::tidy::cppcoreguidelines::ProTypeReinterpretCastCheck, clang::tidy::fuchsia::DefaultArgumentsCheck, clang::tidy::hicpp::ExceptionBaseclassCheck, clang::tidy::hicpp::NoAssemblerCheck, clang::tidy::misc::SizeofExpressionCheck, clang::tidy::misc::StringIntegerAssignmentCheck, clang::tidy::misc::StringLiteralWithEmbeddedNulCheck, clang::tidy::misc::SuspiciousStringCompareCheck, clang::tidy::misc::UnusedRAIICheck, clang::tidy::modernize::PassByValueCheck, clang::tidy::performance::ForRangeCopyCheck, clang::tidy::performance::InefficientVectorOperationCheck, clang::tidy::readability::NonConstParameterCheck, clang::tidy::readability::RedundantFunctionPtrDereferenceCheck, clang::tidy::google::DefaultArgumentsCheck, clang::tidy::google::ExplicitConstructorCheck, clang::tidy::google::runtime::NonConstReferences, clang::tidy::misc::SuspiciousEnumUsageCheck, clang::tidy::modernize::UseBoolLiteralsCheck, clang::tidy::modernize::UseTransparentFunctorsCheck, clang::tidy::performance::ImplicitConversionInLoopCheck, clang::tidy::readability::AvoidConstParamsInDecls, clang::tidy::readability::ElseAfterReturnCheck, clang::tidy::readability::RedundantDeclarationCheck, clang::tidy::llvm::TwineLocalCheck, clang::tidy::misc::NonCopyableObjectsCheck, clang::tidy::misc::UnusedAliasDeclsCheck, clang::tidy::misc::UnusedParametersCheck, clang::tidy::misc::SwappedArgumentsCheck, clang::tidy::modernize::LoopConvertCheck, clang::tidy::modernize::UseOverrideCheck, clang::tidy::readability::RedundantStringCStrCheck, clang::tidy::readability::RedundantStringInitCheck, clang::tidy::modernize::UseAutoCheck, and clang::tidy::modernize::UseNullptrCheck.

Definition at line 163 of file ClangTidy.h.

References Loc.

◆ diag()

DiagnosticBuilder clang::tidy::ClangTidyCheck::diag ( SourceLocation  Loc,
StringRef  Description,
DiagnosticIDs::Level  Level = DiagnosticIDs::Warning 
)

Add a diagnostic with the check's name.

Definition at line 416 of file ClangTidy.cpp.

Referenced by clang::tidy::google::runtime::NonConstReferences::check(), clang::tidy::modernize::UseBoolLiteralsCheck::check(), clang::tidy::modernize::UseTransparentFunctorsCheck::check(), clang::tidy::misc::SuspiciousEnumUsageCheck::check(), clang::tidy::bugprone::DanglingHandleCheck::check(), clang::tidy::performance::ForRangeCopyCheck::check(), clang::tidy::bugprone::StringConstructorCheck::check(), clang::tidy::misc::SizeofExpressionCheck::check(), clang::tidy::misc::SuspiciousStringCompareCheck::check(), clang::tidy::performance::UnnecessaryValueParamCheck::check(), clang::tidy::readability::NamespaceCommentCheck::check(), clang::tidy::readability::ImplicitBoolConversionCheck::check(), clang::tidy::misc::SuspiciousMissingCommaCheck::check(), clang::tidy::modernize::UseDefaultMemberInitCheck::check(), clang::tidy::modernize::RawStringLiteralCheck::check(), clang::tidy::readability::SimplifyBooleanExprCheck::check(), clang::tidy::performance::InefficientStringConcatenationCheck::check(), clang::tidy::performance::MoveConstructorInitCheck::check(), clang::tidy::modernize::ReplaceRandomShuffleCheck::check(), clang::tidy::objc::ForbiddenSubclassingCheck::check(), clang::tidy::modernize::MakeSmartPtrCheck::check(), clang::tidy::modernize::UseEmplaceCheck::check(), clang::tidy::performance::FasterStringFindCheck::check(), clang::tidy::performance::UnnecessaryCopyInitialization::check(), clang::tidy::readability::ContainerSizeEmptyCheck::check(), clang::tidy::objc::PropertyDeclarationCheck::check(), clang::tidy::google::runtime::IntegerTypesCheck::check(), clang::tidy::google::readability::GlobalNamesInHeadersCheck::check(), clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck::check(), clang::tidy::misc::ThrowByValueCatchByReferenceCheck::check(), clang::tidy::performance::TypePromotionInMathFnCheck::check(), clang::tidy::misc::MisplacedWideningCastCheck::check(), clang::tidy::modernize::UseNoexceptCheck::check(), clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::check(), clang::tidy::misc::DefinitionsInHeadersCheck::check(), clang::tidy::modernize::UseEqualsDefaultCheck::check(), clang::tidy::readability::BracesAroundStatementsCheck::check(), clang::tidy::cppcoreguidelines::isEmpty(), clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::onEndOfTranslationUnit(), clang::tidy::readability::IdentifierNamingCheck::onEndOfTranslationUnit(), clang::tidy::bugprone::resolveMocks(), and clang::tidy::performance::UnnecessaryValueParamCheck::storeOptions().

◆ getCurrentMainFile()

StringRef clang::tidy::ClangTidyCheck::getCurrentMainFile ( ) const
inlineprotected

Returns the main file name of the current translation unit.

Definition at line 185 of file ClangTidy.h.

References clang::tidy::ClangTidyContext::getCurrentFile().

◆ getLangOpts()

LangOptions clang::tidy::ClangTidyCheck::getLangOpts ( ) const
inlineprotected

◆ registerMatchers()

virtual void clang::tidy::ClangTidyCheck::registerMatchers ( ast_matchers::MatchFinder *  Finder)
inlinevirtual

Override this to register AST matchers with Finder.

This should be used by clang-tidy checks that analyze code properties that dependent on AST knowledge.

You can register as many matchers as necessary with Finder. Usually, "this" will be used as callback, but you can also specify other callback classes. Thereby, different matchers can trigger different callbacks.

If you need to merge information between the different matchers, you can store these as members of the derived class. However, note that all matches occur in the order of the AST traversal.

Reimplemented in clang::tidy::modernize::ReplaceAutoPtrCheck, clang::tidy::readability::BracesAroundStatementsCheck, clang::tidy::bugprone::ForwardDeclarationNamespaceCheck, clang::tidy::google::runtime::StringReferenceMemberCheck, clang::tidy::modernize::UseEqualsDefaultCheck, clang::tidy::modernize::UseEqualsDeleteCheck, clang::tidy::bugprone::MoveForwardingReferenceCheck, clang::tidy::cppcoreguidelines::NoMallocCheck, clang::tidy::readability::FunctionSizeCheck, clang::tidy::readability::IdentifierNamingCheck, clang::tidy::bugprone::AssertSideEffectCheck, clang::tidy::google::build::UsingNamespaceDirectiveCheck, clang::tidy::misc::LambdaFunctionNameCheck, clang::tidy::bugprone::ArgumentCommentCheck, clang::tidy::cppcoreguidelines::OwningMemoryCheck, clang::tidy::misc::DefinitionsInHeadersCheck, clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck, clang::tidy::google::build::UnnamedNamespaceInHeaderCheck, clang::tidy::modernize::RedundantVoidArgCheck, clang::tidy::modernize::UseNoexceptCheck, clang::tidy::misc::MisplacedWideningCastCheck, clang::tidy::misc::UniqueptrResetReleaseCheck, clang::tidy::performance::TypePromotionInMathFnCheck, clang::tidy::bugprone::BoolPointerImplicitConversionCheck, clang::tidy::google::readability::GlobalNamesInHeadersCheck, clang::tidy::misc::ForwardingReferenceOverloadCheck, clang::tidy::misc::ThrowByValueCatchByReferenceCheck, clang::tidy::misc::UnconventionalAssignOperatorCheck, clang::tidy::readability::NamedParameterCheck, clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck, clang::tidy::google::readability::AvoidCStyleCastsCheck, clang::tidy::android::CloexecOpenCheck, clang::tidy::bugprone::FoldInitTypeCheck, clang::tidy::cppcoreguidelines::SlicingCheck, clang::tidy::google::runtime::IntegerTypesCheck, clang::tidy::modernize::UseUsingCheck, clang::tidy::mpi::BufferDerefCheck, clang::tidy::mpi::TypeMismatchCheck, clang::tidy::objc::PropertyDeclarationCheck, clang::tidy::performance::MoveConstArgCheck, clang::tidy::readability::ContainerSizeEmptyCheck, clang::tidy::readability::InconsistentDeclarationParameterNameCheck, clang::tidy::readability::RedundantSmartptrGetCheck, clang::tidy::readability::StaticAccessedThroughInstanceCheck, clang::tidy::bugprone::VirtualNearMissCheck, clang::tidy::misc::IncorrectRoundings, clang::tidy::modernize::UseEmplaceCheck, clang::tidy::performance::FasterStringFindCheck, clang::tidy::performance::UnnecessaryCopyInitialization, clang::tidy::android::CloexecFopenCheck, clang::tidy::bugprone::InaccurateEraseCheck, clang::tidy::cert::CommandProcessorCheck, clang::tidy::cert::LimitedRandomnessCheck, clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck, clang::tidy::google::objc::AvoidThrowingObjCExceptionCheck, clang::tidy::google::build::ExplicitMakePairCheck, clang::tidy::google::objc::GlobalVariableDeclarationCheck, clang::tidy::modernize::ReplaceRandomShuffleCheck, clang::tidy::objc::ForbiddenSubclassingCheck, clang::tidy::performance::MoveConstructorInitCheck, clang::tidy::performance::NoexceptMoveConstructorCheck, clang::tidy::readability::RedundantControlFlowCheck, clang::tidy::boost::UseToStringCheck, clang::tidy::bugprone::MisplacedOperatorInStrlenInAllocCheck, clang::tidy::bugprone::MultipleStatementMacroCheck, clang::tidy::bugprone::UndefinedMemoryManipulationCheck, clang::tidy::cert::FloatLoopCounter, clang::tidy::cppcoreguidelines::ProBoundsPointerArithmeticCheck, clang::tidy::google::runtime::OverloadedUnaryAndCheck, clang::tidy::misc::NewDeleteOverloadsCheck, clang::tidy::misc::StaticAssertCheck, clang::tidy::misc::UnusedUsingDeclsCheck, clang::tidy::modernize::AvoidBindCheck, clang::tidy::modernize::MakeSmartPtrCheck, clang::tidy::modernize::RawStringLiteralCheck, clang::tidy::modernize::ShrinkToFitCheck, clang::tidy::modernize::UseDefaultMemberInitCheck, clang::tidy::performance::InefficientStringConcatenationCheck, clang::tidy::readability::MisleadingIndentationCheck, clang::tidy::readability::SimplifyBooleanExprCheck, clang::tidy::android::CloexecDupCheck, clang::tidy::bugprone::CopyConstructorInitCheck, clang::tidy::bugprone::IntegerDivisionCheck, clang::tidy::bugprone::UseAfterMoveCheck, clang::tidy::cert::DontModifyStdNamespaceCheck, clang::tidy::cert::PostfixOperatorCheck, clang::tidy::cert::StaticObjectExceptionCheck, clang::tidy::cert::StrToNumCheck, clang::tidy::cppcoreguidelines::ProTypeCstyleCastCheck, clang::tidy::cppcoreguidelines::ProTypeStaticCastDowncastCheck, clang::tidy::cppcoreguidelines::ProTypeUnionAccessCheck, clang::tidy::cppcoreguidelines::ProTypeVarargCheck, clang::tidy::hicpp::SignedBitwiseCheck, clang::tidy::misc::MisplacedConstCheck, clang::tidy::misc::RedundantExpressionCheck, clang::tidy::misc::SizeofContainerCheck, clang::tidy::misc::StringCompareCheck, clang::tidy::misc::SuspiciousMissingCommaCheck, clang::tidy::misc::SuspiciousSemicolonCheck, clang::tidy::misc::UndelegatedConstructorCheck, clang::tidy::modernize::ReturnBracedInitListCheck, clang::tidy::modernize::UnaryStaticAssertCheck, clang::tidy::objc::AvoidNSErrorInitCheck, clang::tidy::objc::AvoidSpinlockCheck, clang::tidy::performance::InefficientAlgorithmCheck, clang::tidy::performance::UnnecessaryValueParamCheck, clang::tidy::readability::DeletedDefaultCheck, clang::tidy::readability::DeleteNullPointerCheck, clang::tidy::readability::ImplicitBoolConversionCheck, clang::tidy::readability::MisplacedArrayIndexCheck, clang::tidy::readability::NamespaceCommentCheck, clang::tidy::readability::RedundantMemberInitCheck, clang::tidy::readability::StaticDefinitionInAnonymousNamespaceCheck, clang::tidy::readability::UniqueptrDeleteReleaseCheck, clang::tidy::android::CloexecAccept4Check, clang::tidy::android::CloexecAcceptCheck, clang::tidy::android::CloexecCreatCheck, clang::tidy::android::CloexecEpollCreate1Check, clang::tidy::android::CloexecEpollCreateCheck, clang::tidy::android::CloexecInotifyInit1Check, clang::tidy::android::CloexecInotifyInitCheck, clang::tidy::android::CloexecMemfdCreateCheck, clang::tidy::android::CloexecSocketCheck, clang::tidy::bugprone::DanglingHandleCheck, clang::tidy::bugprone::StringConstructorCheck, clang::tidy::bugprone::SuspiciousMemsetUsageCheck, clang::tidy::cert::SetLongJmpCheck, clang::tidy::cert::ThrownExceptionTypeCheck, clang::tidy::cert::VariadicFunctionDefCheck, clang::tidy::cppcoreguidelines::InterfacesGlobalInitCheck, clang::tidy::cppcoreguidelines::ProBoundsArrayToPointerDecayCheck, clang::tidy::cppcoreguidelines::ProTypeConstCastCheck, clang::tidy::cppcoreguidelines::ProTypeReinterpretCastCheck, clang::tidy::fuchsia::DefaultArgumentsCheck, clang::tidy::hicpp::ExceptionBaseclassCheck, clang::tidy::hicpp::NoAssemblerCheck, clang::tidy::misc::SizeofExpressionCheck, clang::tidy::misc::StringIntegerAssignmentCheck, clang::tidy::misc::StringLiteralWithEmbeddedNulCheck, clang::tidy::misc::SuspiciousStringCompareCheck, clang::tidy::misc::UnusedRAIICheck, clang::tidy::modernize::PassByValueCheck, clang::tidy::performance::ForRangeCopyCheck, clang::tidy::performance::InefficientVectorOperationCheck, clang::tidy::readability::NonConstParameterCheck, clang::tidy::readability::RedundantFunctionPtrDereferenceCheck, clang::tidy::google::DefaultArgumentsCheck, clang::tidy::google::ExplicitConstructorCheck, clang::tidy::google::runtime::NonConstReferences, clang::tidy::misc::SuspiciousEnumUsageCheck, clang::tidy::modernize::UseBoolLiteralsCheck, clang::tidy::modernize::UseTransparentFunctorsCheck, clang::tidy::performance::ImplicitConversionInLoopCheck, clang::tidy::readability::AvoidConstParamsInDecls, clang::tidy::readability::ElseAfterReturnCheck, clang::tidy::readability::RedundantDeclarationCheck, clang::tidy::llvm::TwineLocalCheck, clang::tidy::misc::NonCopyableObjectsCheck, clang::tidy::misc::UnusedAliasDeclsCheck, clang::tidy::misc::UnusedParametersCheck, clang::tidy::misc::SwappedArgumentsCheck, clang::tidy::modernize::LoopConvertCheck, clang::tidy::modernize::UseOverrideCheck, clang::tidy::readability::RedundantStringCStrCheck, clang::tidy::readability::RedundantStringInitCheck, clang::tidy::modernize::UseAutoCheck, and clang::tidy::modernize::UseNullptrCheck.

Definition at line 159 of file ClangTidy.h.

◆ registerPPCallbacks()

virtual void clang::tidy::ClangTidyCheck::registerPPCallbacks ( CompilerInstance &  Compiler)
inlinevirtual

◆ storeOptions()

virtual void clang::tidy::ClangTidyCheck::storeOptions ( ClangTidyOptions::OptionMap Options)
inlinevirtual

Should store all options supported by this check with their current values or default values for options that haven't been overridden.

The check should use Options.store() to store each option it supports whether it has the default value or it has been overridden.

Reimplemented in clang::tidy::modernize::ReplaceAutoPtrCheck, clang::tidy::readability::BracesAroundStatementsCheck, clang::tidy::modernize::UseEqualsDefaultCheck, clang::tidy::bugprone::ArgumentCommentCheck, clang::tidy::readability::FunctionSizeCheck, clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck, clang::tidy::readability::IdentifierNamingCheck, clang::tidy::bugprone::AssertSideEffectCheck, clang::tidy::cppcoreguidelines::NoMallocCheck, clang::tidy::misc::DefinitionsInHeadersCheck, clang::tidy::cppcoreguidelines::OwningMemoryCheck, clang::tidy::google::build::UnnamedNamespaceInHeaderCheck, clang::tidy::modernize::UseNoexceptCheck, clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck, clang::tidy::google::runtime::IntegerTypesCheck, clang::tidy::misc::MisplacedWideningCastCheck, clang::tidy::objc::PropertyDeclarationCheck, clang::tidy::performance::TypePromotionInMathFnCheck, clang::tidy::google::readability::GlobalNamesInHeadersCheck, clang::tidy::misc::ThrowByValueCatchByReferenceCheck, clang::tidy::modernize::UseEmplaceCheck, clang::tidy::performance::FasterStringFindCheck, clang::tidy::performance::MoveConstructorInitCheck, clang::tidy::modernize::MakeSmartPtrCheck, clang::tidy::objc::ForbiddenSubclassingCheck, clang::tidy::performance::InefficientStringConcatenationCheck, clang::tidy::performance::MoveConstArgCheck, clang::tidy::performance::UnnecessaryValueParamCheck, clang::tidy::readability::StaticAccessedThroughInstanceCheck, clang::tidy::bugprone::DanglingHandleCheck, clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck, clang::tidy::modernize::ReplaceRandomShuffleCheck, clang::tidy::modernize::UseUsingCheck, clang::tidy::performance::InefficientVectorOperationCheck, clang::tidy::google::runtime::NonConstReferences, clang::tidy::misc::SuspiciousEnumUsageCheck, clang::tidy::modernize::RawStringLiteralCheck, clang::tidy::modernize::UseDefaultMemberInitCheck, clang::tidy::modernize::UseTransparentFunctorsCheck, clang::tidy::readability::SimplifyBooleanExprCheck, clang::tidy::misc::SuspiciousMissingCommaCheck, clang::tidy::bugprone::StringConstructorCheck, clang::tidy::misc::SizeofExpressionCheck, clang::tidy::misc::SuspiciousStringCompareCheck, clang::tidy::performance::ForRangeCopyCheck, clang::tidy::readability::ImplicitBoolConversionCheck, clang::tidy::modernize::PassByValueCheck, clang::tidy::modernize::LoopConvertCheck, clang::tidy::modernize::UseAutoCheck, and clang::tidy::modernize::UseNullptrCheck.

Definition at line 174 of file ClangTidy.h.

Referenced by clang::tidy::modernize::RawStringLiteralCheck::storeOptions().

Member Data Documentation

◆ Options

OptionsView clang::tidy::ClangTidyCheck::Options
protected

Definition at line 183 of file ClangTidy.h.

Referenced by clang::tidy::modernize::UseNullptrCheck::storeOptions(), clang::tidy::modernize::LoopConvertCheck::storeOptions(), clang::tidy::modernize::PassByValueCheck::storeOptions(), clang::tidy::performance::ForRangeCopyCheck::storeOptions(), clang::tidy::misc::SizeofExpressionCheck::storeOptions(), clang::tidy::readability::ImplicitBoolConversionCheck::storeOptions(), clang::tidy::bugprone::StringConstructorCheck::storeOptions(), clang::tidy::misc::SuspiciousStringCompareCheck::storeOptions(), clang::tidy::misc::SuspiciousMissingCommaCheck::storeOptions(), clang::tidy::modernize::UseDefaultMemberInitCheck::storeOptions(), clang::tidy::google::runtime::NonConstReferences::storeOptions(), clang::tidy::modernize::UseTransparentFunctorsCheck::storeOptions(), clang::tidy::readability::SimplifyBooleanExprCheck::storeOptions(), clang::tidy::misc::SuspiciousEnumUsageCheck::storeOptions(), clang::tidy::bugprone::DanglingHandleCheck::storeOptions(), clang::tidy::modernize::UseUsingCheck::storeOptions(), clang::tidy::performance::InefficientVectorOperationCheck::storeOptions(), clang::tidy::modernize::ReplaceRandomShuffleCheck::storeOptions(), clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::storeOptions(), clang::tidy::performance::UnnecessaryValueParamCheck::storeOptions(), clang::tidy::modernize::MakeSmartPtrCheck::storeOptions(), clang::tidy::objc::ForbiddenSubclassingCheck::storeOptions(), clang::tidy::misc::ThrowByValueCatchByReferenceCheck::storeOptions(), clang::tidy::modernize::UseEmplaceCheck::storeOptions(), clang::tidy::performance::MoveConstructorInitCheck::storeOptions(), clang::tidy::google::readability::GlobalNamesInHeadersCheck::storeOptions(), clang::tidy::performance::FasterStringFindCheck::storeOptions(), clang::tidy::misc::MisplacedWideningCastCheck::storeOptions(), clang::tidy::performance::TypePromotionInMathFnCheck::storeOptions(), clang::tidy::objc::PropertyDeclarationCheck::storeOptions(), clang::tidy::google::runtime::IntegerTypesCheck::storeOptions(), clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck::storeOptions(), clang::tidy::modernize::UseNoexceptCheck::storeOptions(), clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::storeOptions(), clang::tidy::misc::DefinitionsInHeadersCheck::storeOptions(), clang::tidy::bugprone::AssertSideEffectCheck::storeOptions(), clang::tidy::readability::IdentifierNamingCheck::storeOptions(), clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::storeOptions(), clang::tidy::readability::FunctionSizeCheck::storeOptions(), clang::tidy::bugprone::ArgumentCommentCheck::storeOptions(), clang::tidy::modernize::UseEqualsDefaultCheck::storeOptions(), and clang::tidy::readability::BracesAroundStatementsCheck::storeOptions().


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