[clang-tools-extra] 53df522 - [clang-tidy][NFC] Short circuit getting enum options suggestions.
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Mon May 3 03:20:34 PDT 2021
Author: Nathan James
Date: 2021-05-03T11:20:27+01:00
New Revision: 53df522a0c536d32a60c0ed571097a78ce2541a7
URL: https://github.com/llvm/llvm-project/commit/53df522a0c536d32a60c0ed571097a78ce2541a7
DIFF: https://github.com/llvm/llvm-project/commit/53df522a0c536d32a60c0ed571097a78ce2541a7.diff
LOG: [clang-tidy][NFC] Short circuit getting enum options suggestions.
Use the MaxEditDistance to skip checking candidates we know we'll skip.
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 46b69ed538cb2..6f7f6611c8d20 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -147,7 +147,7 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
StringRef Value = Iter->getValue().Value;
StringRef Closest;
- unsigned EditDistance = -1;
+ unsigned EditDistance = 3;
for (const auto &NameAndEnum : Mapping) {
if (IgnoreCase) {
if (Value.equals_lower(NameAndEnum.second))
@@ -159,7 +159,8 @@ llvm::Optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
EditDistance = 0;
continue;
}
- unsigned Distance = Value.edit_distance(NameAndEnum.second);
+ unsigned Distance =
+ Value.edit_distance(NameAndEnum.second, true, EditDistance);
if (Distance < EditDistance) {
EditDistance = Distance;
Closest = NameAndEnum.second;
More information about the cfe-commits
mailing list