clang-tools
17.0.0git
|
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. More... | |
std::optional< StringRef > | get (StringRef LocalName) const |
Read a named option from the Context . More... | |
StringRef | get (StringRef LocalName, StringRef Default) const |
Read a named option from the Context . More... | |
std::optional< StringRef > | getLocalOrGlobal (StringRef LocalName) const |
Read a named option from the Context . More... | |
StringRef | getLocalOrGlobal (StringRef LocalName, StringRef Default) const |
Read a named option from the Context . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
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 . More... | |
template<> | |
std::optional< bool > | get (StringRef LocalName) const |
Read a named option from the Context and parse it as a bool. More... | |
template<> | |
std::optional< bool > | getLocalOrGlobal (StringRef LocalName) const |
Read a named option from the Context and parse it as a bool. More... | |
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 . More... | |
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.
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.
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 107 of file ClangTidyCheck.cpp.
std::optional< StringRef > clang::tidy::ClangTidyCheck::OptionsView::get | ( | StringRef | LocalName | ) | 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, return std::nullopt
.
Definition at line 55 of file ClangTidyCheck.cpp.
References clang::tidy::ClangTidyContext::getOptionsCollector().
Referenced by get(), clang::tidy::readability::IdentifierNamingCheck::getFileStyleFromOptions(), getLocalOrGlobal(), and clang::tidy::readability::IdentifierNamingCheck::HungarianNotation::loadFileConfig().
|
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().
|
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.
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.
|
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.
|
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.
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 118 of file ClangTidyCheck.cpp.
References clang::tidy::findPriorityOption(), and clang::tidy::ClangTidyContext::getOptionsCollector().
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(), and clang::tidy::bugprone::UncheckedOptionalAccessCheck::UncheckedOptionalAccessCheck().
|
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().
|
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.
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.
|
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.
|
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.
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.
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.
|
inline |
Stores an option with the check-local name LocalName
with integer value Value
to Options
.
Definition at line 354 of file ClangTidyCheck.h.
|
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.