clang-tools 17.0.0git
Public Member Functions | List of all members
clang::tidy::ClangTidyCheck::OptionsView Class Reference

Provides access to the ClangTidyCheck options via check-local names. More...

#include <ClangTidyCheck.h>

Public Member Functions

 OptionsView (StringRef CheckName, const ClangTidyOptions::OptionMap &CheckOptions, ClangTidyContext *Context)
 Initializes the instance using CheckName + "." as a prefix.
 
std::optional< StringRef > get (StringRef LocalName) const
 Read a named option from the Context.
 
StringRef get (StringRef LocalName, StringRef Default) const
 Read a named option from the Context.
 
std::optional< StringRef > getLocalOrGlobal (StringRef LocalName) const
 Read a named option from the Context.
 
StringRef getLocalOrGlobal (StringRef LocalName, StringRef Default) const
 Read a named option from the Context.
 
template<typename T >
std::enable_if_t< std::is_integral< T >::value, std::optional< T > > get (StringRef LocalName) const
 Read a named option from the Context and parse it as an integral type T.
 
template<typename T >
std::enable_if_t< std::is_integral< T >::value, T > get (StringRef LocalName, T Default) const
 Read a named option from the Context and parse it as an integral type T.
 
template<typename T >
std::enable_if_t< std::is_integral< T >::value, std::optional< T > > getLocalOrGlobal (StringRef LocalName) const
 Read a named option from the Context and parse it as an integral type T.
 
template<typename T >
std::enable_if_t< std::is_integral< T >::value, T > getLocalOrGlobal (StringRef LocalName, T Default) const
 Read a named option from the Context and parse it as an integral type T.
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, std::optional< T > > get (StringRef LocalName, bool IgnoreCase=false) const
 Read a named option from the Context and parse it as an enum type T.
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, T > get (StringRef LocalName, T Default, bool IgnoreCase=false) const
 Read a named option from the Context and parse it as an enum type T.
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, std::optional< T > > getLocalOrGlobal (StringRef LocalName, bool IgnoreCase=false) const
 Read a named option from the Context and parse it as an enum type T.
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, T > getLocalOrGlobal (StringRef LocalName, T Default, bool IgnoreCase=false) const
 Read a named option from the Context and parse it as an enum type T.
 
void store (ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
 Stores an option with the check-local name LocalName with string value Value to Options.
 
template<typename T >
std::enable_if_t< std::is_integral< T >::value > store (ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value) const
 Stores an option with the check-local name LocalName with integer value Value to Options.
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value > store (ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value) const
 Stores an option with the check-local name LocalName as the string representation of the Enum Value to Options.
 
template<>
std::optional< bool > get (StringRef LocalName) const
 Read a named option from the Context and parse it as a bool.
 
template<>
std::optional< bool > getLocalOrGlobal (StringRef LocalName) const
 Read a named option from the Context and parse it as a bool.
 
template<>
void store (ClangTidyOptions::OptionMap &Options, StringRef LocalName, bool Value) const
 Stores an option with the check-local name LocalName with bool value Value to Options.
 

Detailed Description

Provides access to the ClangTidyCheck options via check-local names.

Methods of this class prepend CheckName + "." to translate check-local option names to global option names.

Definition at line 139 of file ClangTidyCheck.h.

Constructor & Destructor Documentation

◆ OptionsView()

clang::tidy::ClangTidyCheck::OptionsView::OptionsView ( StringRef  CheckName,
const ClangTidyOptions::OptionMap CheckOptions,
ClangTidyContext Context 
)

Initializes the instance using CheckName + "." as a prefix.

Definition at line 48 of file ClangTidyCheck.cpp.

Member Function Documentation

◆ get() [1/7]

std::optional< bool > clang::tidy::ClangTidyCheck::OptionsView::get< bool > ( StringRef  LocalName) const

Read a named option from the Context and parse it as a bool.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, return std::nullopt.

If the corresponding key can't be parsed as a bool, emit a diagnostic and return std::nullopt.

Definition at line 92 of file ClangTidyCheck.cpp.

References Number.

◆ get() [2/7]

std::optional< StringRef > clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName) const

◆ get() [3/7]

template<typename T >
std::enable_if_t< std::is_integral< T >::value, std::optional< T > > clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName) const
inline

Read a named option from the Context and parse it as an integral type T.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, return std::nullopt.

If the corresponding key can't be parsed as a T, emit a diagnostic and return std::nullopt.

Definition at line 194 of file ClangTidyCheck.h.

References get().

◆ get() [4/7]

template<typename T >
std::enable_if_t< std::is_enum< T >::value, std::optional< T > > clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
bool  IgnoreCase = false 
) const
inline

Read a named option from the Context and parse it as an enum type T.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, return std::nullopt.

If the corresponding key can't be parsed as a T, emit a diagnostic and return std::nullopt.

clang::tidy::OptionEnumMapping must be specialized for T to supply the mapping required to convert between T and a string.

Definition at line 278 of file ClangTidyCheck.h.

◆ get() [5/7]

StringRef clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
StringRef  Default 
) const

Read a named option from the Context.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, returns Default.

Definition at line 217 of file ClangTidyCheck.cpp.

◆ get() [6/7]

template<typename T >
std::enable_if_t< std::is_integral< T >::value, T > clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
Default 
) const
inline

Read a named option from the Context and parse it as an integral type T.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, return Default.

If the corresponding key can't be parsed as a T, emit a diagnostic and return Default.

Definition at line 214 of file ClangTidyCheck.h.

◆ get() [7/7]

template<typename T >
std::enable_if_t< std::is_enum< T >::value, T > clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
Default,
bool  IgnoreCase = false 
) const
inline

Read a named option from the Context and parse it as an enum type T.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, return Default.

If the corresponding key can't be parsed as a T, emit a diagnostic and return Default.

clang::tidy::OptionEnumMapping must be specialized for T to supply the mapping required to convert between T and a string.

Definition at line 299 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [1/7]

std::optional< bool > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal< bool > ( StringRef  LocalName) const

Read a named option from the Context and parse it as a bool.

Reads the option with the check-local name LocalName from the CheckOptions. If the corresponding key is not present, return Default.

If the corresponding key can't be parsed as a bool, emit a diagnostic and return Default.

Definition at line 92 of file ClangTidyCheck.cpp.

◆ getLocalOrGlobal() [2/7]

std::optional< StringRef > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName) const

Read a named option from the Context.

Reads the option with the check-local name LocalName from local or global CheckOptions. Gets local option first. If local is not present, falls back to get global option. If global option is not present either, return std::nullopt.

Definition at line 84 of file ClangTidyCheck.cpp.

References clang::tidy::findPriorityOption(), and clang::tidy::ClangTidyContext::getOptionsCollector().

Referenced by getLocalOrGlobal().

◆ getLocalOrGlobal() [3/7]

template<typename T >
std::enable_if_t< std::is_integral< T >::value, std::optional< T > > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName) const
inline

Read a named option from the Context and parse it as an integral type T.

Reads the option with the check-local name LocalName from local or global CheckOptions. Gets local option first. If local is not present, falls back to get global option. If global option is not present either, return std::nullopt.

If the corresponding key can't be parsed as a T, emit a diagnostic and return std::nullopt.

Definition at line 231 of file ClangTidyCheck.h.

References get(), and getLocalOrGlobal().

◆ getLocalOrGlobal() [4/7]

template<typename T >
std::enable_if_t< std::is_enum< T >::value, std::optional< T > > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
bool  IgnoreCase = false 
) const
inline

Read a named option from the Context and parse it as an enum type T.

Reads the option with the check-local name LocalName from local or global CheckOptions. Gets local option first. If local is not present, falls back to get global option. If global option is not present either, returns std::nullopt.

If the corresponding key can't be parsed as a T, emit a diagnostic and return std::nullopt.

clang::tidy::OptionEnumMapping must be specialized for T to supply the mapping required to convert between T and a string.

Definition at line 318 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [5/7]

StringRef clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
StringRef  Default 
) const

Read a named option from the Context.

Reads the option with the check-local name LocalName from local or global CheckOptions. Gets local option first. If local is not present, falls back to get global option. If global option is not present either, returns Default.

Definition at line 223 of file ClangTidyCheck.cpp.

◆ getLocalOrGlobal() [6/7]

template<typename T >
std::enable_if_t< std::is_integral< T >::value, T > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
Default 
) const
inline

Read a named option from the Context and parse it as an integral type T.

Reads the option with the check-local name LocalName from local or global CheckOptions. Gets local option first. If local is not present, falls back to get global option. If global option is not present either, return Default.

If the corresponding key can't be parsed as a T, emit a diagnostic and return Default.

Definition at line 260 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [7/7]

template<typename T >
std::enable_if_t< std::is_enum< T >::value, T > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
Default,
bool  IgnoreCase = false 
) const
inline

Read a named option from the Context and parse it as an enum type T.

Reads the option with the check-local name LocalName from local or global CheckOptions. Gets local option first. If local is not present, falls back to get global option. If global option is not present either return Default.

If the corresponding key can't be parsed as a T, emit a diagnostic and return Default.

clang::tidy::OptionEnumMapping must be specialized for T to supply the mapping required to convert between T and a string.

Definition at line 340 of file ClangTidyCheck.h.

◆ store() [1/4]

void clang::tidy::ClangTidyCheck::OptionsView::store< bool > ( ClangTidyOptions::OptionMap Options,
StringRef  LocalName,
bool  Value 
) const

Stores an option with the check-local name LocalName with bool value Value to Options.

Definition at line 142 of file ClangTidyCheck.cpp.

References clang::tidy::ClangTidyCheck::Options.

◆ store() [2/4]

void clang::tidy::ClangTidyCheck::OptionsView::store ( ClangTidyOptions::OptionMap Options,
StringRef  LocalName,
StringRef  Value 
) const

Stores an option with the check-local name LocalName with string value Value to Options.

Definition at line 129 of file ClangTidyCheck.cpp.

References clang::tidy::ClangTidyCheck::Options.

Referenced by store(), clang::tidy::google::runtime::IntegerTypesCheck::storeOptions(), clang::tidy::hicpp::SignedBitwiseCheck::storeOptions(), clang::tidy::modernize::RawStringLiteralCheck::storeOptions(), clang::tidy::objc::ForbiddenSubclassingCheck::storeOptions(), clang::tidy::readability::SimplifyBooleanExprCheck::storeOptions(), clang::tidy::abseil::StringFindStartswithCheck::storeOptions(), clang::tidy::abseil::StringFindStrContainsCheck::storeOptions(), clang::tidy::altera::SingleWorkItemBarrierCheck::storeOptions(), clang::tidy::altera::StructPackAlignCheck::storeOptions(), clang::tidy::android::ComparisonInTempFailureRetryCheck::storeOptions(), clang::tidy::bugprone::ArgumentCommentCheck::storeOptions(), clang::tidy::bugprone::AssertSideEffectCheck::storeOptions(), clang::tidy::bugprone::DanglingHandleCheck::storeOptions(), clang::tidy::bugprone::DynamicStaticInitializersCheck::storeOptions(), clang::tidy::bugprone::EasilySwappableParametersCheck::storeOptions(), clang::tidy::bugprone::ExceptionEscapeCheck::storeOptions(), clang::tidy::bugprone::ImplicitWideningOfMultiplicationResultCheck::storeOptions(), clang::tidy::bugprone::MisplacedWideningCastCheck::storeOptions(), clang::tidy::bugprone::NonZeroEnumToBoolConversionCheck::storeOptions(), clang::tidy::bugprone::NotNullTerminatedResultCheck::storeOptions(), clang::tidy::bugprone::ReservedIdentifierCheck::storeOptions(), clang::tidy::bugprone::SignalHandlerCheck::storeOptions(), clang::tidy::bugprone::SignedCharMisuseCheck::storeOptions(), clang::tidy::bugprone::SizeofExpressionCheck::storeOptions(), clang::tidy::bugprone::StringConstructorCheck::storeOptions(), clang::tidy::bugprone::SuspiciousEnumUsageCheck::storeOptions(), clang::tidy::bugprone::SuspiciousIncludeCheck::storeOptions(), clang::tidy::bugprone::SuspiciousMissingCommaCheck::storeOptions(), clang::tidy::bugprone::SuspiciousStringCompareCheck::storeOptions(), clang::tidy::bugprone::TooSmallLoopVariableCheck::storeOptions(), clang::tidy::bugprone::UncheckedOptionalAccessCheck::storeOptions(), clang::tidy::bugprone::UnhandledSelfAssignmentCheck::storeOptions(), clang::tidy::bugprone::UnsafeFunctionsCheck::storeOptions(), clang::tidy::bugprone::UnusedReturnValueCheck::storeOptions(), clang::tidy::cert::NonTrivialTypesLibcMemoryCallsCheck::storeOptions(), clang::tidy::cert::ProperlySeededRandomGeneratorCheck::storeOptions(), clang::tidy::concurrency::MtUnsafeCheck::storeOptions(), clang::tidy::cppcoreguidelines::AvoidDoWhileCheck::storeOptions(), clang::tidy::cppcoreguidelines::InitVariablesCheck::storeOptions(), clang::tidy::cppcoreguidelines::MacroUsageCheck::storeOptions(), clang::tidy::cppcoreguidelines::NarrowingConversionsCheck::storeOptions(), clang::tidy::cppcoreguidelines::NoMallocCheck::storeOptions(), clang::tidy::cppcoreguidelines::OwningMemoryCheck::storeOptions(), clang::tidy::cppcoreguidelines::PreferMemberInitializerCheck::storeOptions(), clang::tidy::cppcoreguidelines::ProBoundsConstantArrayIndexCheck::storeOptions(), clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck::storeOptions(), clang::tidy::cppcoreguidelines::RvalueReferenceParamNotMovedCheck::storeOptions(), clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::storeOptions(), clang::tidy::google::readability::GlobalNamesInHeadersCheck::storeOptions(), clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::storeOptions(), clang::tidy::hicpp::MultiwayPathsCoveredCheck::storeOptions(), clang::tidy::misc::ConstCorrectnessCheck::storeOptions(), clang::tidy::misc::DefinitionsInHeadersCheck::storeOptions(), clang::tidy::misc::NonPrivateMemberVariablesInClassesCheck::storeOptions(), clang::tidy::misc::ThrowByValueCatchByReferenceCheck::storeOptions(), clang::tidy::misc::UniqueptrResetReleaseCheck::storeOptions(), clang::tidy::misc::UnusedParametersCheck::storeOptions(), clang::tidy::misc::UseAnonymousNamespaceCheck::storeOptions(), clang::tidy::modernize::AvoidBindCheck::storeOptions(), clang::tidy::modernize::DeprecatedHeadersCheck::storeOptions(), clang::tidy::modernize::LoopConvertCheck::storeOptions(), clang::tidy::modernize::MakeSmartPtrCheck::storeOptions(), clang::tidy::modernize::PassByValueCheck::storeOptions(), clang::tidy::modernize::ReplaceAutoPtrCheck::storeOptions(), clang::tidy::modernize::ReplaceDisallowCopyAndAssignMacroCheck::storeOptions(), clang::tidy::modernize::ReplaceRandomShuffleCheck::storeOptions(), clang::tidy::modernize::TypeTraitsCheck::storeOptions(), clang::tidy::modernize::UseAutoCheck::storeOptions(), clang::tidy::modernize::UseBoolLiteralsCheck::storeOptions(), clang::tidy::modernize::UseDefaultMemberInitCheck::storeOptions(), clang::tidy::modernize::UseEmplaceCheck::storeOptions(), clang::tidy::modernize::UseEqualsDefaultCheck::storeOptions(), clang::tidy::modernize::UseEqualsDeleteCheck::storeOptions(), clang::tidy::modernize::UseNodiscardCheck::storeOptions(), clang::tidy::modernize::UseNoexceptCheck::storeOptions(), clang::tidy::modernize::UseNullptrCheck::storeOptions(), clang::tidy::modernize::UseOverrideCheck::storeOptions(), clang::tidy::modernize::UseTransparentFunctorsCheck::storeOptions(), clang::tidy::modernize::UseUsingCheck::storeOptions(), clang::tidy::openmp::ExceptionEscapeCheck::storeOptions(), clang::tidy::performance::FasterStringFindCheck::storeOptions(), clang::tidy::performance::ForRangeCopyCheck::storeOptions(), clang::tidy::performance::InefficientStringConcatenationCheck::storeOptions(), clang::tidy::performance::InefficientVectorOperationCheck::storeOptions(), clang::tidy::performance::MoveConstArgCheck::storeOptions(), clang::tidy::performance::NoAutomaticMoveCheck::storeOptions(), clang::tidy::performance::TypePromotionInMathFnCheck::storeOptions(), clang::tidy::performance::UnnecessaryCopyInitialization::storeOptions(), clang::tidy::performance::UnnecessaryValueParamCheck::storeOptions(), clang::tidy::portability::RestrictSystemIncludesCheck::storeOptions(), clang::tidy::portability::SIMDIntrinsicsCheck::storeOptions(), clang::tidy::readability::AvoidConstParamsInDecls::storeOptions(), clang::tidy::readability::BracesAroundStatementsCheck::storeOptions(), clang::tidy::readability::ConstReturnTypeCheck::storeOptions(), clang::tidy::readability::ContainerSizeEmptyCheck::storeOptions(), clang::tidy::readability::ElseAfterReturnCheck::storeOptions(), clang::tidy::readability::FunctionCognitiveComplexityCheck::storeOptions(), clang::tidy::readability::FunctionSizeCheck::storeOptions(), clang::tidy::readability::IdentifierLengthCheck::storeOptions(), clang::tidy::readability::IdentifierNamingCheck::storeOptions(), clang::tidy::readability::ImplicitBoolConversionCheck::storeOptions(), clang::tidy::readability::InconsistentDeclarationParameterNameCheck::storeOptions(), clang::tidy::readability::MagicNumbersCheck::storeOptions(), clang::tidy::readability::OperatorsRepresentationCheck::storeOptions(), clang::tidy::readability::QualifiedAutoCheck::storeOptions(), clang::tidy::readability::RedundantDeclarationCheck::storeOptions(), clang::tidy::readability::RedundantMemberInitCheck::storeOptions(), clang::tidy::readability::RedundantSmartptrGetCheck::storeOptions(), clang::tidy::readability::RedundantStringInitCheck::storeOptions(), clang::tidy::readability::SimplifySubscriptExprCheck::storeOptions(), clang::tidy::readability::StaticAccessedThroughInstanceCheck::storeOptions(), clang::tidy::readability::SuspiciousCallArgumentCheck::storeOptions(), clang::tidy::readability::UniqueptrDeleteReleaseCheck::storeOptions(), clang::tidy::readability::UppercaseLiteralSuffixCheck::storeOptions(), clang::tidy::utils::HeaderGuardCheck::storeOptions(), clang::tidy::RenamerClangTidyCheck::storeOptions(), clang::tidy::utils::TransformerClangTidyCheck::storeOptions(), and clang::tidy::zircon::TemporaryObjectsCheck::storeOptions().

◆ store() [3/4]

template<typename T >
std::enable_if_t< std::is_integral< T >::value > clang::tidy::ClangTidyCheck::OptionsView::store ( ClangTidyOptions::OptionMap Options,
StringRef  LocalName,
Value 
) const
inline

Stores an option with the check-local name LocalName with integer value Value to Options.

Definition at line 354 of file ClangTidyCheck.h.

References clang::tidy::ClangTidyCheck::Options.

◆ store() [4/4]

template<typename T >
std::enable_if_t< std::is_enum< T >::value > clang::tidy::ClangTidyCheck::OptionsView::store ( ClangTidyOptions::OptionMap Options,
StringRef  LocalName,
Value 
) const
inline

Stores an option with the check-local name LocalName as the string representation of the Enum Value to Options.

clang::tidy::OptionEnumMapping must be specialized for T to supply the mapping required to convert between T and a string.

Definition at line 366 of file ClangTidyCheck.h.

References clang::tidy::OptionEnumMapping< T >::getEnumMapping(), clang::tidy::ClangTidyCheck::Options, and store().


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