From 7bae3188e08746566733148a4ceccdb3cf24e93b Mon Sep 17 00:00:00 2001 From: Nathan James Date: Tue, 28 Jul 2020 14:52:32 +0100 Subject: [PATCH] [clang-tidy][NFC] Make OptionsView methods as const where missing --- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp | 7 +++---- clang-tools-extra/clang-tidy/ClangTidyCheck.h | 17 +++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index c24b855..ffd5bf9 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -168,10 +168,9 @@ void ClangTidyCheck::OptionsView::store( store(Options, LocalName, Value ? StringRef("true") : StringRef("false")); } -llvm::Expected -ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName, - ArrayRef Mapping, - bool CheckGlobal, bool IgnoreCase) { +llvm::Expected ClangTidyCheck::OptionsView::getEnumInt( + StringRef LocalName, ArrayRef Mapping, bool CheckGlobal, + bool IgnoreCase) const { auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, LocalName) : CheckOptions.find((NamePrefix + LocalName).str()); diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index 54b7251..4df8071 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -330,7 +330,7 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, llvm::Expected> - get(StringRef LocalName, bool IgnoreCase = false) { + get(StringRef LocalName, bool IgnoreCase = false) const { if (llvm::Expected ValueOr = getEnumInt(LocalName, typeEraseMapping(), false, IgnoreCase)) return static_cast(*ValueOr); @@ -349,7 +349,7 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, T> - get(StringRef LocalName, T Default, bool IgnoreCase = false) { + get(StringRef LocalName, T Default, bool IgnoreCase = false) const { if (auto ValueOr = get(LocalName, IgnoreCase)) return *ValueOr; else @@ -370,8 +370,7 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, llvm::Expected> - getLocalOrGlobal(StringRef LocalName, - bool IgnoreCase = false) { + getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const { if (llvm::Expected ValueOr = getEnumInt(LocalName, typeEraseMapping(), true, IgnoreCase)) return static_cast(*ValueOr); @@ -391,7 +390,8 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, T> - getLocalOrGlobal(StringRef LocalName, T Default, bool IgnoreCase = false) { + getLocalOrGlobal(StringRef LocalName, T Default, + bool IgnoreCase = false) const { if (auto ValueOr = getLocalOrGlobal(LocalName, IgnoreCase)) return *ValueOr; else @@ -420,7 +420,8 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value> - store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value) { + store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, + T Value) const { ArrayRef> Mapping = OptionEnumMapping::getEnumMapping(); auto Iter = llvm::find_if( @@ -436,11 +437,11 @@ public: llvm::Expected getEnumInt(StringRef LocalName, ArrayRef Mapping, - bool CheckGlobal, bool IgnoreCase); + bool CheckGlobal, bool IgnoreCase) const; template std::enable_if_t::value, std::vector> - typeEraseMapping() { + typeEraseMapping() const { ArrayRef> Mapping = OptionEnumMapping::getEnumMapping(); std::vector Result; -- 2.7.4