clang-tools  11.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, ArrayRef< std::pair< StringRef, T >> Mapping, bool IgnoreCase=false)
 Read a named option from the Context and parse it as an enum type T using the Mapping provided. More...
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, T > get (StringRef LocalName, ArrayRef< std::pair< StringRef, T >> Mapping, T Default, bool IgnoreCase=false)
 Read a named option from the Context and parse it as an enum type T using the Mapping provided. More...
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, llvm::Expected< T > > getLocalOrGlobal (StringRef LocalName, ArrayRef< std::pair< StringRef, T >> Mapping, bool IgnoreCase=false)
 Read a named option from the Context and parse it as an enum type T using the Mapping provided. More...
 
template<typename T >
std::enable_if_t< std::is_enum< T >::value, T > getLocalOrGlobal (StringRef LocalName, ArrayRef< std::pair< StringRef, T >> Mapping, T Default, bool IgnoreCase=false)
 Read a named option from the Context and parse it as an enum type T using the Mapping provided. 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...
 
void store (ClangTidyOptions::OptionMap &Options, StringRef LocalName, int64_t Value) const
 Stores an option with the check-local name LocalName with int64_t 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, ArrayRef< std::pair< StringRef, T >> Mapping)
 Stores an option with the check-local name LocalName as the string representation of the Enum Value using the Mapping 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<>
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...
 

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 184 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 202 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 241 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 259 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,
ArrayRef< std::pair< StringRef, T >>  Mapping,
bool  IgnoreCase = false 
)
inline

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

If IgnoreCase is set, it will search the mapping ignoring the case.

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.

Definition at line 324 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,
ArrayRef< std::pair< StringRef, T >>  Mapping,
Default,
bool  IgnoreCase = false 
)
inline

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

If IgnoreCase is set, it will search the mapping ignoring the case.

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 342 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 224 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 279 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 306 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,
ArrayRef< std::pair< StringRef, T >>  Mapping,
bool  IgnoreCase = false 
)
inline

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

If IgnoreCase is set, it will search the mapping ignoring the case.

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.

Definition at line 362 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,
ArrayRef< std::pair< StringRef, T >>  Mapping,
Default,
bool  IgnoreCase = false 
)
inline

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

If IgnoreCase is set, it will search the mapping ignoring the case.

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 382 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/3]

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.

Referenced by store().

◆ store() [2/3]

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

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

Definition at line 158 of file ClangTidyCheck.cpp.

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

◆ store() [3/3]

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

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

Definition at line 406 of file ClangTidyCheck.h.


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