clang-tools  12.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)
 Initializes the instance using CheckName + "." as a prefix. More...
 
llvm::Expected< std::string > get (StringRef LocalName) const
 Read a named option from the Context. More...
 
std::string get (StringRef LocalName, StringRef Default) const
 Read a named option from the Context. More...
 
llvm::Expected< std::string > getLocalOrGlobal (StringRef LocalName) const
 Read a named option from the Context. More...
 
std::string 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::Expected< 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::Expected< 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::Expected< T > > get (StringRef LocalName, bool IgnoreCase=false)
 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)
 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::Expected< T > > getLocalOrGlobal (StringRef LocalName, bool IgnoreCase=false)
 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)
 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)
 Stores an option with the check-local name LocalName as the string representation of the Enum Value to Options. More...
 
template<>
llvm::Expected< bool > get (StringRef LocalName) const
 
template<>
bool get (StringRef LocalName, bool Default) const
 
template<>
llvm::Expected< bool > getLocalOrGlobal (StringRef LocalName) const
 
template<>
bool getLocalOrGlobal (StringRef LocalName, bool Default) const
 
template<>
void store (ClangTidyOptions::OptionMap &Options, StringRef LocalName, bool Value) const
 
template<>
llvm::Expected< bool > get (StringRef LocalName) const
 Read a named option from the Context and parse it as a bool. More...
 
template<>
bool get (StringRef LocalName, bool Default) const
 Read a named option from the Context and parse it as a bool. More...
 
template<>
llvm::Expected< bool > getLocalOrGlobal (StringRef LocalName) const
 Read a named option from the Context and parse it as a bool. More...
 
template<>
bool getLocalOrGlobal (StringRef LocalName, bool Default) 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 191 of file ClangTidyCheck.h.

Constructor & Destructor Documentation

◆ OptionsView()

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

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

Definition at line 67 of file ClangTidyCheck.cpp.

Member Function Documentation

◆ get() [1/10]

template<>
llvm::Expected<bool> clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName) const

Definition at line 116 of file ClangTidyCheck.cpp.

References clang::tidy::getAsBool().

◆ get() [2/10]

template<>
bool clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
bool  Default 
) const

Definition at line 124 of file ClangTidyCheck.cpp.

◆ get() [3/10]

llvm::Expected< std::string > 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, returns a MissingOptionError.

Definition at line 72 of file ClangTidyCheck.cpp.

◆ get() [4/10]

template<>
llvm::Expected<bool> clang::tidy::ClangTidyCheck::OptionsView::get ( 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, returns a MissingOptionError. If the corresponding key can't be parsed as a bool, return an UnparseableIntegerOptionError.

◆ get() [5/10]

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

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 209 of file ClangTidyCheck.h.

◆ get() [6/10]

template<typename T >
std::enable_if_t<std::is_integral<T>::value, llvm::Expected<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, returns a MissingOptionError. If the corresponding key can't be parsed as a T, return an UnparseableIntegerOptionError.

Definition at line 248 of file ClangTidyCheck.h.

◆ get() [7/10]

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 or it can't be parsed as a T, returns Default.

Definition at line 266 of file ClangTidyCheck.h.

◆ get() [8/10]

template<typename T >
std::enable_if_t<std::is_enum<T>::value, llvm::Expected<T> > clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
bool  IgnoreCase = false 
)
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, returns a MissingOptionError. If the key can't be parsed as a T returns a UnparseableEnumOptionError.

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

Definition at line 333 of file ClangTidyCheck.h.

◆ get() [9/10]

template<typename T >
std::enable_if_t<std::is_enum<T>::value, T> clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
Default,
bool  IgnoreCase = false 
)
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 or it can't be parsed as a T, returns Default.

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

Definition at line 352 of file ClangTidyCheck.h.

◆ get() [10/10]

template<>
bool clang::tidy::ClangTidyCheck::OptionsView::get ( StringRef  LocalName,
bool  Default 
) 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 or it can't be parsed as a bool, returns Default.

◆ getLocalOrGlobal() [1/10]

template<>
llvm::Expected<bool> clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName) const

◆ getLocalOrGlobal() [2/10]

template<>
bool clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
bool  Default 
) const

Definition at line 143 of file ClangTidyCheck.cpp.

◆ getLocalOrGlobal() [3/10]

llvm::Expected< std::string > 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, returns a MissingOptionError.

Definition at line 94 of file ClangTidyCheck.cpp.

References clang::tidy::findPriorityOption().

◆ getLocalOrGlobal() [4/10]

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

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 231 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [5/10]

template<typename T >
std::enable_if_t<std::is_integral<T>::value, llvm::Expected<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, returns a MissingOptionError. If the corresponding key can't be parsed as a T, return an UnparseableIntegerOptionError.

Definition at line 286 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [6/10]

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 or it can't be parsed as a T, returns Default.

Definition at line 313 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [7/10]

template<typename T >
std::enable_if_t<std::is_enum<T>::value, llvm::Expected<T> > clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
bool  IgnoreCase = false 
)
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 a MissingOptionError. If the key can't be parsed as a T returns a UnparseableEnumOptionError.

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

Definition at line 373 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [8/10]

template<typename T >
std::enable_if_t<std::is_enum<T>::value, T> clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
Default,
bool  IgnoreCase = false 
)
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 or it can't be parsed as a T, returns Default.

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

Definition at line 394 of file ClangTidyCheck.h.

◆ getLocalOrGlobal() [9/10]

template<>
llvm::Expected<bool> clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( 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 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 a MissingOptionError. If the corresponding key can't be parsed as a bool, return an UnparseableIntegerOptionError.

◆ getLocalOrGlobal() [10/10]

template<>
bool clang::tidy::ClangTidyCheck::OptionsView::getLocalOrGlobal ( StringRef  LocalName,
bool  Default 
) const

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

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 or it can't be parsed as a bool, returns Default.

◆ store() [1/5]

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

Definition at line 165 of file ClangTidyCheck.cpp.

References clang::tidy::findPriorityOption(), and store().

◆ store() [2/5]

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 152 of file ClangTidyCheck.cpp.

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

Referenced by store().

◆ store() [3/5]

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 411 of file ClangTidyCheck.h.

◆ store() [4/5]

template<typename T >
std::enable_if_t<std::is_enum<T>::value> clang::tidy::ClangTidyCheck::OptionsView::store ( ClangTidyOptions::OptionMap Options,
StringRef  LocalName,
Value 
)
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 423 of file ClangTidyCheck.h.

References clang::tidy::OptionEnumMapping< T >::getEnumMapping().

◆ store() [5/5]

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

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


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