[clang-tidy][NFC] Make OptionsView methods as const where missing

This commit is contained in:
Nathan James 2020-07-28 14:52:32 +01:00
parent bd93f5ce07
commit 7bae3188e0
2 changed files with 12 additions and 12 deletions

View File

@ -168,10 +168,9 @@ void ClangTidyCheck::OptionsView::store<bool>(
store(Options, LocalName, Value ? StringRef("true") : StringRef("false"));
}
llvm::Expected<int64_t>
ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
ArrayRef<NameAndValue> Mapping,
bool CheckGlobal, bool IgnoreCase) {
llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
StringRef LocalName, ArrayRef<NameAndValue> Mapping, bool CheckGlobal,
bool IgnoreCase) const {
auto Iter = CheckGlobal
? findPriorityOption(CheckOptions, NamePrefix, LocalName)
: CheckOptions.find((NamePrefix + LocalName).str());

View File

@ -330,7 +330,7 @@ public:
/// supply the mapping required to convert between ``T`` and a string.
template <typename T>
std::enable_if_t<std::is_enum<T>::value, llvm::Expected<T>>
get(StringRef LocalName, bool IgnoreCase = false) {
get(StringRef LocalName, bool IgnoreCase = false) const {
if (llvm::Expected<int64_t> ValueOr =
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
return static_cast<T>(*ValueOr);
@ -349,7 +349,7 @@ public:
/// supply the mapping required to convert between ``T`` and a string.
template <typename T>
std::enable_if_t<std::is_enum<T>::value, T>
get(StringRef LocalName, T Default, bool IgnoreCase = false) {
get(StringRef LocalName, T Default, bool IgnoreCase = false) const {
if (auto ValueOr = get<T>(LocalName, IgnoreCase))
return *ValueOr;
else
@ -370,8 +370,7 @@ public:
/// supply the mapping required to convert between ``T`` and a string.
template <typename T>
std::enable_if_t<std::is_enum<T>::value, llvm::Expected<T>>
getLocalOrGlobal(StringRef LocalName,
bool IgnoreCase = false) {
getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
if (llvm::Expected<int64_t> ValueOr =
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
return static_cast<T>(*ValueOr);
@ -391,7 +390,8 @@ public:
/// supply the mapping required to convert between ``T`` and a string.
template <typename T>
std::enable_if_t<std::is_enum<T>::value, T>
getLocalOrGlobal(StringRef LocalName, T Default, bool IgnoreCase = false) {
getLocalOrGlobal(StringRef LocalName, T Default,
bool IgnoreCase = false) const {
if (auto ValueOr = getLocalOrGlobal<T>(LocalName, IgnoreCase))
return *ValueOr;
else
@ -420,7 +420,8 @@ public:
/// supply the mapping required to convert between ``T`` and a string.
template <typename T>
std::enable_if_t<std::is_enum<T>::value>
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value) {
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
T Value) const {
ArrayRef<std::pair<T, StringRef>> Mapping =
OptionEnumMapping<T>::getEnumMapping();
auto Iter = llvm::find_if(
@ -436,11 +437,11 @@ public:
llvm::Expected<int64_t> getEnumInt(StringRef LocalName,
ArrayRef<NameAndValue> Mapping,
bool CheckGlobal, bool IgnoreCase);
bool CheckGlobal, bool IgnoreCase) const;
template <typename T>
std::enable_if_t<std::is_enum<T>::value, std::vector<NameAndValue>>
typeEraseMapping() {
typeEraseMapping() const {
ArrayRef<std::pair<T, StringRef>> Mapping =
OptionEnumMapping<T>::getEnumMapping();
std::vector<NameAndValue> Result;