Skip to content

Commit ae9bf17

Browse files
authored
[clang-tidy] remove never used IgnoreCase in option (#122573)
1 parent ba58d35 commit ae9bf17

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ void ClangTidyCheck::OptionsView::store<bool>(
163163
store(Options, LocalName, Value ? StringRef("true") : StringRef("false"));
164164
}
165165

166-
std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
167-
StringRef LocalName, ArrayRef<NameAndValue> Mapping, bool CheckGlobal,
168-
bool IgnoreCase) const {
166+
std::optional<int64_t>
167+
ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
168+
ArrayRef<NameAndValue> Mapping,
169+
bool CheckGlobal) const {
169170
if (!CheckGlobal && Context->getOptionsCollector())
170171
Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
171172
auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
@@ -178,12 +179,10 @@ std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
178179
StringRef Closest;
179180
unsigned EditDistance = 3;
180181
for (const auto &NameAndEnum : Mapping) {
181-
if (IgnoreCase) {
182-
if (Value.equals_insensitive(NameAndEnum.second))
183-
return NameAndEnum.first;
184-
} else if (Value == NameAndEnum.second) {
182+
if (Value == NameAndEnum.second) {
185183
return NameAndEnum.first;
186-
} else if (Value.equals_insensitive(NameAndEnum.second)) {
184+
}
185+
if (Value.equals_insensitive(NameAndEnum.second)) {
187186
Closest = NameAndEnum.second;
188187
EditDistance = 0;
189188
continue;

clang-tools-extra/clang-tidy/ClangTidyCheck.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
333333
/// supply the mapping required to convert between ``T`` and a string.
334334
template <typename T>
335335
std::enable_if_t<std::is_enum_v<T>, std::optional<T>>
336-
get(StringRef LocalName, bool IgnoreCase = false) const {
336+
get(StringRef LocalName) const {
337337
if (std::optional<int64_t> ValueOr =
338-
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
338+
getEnumInt(LocalName, typeEraseMapping<T>(), false))
339339
return static_cast<T>(*ValueOr);
340340
return std::nullopt;
341341
}
@@ -353,9 +353,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
353353
/// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
354354
/// supply the mapping required to convert between ``T`` and a string.
355355
template <typename T>
356-
std::enable_if_t<std::is_enum_v<T>, T> get(StringRef LocalName, T Default,
357-
bool IgnoreCase = false) const {
358-
return get<T>(LocalName, IgnoreCase).value_or(Default);
356+
std::enable_if_t<std::is_enum_v<T>, T> get(StringRef LocalName,
357+
T Default) const {
358+
return get<T>(LocalName).value_or(Default);
359359
}
360360

361361
/// Read a named option from the ``Context`` and parse it as an
@@ -373,9 +373,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
373373
/// supply the mapping required to convert between ``T`` and a string.
374374
template <typename T>
375375
std::enable_if_t<std::is_enum_v<T>, std::optional<T>>
376-
getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
376+
getLocalOrGlobal(StringRef LocalName) const {
377377
if (std::optional<int64_t> ValueOr =
378-
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
378+
getEnumInt(LocalName, typeEraseMapping<T>(), true))
379379
return static_cast<T>(*ValueOr);
380380
return std::nullopt;
381381
}
@@ -394,10 +394,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
394394
/// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
395395
/// supply the mapping required to convert between ``T`` and a string.
396396
template <typename T>
397-
std::enable_if_t<std::is_enum_v<T>, T>
398-
getLocalOrGlobal(StringRef LocalName, T Default,
399-
bool IgnoreCase = false) const {
400-
return getLocalOrGlobal<T>(LocalName, IgnoreCase).value_or(Default);
397+
std::enable_if_t<std::is_enum_v<T>, T> getLocalOrGlobal(StringRef LocalName,
398+
T Default) const {
399+
return getLocalOrGlobal<T>(LocalName).value_or(Default);
401400
}
402401

403402
/// Stores an option with the check-local name \p LocalName with
@@ -454,7 +453,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
454453

455454
std::optional<int64_t> getEnumInt(StringRef LocalName,
456455
ArrayRef<NameAndValue> Mapping,
457-
bool CheckGlobal, bool IgnoreCase) const;
456+
bool CheckGlobal) const;
458457

459458
template <typename T>
460459
std::enable_if_t<std::is_enum_v<T>, std::vector<NameAndValue>>

clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,6 @@ TEST(ValidConfiguration, ValidEnumOptions) {
417417
CHECK_VAL(TestCheck.getIntLocal<Colours>("Valid"), Colours::Red);
418418
CHECK_VAL(TestCheck.getIntGlobal<Colours>("GlobalValid"), Colours::Violet);
419419

420-
CHECK_VAL(
421-
TestCheck.getIntLocal<Colours>("ValidWrongCase", /*IgnoreCase*/ true),
422-
Colours::Red);
423-
CHECK_VAL(TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase",
424-
/*IgnoreCase*/ true),
425-
Colours::Violet);
426-
427420
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").has_value());
428421
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").has_value());
429422
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").has_value());

0 commit comments

Comments
 (0)