clang-tools  15.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. More...
 
llvm::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...
 
llvm::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, llvm::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, llvm::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, llvm::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, llvm::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<>
llvm::Optional< bool > get (StringRef LocalName) const
 Read a named option from the Context and parse it as a bool. More...
 
template<>
llvm::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...
 

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]

llvm::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 None.

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

Definition at line 99 of file ClangTidyCheck.cpp.

◆ get() [2/7]

llvm::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 None.

Definition at line 55 of file ClangTidyCheck.cpp.

Referenced by get(), clang::tidy::readability::IdentifierNamingCheck::getFileStyleFromOptions(), getLocalOrGlobal(), and clang::tidy::readability::IdentifierNamingCheck::HungarianNotation::loadFileConfig().

◆ get() [3/7]

template<typename T >
std::enable_if_t<std::is_integral<T>::value, llvm::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 None.

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

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, llvm::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 None.

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

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 205 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]

llvm::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 110 of file ClangTidyCheck.cpp.

References clang::tidy::findPriorityOption().

◆ getLocalOrGlobal() [2/7]

llvm::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 None.

Definition at line 77 of file ClangTidyCheck.cpp.

References clang::tidy::findPriorityOption().

Referenced by getLocalOrGlobal().

◆ getLocalOrGlobal() [3/7]

template<typename T >
std::enable_if_t<std::is_integral<T>::value, llvm::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 None.

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

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, llvm::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 None.

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

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 211 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 133 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 120 of file ClangTidyCheck.cpp.

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

◆ 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.

◆ 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.


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