diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 4aa9fe228ee7..341343e90822 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -163,9 +163,10 @@ void ClangTidyCheck::OptionsView::store( store(Options, LocalName, Value ? StringRef("true") : StringRef("false")); } -std::optional ClangTidyCheck::OptionsView::getEnumInt( - StringRef LocalName, ArrayRef Mapping, bool CheckGlobal, - bool IgnoreCase) const { +std::optional +ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName, + ArrayRef Mapping, + bool CheckGlobal) const { if (!CheckGlobal && Context->getOptionsCollector()) Context->getOptionsCollector()->insert((NamePrefix + LocalName).str()); auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, @@ -178,12 +179,10 @@ std::optional ClangTidyCheck::OptionsView::getEnumInt( StringRef Closest; unsigned EditDistance = 3; for (const auto &NameAndEnum : Mapping) { - if (IgnoreCase) { - if (Value.equals_insensitive(NameAndEnum.second)) - return NameAndEnum.first; - } else if (Value == NameAndEnum.second) { + if (Value == NameAndEnum.second) { return NameAndEnum.first; - } else if (Value.equals_insensitive(NameAndEnum.second)) { + } + if (Value.equals_insensitive(NameAndEnum.second)) { Closest = NameAndEnum.second; EditDistance = 0; continue; diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index 7427aa9bf48f..037526a0bd9a 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -333,9 +333,9 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t, std::optional> - get(StringRef LocalName, bool IgnoreCase = false) const { + get(StringRef LocalName) const { if (std::optional ValueOr = - getEnumInt(LocalName, typeEraseMapping(), false, IgnoreCase)) + getEnumInt(LocalName, typeEraseMapping(), false)) return static_cast(*ValueOr); return std::nullopt; } @@ -353,9 +353,9 @@ public: /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template - std::enable_if_t, T> get(StringRef LocalName, T Default, - bool IgnoreCase = false) const { - return get(LocalName, IgnoreCase).value_or(Default); + std::enable_if_t, T> get(StringRef LocalName, + T Default) const { + return get(LocalName).value_or(Default); } /// Read a named option from the ``Context`` and parse it as an @@ -373,9 +373,9 @@ public: /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t, std::optional> - getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const { + getLocalOrGlobal(StringRef LocalName) const { if (std::optional ValueOr = - getEnumInt(LocalName, typeEraseMapping(), true, IgnoreCase)) + getEnumInt(LocalName, typeEraseMapping(), true)) return static_cast(*ValueOr); return std::nullopt; } @@ -394,10 +394,9 @@ public: /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to /// supply the mapping required to convert between ``T`` and a string. template - std::enable_if_t, T> - getLocalOrGlobal(StringRef LocalName, T Default, - bool IgnoreCase = false) const { - return getLocalOrGlobal(LocalName, IgnoreCase).value_or(Default); + std::enable_if_t, T> getLocalOrGlobal(StringRef LocalName, + T Default) const { + return getLocalOrGlobal(LocalName).value_or(Default); } /// Stores an option with the check-local name \p LocalName with @@ -454,7 +453,7 @@ public: std::optional getEnumInt(StringRef LocalName, ArrayRef Mapping, - bool CheckGlobal, bool IgnoreCase) const; + bool CheckGlobal) const; template std::enable_if_t, std::vector> diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp index af4f66ae3c54..aaec0e6b50bb 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp @@ -417,13 +417,6 @@ TEST(ValidConfiguration, ValidEnumOptions) { CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red); CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet); - CHECK_VAL( - TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true), - Colours::Red); - CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase", - /*IgnoreCase*/ true), - Colours::Violet); - EXPECT_FALSE(TestCheck.getIntLocal("ValidWrongCase").has_value()); EXPECT_FALSE(TestCheck.getIntLocal("NearMiss").has_value()); EXPECT_FALSE(TestCheck.getIntGlobal("GlobalInvalid").has_value());